FastUIDraw
glyph_attribute.hpp
Go to the documentation of this file.
1 /*!
2  * \file glyph_attribute.hpp
3  * \brief file glyph_attribute.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_GLYPH_ATTRIBUTE_HPP
21 #define FASTUIDRAW_GLYPH_ATTRIBUTE_HPP
22 
23 #include <fastuidraw/util/util.hpp>
24 #include <fastuidraw/util/vecN.hpp>
27 
28 namespace fastuidraw
29 {
30 /*!\addtogroup Glyph
31  * @{
32  */
33  /*!
34  * \brief
35  * A GlyphAttribute represents one \ref PainterAttribute per
36  * glyph corner.
37  */
39  {
40  public:
41  /*!
42  * Enumeration to define bit-masks of if an index
43  * is on the right or left side and on the bottom
44  * or top side of a glyph.
45  */
47  {
48  right_corner_mask = 1,
49  top_corner_mask = 2,
50  };
51 
52  /*!
53  * Enumeration naming the corners of a glyph.
54  */
55  enum corner_t
56  {
57  bottom_left_corner = 0,
58  bottom_right_corner = right_corner_mask,
59  top_left_corner = top_corner_mask,
60  top_right_corner = right_corner_mask | top_corner_mask
61  };
62 
63  /*!
64  * When packing 8-bit texel data into the store, each
65  * 32-bit value of the store holds a 2x2 block of 8-bit
66  * texels. This enumeration describes the packing an
67  * an attribute to get the texel data.
68  */
70  {
71  rect_width_num_bits = 8,
72  rect_height_num_bits = 8,
73  rect_x_num_bits = 8,
74  rect_y_num_bits = 8,
75 
76  rect_width_bit0 = 0,
77  rect_height_bit0 = rect_width_bit0 + rect_width_num_bits,
78  rect_x_bit0 = rect_height_bit0 + rect_height_num_bits,
79  rect_y_bit0 = rect_x_bit0 + rect_x_num_bits,
80  };
81 
82  /*!
83  * Pack into this GlyphAttribute via \ref rect_glyph_layout
84  * to access texel data from the store.
85  */
86  void
87  pack_texel_rect(unsigned int width, unsigned int height);
88 
89  /*!
90  * \brief
91  * Represents an opaque array of \ref GlyphAttribute
92  * values.
93  */
95  {
96  public:
97  /*!
98  * Return the size of Array
99  */
100  unsigned int
101  size(void) const;
102 
103  /*!
104  * change the size of Array
105  */
106  void
107  resize(unsigned int);
108 
109  /*!
110  * Equivalent to resize(0).
111  */
112  void
113  clear(void)
114  {
115  resize(0);
116  }
117 
118  /*!
119  * Returns a reference to an element of the Array
120  */
122  operator[](unsigned int);
123 
124  /*!
125  * Returns a reference to an element of the Array
126  */
127  const GlyphAttribute&
128  operator[](unsigned int) const;
129 
130  /*!
131  * Return the backing store of the Array; valid
132  * until resize() is called.
133  */
135  data(void) const;
136 
137  /*!
138  * Return the backing store of the Array; valid
139  * until resize() is called.
140  */
142  data(void);
143 
144  private:
145  friend class GlyphCache;
146  friend class Glyph;
147 
148  Array(void *d):
149  m_d(d)
150  {}
151 
152  void *m_d;
153  };
154 
155  /*!
156  * The data of this single per-corner attribute,
157  * enumerated by \ref corner_t.
158  */
160  };
161 /*! @} */
162 }
163 
164 #endif
Represents an opaque array of GlyphAttribute values.
void pack_texel_rect(unsigned int width, unsigned int height)
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
A GlyphCache represents a cache of glyphs and manages the uploading of the data to a GlyphAtlas...
Definition: glyph_cache.hpp:43
file c_array.hpp
file glyph_atlas.hpp
GlyphAttribute & operator[](unsigned int)
c_array< const GlyphAttribute > data(void) const
file util.hpp
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
unsigned int size(void) const
vecN< uint32_t, 4 > m_data
A GlyphAttribute represents one Painter Attribute per glyph corner.
file vecN.hpp
A Glyph is essentially an opaque pointer to data for rendering and performing layout of a glyph...
Definition: glyph.hpp:48
Class for which copy ctor and assignment operator are private functions.
Definition: util.hpp:505