FastUIDraw
painter_backend.hpp
Go to the documentation of this file.
1 /*!
2  * \file painter_backend.hpp
3  * \brief file painter_backend.hpp
4  *
5  * Copyright 2016 by Intel.
6  *
7  * Contact: kevin.rogovin@gmail.com
8  *
9  * This Source Code Form is subject to the
10  * terms of the Mozilla Public License, v. 2.0.
11  * If a copy of the MPL was not distributed with
12  * this file, You can obtain one at
13  * http://mozilla.org/MPL/2.0/.
14  *
15  * \author Kevin Rogovin <kevin.rogovin@gmail.com>
16  *
17  */
18 
19 
20 #ifndef FASTUIDRAW_PAINTER_BACKEND_HPP
21 #define FASTUIDRAW_PAINTER_BACKEND_HPP
22 
24 #include <fastuidraw/util/rect.hpp>
26 #include <fastuidraw/image.hpp>
31 
32 
33 namespace fastuidraw
34 {
35 /*!\addtogroup PainterBackend
36  * @{
37  */
38 
39  /*!
40  * \brief
41  * A PainterBackend is an interface that defines the API-specific
42  * elements to implement \ref Painter. A fixed PainterBackend will
43  * only be used by a single \ref Painter.
44  *
45  * A \ref Painter will use a \ref PainterBackend as follows within a
46  * Painter::begin() and Painter::end() pair.
47  * \code
48  * fastuidraw::PainterBackend &backend;
49  *
50  * backend.on_painter_begin();
51  * for (how many surfaces S needed to draw all)
52  * {
53  * std::vector<fastuidraw::reference_counted_ptr<fastuidraw::PainterDraw> > draws;
54  * for (how many PainterDraw objects needed to draw what is drawn in S)
55  * {
56  * fastuidraw::reference_counted_ptr<fastuidraw::PainterDraw> p;
57  *
58  * p = backend.map_draw();
59  * // fill the buffers on p, potentially calling
60  * // PainterDraw::draw_break() several times.
61  * p.get()->unmap(attributes_written, indices_written, data_store_written);
62  * draws.push_back(p);
63  * }
64  * backend.on_pre_draw(S, maybe_clear_color_buffer, maybe_begin_new_target);
65  * for (p in draws)
66  * {
67  * p.get()->draw();
68  * }
69  * draws.clear();
70  * backend.on_post_draw();
71  * }
72  * \endcode
73  */
74  class PainterBackend:public reference_counted<PainterBackend>::concurrent
75  {
76  public:
77  virtual
79  {}
80 
81  /*!
82  * To be implemented by a derived class to return
83  * the number of attributes a PainterDraw returned
84  * by map_draw() is guaranteed to hold.
85  */
86  virtual
87  unsigned int
88  attribs_per_mapping(void) const = 0;
89 
90  /*!
91  * To be implemented by a derived class to return
92  * the number of indices a PainterDraw returned
93  * by map_draw() is guaranteed to hold.
94  */
95  virtual
96  unsigned int
97  indices_per_mapping(void) const = 0;
98 
99  /*!
100  * Called just before calling PainterDraw::draw() on a sequence
101  * of PainterDraw objects who have had their PainterDraw::unmap()
102  * routine called. An implementation will will clear the depth
103  * (aka occlusion) buffer and optionally the color buffer in the
104  * viewport of the \ref PainterSurface.
105  * \param surface the \ref PainterSurface to which to
106  * render content
107  * \param clear_color_buffer if true, clear the color buffer
108  * on the viewport of the surface.
109  * \param begin_new_target if true indicates that drawing is to
110  * start on the surface (typically this
111  * means that when this is true that the
112  * backend will clear all auxiliary buffers
113  * (such as the depth buffer).
114  */
115  virtual
116  void
118  bool clear_color_buffer,
119  bool begin_new_target) = 0;
120 
121  /*!
122  * Called just after calling PainterDraw::draw()
123  * on a sequence of PainterDraw objects.
124  */
125  virtual
126  void
127  on_post_draw(void) = 0;
128 
129  /*!
130  * Called to return an action to bind an Image whose backing
131  * store requires API binding.
132  * \param slot which of the external image slots to bind the image to
133  * \param im Image backed by a gfx API surface that in order to be used,
134  * must be bound. In patricular im's Image::type() value
135  * is Image::context_texture2d
136  */
137  virtual
139  bind_image(unsigned int slot,
140  const reference_counted_ptr<const Image> &im) = 0;
141 
142  /*!
143  * Called to return an action to bind a \ref PainterSurface
144  * to be used as the read from the deferred coverage buffer.
145  * \param cvg_surface coverage surface backing the deferred
146  * coverage buffer from which to read
147  */
148  virtual
151 
152  /*!
153  * To be implemented by a derived class to return a PainterDraw
154  * for filling of data.
155  */
156  virtual
158  map_draw(void) = 0;
159 
160  /*!
161  * To be implemented by a derived class to perform any caching
162  * or other operations when \ref Painter has Painter::begin().
163  */
164  virtual
165  void
166  on_painter_begin(void) = 0;
167  };
168 /*! @} */
169 
170 }
171 
172 #endif
file painter_surface.hpp
virtual void on_post_draw(void)=0
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
A wrapper over a pointer to implement reference counting.
virtual void on_pre_draw(const reference_counted_ptr< PainterSurface > &surface, bool clear_color_buffer, bool begin_new_target)=0
file blend_mode.hpp
file glyph_atlas.hpp
virtual unsigned int attribs_per_mapping(void) const =0
virtual reference_counted_ptr< PainterDrawBreakAction > bind_coverage_surface(const reference_counted_ptr< PainterSurface > &cvg_surface)=0
virtual unsigned int indices_per_mapping(void) const =0
virtual reference_counted_ptr< PainterDrawBreakAction > bind_image(unsigned int slot, const reference_counted_ptr< const Image > &im)=0
virtual reference_counted_ptr< PainterDraw > map_draw(void)=0
Defines default reference counting base classes.
A PainterBackend is an interface that defines the API-specific elements to implement Painter...
file colorstop_atlas.hpp
file painter_draw.hpp
file painter_shader_registrar.hpp
virtual void on_painter_begin(void)=0
file image.hpp