Files
moslab-code/src/l4/pkg/mag-gfx/include/clip_guard
2025-09-12 15:55:45 +02:00

44 lines
798 B
C++

// vi:ft=cpp
/*
* (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* This file is part of TUD:OS and distributed under the terms of the
* GNU General Public License 2.
* Please see the COPYING-GPL-2 file for details.
*/
#pragma once
#include <l4/mag-gfx/canvas>
namespace Mag_gfx {
class Clip_guard
{
private:
Canvas *_c;
Rect _o;
Clip_guard(Clip_guard const &);
void operator = (Clip_guard const &);
public:
Clip_guard() : _c(0), _o() {}
Clip_guard(Canvas *canvas, Rect const &n)
: _c(canvas), _o(_c->clip())
{ _c->set_clipping(_o & n); }
void init(Canvas *c, Rect const &n)
{
_c = c;
_o = c->clip();
_c->set_clipping(_o & n);
}
~Clip_guard() { _c->set_clipping(_o); }
};
}