FastUIDraw
painter_stroke_shader.hpp
Go to the documentation of this file.
1 /*!
2  * \file painter_stroke_shader.hpp
3  * \brief file painter_stroke_shader.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_STROKE_SHADER_HPP
21 #define FASTUIDRAW_PAINTER_STROKE_SHADER_HPP
22 
28 
29 namespace fastuidraw
30 {
31 
32 /*!\addtogroup PainterShaders
33  * @{
34  */
35 
36  ///@cond
37  class PainterAttributeData;
38  ///@endcond
39 
40  /*!
41  * \brief
42  * A StrokingDataSelector is an interface to assist Painter
43  * to select correct LOD for rounded joins and caps when
44  * drawing rounded joins and caps. In addition it also
45  * informs Painter if stroking via arcs is possible with
46  * the stroking parameters.
47  */
49  public reference_counted<StrokingDataSelectorBase>::concurrent,
50  public PathEnums
51  {
52  public:
53  /*!
54  * To be implemented by a derived class to compute the value
55  * used to select rounded join level of detail (\ref
56  * StrokedPath::rounded_joins()) and rounded cap level of detail
57  * (\ref StrokedPath::rounded_caps()).
58  * \param data packed data to be sent to the shader
59  * \param path_magnification by how much the path is magnified
60  * from its native coordiantes to pixel
61  * coordinates.
62  * \param curve_flatness curve flatness
63  */
64  virtual
65  float
67  float path_magnification,
68  float curve_flatness) const = 0;
69 
70  /*!
71  * To be implemented by a derived class to give by how
72  * much the stroking gives thickness to the stroked path.
73  * These values are geometrically added together. The
74  * intersection test performed is to first inflate the
75  * bounding boxes in local coordinates by the output
76  * out_item_space_distance, then to convert the box
77  * to clip-coordinates and then push each clip-equation
78  * by *out_pixel_space_distance
79  * \param data packed data to be sent to the shader
80  * \param[out] out_values output with array indexed as according
81  * to \ref path_geometry_inflation_index_t
82  */
83  virtual
84  void
86  c_array<float> out_values) const = 0;
87 
88  /*!
89  * To be implemented by a derived class to specify if
90  * arc-stroking is possible with the stroking parameters.
91  * \param data packed data to be sent to the shader
92  */
93  virtual
94  bool
96 
97  /*!
98  * To be implemented by a derived class to specify if the passed
99  * data is suitable for it.
100  * \param data packed data to be sent to the shader
101  */
102  virtual
103  bool
104  data_compatible(c_array<const uvec4 > data) const = 0;
105  };
106 
107  /*!
108  * \brief
109  * A PainterStrokeShader holds shaders for stroking. It is to hold
110  * shaders for stroking paths linearly or via arcs with and without
111  * anti-aliasing along with meta-data to inform what shading is faster.
112  */
114  {
115  public:
116  /*!
117  * Enumeration to specify what shader
118  */
120  {
121  /*!
122  * Specify the shader for rendering a stroked path without
123  * anti-aliasing. The depth value emitted in the item's
124  * vertex shader should be z-value to guarantee that there
125  * is no overdraw, see \ref StrokedPoint::depth() and \ref
126  * ArcStrokedPoint::depth().
127  */
129 
130  /*!
131  * Specifies a two-pass shader where the first pass renders to the
132  * deferred coverage buffer (via PainterItemShader::coverage_shader())
133  * and the second pass reads from it. The depth value emitted in the
134  * item's vertex shader should be z-value to guarantee that
135  * there is no overdraw, see \ref StrokedPoint::depth() and \ref
136  * ArcStrokedPoint::depth().
137  */
139 
140  number_shader_types,
141  };
142 
143  /*!
144  * Ctor
145  */
146  PainterStrokeShader(void);
147 
148  /*!
149  * Copy ctor.
150  */
152 
154 
155  /*!
156  * Assignment operator.
157  */
159  operator=(const PainterStrokeShader &rhs);
160 
161  /*!
162  * Swap operation
163  * \param obj object with which to swap
164  */
165  void
167 
168  /*!
169  * Returns the \ref PainterItemShader for a given pass of a given
170  * type of stroking.
171  * \param tp specify to return a shader for arc or linear stroking
172  * \param sh spcify which shader to return
173  */
175  shader(enum PainterEnums::stroking_method_t tp, enum shader_type_t sh) const;
176 
177  /*!
178  * Set the value returned by shader(enum PainterEnums::stroking_method_t, enum shader_type_t) const.
179  * \param tp specify to return shader for arc or linear stroking
180  * \param sh spcify which shader to return
181  * \param v value to use
182  */
184  shader(enum PainterEnums::stroking_method_t tp, enum shader_type_t sh,
186 
187  /*!
188  * Return what PainterEnums::stroking_method_t is fastest to
189  * stroke with anti-aliasing.
190  */
192  fastest_anti_aliased_stroking_method(void) const;
193 
194  /*!
195  * Set the value returned by fastest_anti_aliased_stroking_method(void) const.
196  * \param v value to use
197  */
199  fastest_anti_aliased_stroking_method(enum PainterEnums::stroking_method_t v);
200 
201  /*!
202  * Return the fastest stroking method to use when stroking
203  * without anti-aliasing.
204  */
206  fastest_non_anti_aliased_stroking_method(void) const;
207 
208  /*!
209  * Set the value returned by fastest_non_anti_aliased_stroking_method(void) const.
210  * \param v value to use
211  */
213  fastest_non_anti_aliased_stroking_method(enum PainterEnums::stroking_method_t v);
214 
215  /*!
216  * Returns the StrokingDataSelectorBase associated to this
217  * PainterStrokeShader.
218  */
220  stroking_data_selector(void) const;
221 
222  /*!
223  * Set the value returned by stroking_data_selector(void) const.
224  * \param sh value to use
225  */
227  stroking_data_selector(const reference_counted_ptr<const StrokingDataSelectorBase> &sh);
228 
229  private:
230  void *m_d;
231  };
232 
233 /*! @} */
234 }
235 
236 #endif
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
A wrapper over a pointer to implement reference counting.
A PainterStrokeShader holds shaders for stroking. It is to hold shaders for stroking paths linearly o...
file painter_shader_data.hpp
void swap(reference_counted_ptr< T > &lhs, reference_counted_ptr< T > &rhs)
virtual void stroking_distances(c_array< const uvec4 > data, c_array< float > out_values) const =0
file painter_item_shader.hpp
virtual bool arc_stroking_possible(c_array< const uvec4 > data) const =0
A c_array is a wrapper over a C pointer with a size parameter to facilitate bounds checking and provi...
Definition: c_array.hpp:43
file painter_enums.hpp
A StrokingDataSelector is an interface to assist Painter to select correct LOD for rounded joins and ...
Class to encapsulate enumerations used by Path and PathContour.
Definition: path_enums.hpp:33
Defines default reference counting base classes.
file path_enums.hpp
file painter_draw.hpp
virtual bool data_compatible(c_array< const uvec4 > data) const =0
virtual float compute_thresh(c_array< const uvec4 > data, float path_magnification, float curve_flatness) const =0