FastUIDraw
shader_filled_path.hpp
1 /*!
2  * \file filled_path.hpp
3  * \brief file filled_path.hpp
4  *
5  * Copyright 2019 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_SHADER_FILLED_PATH_HPP
21 #define FASTUIDRAW_SHADER_FILLED_PATH_HPP
22 
24 #include <fastuidraw/util/vecN.hpp>
26 #include <fastuidraw/util/rect.hpp>
33 
34 namespace fastuidraw {
35 
36 ///@cond
37 class Path;
38 ///@endcond
39 
40 /*!\addtogroup Paths
41  * @{
42  */
43 
44 /*!
45  * \brief
46  * A ShaderFilledPath represents a path that is drawn as a rectangle
47  * where the fragment shader acting on the rectangle performs the
48  * coverage computation of each pixel. Generally speaking, one
49  * should only fill paths via a ShaderFilledPath when a filled
50  * path when drawn has very high density of edges.
51  */
53  public reference_counted<ShaderFilledPath>::non_concurrent
54 {
55 public:
56  /*!
57  * A Builder is the means of specifying the contours for
58  * a \ref ShaderFilledPath.
59  */
61  {
62  public:
63  Builder(void);
64  ~Builder();
65 
66  /*!
67  * Start a contour. Before starting a new contour
68  * the previous contour must be closed by calling
69  * line_to() or quadratic_to() connecting to the
70  * start point of the previous contour.
71  * \param pt start point of the new contour
72  */
73  void
74  move_to(vec2 pt);
75 
76  /*!
77  * Add a line segment connecting the end point of the
78  * last curve or line segment of the current contour to
79  * a given point.
80  * \param pt end point of the new line segment
81  */
82  void
83  line_to(vec2 pt);
84 
85  /*!
86  * Add a quadratic curveconnecting the end point of the
87  * last curve or line segment of the current contour
88  * \param ct control point of the quadratic curve
89  * \param pt end point of the quadratic curve
90  */
91  void
92  quadratic_to(vec2 ct, vec2 pt);
93 
94  /*!
95  * Add the contours from a Path. Each contour of the
96  * passed path will start with a move_to().
97  * \param tol when approximating an interpolate, the tolerance
98  * to use for how close the approximation needs to be
99  * \param path \ref Path to add
100  */
101  void
102  add_path(float tol, const Path &path);
103 
104  private:
105  friend class ShaderFilledPath;
106  void *m_d;
107  };
108 
109  /*!
110  * Ctor.
111  * \param B \ref Builder object specifying the contours
112  * of the \ref ShaderFilledPath constructed.
113  */
114  explicit
115  ShaderFilledPath(const Builder &B);
116 
117  ~ShaderFilledPath();
118 
119  /*!
120  * Returns the \ref PainterAttribute and \ref PainterIndex data
121  * to draw the filled path. The attribute data is packed so that
122  * it is to be shaded by a \ref PainterGlyphShader.
123  * \param glyph_atlas \ref GlyphAtlas to place GPU data
124  * \param fill_rule full rule with which to fill the path
125  * \param out_attribs location to which to write attributes
126  * \param out_indices location to which to write indices
127  */
128  void
129  render_data(GlyphAtlas &glyph_atlas,
130  enum PainterEnums::fill_rule_t fill_rule,
131  c_array<const PainterAttribute> *out_attribs,
132  c_array<const PainterIndex> *out_indices) const;
133 
134  /*!
135  * Returns the \ref glyph_type of the ShaderFilledPath.
136  * Any \ref PainterGlyphShader that accepts the returned
137  * \ref glyph_type can then also be used to draw the
138  * ShaderFilledPath.
139  */
140  enum glyph_type
141  render_type(void) const;
142 
143 private:
144  void *m_d;
145 };
146 
147 /*! @} */
148 
149 } //namespace f
150 
151 #endif
A GlyphAtlas is a common location to place glyph data of an application. Ideally, all glyph data is p...
file fastuidraw_memory.hpp
file glyph_render_data.hpp
file matrix.hpp
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
void add_path(float tol, const Path &path)
A ShaderFilledPath represents a path that is drawn as a rectangle where the fragment shader acting on...
file c_array.hpp
file glyph_atlas.hpp
glyph_type
Provides an enumeration of the rendering data for a glyph.
void render_data(GlyphAtlas &glyph_atlas, enum PainterEnums::fill_rule_t fill_rule, c_array< const PainterAttribute > *out_attribs, c_array< const PainterIndex > *out_indices) const
file painter_attribute_data.hpp
void quadratic_to(vec2 ct, vec2 pt)
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
file vecN.hpp
fill_rule_t
Enumerations specifying common fill rules.
Defines default reference counting base classes.
A Path represents a collection of PathContour objects.
Definition: path.hpp:668
Class for which copy ctor and assignment operator are private functions.
Definition: util.hpp:505
enum glyph_type render_type(void) const
file reference_counted.hpp