]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/scout-gfx/include/redraw_manager
Update
[l4.git] / l4 / pkg / scout-gfx / include / redraw_manager
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/geometry>
13 #include <l4/scout-gfx/widget>
14
15 namespace Scout_gfx {
16
17 using Mag_gfx::Canvas;
18 using Mag_gfx::Point;
19 using Mag_gfx::Area;
20 using Mag_gfx::Rect;
21
22 class Screen_update
23 {
24 public:
25
26   virtual ~Screen_update() { }
27
28   /**
29    * Flip fore and back buffers
30    */
31   virtual void flip_buf_scr() { }
32
33   /**
34    * Copy background buffer to foreground
35    */
36   virtual void copy_buf_to_scr(Rect const &) { }
37
38   /**
39    * Flush pixels of specified screen area
40    */
41   virtual void scr_update(Rect const &r) = 0;
42 };
43
44 class Redraw_manager
45 {
46 private:
47
48   Rect _dirty;
49   int            _cnt;           /* nb of requests since last process */
50   Widget       *_root;          /* root element for drawing          */
51   Canvas        *_canvas;        /* graphics backend                  */
52   Screen_update *_scr_update;    /* flushing pixels in backend        */
53   Area _win;                     /* current size of output window     */
54
55 public:
56
57   /**
58    * Constructor
59    */
60   Redraw_manager()
61   : _cnt(0), _root(0), _canvas(0), _scr_update(0), _win(Area())
62   {}
63
64   /**
65    * Accessor functions
66    */
67   Canvas *canvas() const { return _canvas; }
68
69   void setup(Canvas *canvas, Screen_update *scr_update, Area const &win)
70   {
71     _canvas = canvas;
72     _scr_update = scr_update;
73     _win = win;
74   }
75
76   
77   /**
78    * Define root element for issueing drawing operations
79    */
80   inline void root(Widget *root) { _root = root; }
81
82   /**
83    * Collect redraw requests
84    */
85   void request(Rect const &r);
86
87   /**
88    * Process redrawing operations
89    */
90   void process(Rect const &view);
91 };
92
93 }