aboutsummaryrefslogtreecommitdiff
path: root/dw/imgrenderer.hh
blob: e254ae66b97d9c38c64081697f6c0bbb957ba9a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef __DW_IMGRENDERER_HH__
#define __DW_IMGRENDERER_HH__

#ifndef __INCLUDED_FROM_DW_CORE_HH__
#   error Do not include this file directly, use "core.hh" instead.
#endif

namespace dw {
namespace core {

/**
 * \brief ...
 *
 * \sa \ref dw-images-and-backgrounds
 */
class ImgRenderer
{
public:
   virtual ~ImgRenderer () { }

   /** 
    * \brief Called, when an image buffer is attached.
    *
    * This is typically the case when all meta data (size, depth) has been read.
    */
   virtual void setBuffer (core::Imgbuf *buffer, bool resize = false) = 0;

   /** 
    * \brief Called, when data from a row is available and has been copied into
    *    the image buffer.
    *
    * The implementation will typically queue the respective area for drawing.
    */
   virtual void drawRow (int row) = 0;
};

/**
 * \brief Implementation of ImgRenderer, which distributes all calls
 * to a set of other implementations of ImgRenderer.
 *
 * The order of the call children is not defined, especially not
 * identical to the order in which they have been added.
 */
class ImgRendererDist: public ImgRenderer
{
   lout::container::typed::HashSet <lout::object::TypedPointer <ImgRenderer> >
      *children;

public:
   inline ImgRendererDist ()
   { children = new lout::container::typed::HashSet
         <lout::object::TypedPointer <ImgRenderer> > (true); }
   ~ImgRendererDist () { delete children; }

   void setBuffer (core::Imgbuf *buffer, bool resize);
   void drawRow (int row);

   void put (ImgRenderer *child)
   { children->put (new lout::object::TypedPointer <ImgRenderer> (child)); }
   void remove (ImgRenderer *child)
   { lout::object::TypedPointer <ImgRenderer> tp (child);
     children->remove (&tp); }
};

} // namespace core
} // namespace dw

#endif // __DW_IMGRENDERER_HH__