FastUIDraw
painter_attribute_writer.hpp
Go to the documentation of this file.
1 /*!
2  * \file painter_attribute_writer.hpp
3  * \brief file painter_attribute_writer.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_ATTRIBUTE_WRITER_HPP
20 #define FASTUIDRAW_PAINTER_ATTRIBUTE_WRITER_HPP
21 
22 #include <fastuidraw/util/util.hpp>
25 
26 namespace fastuidraw
27 {
28  ///@cond
29  class PainterItemShader;
30  class PainterItemCoverageShader;
31  ///@endcond
32 /*!\addtogroup PainterAttribute
33  * @{
34  */
35 
36  /*!
37  * \brief
38  * Provides an interface to write attribute and index data when
39  * a simple copy of data from \ref c_array objects is not sufficient.
40  *
41  * A \ref PainterAttributeWriter is to be stateless. However, in
42  * order to be able to successfully write multiple chunks of
43  * attributes and indices, a \ref PainterAttributeWriter is given
44  * a "cookie" (see \ref WriteState) which represents how far along
45  * streaming it is.
46  */
48  {
49  public:
50  /*!
51  * A \ref WriteState represents how far along a \ref
52  * PainterAttributeWriter has written its attribute
53  * and index data along with if there is more to write.
54  */
55  class WriteState
56  {
57  public:
58  /*!
59  * \ref m_state represents how far along a \ref
60  * PainterAttributeWriter has written its attribute
61  * and index data. The length of state will be
62  * \ref PainterAttributeWriter::state_length().
63  */
65 
66  /*!
67  * Gives the minimum size of the next attribute array
68  * passed to \ref PainterAttributeWriter::write_data()
69  * must be in order to successfully write data.
70  */
72 
73  /*!
74  * Gives the minimum size of the next index array
75  * passed to \ref PainterAttributeWriter::write_data()
76  * must be in order to successfully write data.
77  */
78  unsigned int m_min_indices_for_next;
79 
80  /*!
81  * Gives the range of z-values that the vertex
82  * shader will emit in the next call to \ref
83  * PainterAttributeWriter::write_data().
84  */
86 
87  /*!
88  * If non-null, overrides what shader the caller
89  * provided when rendering to a color buffer.
90  */
92 
93  /*!
94  * If non-null, overrides what shader the caller
95  * provided when rendering to a coverage buffer.
96  */
98  };
99 
100  virtual
102  {}
103 
104  /*!
105  * To be implemented by a derived class to indicate
106  * if the attribute rendering requires a coverage
107  * buffer.
108  */
109  virtual
110  bool
111  requires_coverage_buffer(void) const = 0;
112 
113  /*!
114  * To be implemented by a derived class to return how large
115  * the array \ref PainterAttributeWriter::WriteState::m_state
116  * should be.
117  */
118  virtual
119  unsigned int
120  state_length(void) const = 0;
121 
122  /*!
123  * To be implemented by a derived clas to initialize a
124  * \ref PainterAttributeWriter::WriteState to indicate the
125  * start of writing data for a subsequence calls to \ref
126  * write_data(). To return true if there is attribute and
127  * index data to upload.
128  * \param state \ref PainterAttributeWriter::WriteState to
129  * initialize.
130  */
131  virtual
132  bool
133  initialize_state(WriteState *state) const = 0;
134 
135  /*!
136  * To be implemented by a derived class. Called by the
137  * caller of a \ref PainterAttributeWriter to indicate
138  * that a new data store has been started.
139  * \param state \ref PainterAttributeWriter::WriteState
140  * to update
141  */
142  virtual
143  void
144  on_new_store(WriteState *state) const = 0;
145 
146  /*!
147  * To be implemented by a derived class to write attribute
148  * and index data. Returns true if there is further attribute
149  * and index data to upload.
150  * \param dst_attribs location to which to write attributes.
151  * The size of the array is guaranteed by
152  * the caller to be atleast the value of
153  * \ref WriteState::m_min_attributes_for_next.
154  * \param dst_indices location to which to write indices.
155  * The size of the array is guaranteed by
156  * the caller to be atleast the value of
157  * \ref WriteState::m_min_indices_for_next.
158  * \param attrib_location index value of the attribute at
159  * dst_attribs[0].
160  * \param state the write state of the session which is to be
161  * updated for the next call to write_data().
162  * \param num_attribs_written location to which to write
163  * the number of attributes
164  * written by the call to \ref
165  * write_data().
166  * \param num_indices_written location to which to write the
167  * number of indices written by the
168  * call to \ref write_data().
169  */
170  virtual
171  bool
173  c_array<PainterIndex> dst_indices,
174  unsigned int attrib_location,
175  WriteState *state,
176  unsigned int *num_attribs_written,
177  unsigned int *num_indices_written) const = 0;
178  };
179 /*! @} */
180 }
181 
182 #endif
virtual void on_new_store(WriteState *state) const =0
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
virtual bool initialize_state(WriteState *state) const =0
virtual bool requires_coverage_buffer(void) const =0
file c_array.hpp
virtual bool write_data(c_array< PainterAttribute > dst_attribs, c_array< PainterIndex > dst_indices, unsigned int attrib_location, WriteState *state, unsigned int *num_attribs_written, unsigned int *num_indices_written) const =0
virtual unsigned int state_length(void) const =0
Provides an interface to write attribute and index data when a simple copy of data from c_array objec...
file util.hpp
A PainterItemCoverageShader represents a shader to draw an item to a coverage buffer (see PainterSurf...
file painter_attribute.hpp
Class for which copy ctor and assignment operator are private functions.
Definition: util.hpp:505
A PainterItemShader represents a shader to draw an item (typically a vertex and fragment shader pair)...