FastUIDraw
painter_shader_registrar.hpp
Go to the documentation of this file.
1 /*!
2  * \file painter_shader_registrar.hpp
3  * \brief file painter_shader_registrar.hpp
4  *
5  * Copyright 2018 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_SHADER_REGISTRAR_HPP
21 #define FASTUIDRAW_PAINTER_SHADER_REGISTRAR_HPP
22 
25 
26 namespace fastuidraw
27 {
28 /*!\addtogroup PainterBackend
29  * @{
30  */
31 
32  /*!
33  * \brief
34  * A PainterShaderRegistrar is an interface that defines the assigning of
35  * PainterShader::ID() to a \ref PainterShader. PainterShader objects
36  * are registered to a unique PainterShaderRegistrar for their lifetime.
37  */
39  public reference_counted<PainterShaderRegistrar>::concurrent
40  {
41  public:
42  /*!
43  * Ctor.
44  */
46 
47  virtual
49 
50  /*!
51  * Returns a unique ID for the \ref PainterShaderRegistrar, this
52  * unique value will be used only by this PainterShaderRegistrar
53  * even if it destroyed, no other \ref PainterShaderRegistrar will
54  * have it.
55  */
56  unsigned int
57  unique_id(void) const;
58 
59  /*!
60  * Registers an item shader for use; registering a shader more than
61  * once to the SAME PainterShaderRegistrar has no effect. However,
62  * registering a shader to multiple PainterShaderRegistrar objects
63  * is an error.
64  */
65  void
67 
68  /*!
69  * Registers an item shader for use; registering a shader more than
70  * once to the SAME PainterShaderRegistrar has no effect. However,
71  * registering a shader to multiple PainterShaderRegistrar objects
72  * is an error.
73  */
74  void
76 
77  /*!
78  * Registers a blend shader for use; registering a shader more than
79  * once to the SAME PainterShaderRegistrar has no effect. However,
80  * registering a shader to multiple PainterShaderRegistrar objects
81  * is an error.
82  */
83  void
85 
86  /*!
87  * Registers a brush shader for use; registering a shader more than
88  * once to the SAME PainterShaderRegistrar has no effect. However,
89  * registering a shader to multiple PainterShaderRegistrar objects
90  * is an error.
91  */
92  void
94 
95  /*!
96  * Registers each of the sub-shaders of a \ref PainterImageBrushShader.
97  */
98  void
100 
101  /*!
102  * Registers each of the sub-shaders of a \ref PainterGradientBrushShader.
103  */
104  void
106 
107  /*!
108  * Provided as a conveniance to allow registering shaders
109  * through reference counted pointers.
110  */
111  template<typename T>
112  void
114  {
115  register_shader(shader.get());
116  }
117 
118  /*!
119  * Register each \ref PainterItemShader in a \ref
120  * PainterStrokeShader
121  */
122  void
124 
125  /*!
126  * Register each \ref PainterItemShader in a \ref
127  * PainterFillShader
128  */
129  void
131 
132  /*!
133  * Register each \ref PainterStrokeShader in a \ref
134  * PainterDashedStrokeShaderSet
135  */
136  void
138 
139  /*!
140  * Register each of the reference_counted_ptr<PainterShader>
141  * in a PainterGlyphShader.
142  */
143  void
145 
146  /*!
147  * Register each of the \ref PainterBlendShader
148  * in a \ref PainterBlendShaderSet.
149  */
150  void
152 
153  /*!
154  * Register each of the \ref PainterBrushShader
155  * in a \ref PainterBrushShaderSet.
156  */
157  void
159 
160  /*!
161  * Register each of the shaders in a PainterShaderSet.
162  */
163  void
165 
166  protected:
167 
168  /*!
169  * Return the \ref Mutex used to make this object thread safe.
170  */
171  Mutex&
172  mutex(void);
173 
174  /*!
175  * To be implemented by a derived class to return true
176  * if and only if a \ref PainterBlendShader objects
177  * with a given \ref PainterBlendShader::shader_type
178  * value for \ref PainterBlendShader::type() is supported.
179  * The return values must be unchanging for the lifetime
180  * of the \ref PainterShaderRegistrar object.
181  */
182  virtual
183  bool
185 
186  /*!
187  * To be implemented by a derived class to take into use
188  * an item shader. Typically this means inserting the
189  * the shader into a large uber shader. Returns
190  * the PainterShader::Tag to be used by the backend
191  * to identify the shader. An implementation will never
192  * be passed an object for which PainterShader::parent()
193  * is non-nullptr. In addition, mutex() will be locked on
194  * entry.
195  * \param shader shader whose Tag is to be computed
196  */
197  virtual
200 
201  /*!
202  * To be implemented by a derived class to compute the PainterShader::group()
203  * of a sub-shader. When called, the value of the shader's PainterShader::ID()
204  * and PainterShader::registered_to() are already set correctly. In addition,
205  * the value of PainterShader::group() is initialized to the same value as
206  * that of the PainterItemShader::parent(). In addition, mutex() will be
207  * locked on entry.
208  * \param shader shader whose group is to be computed
209  */
210  virtual
211  uint32_t
213 
214  /*!
215  * To be implemented by a derived class to take into use
216  * an item shader. Typically this means inserting the
217  * the shader into a large uber shader. Returns
218  * the PainterShader::Tag to be used by the backend
219  * to identify the shader. An implementation will never
220  * be passed an object for which PainterShader::parent()
221  * is non-nullptr. In addition, mutex() will be locked on
222  * entry.
223  * \param shader shader whose Tag is to be computed
224  */
225  virtual
228 
229  /*!
230  * To be implemented by a derived class to compute the PainterShader::group()
231  * of a sub-shader. When called, the value of the shader's PainterShader::ID()
232  * and PainterShader::registered_to() are already set correctly. In addition,
233  * the value of PainterShader::group() is initialized to the same value as
234  * that of the PainterItemShader::parent(). In addition, mutex() will be
235  * locked on entry.
236  * \param shader shader whose group is to be computed
237  */
238  virtual
239  uint32_t
241 
242  /*!
243  * To be implemented by a derived class to take into use
244  * a blend shader. Typically this means inserting the
245  * the blend shader into a large uber shader. Returns
246  * the PainterShader::Tag to be used by the backend
247  * to identify the shader. An implementation will never
248  * be passed an object for which PainterShader::parent()
249  * is non-nullptr. In addition, mutex() will be locked on
250  * entry.
251  * \param shader shader whose Tag is to be computed
252  */
253  virtual
256 
257  /*!
258  * To be implemented by a derived class to compute the PainterShader::group()
259  * of a sub-shader. When called, the value of the shader's PainterShader::ID()
260  * and PainterShader::registered_to() are already set correctly. In addition,
261  * the value of PainterShader::group() is initialized to the same value as
262  * that of the PainterBlendShader::parent(). In addition, mutex() will be
263  * locked on entry.
264  * \param shader shader whose group is to be computed
265  */
266  virtual
267  uint32_t
269 
270  /*!
271  * To be implemented by a derived class to take into use
272  * a blend shader. Typically this means inserting the
273  * the blend shader into a large uber shader. Returns
274  * the PainterShader::Tag to be used by the backend
275  * to identify the shader. An implementation will never
276  * be passed an object for which PainterShader::parent()
277  * is non-nullptr. In addition, mutex() will be locked on
278  * entry.
279  * \param shader shader whose Tag is to be computed
280  */
281  virtual
284 
285  /*!
286  * To be implemented by a derived class to compute the PainterShader::group()
287  * of a sub-shader. When called, the value of the shader's PainterShader::ID()
288  * and PainterShader::registered_to() are already set correctly. In addition,
289  * the value of PainterShader::group() is initialized to the same value as
290  * that of the PainterBrushShader::parent(). In addition, mutex() will be
291  * locked on entry.
292  * \param shader shader whose group is to be computed
293  */
294  virtual
295  uint32_t
297 
298  private:
299  void *m_d;
300  };
301 /*! @} */
302 
303 }
304 
305 #endif
virtual PainterShader::Tag absorb_custom_brush_shader(const reference_counted_ptr< PainterBrushShader > &shader)=0
A PainterBlendShader represents a shader for performing blending operations.
A PainterDashedStrokeShaderSet holds a collection of PainterStrokeShaderSet objects for the purpose o...
virtual PainterShader::Tag absorb_item_shader(const reference_counted_ptr< PainterItemShader > &shader)=0
unsigned int unique_id(void) const
file mutex.hpp
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
A PainterFillShader holds the shaders for drawing filled paths. Anti-aliasing is accomplished by draw...
void register_shader(const reference_counted_ptr< T > &shader)
virtual uint32_t compute_item_coverage_sub_shader_group(const reference_counted_ptr< PainterItemCoverageShader > &shader)=0
void register_shader(PainterItemShader *shader)
A wrapper over a pointer to implement reference counting.
A PainterImageBrushShader represents a single PainterBrushShader together with sub-shaders of it that...
A PainterStrokeShader holds shaders for stroking. It is to hold shaders for stroking paths linearly o...
A PainterBlendShaderSet represents a set of shaders for the blend modes enumerated by PainterEnums::b...
virtual uint32_t compute_custom_brush_sub_shader_group(const reference_counted_ptr< PainterBrushShader > &shader)=0
virtual bool blend_type_supported(enum PainterBlendShader::shader_type) const =0
virtual uint32_t compute_item_sub_shader_group(const reference_counted_ptr< PainterItemShader > &shader)=0
A PainterBrushShaderSet holds the PainterBrushShader objects to be used with the default brushes...
A Tag is how a PainterShader is described for and by a PainterShaderRegistrar.
A PainterShaderRegistrar is an interface that defines the assigning of PainterShader::ID() to a Paint...
A PainterShaderSet provides shaders for blending and drawing each of the item types glyphs...
virtual PainterShader::Tag absorb_blend_shader(const reference_counted_ptr< PainterBlendShader > &shader)=0
A PainterItemCoverageShader represents a shader to draw an item to a coverage buffer (see PainterSurf...
Defines default reference counting base classes.
A PainterGlyphShader holds a shader for each glyph_type. The shaders are to handle attribute data as ...
file painter_shader_set.hpp
A PainterBrushShader represents a shader for performing a custom brush coloring.
virtual uint32_t compute_blend_sub_shader_group(const reference_counted_ptr< PainterBlendShader > &shader)=0
A PainterItemShader represents a shader to draw an item (typically a vertex and fragment shader pair)...
shader_type
Enumeration to specify how blend shader operates.
A PainterGradientBrushShader represents a set of brush shaders to to perform a gradient. Internally it containts four generic parent shaders:
virtual PainterShader::Tag absorb_item_coverage_shader(const reference_counted_ptr< PainterItemCoverageShader > &shader)=0