Skip to content

Commit

Permalink
GC & Drawing: Further work on clipping.
Browse files Browse the repository at this point in the history
Still disabled as it does not work correctly.
  • Loading branch information
waddlesplash committed May 10, 2023
1 parent f59e78e commit 78d3a6b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
6 changes: 6 additions & 0 deletions xlib/Drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ extern "C" {
class DrawStateManager
{
XDrawable* _drawable;
GC _gc;

public:
DrawStateManager(Drawable w, GC gc)
{
_drawable = Drawables::get(w);
_gc = gc;
if (!_drawable)
return;

Expand All @@ -41,6 +43,10 @@ class DrawStateManager
if (!_drawable)
return;

if (_x_gc_has_clipping(_gc)) {
_drawable->view()->ConstrainClippingRegion(NULL);
_gc->dirty |= GCClipMask;
}
_drawable->view()->UnlockLooper();
}

Expand Down
20 changes: 14 additions & 6 deletions xlib/GC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,16 @@ XSetClipMask(Display* display, GC gc, Pixmap pixmap)
return Success;
}

bool
_x_gc_has_clipping(GC gc)
{
ClipMask* mask = gc_clip_mask(gc, false);
if (!mask)
return false;

return mask->region.CountRects() > 0;
}

extern "C" Status
XSetDashes(Display *display, GC gc, int dash_offset, const char *dash_list, int n)
{
Expand Down Expand Up @@ -561,17 +571,15 @@ _x_check_gc(XDrawable* drawable, GC gc)
}

if (gc->dirty & (GCClipMask | GCClipXOrigin | GCClipYOrigin)) {
//view->ConstrainClippingRegion(NULL);
ClipMask* mask = gc_clip_mask(gc, false);
if (mask && mask->region.CountRects()) {
// TODO: Breaks getting Expose messages!
UNIMPLEMENTED();
#if 0
view->ConstrainClippingRegion(NULL);
ClipMask* mask = gc_clip_mask(gc, false);
if (mask && mask->region.CountRects() > 0) {
BRegion region = mask->region;
region.OffsetBy(gc->values.clip_x_origin, gc->values.clip_y_origin);
view->ConstrainClippingRegion(&region);
#endif
}
#endif
}

gc->dirty = 0;
Expand Down
1 change: 1 addition & 0 deletions xlib/GC.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
namespace BeXlib { class XDrawable; }

void _x_check_gc(BeXlib::XDrawable* drawable, GC gc);
bool _x_gc_has_clipping(GC gc);

0 comments on commit 78d3a6b

Please sign in to comment.