diff --git a/src/effect/effect.cpp b/src/effect/effect.cpp index 9d903b72a1..2f6b1313cb 100644 --- a/src/effect/effect.cpp +++ b/src/effect/effect.cpp @@ -215,19 +215,12 @@ public: qreal brightness; int screen; qreal crossFadeProgress; - QMatrix4x4 projectionMatrix; }; WindowPaintData::WindowPaintData() - : WindowPaintData(QMatrix4x4()) -{ -} - -WindowPaintData::WindowPaintData(const QMatrix4x4 &projectionMatrix) : PaintData() , d(std::make_unique()) { - setProjectionMatrix(projectionMatrix); setOpacity(1.0); setSaturation(1.0); setBrightness(1.0); @@ -251,7 +244,6 @@ WindowPaintData::WindowPaintData(const WindowPaintData &other) setBrightness(other.brightness()); setScreen(other.screen()); setCrossFadeProgress(other.crossFadeProgress()); - setProjectionMatrix(other.projectionMatrix()); } WindowPaintData::~WindowPaintData() = default; @@ -324,21 +316,6 @@ qreal WindowPaintData::multiplyBrightness(qreal factor) return d->brightness; } -void WindowPaintData::setProjectionMatrix(const QMatrix4x4 &matrix) -{ - d->projectionMatrix = matrix; -} - -QMatrix4x4 WindowPaintData::projectionMatrix() const -{ - return d->projectionMatrix; -} - -QMatrix4x4 &WindowPaintData::rprojectionMatrix() -{ - return d->projectionMatrix; -} - WindowPaintData &WindowPaintData::operator*=(qreal scale) { this->setXScale(this->xScale() * scale); diff --git a/src/effect/effect.h b/src/effect/effect.h index 777a2a149d..378eb8f0e1 100644 --- a/src/effect/effect.h +++ b/src/effect/effect.h @@ -300,7 +300,6 @@ class KWIN_EXPORT WindowPaintData : public PaintData { public: WindowPaintData(); - explicit WindowPaintData(const QMatrix4x4 &projectionMatrix); WindowPaintData(const WindowPaintData &other); ~WindowPaintData() override; /** @@ -437,23 +436,6 @@ public: */ qreal crossFadeProgress() const; - /** - * Sets the projection matrix that will be used when painting the window. - * - * The default projection matrix can be overridden by setting this matrix - */ - void setProjectionMatrix(const QMatrix4x4 &matrix); - - /** - * Returns the current projection matrix. - */ - QMatrix4x4 projectionMatrix() const; - - /** - * Returns a reference to the projection matrix. - */ - QMatrix4x4 &rprojectionMatrix(); - private: const std::unique_ptr d; }; diff --git a/src/effect/offscreeneffect.cpp b/src/effect/offscreeneffect.cpp index c24c88c430..873b9e7fd6 100644 --- a/src/effect/offscreeneffect.cpp +++ b/src/effect/offscreeneffect.cpp @@ -117,14 +117,8 @@ void OffscreenData::maybeRender(EffectWindow *window) glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); - QMatrix4x4 projectionMatrix; - projectionMatrix.ortho(QRectF(0, 0, textureSize.width(), textureSize.height())); - WindowPaintData data; - data.setXTranslation(-logicalGeometry.x()); - data.setYTranslation(-logicalGeometry.y()); data.setOpacity(1.0); - data.setProjectionMatrix(projectionMatrix); const int mask = Effect::PAINT_WINDOW_TRANSFORMED | Effect::PAINT_WINDOW_TRANSLUCENT; effects->drawWindow(renderTarget, viewport, window, mask, infiniteRegion(), data); @@ -185,7 +179,7 @@ void OffscreenData::paint(const RenderTarget &renderTarget, const RenderViewport const qreal rgb = data.brightness() * data.opacity(); const qreal a = data.opacity(); - QMatrix4x4 mvp = data.projectionMatrix(); + QMatrix4x4 mvp = viewport.projectionMatrix(); mvp.translate(std::round(window->x() * scale), std::round(window->y() * scale)); const auto toXYZ = renderTarget.colorDescription().colorimetry().toXYZ(); diff --git a/src/plugins/backgroundcontrast/contrast.cpp b/src/plugins/backgroundcontrast/contrast.cpp index 56c1f92426..409f033472 100644 --- a/src/plugins/backgroundcontrast/contrast.cpp +++ b/src/plugins/backgroundcontrast/contrast.cpp @@ -422,7 +422,7 @@ void ContrastEffect::drawWindow(const RenderTarget &renderTarget, const RenderVi const QRegion effectiveShape = shape & region & screen; if (!effectiveShape.isEmpty()) { - doContrast(renderTarget, viewport, w, effectiveShape, w->opacity() * data.opacity(), data.projectionMatrix()); + doContrast(renderTarget, viewport, w, effectiveShape, w->opacity() * data.opacity(), viewport.projectionMatrix()); } } diff --git a/src/plugins/blur/blur.cpp b/src/plugins/blur/blur.cpp index e5feee0bb5..a29e4710f0 100644 --- a/src/plugins/blur/blur.cpp +++ b/src/plugins/blur/blur.cpp @@ -774,7 +774,7 @@ void BlurEffect::blur(const RenderTarget &renderTarget, const RenderViewport &vi GLFramebuffer::popFramebuffer(); const auto &read = renderInfo.framebuffers[1]; - projectionMatrix = data.projectionMatrix(); + projectionMatrix = viewport.projectionMatrix(); projectionMatrix.translate(deviceBackgroundRect.x(), deviceBackgroundRect.y()); m_upsamplePass.shader->setUniform(m_upsamplePass.mvpMatrixLocation, projectionMatrix); @@ -816,7 +816,7 @@ void BlurEffect::blur(const RenderTarget &renderTarget, const RenderViewport &vi if (GLTexture *noiseTexture = ensureNoiseTexture()) { ShaderManager::instance()->pushShader(m_noisePass.shader.get()); - QMatrix4x4 projectionMatrix = data.projectionMatrix(); + QMatrix4x4 projectionMatrix = viewport.projectionMatrix(); projectionMatrix.translate(deviceBackgroundRect.x(), deviceBackgroundRect.y()); m_noisePass.shader->setUniform(m_noisePass.mvpMatrixLocation, projectionMatrix); diff --git a/src/plugins/screencast/windowscreencastsource.cpp b/src/plugins/screencast/windowscreencastsource.cpp index f3acbeb9ba..7679f9580c 100644 --- a/src/plugins/screencast/windowscreencastsource.cpp +++ b/src/plugins/screencast/windowscreencastsource.cpp @@ -64,13 +64,10 @@ void WindowScreenCastSource::render(GLFramebuffer *target) RenderTarget renderTarget(target); RenderViewport viewport(m_window->clientGeometry(), 1, renderTarget); - WindowPaintData data; - data.setProjectionMatrix(viewport.projectionMatrix()); - GLFramebuffer::pushFramebuffer(target); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); - Compositor::self()->scene()->renderer()->renderItem(renderTarget, viewport, m_window->windowItem(), Scene::PAINT_WINDOW_TRANSFORMED, infiniteRegion(), data); + Compositor::self()->scene()->renderer()->renderItem(renderTarget, viewport, m_window->windowItem(), Scene::PAINT_WINDOW_TRANSFORMED, infiniteRegion(), WindowPaintData{}); GLFramebuffer::popFramebuffer(); } diff --git a/src/plugins/screenshot/screenshot.cpp b/src/plugins/screenshot/screenshot.cpp index 9e7479d816..54b27d7993 100644 --- a/src/plugins/screenshot/screenshot.cpp +++ b/src/plugins/screenshot/screenshot.cpp @@ -228,7 +228,6 @@ void ScreenShotEffect::takeScreenShot(ScreenShotWindowData *screenshot) { EffectWindow *window = screenshot->window; - WindowPaintData d; QRectF geometry = window->expandedGeometry(); qreal devicePixelRatio = 1; @@ -258,9 +257,6 @@ void ScreenShotEffect::takeScreenShot(ScreenShotWindowData *screenshot) validTarget = target->valid(); } if (validTarget) { - d.setXTranslation(-geometry.x()); - d.setYTranslation(-geometry.y()); - // render window into offscreen texture int mask = PAINT_WINDOW_TRANSFORMED | PAINT_WINDOW_TRANSLUCENT; QImage img; @@ -272,10 +268,7 @@ void ScreenShotEffect::takeScreenShot(ScreenShotWindowData *screenshot) glClear(GL_COLOR_BUFFER_BIT); glClearColor(0.0, 0.0, 0.0, 1.0); - QMatrix4x4 projection; - projection.ortho(QRect(0, 0, geometry.width() * devicePixelRatio, geometry.height() * devicePixelRatio)); - d.setProjectionMatrix(projection); - + WindowPaintData d; effects->drawWindow(renderTarget, viewport, window, mask, infiniteRegion(), d); // copy content from framebuffer into image diff --git a/src/plugins/thumbnailaside/thumbnailaside.cpp b/src/plugins/thumbnailaside/thumbnailaside.cpp index 6f774eea16..21a388de95 100644 --- a/src/plugins/thumbnailaside/thumbnailaside.cpp +++ b/src/plugins/thumbnailaside/thumbnailaside.cpp @@ -62,7 +62,7 @@ void ThumbnailAsideEffect::paintScreen(const RenderTarget &renderTarget, const R for (const Data &d : std::as_const(windows)) { if (painted.intersects(d.rect)) { - WindowPaintData data(viewport.projectionMatrix()); + WindowPaintData data; data.multiplyOpacity(opacity); QRect region; setPositionTransformations(data, region, d.window, d.rect, Qt::KeepAspectRatio); diff --git a/src/scene/cursorscene.cpp b/src/scene/cursorscene.cpp index 6f3ba58f57..49a118e9f3 100644 --- a/src/scene/cursorscene.cpp +++ b/src/scene/cursorscene.cpp @@ -58,7 +58,7 @@ void CursorScene::paint(const RenderTarget &renderTarget, const QRegion ®ion) RenderViewport viewport(QRectF(QPointF(), QSizeF(renderTarget.size()) / m_paintedOutput->scale()), m_paintedOutput->scale(), renderTarget); m_renderer->beginFrame(renderTarget, viewport); m_renderer->renderBackground(renderTarget, viewport, region); - m_renderer->renderItem(renderTarget, viewport, m_rootItem.get(), 0, region, WindowPaintData(viewport.projectionMatrix())); + m_renderer->renderItem(renderTarget, viewport, m_rootItem.get(), 0, region, WindowPaintData{}); m_renderer->endFrame(); } diff --git a/src/scene/itemrenderer_opengl.cpp b/src/scene/itemrenderer_opengl.cpp index 44ec0918e3..7f3a052ba3 100644 --- a/src/scene/itemrenderer_opengl.cpp +++ b/src/scene/itemrenderer_opengl.cpp @@ -260,7 +260,7 @@ void ItemRendererOpenGL::renderItem(const RenderTarget &renderTarget, const Rend } RenderContext renderContext{ - .projectionMatrix = data.projectionMatrix(), + .projectionMatrix = viewport.projectionMatrix(), .clip = region, .hardwareClipping = region != infiniteRegion() && ((mask & Scene::PAINT_WINDOW_TRANSFORMED) || (mask & Scene::PAINT_SCREEN_TRANSFORMED)), .renderTargetScale = viewport.scale(), diff --git a/src/scene/workspacescene.cpp b/src/scene/workspacescene.cpp index 8c1614f0e8..7ff7e4b2c3 100644 --- a/src/scene/workspacescene.cpp +++ b/src/scene/workspacescene.cpp @@ -435,7 +435,7 @@ void WorkspaceScene::paintSimpleScreen(const RenderTarget &renderTarget, const R if (m_dndIcon) { const QRegion repaint = region & m_dndIcon->mapToGlobal(m_dndIcon->boundingRect()).toRect(); if (!repaint.isEmpty()) { - m_renderer->renderItem(renderTarget, viewport, m_dndIcon.get(), 0, repaint, WindowPaintData(viewport.projectionMatrix())); + m_renderer->renderItem(renderTarget, viewport, m_dndIcon.get(), 0, repaint, WindowPaintData{}); } } } @@ -462,7 +462,7 @@ void WorkspaceScene::paintWindow(const RenderTarget &renderTarget, const RenderV return; } - WindowPaintData data(viewport.projectionMatrix()); + WindowPaintData data; effects->paintWindow(renderTarget, viewport, item->effectWindow(), mask, region, data); } diff --git a/src/scripting/windowthumbnailitem.cpp b/src/scripting/windowthumbnailitem.cpp index d8b26d980e..d2b46747fe 100644 --- a/src/scripting/windowthumbnailitem.cpp +++ b/src/scripting/windowthumbnailitem.cpp @@ -117,6 +117,7 @@ void WindowThumbnailSource::update() if (!m_offscreenTexture) { return; } + m_offscreenTexture->setContentTransform(OutputTransform::FlipY); m_offscreenTexture->setFilter(GL_LINEAR); m_offscreenTexture->setWrapMode(GL_CLAMP_TO_EDGE); m_offscreenTarget = std::make_unique(m_offscreenTexture.get()); @@ -128,18 +129,11 @@ void WindowThumbnailSource::update() glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); - QMatrix4x4 projectionMatrix; - projectionMatrix.ortho(geometry.x() * devicePixelRatio, (geometry.x() + geometry.width()) * devicePixelRatio, - geometry.y() * devicePixelRatio, (geometry.y() + geometry.height()) * devicePixelRatio, -1, 1); - - WindowPaintData data; - data.setProjectionMatrix(projectionMatrix); - // The thumbnail must be rendered using kwin's opengl context as VAOs are not // shared across contexts. Unfortunately, this also introduces a latency of 1 // frame, which is not ideal, but it is acceptable for things such as thumbnails. const int mask = Scene::PAINT_WINDOW_TRANSFORMED; - Compositor::self()->scene()->renderer()->renderItem(offscreenRenderTarget, offscreenViewport, m_handle->windowItem(), mask, infiniteRegion(), data); + Compositor::self()->scene()->renderer()->renderItem(offscreenRenderTarget, offscreenViewport, m_handle->windowItem(), mask, infiniteRegion(), WindowPaintData{}); GLFramebuffer::popFramebuffer(); // The fence is needed to avoid the case where qtquick renderer starts using