Commit 0f3380f3 authored by Thomas Lübking's avatar Thomas Lübking
Browse files

split decorationRect / visibleRect usage

REVIEW: 104215
parent 30ee236d
......@@ -2405,12 +2405,7 @@ void Client::setSessionInteract(bool needed)
QRect Client::decorationRect() const
{
if (decoration && decoration->widget()) {
QRect r = decoration->widget()->rect().translated(-padding_left, -padding_top);
if (hasShadow())
r |= shadow()->shadowRegion().boundingRect();
return r;
} else if (hasShadow()) {
return shadow()->shadowRegion().boundingRect();
return decoration->widget()->rect().translated(-padding_left, -padding_top);
} else {
return QRect(0, 0, width(), height());
}
......
......@@ -762,7 +762,7 @@ void Toplevel::addRepaint(const QRegion& r)
void Toplevel::addRepaintFull()
{
repaints_region = decorationRect();
repaints_region = visibleRect().translated(-pos());
workspace()->checkCompositeTimer();
}
......
......@@ -149,11 +149,7 @@ void Deleted::layoutDecorationRects(QRect& left, QRect& top, QRect& right, QRect
QRect Deleted::decorationRect() const
{
QRect r(rect());
r.adjust(-padding_left, -padding_top, padding_top, padding_bottom);
if (hasShadow())
r |= shadow()->shadowRegion().boundingRect();
return r;
return rect().adjusted(-padding_left, -padding_top, padding_top, padding_bottom);
}
QRect Deleted::transparentRect() const
......
......@@ -1946,7 +1946,7 @@ void Client::setGeometry(int x, int y, int w, int h, ForceGeometry_t force, bool
discardWindowPixmap();
emit geometryShapeChanged(this, geom_before_block);
}
const QRect deco_rect = decorationRect().translated(geom.x(), geom.y());
const QRect deco_rect = visibleRect();
addWorkspaceRepaint(deco_rect_before_block);
addWorkspaceRepaint(deco_rect);
geom_before_block = geom;
......@@ -2019,7 +2019,7 @@ void Client::plainResize(int w, int h, ForceGeometry_t force, bool emitJs)
workspace()->checkUnredirect();
discardWindowPixmap();
emit geometryShapeChanged(this, geom_before_block);
const QRect deco_rect = decorationRect().translated(geom.x(), geom.y());
const QRect deco_rect = visibleRect();
addWorkspaceRepaint(deco_rect_before_block);
addWorkspaceRepaint(deco_rect);
geom_before_block = geom;
......@@ -2064,7 +2064,7 @@ void Client::move(int x, int y, ForceGeometry_t force)
workspace()->tiling()->notifyTilingWindowMove(this, moveResizeGeom, initialMoveResizeGeom);
#endif
// client itself is not damaged
const QRect deco_rect = decorationRect().translated(geom.x(), geom.y());
const QRect deco_rect = visibleRect();
addWorkspaceRepaint(deco_rect_before_block);
addWorkspaceRepaint(deco_rect); // trigger repaint of window's new location
geom_before_block = geom;
......
......@@ -213,7 +213,7 @@ void Scene::paintGenericScreen(int orig_mask, ScreenPaintData)
// Reset the repaint_region.
// This has to be done here because many effects schedule a repaint for
// the next frame within Effects::prePaintWindow.
topw->resetRepaints(topw->decorationRect());
topw->resetRepaints(topw->visibleRect().translated(-topw->pos()));
WindowPrePaintData data;
data.mask = orig_mask | (w->isOpaque() ? PAINT_WINDOW_OPAQUE : PAINT_WINDOW_TRANSLUCENT);
......@@ -269,7 +269,7 @@ void Scene::paintSimpleScreen(int orig_mask, QRegion region)
// Reset the repaint_region.
// This has to be done here because many effects schedule a repaint for
// the next frame within Effects::prePaintWindow.
topw->resetRepaints(topw->decorationRect());
topw->resetRepaints(topw->visibleRect().translated(-topw->pos()));
// Clip out the decoration for opaque windows; the decoration is drawn in the second pass
if (w->isOpaque()) {
// the window is fully opaque
......@@ -314,7 +314,7 @@ void Scene::paintSimpleScreen(int orig_mask, QRegion region)
// In case there is a window with a higher stackposition which has translucent regions
// (e.g. decorations) that still have to be drawn, we also have to repaint the current window
// in these particular regions
data->region |= (upperTranslucentDamage & tlw->decorationRect().translated(tlw->pos()));
data->region |= (upperTranslucentDamage & tlw->visibleRect());
// subtract the parts which have possibly been drawn already as part of
// a higher opaque window
......@@ -360,7 +360,7 @@ void Scene::paintSimpleScreen(int orig_mask, QRegion region)
Toplevel *tlw = data.key()->window();
// add all regions of the lower windows which have already be drawn in the 1st pass
data->region |= (lowerOpaqueDamage & tlw->decorationRect().translated(tlw->pos()));
data->region |= (lowerOpaqueDamage & tlw->visibleRect());
// and extend that region by opaque parts of ourself
lowerOpaqueDamage |= data->painted_1stpass;
......@@ -572,7 +572,7 @@ WindowQuadList Scene::Window::buildQuads(bool force) const
if (cached_quad_list != NULL && !force)
return *cached_quad_list;
WindowQuadList ret;
if (toplevel->clientPos() == QPoint(0, 0) && toplevel->clientSize() == toplevel->visibleRect().size())
if (toplevel->clientPos() == QPoint(0, 0) && toplevel->clientSize() == toplevel->decorationRect().size())
ret = makeQuads(WindowQuadContents, shape()); // has no decoration
else {
Client *client = dynamic_cast<Client*>(toplevel);
......
......@@ -355,6 +355,7 @@ void SceneXrender::windowAdded(Toplevel* c)
//****************************************
QPixmap *SceneXrender::Window::temp_pixmap = 0;
QRect SceneXrender::Window::temp_visibleRect;
SceneXrender::Window::Window(Toplevel* c)
: Scene::Window(c)
......@@ -483,14 +484,14 @@ QPoint SceneXrender::Window::mapToScreen(int mask, const WindowPaintData &data,
void SceneXrender::Window::prepareTempPixmap()
{
const QRect r = static_cast<Client*>(toplevel)->decorationRect();
temp_visibleRect = toplevel->visibleRect().translated(-toplevel->pos());
if (temp_pixmap && Extensions::nonNativePixmaps())
XFreePixmap(display(), temp_pixmap->handle()); // The picture owns the pixmap now
if (!temp_pixmap)
temp_pixmap = new QPixmap(r.width(), r.height());
else if (temp_pixmap->width() < r.width() || temp_pixmap->height() < r.height()) {
*temp_pixmap = QPixmap(r.width(), r.height());
temp_pixmap = new QPixmap(temp_visibleRect.size());
else if (temp_pixmap->width() < temp_visibleRect.width() || temp_pixmap->height() < temp_visibleRect.height()) {
*temp_pixmap = QPixmap(temp_visibleRect.size());
scene_setXRenderOffscreenTarget(0); // invalidate, better crash than cause weird results for developers
}
if (Extensions::nonNativePixmaps()) {
......@@ -543,9 +544,7 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
Client *client = dynamic_cast<Client*>(toplevel);
Deleted *deleted = dynamic_cast<Deleted*>(toplevel);
const QRect decorationRect = toplevel->decorationRect();
if (client && Workspace::self()->decorationHasAlpha())
transformed_shape = decorationRect;
else if (deleted && Workspace::self()->decorationHasAlpha())
if ((client || deleted) && Workspace::self()->decorationHasAlpha())
transformed_shape = decorationRect;
else
transformed_shape = shape();
......@@ -610,9 +609,10 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
Picture renderTarget = buffer;
if (blitInTempPixmap) {
if (scene_xRenderOffscreenTarget())
if (scene_xRenderOffscreenTarget()) {
temp_visibleRect = toplevel->visibleRect().translated(-toplevel->pos());
renderTarget = *scene_xRenderOffscreenTarget();
else {
} else {
prepareTempPixmap();
renderTarget = temp_pixmap->x11PictureHandle();
}
......@@ -640,7 +640,7 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
//END OF STUPID RADEON HACK
}
#define MAP_RECT_TO_TARGET(_RECT_) \
if (blitInTempPixmap) _RECT_.translate(-decorationRect.topLeft()); else _RECT_ = mapToScreen(mask, data, _RECT_)
if (blitInTempPixmap) _RECT_.translate(-temp_visibleRect.topLeft()); else _RECT_ = mapToScreen(mask, data, _RECT_)
//BEGIN deco preparations
bool noBorder = true;
......@@ -696,7 +696,7 @@ void SceneXrender::Window::performPaint(int mask, QRegion region, WindowPaintDat
//BEGIN client preparations
QRect dr = cr;
if (blitInTempPixmap) {
dr.translate(-decorationRect.topLeft());
dr.translate(-temp_visibleRect.topLeft());
} else {
dr = mapToScreen(mask, data, dr); // Destination rect
if (scaled) {
......@@ -757,13 +757,14 @@ XRenderComposite(display(), PictOpOver, _PART_->x11PictureHandle(), decorationAl
// fake brightness change by overlaying black
XRenderColor col = { 0, 0, 0, 0xffff *(1 - data.brightness) * data.opacity };
if (blitInTempPixmap) {
XRenderFillRectangle(display(), PictOpOver, renderTarget, &col, -decorationRect.left(), -decorationRect.top(), width(), height());
XRenderFillRectangle(display(), PictOpOver, renderTarget, &col,
-temp_visibleRect.left(), -temp_visibleRect.top(), width(), height());
} else {
XRenderFillRectangle(display(), PictOpOver, renderTarget, &col, wr.x(), wr.y(), wr.width(), wr.height());
}
}
if (blitInTempPixmap) {
const QRect r = mapToScreen(mask, data, decorationRect);
const QRect r = mapToScreen(mask, data, temp_visibleRect);
XRenderSetPictureTransform(display(), temp_pixmap->x11PictureHandle(), &xform);
XRenderSetPictureFilter(display(), temp_pixmap->x11PictureHandle(), const_cast<char*>("good"), NULL, 0);
XRenderComposite(display(), PictOpOver, temp_pixmap->x11PictureHandle(), None, buffer,
......
......@@ -93,6 +93,7 @@ private:
double alpha_cached_opacity;
QRegion transformed_shape;
static QPixmap *temp_pixmap;
static QRect temp_visibleRect;
};
class SceneXrender::EffectFrame
......
......@@ -96,10 +96,7 @@ QDebug& operator<<(QDebug& stream, const ConstToplevelList& list)
QRect Toplevel::decorationRect() const
{
QRect r(rect());
if (hasShadow())
r |= shadow()->shadowRegion().boundingRect();
return r;
return rect();
}
void Toplevel::detectShape(Window id)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment