FastUIDraw
painter_dashed_stroke_params.hpp
Go to the documentation of this file.
1 /*!
2  * \file painter_dashed_stroke_params.hpp
3  * \brief file painter_dashed_stroke_params.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 #ifndef FASTUIDRAW_PAINTER_DASHED_STROKE_PARAMS_HPP
20 #define FASTUIDRAW_PAINTER_DASHED_STROKE_PARAMS_HPP
21 
25 
26 namespace fastuidraw
27 {
28 /*!\addtogroup PainterShaderData
29  * @{
30  */
31 
32  /*!
33  * \brief
34  * Class to specify dashed stroking parameters, data is packed
35  * as according to PainterDashedStrokeParams::stroke_data_offset_t.
36  * Data for dashing is packed [TODO describe].
37  */
39  {
40  public:
41  /*!
42  * \brief
43  * Enumeration that provides offsets for the stroking
44  * parameters. The dashed pattern is packed in the next
45  * block of the data store.
46  */
48  {
49  stroke_radius_offset, /*!< offset to dashed stroke radius (packed as float) */
50  stroke_miter_limit_offset, /*!< offset to dashed stroke miter limit (packed as float) */
51  stroking_units_offset, /*!< Offset to stroking units (packed as uint) */
52  stroke_dash_offset_offset, /*!< offset to dash offset value for dashed stroking (packed as float) */
53  stroke_total_length_offset, /*!< offset to total legnth of dash pattern (packed as float) */
54  stroke_first_interval_start_offset, /*!< offset to value recording the start of the first interval (packed as float) */
55  stroke_first_interval_start_on_looping_offset, /*!< offset to value recording the start of the first interval on looping (packed as float) */
56  stroke_number_intervals_offset, /*!< offset to value giving the number of intervals (packed as uint) */
57 
58  stroke_static_data_size /*!< size of static data for dashed stroking */
59  };
60 
61  /*!
62  * \brief
63  * A DashPatternElement is an element of a dash pattern.
64  * It specifies how long to draw then how much space to
65  * emit before the next DashPatternElement.
66  */
68  {
69  public:
70  /*!
71  * Ctor, intializes both \ref m_draw_length and
72  * \ref m_space_length as 0.
73  */
75  m_draw_length(0.0f),
76  m_space_length(0.0f)
77  {}
78 
79  /*!
80  * Ctor.
81  * \param d value with which to initialize \ref m_draw_length
82  * \param s value with which to initialize \ref m_space_length
83  */
84  DashPatternElement(float d, float s):
85  m_draw_length(d),
87  {}
88 
89  /*!
90  * How long to draw
91  */
93 
94  /*!
95  * How much space to next DashPatternElement
96  */
98  };
99 
100  /*!
101  * Ctor.
102  */
104 
105  /*!
106  * Copy ctor.
107  */
109 
111 
112  /*!
113  * Assignment operator.
114  * \param obj value from which to copy
115  */
118 
119  /*!
120  * Swap operation
121  * \param obj object with which to swap
122  */
123  void
125 
126  /*!
127  * The miter limit for miter joins
128  */
129  float
130  miter_limit(void) const;
131 
132  /*!
133  * Set the value of miter_limit(void) const
134  * value is clamped to be non-negative.
135  */
137  miter_limit(float f);
138 
139  /*!
140  * The stroking width
141  */
142  float
143  width(void) const;
144 
145  /*!
146  * Set the value of width(void) const,
147  * values are clamped to be non-negative.
148  */
150  width(float f);
151 
152  /*!
153  * The stroking radius, equivalent to
154  * \code
155  * width() * 0.5
156  * \endcode
157  */
158  float
159  radius(void) const;
160 
161  /*!
162  * Set the value of radius(void) const,
163  * equivalent to
164  * \code
165  * width(2.0 * f)
166  * \endcode
167  */
169  radius(float f);
170 
171  /*!
172  * Returns the units of the stroking, default value is
173  * \ref PainterStrokeParams::path_stroking_units
174  */
176  stroking_units(void) const;
177 
178  /*!
179  * Set the value of stroking_units(void) const,
180  * values are clamped to be non-negative.
181  */
184 
185  /*!
186  * The dashed offset, i.e. the starting point of the
187  * dash pattern to start dashed stroking.
188  */
189  float
190  dash_offset(void) const;
191 
192  /*!
193  * Set the value of dash_offset(void) const
194  */
196  dash_offset(float f);
197 
198  /*!
199  * Returns the dash pattern for stroking.
200  */
202  dash_pattern(void) const;
203 
204  /*!
205  * Set the value return by dash_pattern(void) const.
206  * \param v dash pattern; the values are -copied-.
207  */
210 
211  /*!
212  * Returns a StrokingDataSelectorBase suitable for PainterDashedStrokeParams.
213  * \param pixel_arc_stroking_possible if true, will inform that arc-stroking width
214  * in PainterStrokeParams::pixel_stroking_units
215  * is possible.
216  */
217  static
219  stroking_data_selector(bool pixel_arc_stroking_possible);
220 
221  unsigned int
222  data_size(void) const override;
223 
224  void
225  pack_data(c_array<uvec4> dst) const override;
226 
227  private:
228  void *m_d;
229  };
230 /*! @} */
231 
232 } //namespace fastuidraw
233 
234 #endif
stroke_data_offset_t
Enumeration that provides offsets for the stroking parameters. The dashed pattern is packed in the ne...
enum PainterStrokeParams::stroking_units_t stroking_units(void) const
static reference_counted_ptr< const StrokingDataSelectorBase > stroking_data_selector(bool pixel_arc_stroking_possible)
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
A wrapper over a pointer to implement reference counting.
stroking_units_t
Enumeration to specify the units of the stroking radius.
file painter_dashed_stroke_shader_set.hpp
void pack_data(c_array< uvec4 > dst) const override
A DashPatternElement is an element of a dash pattern. It specifies how long to draw then how much spa...
file painter_shader_data.hpp
Class to specify dashed stroking parameters, data is packed as according to PainterDashedStrokeParams...
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
c_array< const DashPatternElement > dash_pattern(void) const
file painter_stroke_params.hpp
PainterDashedStrokeParams & operator=(const PainterDashedStrokeParams &obj)
unsigned int data_size(void) const override
PainterItemShaderData holds custom data for item shaders.
void swap(PainterDashedStrokeParams &obj)