FastUIDraw
painter_item_matrix.hpp
Go to the documentation of this file.
1 /*!
2  * \file painter_item_matrix.hpp
3  * \brief file painter_item_matrix.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_ITEM_MATRIX_HPP
21 #define FASTUIDRAW_PAINTER_ITEM_MATRIX_HPP
22 
23 #include <fastuidraw/util/util.hpp>
24 #include <fastuidraw/util/vecN.hpp>
27 
28 namespace fastuidraw
29 {
30 /*!\addtogroup PainterBackend
31  * @{
32  */
33 
34  /*!
35  * \brief
36  * A PainterItemMatrix holds the value for the
37  * transformation from item coordinates to the coordinates
38  * in which the clipping rectangle applies.
39  */
41  {
42  public:
43 
44  /*!
45  * \brief
46  * Enumeration that provides offsets for the
47  * item matrix from the location of that data
48  * (item_matrix_offset) in units of uint32_t.
49  */
51  {
52  matrix_row0_col0_offset, /*!< offset of m_item_matrix(0, 0) (packed as float) */
53  matrix_row0_col1_offset, /*!< offset of m_item_matrix(0, 1) (packed as float) */
54  matrix_row0_col2_offset, /*!< offset of m_item_matrix(0, 2) (packed as float) */
55  matrix_row1_col0_offset, /*!< offset of m_item_matrix(1, 0) (packed as float) */
56  matrix_row1_col1_offset, /*!< offset of m_item_matrix(1, 1) (packed as float) */
57  matrix_row1_col2_offset, /*!< offset of m_item_matrix(1, 2) (packed as float) */
58  matrix_row2_col0_offset, /*!< offset of m_item_matrix(2, 0) (packed as float) */
59  matrix_row2_col1_offset, /*!< offset of m_item_matrix(2, 1) (packed as float) */
60  matrix_row2_col2_offset, /*!< offset of m_item_matrix(2, 2) (packed as float) */
61 
62  normalized_translate_x, /*!< offset of m_normalized_translate.x() */
63  normalized_translate_y, /*!< offset of m_normalized_translate.y() */
64 
65  matrix_data_size, /*!< Size of the data for the item matrix */
66 
67  matrix_col0_row0_offset = matrix_row0_col0_offset, /*!< alias of \ref matrix_row0_col0_offset */
68  matrix_col0_row1_offset = matrix_row1_col0_offset, /*!< alias of \ref matrix_row1_col0_offset */
69  matrix_col0_row2_offset = matrix_row2_col0_offset, /*!< alias of \ref matrix_row2_col0_offset */
70  matrix_col1_row0_offset = matrix_row0_col1_offset, /*!< alias of \ref matrix_row0_col1_offset */
71  matrix_col1_row1_offset = matrix_row1_col1_offset, /*!< alias of \ref matrix_row1_col1_offset */
72  matrix_col1_row2_offset = matrix_row2_col1_offset, /*!< alias of \ref matrix_row2_col1_offset */
73  matrix_col2_row0_offset = matrix_row0_col2_offset, /*!< alias of \ref matrix_row0_col2_offset */
74  matrix_col2_row1_offset = matrix_row1_col2_offset, /*!< alias of \ref matrix_row1_col2_offset */
75  matrix_col2_row2_offset = matrix_row2_col2_offset, /*!< alias of \ref matrix_row2_col2_offset */
76  };
77 
78  /*!
79  * Ctor from a float3x3
80  * \param m value with which to initailize \ref m_item_matrix
81  * \param t value with which to initailize \ref m_normalized_translate
82  */
83  explicit
84  PainterItemMatrix(const float3x3 &m, const vec2 &t = vec2(0.0f, 0.0f)):
85  m_item_matrix(m),
87  {}
88 
89  /*!
90  * Ctor, initializes \ref m_item_matrix as the identity matrix
91  * \param t value with which to initailize \ref m_normalized_translate
92  */
93  PainterItemMatrix(const vec2 &t = vec2(0.0f, 0.0f)):
95  {}
96 
97  /*!
98  * Returns the length of the data needed to encode the data.
99  * Data is padded to be multiple of 4.
100  */
101  unsigned int
102  data_size(void) const
103  {
105  }
106 
107  /*!
108  * Pack the values of this PainterItemMatrix
109  * \param dst place to which to pack data
110  */
111  void
112  pack_data(c_array<uvec4> dst) const;
113 
114  /*!
115  * The 3x3 matrix tranforming from item coordinate
116  * to the coordinates of the clipping rectange.
117  */
119 
120  /*!
121  * The translation in normalized device coordinates
122  * to apply to all vertices. For various internal
123  * implementation details, it is more efficient
124  * to have them seperate here instead of concating
125  * it to \ref m_item_matrix
126  */
128  };
129 /*! @} */
130 
131 } //namespace
132 
133 #endif
A PainterItemMatrix holds the value for the transformation from item coordinates to the coordinates i...
#define FASTUIDRAW_NUMBER_BLOCK4_NEEDED(X)
Definition: util.hpp:42
PainterItemMatrix(const vec2 &t=vec2(0.0f, 0.0f))
PainterItemMatrix(const float3x3 &m, const vec2 &t=vec2(0.0f, 0.0f))
file matrix.hpp
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
unsigned int data_size(void) const
file c_array.hpp
vecN< float, 2 > vec2
Definition: vecN.hpp:1231
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
file vecN.hpp
void pack_data(c_array< uvec4 > dst) const
item_matrix_data_offset_t
Enumeration that provides offsets for the item matrix from the location of that data (item_matrix_off...