libkwineffects: use std::unique_ptr in GLTexture
The implicit internal sharing stuff wasn't used in KWin, and the way the d pointer was initialized was horrible
This commit is contained in:
parent
3eb5f18861
commit
bfc8bcb24a
5 changed files with 6 additions and 27 deletions
|
@ -418,7 +418,7 @@ void EglSurfaceTextureX11::update(const QRegion ®ion)
|
|||
}
|
||||
|
||||
EglPixmapTexture::EglPixmapTexture(EglBackend *backend)
|
||||
: GLTexture(*new EglPixmapTexturePrivate(this, backend))
|
||||
: GLTexture(std::make_unique<EglPixmapTexturePrivate>(this, backend))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -871,7 +871,7 @@ void GlxSurfaceTextureX11::update(const QRegion ®ion)
|
|||
}
|
||||
|
||||
GlxPixmapTexture::GlxPixmapTexture(GlxBackend *backend)
|
||||
: GLTexture(*new GlxPixmapTexturePrivate(this, backend))
|
||||
: GLTexture(std::make_unique<GlxPixmapTexturePrivate>(this, backend))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -89,13 +89,8 @@ GLTexture::GLTexture(GLenum target)
|
|||
d->m_target = target;
|
||||
}
|
||||
|
||||
GLTexture::GLTexture(GLTexturePrivate &dd)
|
||||
: d_ptr(&dd)
|
||||
{
|
||||
}
|
||||
|
||||
GLTexture::GLTexture(const GLTexture &tex)
|
||||
: d_ptr(tex.d_ptr)
|
||||
GLTexture::GLTexture(std::unique_ptr<GLTexturePrivate> &&dd)
|
||||
: d_ptr(std::move(dd))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -271,12 +266,6 @@ bool GLTexture::create()
|
|||
return d->m_texture != GL_NONE;
|
||||
}
|
||||
|
||||
GLTexture &GLTexture::operator=(const GLTexture &tex)
|
||||
{
|
||||
d_ptr = tex.d_ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
GLTexturePrivate::GLTexturePrivate()
|
||||
: m_texture(0)
|
||||
, m_target(0)
|
||||
|
@ -437,11 +426,6 @@ void GLTexture::update(const QImage &image, const QPoint &offset, const QRect &s
|
|||
}
|
||||
}
|
||||
|
||||
void GLTexture::discard()
|
||||
{
|
||||
d_ptr = new GLTexturePrivate();
|
||||
}
|
||||
|
||||
void GLTexture::bind()
|
||||
{
|
||||
Q_D(GLTexture);
|
||||
|
|
|
@ -49,7 +49,6 @@ class KWINGLUTILS_EXPORT GLTexture
|
|||
{
|
||||
public:
|
||||
explicit GLTexture(GLenum target);
|
||||
GLTexture(const GLTexture &tex);
|
||||
explicit GLTexture(const QImage &image, GLenum target = GL_TEXTURE_2D);
|
||||
explicit GLTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D);
|
||||
explicit GLTexture(const QString &fileName);
|
||||
|
@ -71,8 +70,6 @@ public:
|
|||
explicit GLTexture(GLuint textureId, GLenum internalFormat, const QSize &size, int levels = 1);
|
||||
virtual ~GLTexture();
|
||||
|
||||
GLTexture &operator=(const GLTexture &tex);
|
||||
|
||||
bool isNull() const;
|
||||
QSize size() const;
|
||||
void setSize(const QSize &size);
|
||||
|
@ -114,7 +111,6 @@ public:
|
|||
QMatrix4x4 matrix(TextureCoordinateType type) const;
|
||||
|
||||
void update(const QImage &image, const QPoint &offset = QPoint(0, 0), const QRect &src = QRect());
|
||||
virtual void discard();
|
||||
void bind();
|
||||
void unbind();
|
||||
void render(const QSizeF &size, double scale);
|
||||
|
@ -163,8 +159,8 @@ public:
|
|||
static bool supportsFormatRG();
|
||||
|
||||
protected:
|
||||
QExplicitlySharedDataPointer<GLTexturePrivate> d_ptr;
|
||||
GLTexture(GLTexturePrivate &dd);
|
||||
const std::unique_ptr<GLTexturePrivate> d_ptr;
|
||||
GLTexture(std::unique_ptr<GLTexturePrivate> &&dd);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(GLTexture)
|
||||
|
|
|
@ -466,7 +466,6 @@ void ContrastEffect::doContrast(const RenderTarget &renderTarget, const RenderVi
|
|||
vbo->draw(GL_TRIANGLES, 0, actualShape.rectCount() * 6);
|
||||
|
||||
scratch.unbind();
|
||||
scratch.discard();
|
||||
|
||||
vbo->unbindArrays();
|
||||
|
||||
|
|
Loading…
Reference in a new issue