scene: Pass dirty region to SceneOpenGLTexture::updateTexture

This commit is contained in:
Vlad Zahorodnii 2021-02-03 22:34:14 +02:00
parent 369b768f36
commit 0f1afdbdc0
7 changed files with 16 additions and 15 deletions

View file

@ -435,7 +435,7 @@ bool AbstractEglTexture::loadTexture(WindowPixmap *pixmap)
return loadEglTexture(buffer); return loadEglTexture(buffer);
} }
void AbstractEglTexture::updateTexture(WindowPixmap *pixmap) void AbstractEglTexture::updateTexture(WindowPixmap *pixmap, const QRegion &region)
{ {
// FIXME: Refactor this method. // FIXME: Refactor this method.
@ -444,7 +444,7 @@ void AbstractEglTexture::updateTexture(WindowPixmap *pixmap)
if (updateFromFBO(pixmap->fbo())) { if (updateFromFBO(pixmap->fbo())) {
return; return;
} }
if (updateFromInternalImageObject(pixmap)) { if (updateFromInternalImageObject(pixmap, region)) {
return; return;
} }
return; return;
@ -681,7 +681,7 @@ static QRegion scale(const QRegion &region, qreal scaleFactor)
return scaled; return scaled;
} }
bool AbstractEglTexture::updateFromInternalImageObject(WindowPixmap *pixmap) bool AbstractEglTexture::updateFromInternalImageObject(WindowPixmap *pixmap, const QRegion &region)
{ {
const QImage image = pixmap->internalImage(); const QImage image = pixmap->internalImage();
if (image.isNull()) { if (image.isNull()) {
@ -693,7 +693,7 @@ bool AbstractEglTexture::updateFromInternalImageObject(WindowPixmap *pixmap)
return loadInternalImageObject(pixmap); return loadInternalImageObject(pixmap);
} }
createTextureSubImage(image, scale(pixmap->toplevel()->damage(), image.devicePixelRatio())); createTextureSubImage(image, scale(region, image.devicePixelRatio()));
return true; return true;
} }

View file

@ -96,7 +96,7 @@ class KWIN_EXPORT AbstractEglTexture : public SceneOpenGLTexturePrivate
public: public:
~AbstractEglTexture() override; ~AbstractEglTexture() override;
bool loadTexture(WindowPixmap *pixmap) override; bool loadTexture(WindowPixmap *pixmap) override;
void updateTexture(WindowPixmap *pixmap) override; void updateTexture(WindowPixmap *pixmap, const QRegion &region) override;
OpenGLBackend *backend() override; OpenGLBackend *backend() override;
protected: protected:
@ -120,7 +120,7 @@ private:
bool loadInternalImageObject(WindowPixmap *pixmap); bool loadInternalImageObject(WindowPixmap *pixmap);
EGLImageKHR attach(const QPointer<KWaylandServer::BufferInterface> &buffer); EGLImageKHR attach(const QPointer<KWaylandServer::BufferInterface> &buffer);
bool updateFromFBO(const QSharedPointer<QOpenGLFramebufferObject> &fbo); bool updateFromFBO(const QSharedPointer<QOpenGLFramebufferObject> &fbo);
bool updateFromInternalImageObject(WindowPixmap *pixmap); bool updateFromInternalImageObject(WindowPixmap *pixmap, const QRegion &region);
SceneOpenGLTexture *q; SceneOpenGLTexture *q;
AbstractEglBackend *m_backend; AbstractEglBackend *m_backend;
EGLImageKHR m_image; EGLImageKHR m_image;

View file

@ -47,10 +47,10 @@ bool SceneOpenGLTexture::load(WindowPixmap *pixmap)
return d->loadTexture(pixmap); return d->loadTexture(pixmap);
} }
void SceneOpenGLTexture::updateFromPixmap(WindowPixmap *pixmap) void SceneOpenGLTexture::updateFromPixmap(WindowPixmap *pixmap, const QRegion &region)
{ {
Q_D(SceneOpenGLTexture); Q_D(SceneOpenGLTexture);
d->updateTexture(pixmap); d->updateTexture(pixmap, region);
} }
SceneOpenGLTexturePrivate::SceneOpenGLTexturePrivate() SceneOpenGLTexturePrivate::SceneOpenGLTexturePrivate()
@ -61,9 +61,10 @@ SceneOpenGLTexturePrivate::~SceneOpenGLTexturePrivate()
{ {
} }
void SceneOpenGLTexturePrivate::updateTexture(WindowPixmap *pixmap) void SceneOpenGLTexturePrivate::updateTexture(WindowPixmap *pixmap, const QRegion &region)
{ {
Q_UNUSED(pixmap) Q_UNUSED(pixmap)
Q_UNUSED(region)
} }
} }

View file

@ -33,7 +33,7 @@ private:
SceneOpenGLTexture(SceneOpenGLTexturePrivate& dd); SceneOpenGLTexture(SceneOpenGLTexturePrivate& dd);
bool load(WindowPixmap *pixmap); bool load(WindowPixmap *pixmap);
void updateFromPixmap(WindowPixmap *pixmap); void updateFromPixmap(WindowPixmap *pixmap, const QRegion &region);
Q_DECLARE_PRIVATE(SceneOpenGLTexture) Q_DECLARE_PRIVATE(SceneOpenGLTexture)
@ -46,7 +46,7 @@ public:
~SceneOpenGLTexturePrivate() override; ~SceneOpenGLTexturePrivate() override;
virtual bool loadTexture(WindowPixmap *pixmap) = 0; virtual bool loadTexture(WindowPixmap *pixmap) = 0;
virtual void updateTexture(WindowPixmap *pixmap); virtual void updateTexture(WindowPixmap *pixmap, const QRegion &region);
virtual OpenGLBackend *backend() = 0; virtual OpenGLBackend *backend() = 0;
protected: protected:

View file

@ -614,7 +614,7 @@ bool EglStreamTexture::loadTexture(WindowPixmap *pixmap)
} }
} }
void EglStreamTexture::updateTexture(WindowPixmap *pixmap) void EglStreamTexture::updateTexture(WindowPixmap *pixmap, const QRegion &region)
{ {
using namespace KWaylandServer; using namespace KWaylandServer;
SurfaceInterface *surface = pixmap->surface(); SurfaceInterface *surface = pixmap->surface();
@ -634,7 +634,7 @@ void EglStreamTexture::updateTexture(WindowPixmap *pixmap)
} }
} else { } else {
// Not an EGLStream surface // Not an EGLStream surface
AbstractEglTexture::updateTexture(pixmap); AbstractEglTexture::updateTexture(pixmap, region);
} }
} }

View file

@ -82,7 +82,7 @@ class EglStreamTexture : public AbstractEglTexture
public: public:
~EglStreamTexture() override; ~EglStreamTexture() override;
bool loadTexture(WindowPixmap *pixmap) override; bool loadTexture(WindowPixmap *pixmap) override;
void updateTexture(WindowPixmap *pixmap) override; void updateTexture(WindowPixmap *pixmap, const QRegion &region) override;
private: private:
EglStreamTexture(SceneOpenGLTexture *texture, EglStreamBackend *backend); EglStreamTexture(SceneOpenGLTexture *texture, EglStreamBackend *backend);

View file

@ -1629,7 +1629,7 @@ bool OpenGLWindowPixmap::bind()
{ {
if (!m_texture->isNull()) { if (!m_texture->isNull()) {
if (needsPixmapUpdate(this)) { if (needsPixmapUpdate(this)) {
m_texture->updateFromPixmap(this); m_texture->updateFromPixmap(this, toplevel->damage());
// mipmaps need to be updated // mipmaps need to be updated
m_texture->setDirty(); m_texture->setDirty();
} }