kwineffects: Remove PaintClipper
PaintClipper worked only with the XRender backend, which is gone now.
This commit is contained in:
parent
3ae400772b
commit
f280423b92
6 changed files with 14 additions and 192 deletions
|
@ -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.
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
***************************************************************/
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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<float> 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<float> 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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue