]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/mag-gfx/include/clip_guard
update
[l4.git] / l4 / pkg / mag-gfx / include / clip_guard
1 // vi:ft=cpp
2 /*
3  * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  */
10 #pragma once
11
12 #include <l4/mag-gfx/canvas>
13
14 namespace Mag_gfx {
15
16 class Clip_guard
17 {
18 private:
19   Canvas *_c;
20   Rect _o;
21
22   Clip_guard(Clip_guard const &);
23   void operator = (Clip_guard const &);
24
25 public:
26   Clip_guard() : _c(0), _o() {}
27
28   Clip_guard(Canvas *canvas, Rect const &n)
29   : _c(canvas), _o(_c->clip())
30   { _c->set_clipping(_o & n); }
31
32   void init(Canvas *c, Rect const &n)
33   {
34     _c = c;
35     _o = c->clip();
36     _c->set_clipping(_o & n);
37   }
38
39   ~Clip_guard() { _c->set_clipping(_o); }
40
41 };
42
43 }