diff options
| author | Dana Jansens <danakj@orodu.net> | 2003-02-11 22:10:50 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2003-02-11 22:10:50 +0000 |
| commit | 2808ab5bad8ff49a1af909c2515288310cc89378 (patch) | |
| tree | cbc21dc8b7289f031d12d86d1e3f4553983db8f4 /otk/rendercontrol.cc | |
| parent | 58847af218e486f5c1a34ffe947a961a74f97c0a (diff) | |
add RenderControl::drawMask
Diffstat (limited to 'otk/rendercontrol.cc')
| -rw-r--r-- | otk/rendercontrol.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/otk/rendercontrol.cc b/otk/rendercontrol.cc index 58c8f555..edf4a470 100644 --- a/otk/rendercontrol.cc +++ b/otk/rendercontrol.cc @@ -190,4 +190,28 @@ void RenderControl::drawSolidBackground(Surface& sf, } } +void RenderControl::drawMask(Surface &sf, const RenderColor &color, + const PixmapMask &mask) const +{ + assert(_screen == sf._screen); + assert(_screen == color.screen()); + + if (mask.mask == None) return; // no mask given + + int width = sf.size().width(), height = sf.size().height(); + + // set the clip region + int x = (width - mask.w) / 2, y = (height - mask.h) / 2; + XSetClipMask(**display, color.gc(), mask.mask); + XSetClipOrigin(**display, color.gc(), x, y); + + // fill in the clipped region + XFillRectangle(**display, sf.pixmap(), color.gc(), x, y, + x + mask.w, y + mask.h); + + // unset the clip region + XSetClipMask(**display, color.gc(), None); + XSetClipOrigin(**display, color.gc(), 0, 0); +} + } |
