diff --git a/src/backends/x11/standalone/eglbackend.cpp b/src/backends/x11/standalone/eglbackend.cpp index b9697017f4..ce9d18bc95 100644 --- a/src/backends/x11/standalone/eglbackend.cpp +++ b/src/backends/x11/standalone/eglbackend.cpp @@ -215,11 +215,13 @@ EglSurfaceTextureX11::EglSurfaceTextureX11(EglBackend *backend, SurfacePixmapX11 bool EglSurfaceTextureX11::create() { - auto texture = new EglPixmapTexture(static_cast(m_backend)); + auto texture = std::make_unique(static_cast(m_backend)); if (texture->create(m_pixmap)) { - m_texture.reset(texture); + m_texture = std::move(texture); + return true; + } else { + return false; } - return !m_texture.isNull(); } void EglSurfaceTextureX11::update(const QRegion ®ion) diff --git a/src/backends/x11/standalone/glxbackend.cpp b/src/backends/x11/standalone/glxbackend.cpp index f4555c8584..156cdf15c0 100644 --- a/src/backends/x11/standalone/glxbackend.cpp +++ b/src/backends/x11/standalone/glxbackend.cpp @@ -872,11 +872,13 @@ GlxSurfaceTextureX11::GlxSurfaceTextureX11(GlxBackend *backend, SurfacePixmapX11 bool GlxSurfaceTextureX11::create() { - auto texture = new GlxPixmapTexture(static_cast(m_backend)); + auto texture = std::make_unique(static_cast(m_backend)); if (texture->create(m_pixmap)) { - m_texture.reset(texture); + m_texture = std::move(texture); + return true; + } else { + return false; } - return !m_texture.isNull(); } void GlxSurfaceTextureX11::update(const QRegion ®ion) diff --git a/src/platformsupport/scenes/opengl/openglsurfacetexture.cpp b/src/platformsupport/scenes/opengl/openglsurfacetexture.cpp index 07a71ec576..2d406a040b 100644 --- a/src/platformsupport/scenes/opengl/openglsurfacetexture.cpp +++ b/src/platformsupport/scenes/opengl/openglsurfacetexture.cpp @@ -21,7 +21,7 @@ OpenGLSurfaceTexture::~OpenGLSurfaceTexture() bool OpenGLSurfaceTexture::isValid() const { - return !m_texture.isNull(); + return m_texture != nullptr; } OpenGLBackend *OpenGLSurfaceTexture::backend() const @@ -31,7 +31,7 @@ OpenGLBackend *OpenGLSurfaceTexture::backend() const GLTexture *OpenGLSurfaceTexture::texture() const { - return m_texture.data(); + return m_texture.get(); } } // namespace KWin diff --git a/src/platformsupport/scenes/opengl/openglsurfacetexture.h b/src/platformsupport/scenes/opengl/openglsurfacetexture.h index 9ee7a8d9ce..a0e4a69573 100644 --- a/src/platformsupport/scenes/opengl/openglsurfacetexture.h +++ b/src/platformsupport/scenes/opengl/openglsurfacetexture.h @@ -30,7 +30,7 @@ public: protected: OpenGLBackend *m_backend; - QScopedPointer m_texture; + std::unique_ptr m_texture; }; } // namespace KWin diff --git a/src/surfaceitem.cpp b/src/surfaceitem.cpp index def9720e6b..117ff9ac57 100644 --- a/src/surfaceitem.cpp +++ b/src/surfaceitem.cpp @@ -59,17 +59,17 @@ QRegion SurfaceItem::damage() const SurfacePixmap *SurfaceItem::pixmap() const { if (m_pixmap && m_pixmap->isValid()) { - return m_pixmap.data(); + return m_pixmap.get(); } if (m_previousPixmap && m_previousPixmap->isValid()) { - return m_previousPixmap.data(); + return m_previousPixmap.get(); } return nullptr; } SurfacePixmap *SurfaceItem::previousPixmap() const { - return m_previousPixmap.data(); + return m_previousPixmap.get(); } void SurfaceItem::referencePreviousPixmap() @@ -92,8 +92,8 @@ void SurfaceItem::unreferencePreviousPixmap() void SurfaceItem::updatePixmap() { - if (m_pixmap.isNull()) { - m_pixmap.reset(createPixmap()); + if (!m_pixmap) { + m_pixmap = createPixmap(); } if (m_pixmap->isValid()) { m_pixmap->update(); @@ -108,9 +108,9 @@ void SurfaceItem::updatePixmap() void SurfaceItem::discardPixmap() { - if (!m_pixmap.isNull()) { + if (m_pixmap) { if (m_pixmap->isValid()) { - m_previousPixmap.reset(m_pixmap.take()); + m_previousPixmap = std::move(m_pixmap); m_previousPixmap->markAsDiscarded(); referencePreviousPixmap(); } else { diff --git a/src/surfaceitem.h b/src/surfaceitem.h index 61401e122f..effb1545ea 100644 --- a/src/surfaceitem.h +++ b/src/surfaceitem.h @@ -44,7 +44,7 @@ public: protected: explicit SurfaceItem(Window *window, Item *parent = nullptr); - virtual SurfacePixmap *createPixmap() = 0; + virtual std::unique_ptr createPixmap() = 0; void preprocess() override; WindowQuadList buildQuads() const override; @@ -52,8 +52,8 @@ protected: Window *m_window; QRegion m_damage; - QScopedPointer m_pixmap; - QScopedPointer m_previousPixmap; + std::unique_ptr m_pixmap; + std::unique_ptr m_previousPixmap; QMatrix4x4 m_surfaceToBufferMatrix; int m_referencePixmapCounter = 0; }; diff --git a/src/surfaceitem_internal.cpp b/src/surfaceitem_internal.cpp index 704122279f..8a1dd4c83d 100644 --- a/src/surfaceitem_internal.cpp +++ b/src/surfaceitem_internal.cpp @@ -31,9 +31,9 @@ QRegion SurfaceItemInternal::shape() const return QRegion(rect()); } -SurfacePixmap *SurfaceItemInternal::createPixmap() +std::unique_ptr SurfaceItemInternal::createPixmap() { - return new SurfacePixmapInternal(this); + return std::make_unique(this); } void SurfaceItemInternal::handleBufferGeometryChanged(Window *window, const QRect &old) diff --git a/src/surfaceitem_internal.h b/src/surfaceitem_internal.h index dfe8289353..5bcc19f543 100644 --- a/src/surfaceitem_internal.h +++ b/src/surfaceitem_internal.h @@ -31,7 +31,7 @@ private Q_SLOTS: void handleBufferGeometryChanged(Window *window, const QRect &old); protected: - SurfacePixmap *createPixmap() override; + std::unique_ptr createPixmap() override; }; class KWIN_EXPORT SurfacePixmapInternal final : public SurfacePixmap diff --git a/src/surfaceitem_wayland.cpp b/src/surfaceitem_wayland.cpp index d24c25373e..59c9581044 100644 --- a/src/surfaceitem_wayland.cpp +++ b/src/surfaceitem_wayland.cpp @@ -132,9 +132,9 @@ void SurfaceItemWayland::handleSubSurfaceMappedChanged() setVisible(m_surface->isMapped()); } -SurfacePixmap *SurfaceItemWayland::createPixmap() +std::unique_ptr SurfaceItemWayland::createPixmap() { - return new SurfacePixmapWayland(this); + return std::make_unique(this); } SurfacePixmapWayland::SurfacePixmapWayland(SurfaceItemWayland *item, QObject *parent) diff --git a/src/surfaceitem_wayland.h b/src/surfaceitem_wayland.h index 2e4caae256..4b0f157daf 100644 --- a/src/surfaceitem_wayland.h +++ b/src/surfaceitem_wayland.h @@ -45,7 +45,7 @@ private Q_SLOTS: void handleSubSurfaceMappedChanged(); protected: - SurfacePixmap *createPixmap() override; + std::unique_ptr createPixmap() override; private: SurfaceItemWayland *getOrCreateSubSurfaceItem(KWaylandServer::SubSurfaceInterface *s); diff --git a/src/surfaceitem_x11.cpp b/src/surfaceitem_x11.cpp index 6c5e106856..501736b18d 100644 --- a/src/surfaceitem_x11.cpp +++ b/src/surfaceitem_x11.cpp @@ -146,9 +146,9 @@ QRegion SurfaceItemX11::opaque() const } } -SurfacePixmap *SurfaceItemX11::createPixmap() +std::unique_ptr SurfaceItemX11::createPixmap() { - return new SurfacePixmapX11(this); + return std::make_unique(this); } SurfacePixmapX11::SurfacePixmapX11(SurfaceItemX11 *item, QObject *parent) diff --git a/src/surfaceitem_x11.h b/src/surfaceitem_x11.h index 55cfc23dfc..a652bddabd 100644 --- a/src/surfaceitem_x11.h +++ b/src/surfaceitem_x11.h @@ -40,7 +40,7 @@ private Q_SLOTS: void handleGeometryShapeChanged(); protected: - SurfacePixmap *createPixmap() override; + std::unique_ptr createPixmap() override; private: xcb_damage_damage_t m_damageHandle = XCB_NONE;