diff options
author | Gatis Paeglis <gatis.paeglis@qt.io> | 2018-03-15 18:07:48 +0100 |
---|---|---|
committer | Gatis Paeglis <gatis.paeglis@qt.io> | 2018-04-14 17:02:53 +0000 |
commit | cba414a26b58b867d0c46ac214606e29e4bbdd94 (patch) | |
tree | 935c384a68a43cef62a2a54300f46673d7c384cc /src/plugins/platforms/xcb/qxcbbackingstore.cpp | |
parent | 0dd3e02aacf7db51a1ab75170f9ceb759f334fec (diff) |
xcb: cleanup the code for detecting when to create/destroy SHM segment
- removed the check for "m_segmentSize > 0" as according to the code it
will never be <= 0.
- wrap the entire logic in connection()->hasShm() { .. } as that is when
the logic becomes relevant. This makes the code more readable.
Change-Id: I572420df8e29cc46593f8a13c250f8c05c6a9108
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbbackingstore.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbbackingstore.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index 659d1c53cb..8cfcc49f9a 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -219,12 +219,14 @@ void QXcbBackingStoreImage::create(const QSize &size, const xcb_format_t *fmt, Q if (!segmentSize) return; - if (hasShm() && m_segmentSize > 0 && (m_segmentSize < segmentSize || m_segmentSize / 2 >= segmentSize)) - destroyShmSegment(m_segmentSize); - if (!hasShm() && connection()->hasShm()) - { - qCDebug(lcQpaXcb) << "creating shared memory" << segmentSize << "for" << size << "depth" << fmt->depth << "bits" << fmt->bits_per_pixel; - createShmSegment(segmentSize); + if (connection()->hasShm()) { + if (m_shm_info.shmaddr && (m_segmentSize < segmentSize || m_segmentSize / 2 >= segmentSize)) + destroyShmSegment(m_segmentSize); + if (!m_shm_info.shmaddr) { + qCDebug(lcQpaXcb) << "creating shared memory" << segmentSize << "for" + << size << "depth" << fmt->depth << "bits" << fmt->bits_per_pixel; + createShmSegment(segmentSize); + } } m_xcb_image->data = m_shm_info.shmaddr ? m_shm_info.shmaddr : (uint8_t *)malloc(segmentSize); |