diff --git a/src/effects/slide/slide.cpp b/src/effects/slide/slide.cpp index ddbbce236b..5777963079 100644 --- a/src/effects/slide/slide.cpp +++ b/src/effects/slide/slide.cpp @@ -165,12 +165,6 @@ void SlideEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData & } } - // If screen is painted with either PAINT_SCREEN_TRANSFORMED or - // PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS there is no clipping!! - // Push the screen geometry to the paint clipper so everything outside - // of the screen geometry is clipped. - PaintClipper pc(QRegion(effects->virtualScreenGeometry())); - // Screen is painted in several passes. Each painting pass paints // a single virtual desktop. There could be either 2 or 4 painting // passes, depending how an user moves between virtual desktops. diff --git a/src/effects/slideback/slideback.cpp b/src/effects/slideback/slideback.cpp index 4cd7e919f3..37dfa484e5 100644 --- a/src/effects/slideback/slideback.cpp +++ b/src/effects/slideback/slideback.cpp @@ -177,8 +177,6 @@ void SlideBackEffect::paintWindow(EffectWindow *w, int mask, QRegion region, Win region = region.intersected(r); } effects->paintWindow(w, mask, region, data); - for (int i = clippedRegions.count() - 1; i > -1; --i) - PaintClipper::pop(clippedRegions.at(i)); clippedRegions.clear(); } diff --git a/src/libkwineffects/kwineffects.cpp b/src/libkwineffects/kwineffects.cpp index 31dc8cf44d..856a42339e 100644 --- a/src/libkwineffects/kwineffects.cpp +++ b/src/libkwineffects/kwineffects.cpp @@ -1300,106 +1300,6 @@ bool WindowQuadList::isTransformed() const return std::any_of(constBegin(), constEnd(), [] (const WindowQuad & q) { return q.isTransformed(); }); } -/*************************************************************** - PaintClipper -***************************************************************/ - -QStack< QRegion >* PaintClipper::areas = nullptr; - -PaintClipper::PaintClipper(const QRegion& allowed_area) - : area(allowed_area) -{ - push(area); -} - -PaintClipper::~PaintClipper() -{ - pop(area); -} - -void PaintClipper::push(const QRegion& allowed_area) -{ - if (allowed_area == infiniteRegion()) // don't push these - return; - if (areas == nullptr) - areas = new QStack< QRegion >; - areas->push(allowed_area); -} - -void PaintClipper::pop(const QRegion& allowed_area) -{ - if (allowed_area == infiniteRegion()) - return; - Q_ASSERT(areas != nullptr); - Q_ASSERT(areas->top() == allowed_area); - areas->pop(); - if (areas->isEmpty()) { - delete areas; - areas = nullptr; - } -} - -bool PaintClipper::clip() -{ - return areas != nullptr; -} - -QRegion PaintClipper::paintArea() -{ - Q_ASSERT(areas != nullptr); // can be called only with clip() == true - const QSize &s = effects->virtualScreenSize(); - QRegion ret(0, 0, s.width(), s.height()); - for (const QRegion & r : qAsConst(*areas)) { - ret &= r; - } - return ret; -} - -struct PaintClipper::Iterator::Data { - Data() : index(0) {} - int index; - QRegion region; -}; - -PaintClipper::Iterator::Iterator() - : data(new Data) -{ - if (clip() && effects->isOpenGLCompositing()) { - data->region = paintArea(); - data->index = -1; - next(); // move to the first one - } -} - -PaintClipper::Iterator::~Iterator() -{ - delete data; -} - -bool PaintClipper::Iterator::isDone() -{ - if (!clip()) - return data->index == 1; // run once - if (effects->isOpenGLCompositing()) - return data->index >= data->region.rectCount(); // run once per each area - abort(); -} - -void PaintClipper::Iterator::next() -{ - data->index++; -} - -QRect PaintClipper::Iterator::boundingRect() const -{ - if (!clip()) - return infiniteRegion(); - if (effects->isOpenGLCompositing()) - return *(data->region.begin() + data->index); - abort(); - return infiniteRegion(); -} - /*************************************************************** Motion1D ***************************************************************/ diff --git a/src/libkwineffects/kwineffects.h b/src/libkwineffects/kwineffects.h index d812cc62a7..6a7ab51f9c 100644 --- a/src/libkwineffects/kwineffects.h +++ b/src/libkwineffects/kwineffects.h @@ -3125,71 +3125,6 @@ public: QRegion paint; }; -/** - * @short Helper class for restricting painting area only to allowed area. - * - * This helper class helps specifying areas that should be painted, clipping - * out the rest. The simplest usage is creating an object on the stack - * and giving it the area that is allowed to be painted to. When the object - * is destroyed, the restriction will be removed. - * Note that all painting code must use paintArea() to actually perform the clipping. - */ -class KWINEFFECTS_EXPORT PaintClipper -{ -public: - /** - * Calls push(). - */ - explicit PaintClipper(const QRegion& allowed_area); - /** - * Calls pop(). - */ - ~PaintClipper(); - /** - * Allows painting only in the given area. When areas have been already - * specified, painting is allowed only in the intersection of all areas. - */ - static void push(const QRegion& allowed_area); - /** - * Removes the given area. It must match the top item in the stack. - */ - static void pop(const QRegion& allowed_area); - /** - * Returns true if any clipping should be performed. - */ - static bool clip(); - /** - * If clip() returns true, this function gives the resulting area in which - * painting is allowed. It is usually simpler to use the helper Iterator class. - */ - static QRegion paintArea(); - /** - * Helper class to perform the clipped painting. The usage is: - * @code - * for ( PaintClipper::Iterator iterator; - * !iterator.isDone(); - * iterator.next()) - * { // do the painting, possibly use iterator.boundingRect() - * } - * @endcode - */ - class KWINEFFECTS_EXPORT Iterator - { - public: - Iterator(); - ~Iterator(); - bool isDone(); - void next(); - QRect boundingRect() const; - private: - struct Data; - Data* data; - }; -private: - QRegion area; - static QStack< QRegion >* areas; -}; - /** * @internal */ diff --git a/src/plugins/scenes/opengl/scene_opengl.cpp b/src/plugins/scenes/opengl/scene_opengl.cpp index 84babd7003..85b9800580 100644 --- a/src/plugins/scenes/opengl/scene_opengl.cpp +++ b/src/plugins/scenes/opengl/scene_opengl.cpp @@ -761,25 +761,23 @@ QMatrix4x4 SceneOpenGL::transformation(int mask, const ScreenPaintData &data) co void SceneOpenGL::paintBackground(const QRegion ®ion) { - PaintClipper pc(region); - if (!PaintClipper::clip()) { + if (region == infiniteRegion()) { glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); - return; + } else if (!region.isEmpty()) { + QVector verts; + verts.reserve(region.rectCount() * 6 * 2); + + for (const QRect &r : region) { + verts << r.x() + r.width() << r.y(); + verts << r.x() << r.y(); + verts << r.x() << r.y() + r.height(); + verts << r.x() << r.y() + r.height(); + verts << r.x() + r.width() << r.y() + r.height(); + verts << r.x() + r.width() << r.y(); + } + doPaintBackground(verts); } - if (pc.clip() && pc.paintArea().isEmpty()) - return; // no background to paint - QVector verts; - for (PaintClipper::Iterator iterator; !iterator.isDone(); iterator.next()) { - QRect r = iterator.boundingRect(); - verts << r.x() + r.width() << r.y(); - verts << r.x() << r.y(); - verts << r.x() << r.y() + r.height(); - verts << r.x() << r.y() + r.height(); - verts << r.x() + r.width() << r.y() + r.height(); - verts << r.x() + r.width() << r.y(); - } - doPaintBackground(verts); } void SceneOpenGL::extendPaintRegion(QRegion ®ion, bool opaqueFullscreen) diff --git a/src/scene.cpp b/src/scene.cpp index ae6309063c..55c926dc92 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -210,9 +210,6 @@ void Scene::paintScreen(int* mask, const QRegion &damage, const QRegion &repaint damaged_region = QRegion(); m_paintScreenCount = 0; - - // make sure all clipping is restored - Q_ASSERT(!PaintClipper::clip()); } // the function that'll be eventually called by paintScreen() above