FastUIDraw
painter_packed_value_pool.hpp
Go to the documentation of this file.
1 /*!
2  * \file painter_packed_value_pool.hpp
3  * \brief file painter_packed_value_pool.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_PACKED_VALUE_POOL_HPP
21 #define FASTUIDRAW_PAINTER_PACKED_VALUE_POOL_HPP
22 
24 
25 namespace fastuidraw
26 {
27 
28 /*!\addtogroup PainterShaderData
29  * @{
30  */
31 
32  /*!
33  * \brief
34  * A PainterPackedValuePool can be used to create PainterPackedValue
35  * objects.
36  *
37  * Just like PainterPackedValue, PainterPackedValuePool is
38  * NOT thread safe, as such it is not a safe operation to use the
39  * same PainterPackedValuePool object from multiple threads at the
40  * same time. A fixed PainterPackedValuePool can create \ref
41  * PainterPackedValue objects used by different \ref Painter objects.
42  */
44  {
45  public:
46  /*!
47  * Ctor.
48  */
49  explicit
51 
53 
54  /*!
55  * Create and return a PainterPackedValue<PainterItemShaderData>
56  * object for the value of a PainterItemShaderData object.
57  * \param value data to pack into returned PainterPackedValue
58  */
61 
62  /*!
63  * Create and return a PainterPackedValue<PainterBlendShaderData>
64  * object for the value of a PainterBlendShaderData object.
65  * \param value data to pack into returned PainterPackedValue
66  */
69 
70  /*!
71  * Create and return a PainterPackedValue<PainterBrushShaderData>
72  * object for the value of a PainterBrushShaderData object.
73  * \param value data to pack into returned PainterPackedValue
74  */
77 
78  /*!
79  * Returns a \ref PainterData::brush_value whose data is
80  * packed from a \ref PainterBrush value.
81  */
84  {
85  PainterData::brush_value R(&brush);
86  R.make_packed(*this);
87  return R;
88  }
89 
90  /*!
91  * Returns a \ref PainterData::brush_value whose data is
92  * packed from a \ref PainterCustomBrush value.
93  */
96  {
97  PainterData::brush_value R(brush);
98  R.make_packed(*this);
99  return R;
100  }
101 
102  private:
103  void *m_d;
104  };
105 
106 /*! @} */
107 
108  template<typename T>
109  void
112  {
113  if (!m_packed_value && m_value != nullptr)
114  {
115  m_packed_value = pool.create_packed_value(*m_value);
116  m_value = nullptr;
117  }
118  }
119 
120 } //namespace
121 
122 #endif
A PainterPackedValue represents a handle to an object that stores packed state data and tracks if tha...
A PainterPackedValuePool can be used to create PainterPackedValue objects.
void make_packed(PainterPackedValuePool &pool)
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
void make_packed(PainterPackedValuePool &pool)
PainterData::brush_value create_packed_brush(const PainterBrush &brush)
A PainterCustomBrush is just a conveniance to wrap a pointer to a PainterBrushShader together with a ...
Base class to hold custom data for custom brush shaders.
A brush_value stores the brush applied; it stores a pointer to a PainterBrushShader together with a P...
A PainterBrush defines a brush for painting via Painter.
PainterBlendShaderData holds custom data for blend shaders.
file painter_data.hpp
PainterPackedValue< PainterItemShaderData > create_packed_value(const PainterItemShaderData &value)
Class for which copy ctor and assignment operator are private functions.
Definition: util.hpp:505
PainterItemShaderData holds custom data for item shaders.
PainterData::brush_value create_packed_brush(const PainterCustomBrush &brush)