Changeset View
Changeset View
Standalone View
Standalone View
effects/blur/blur.cpp
Show First 20 Lines • Show All 604 Lines • ▼ Show 20 Line(s) | 585 | { | |||
---|---|---|---|---|---|
605 | 605 | | |||
606 | m_noiseTexture = GLTexture(noiseImage); | 606 | m_noiseTexture = GLTexture(noiseImage); | ||
607 | m_noiseTexture.setFilter(GL_NEAREST); | 607 | m_noiseTexture.setFilter(GL_NEAREST); | ||
608 | m_noiseTexture.setWrapMode(GL_REPEAT); | 608 | m_noiseTexture.setWrapMode(GL_REPEAT); | ||
609 | } | 609 | } | ||
610 | 610 | | |||
611 | void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float opacity, const QMatrix4x4 &screenProjection, bool isDock, QRect windowRect) | 611 | void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float opacity, const QMatrix4x4 &screenProjection, bool isDock, QRect windowRect) | ||
612 | { | 612 | { | ||
613 | QRegion expandedBlurRegion = expand(shape) & expand(screen); | 613 | // Blur would not render correctly on a secondary monitor because of wrong coordinates | ||
614 | // BUG: 393723 | ||||
615 | const int xTranslate = -screen.x(); | ||||
616 | const int yTranslate = effects->virtualScreenSize().height() - screen.height() - screen.y(); | ||||
davidedmundson: to clarify in simpler terms.
I'm sure this needs to be
yTranslate = -screen.y();
can you… | |||||
617 | | ||||
zzag: Why QRegion? | |||||
618 | const QRegion expandedBlurRegion = expand(shape) & expand(screen); | ||||
614 | 619 | | |||
615 | // Upload geometry for the down and upsample iterations | 620 | // Upload geometry for the down and upsample iterations | ||
Please test vertically stacked monitors. I'm 90% sure we now have a bug here. We have 3 possible co-ordinate systems:
it makes sense to move expandedBlurRegion from 1 to 2, but your y translate looks like you're moving it from 1 to 3 which is problematic as glCopyTexSubImage2D flips y again. davidedmundson: Please test vertically stacked monitors.
I'm 90% sure we now have a bug here.
We have 3… | |||||
I tried:
All work perfectly. anemeth: I tried:
- vertical and horizontal stacked displays
- different positions, even… | |||||
There is bug on Wayland. https://bugs.kde.org/show_bug.cgi?id=396055 kpiwowarski: There is bug on Wayland. https://bugs.kde.org/show_bug.cgi?id=396055 | |||||
616 | GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); | 621 | GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); | ||
617 | uploadGeometry(vbo, expandedBlurRegion, shape); | 622 | | ||
623 | uploadGeometry(vbo, expandedBlurRegion.translated(xTranslate, yTranslate), shape); | ||||
618 | vbo->bindArrays(); | 624 | vbo->bindArrays(); | ||
619 | 625 | | |||
626 | const QRect sourceRect = expandedBlurRegion.boundingRect() & screen; | ||||
627 | const QRect destRect = sourceRect.translated(xTranslate, yTranslate); | ||||
628 | | ||||
629 | GLRenderTarget::pushRenderTargets(m_renderTargetStack); | ||||
630 | int blurRectCount = expandedBlurRegion.rectCount() * 6; | ||||
631 | | ||||
620 | /* | 632 | /* | ||
621 | * If the window is a dock or panel we avoid the "extended blur" effect. | 633 | * If the window is a dock or panel we avoid the "extended blur" effect. | ||
622 | * Extended blur is when windows that are not under the blurred area affect | 634 | * Extended blur is when windows that are not under the blurred area affect | ||
623 | * the final blur result. | 635 | * the final blur result. | ||
624 | * We want to avoid this on panels, because it looks really weird and ugly | 636 | * We want to avoid this on panels, because it looks really weird and ugly | ||
625 | * when maximized windows or windows near the panel affect the dock blur. | 637 | * when maximized windows or windows near the panel affect the dock blur. | ||
626 | */ | 638 | */ | ||
627 | isDock ? m_renderTextures.last().bind() : m_renderTextures[0].bind(); | | |||
628 | | ||||
629 | QRect copyRect = expandedBlurRegion.boundingRect() & screen; | | |||
630 | glCopyTexSubImage2D( | | |||
631 | GL_TEXTURE_2D, | | |||
632 | 0, | | |||
633 | copyRect.x(), | | |||
634 | effects->virtualScreenSize().height() - copyRect.y() - copyRect.height(), | | |||
635 | copyRect.x(), | | |||
636 | effects->virtualScreenSize().height() - copyRect.y() - copyRect.height(), | | |||
637 | copyRect.width(), | | |||
638 | copyRect.height() | | |||
639 | ); | | |||
640 | | ||||
641 | GLRenderTarget::pushRenderTargets(m_renderTargetStack); | | |||
642 | int blurRectCount = expandedBlurRegion.rectCount() * 6; | | |||
643 | | ||||
644 | if (isDock) { | 639 | if (isDock) { | ||
zzag: Unrelated change. | |||||
645 | copyScreenSampleTexture(vbo, blurRectCount, shape, screen.size(), screenProjection); | 640 | m_renderTargets.last()->blitFromFramebuffer(sourceRect, destRect); | ||
641 | copyScreenSampleTexture(vbo, blurRectCount, shape.translated(xTranslate, yTranslate), screenProjection); | ||||
646 | } else { | 642 | } else { | ||
643 | m_renderTargets.first()->blitFromFramebuffer(sourceRect, destRect); | ||||
644 | | ||||
647 | // Remove the m_renderTargets[0] from the top of the stack that we will not use | 645 | // Remove the m_renderTargets[0] from the top of the stack that we will not use | ||
648 | GLRenderTarget::popRenderTarget(); | 646 | GLRenderTarget::popRenderTarget(); | ||
649 | } | 647 | } | ||
650 | 648 | | |||
651 | downSampleTexture(vbo, blurRectCount); | 649 | downSampleTexture(vbo, blurRectCount); | ||
652 | upSampleTexture(vbo, blurRectCount); | 650 | upSampleTexture(vbo, blurRectCount); | ||
653 | 651 | | |||
654 | // Modulate the blurred texture with the window opacity if the window isn't opaque | 652 | // Modulate the blurred texture with the window opacity if the window isn't opaque | ||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | 734 | for (int i = m_downSampleIterations - 1; i >= 1; i--) { | |||
745 | 743 | | |||
746 | vbo->draw(GL_TRIANGLES, blurRectCount * i, blurRectCount); | 744 | vbo->draw(GL_TRIANGLES, blurRectCount * i, blurRectCount); | ||
747 | GLRenderTarget::popRenderTarget(); | 745 | GLRenderTarget::popRenderTarget(); | ||
748 | } | 746 | } | ||
749 | 747 | | |||
750 | m_shader->unbind(); | 748 | m_shader->unbind(); | ||
751 | } | 749 | } | ||
752 | 750 | | |||
753 | void BlurEffect::copyScreenSampleTexture(GLVertexBuffer *vbo, int blurRectCount, QRegion blurShape, QSize screenSize, QMatrix4x4 screenProjection) | 751 | void BlurEffect::copyScreenSampleTexture(GLVertexBuffer *vbo, int blurRectCount, QRegion blurShape, QMatrix4x4 screenProjection) | ||
754 | { | 752 | { | ||
755 | m_shader->bind(BlurShader::CopySampleType); | 753 | m_shader->bind(BlurShader::CopySampleType); | ||
756 | 754 | | |||
757 | m_shader->setModelViewProjectionMatrix(screenProjection); | 755 | m_shader->setModelViewProjectionMatrix(screenProjection); | ||
758 | m_shader->setTargetTextureSize(screenSize); | 756 | m_shader->setTargetTextureSize(effects->virtualScreenSize()); | ||
759 | 757 | | |||
760 | /* | 758 | /* | ||
761 | * This '1' sized adjustment is necessary do avoid windows affecting the blur that are | 759 | * This '1' sized adjustment is necessary do avoid windows affecting the blur that are | ||
762 | * right next to this window. | 760 | * right next to this window. | ||
763 | */ | 761 | */ | ||
764 | m_shader->setBlurRect(blurShape.boundingRect().adjusted(1, 1, -1, -1), screenSize); | 762 | m_shader->setBlurRect(blurShape.boundingRect().adjusted(1, 1, -1, -1), effects->virtualScreenSize()); | ||
763 | m_renderTextures.last().bind(); | ||||
765 | 764 | | |||
766 | vbo->draw(GL_TRIANGLES, 0, blurRectCount); | 765 | vbo->draw(GL_TRIANGLES, 0, blurRectCount); | ||
767 | GLRenderTarget::popRenderTarget(); | 766 | GLRenderTarget::popRenderTarget(); | ||
768 | 767 | | |||
769 | m_shader->unbind(); | 768 | m_shader->unbind(); | ||
770 | } | 769 | } | ||
771 | 770 | | |||
772 | } // namespace KWin | 771 | } // namespace KWin | ||
773 | 772 | |
to clarify in simpler terms.
I'm sure this needs to be
yTranslate = -screen.y();
can you please test with that.