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