FastUIDraw
painter_brush_shader_data.hpp
Go to the documentation of this file.
1 /*!
2  * \file painter_brush_shader_data.hpp
3  * \brief file painter_brush_shader_data.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_PAINTER_BRUSH_SHADER_DATA_HPP
21 #define FASTUIDRAW_PAINTER_BRUSH_SHADER_DATA_HPP
22 
24 #include <fastuidraw/util/util.hpp>
25 #include <fastuidraw/image.hpp>
26 
27 namespace fastuidraw
28 {
29 /*!\addtogroup PainterShaderData
30  * @{
31  */
32 
33  /*!
34  * \brief
35  * Base class to hold custom data for custom brush shaders.
36  */
38  {
39  public:
40  virtual
42  {}
43 
44  /*!
45  * To be implemented by a derived class to pack the
46  * data.
47  * \param dst location to which to pack the data
48  */
49  virtual
50  void
51  pack_data(c_array<uvec4> dst) const = 0;
52 
53  /*!
54  * To be implemented by a derived class to return
55  * the number of uvec4 blocks needed
56  * to pack the data.
57  */
58  virtual
59  unsigned int
60  data_size(void) const = 0;
61 
62  /*!
63  * To be optionally implemented by a derived class to
64  * save references to resources that need to be resident
65  * after packing. Default implementation does nothing.
66  * \param dst location to which to save resources.
67  */
68  virtual
69  void
71  {
72  FASTUIDRAWunused(dst);
73  }
74 
75  /*!
76  * To be optionally implemented by a derived class to
77  * return the number of resources that need to be resident
78  * after packing. Default implementation returns 0.
79  */
80  virtual
81  unsigned int
82  number_resources(void) const
83  {
84  return 0;
85  }
86 
87  /*!
88  * To be implemented by a derived class to return a \ref
89  * c_array of references to \ref Image objects whose
90  * Image::type() value is \ref Image::context_texture2d.
91  * The i'th entry in the returned array will be bound to
92  * the i'th external texture slot of the backend via the
93  * \ref PainterDrawBreakAction objected returned by \ref
94  * PainterBackend::bind_image(). Default implementation
95  * is to return an empty array.
96  */
97  virtual
99  bind_images(void) const
100  {
102  }
103  };
104 
105 /*! @} */
106 
107 } //namespace fastuidraw
108 
109 #endif
virtual void save_resources(c_array< reference_counted_ptr< const resource_base > > dst) const
all classes and functions of FastUIDraw are in the namespace fastuidraw.
Definition: colorstop.hpp:28
A wrapper over a pointer to implement reference counting.
virtual c_array< const reference_counted_ptr< const Image > > bind_images(void) const
virtual unsigned int data_size(void) const =0
virtual void pack_data(c_array< uvec4 > dst) const =0
file c_array.hpp
#define FASTUIDRAWunused(X)
Definition: util.hpp:84
file util.hpp
Base class to hold custom data for custom brush shaders.
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
Class for which copy ctor and assignment operator are private functions.
Definition: util.hpp:505
virtual unsigned int number_resources(void) const
file image.hpp