Moved SetUpdate propagation to UpdateNodes
[platform/core/uifw/dali-core.git] / dali / internal / render / renderers / gpu-buffer.h
1 #ifndef DALI_INTERNAL_RENDERERS_GPU_BUFFER_H
2 #define DALI_INTERNAL_RENDERERS_GPU_BUFFER_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/graphics-api/graphics-controller.h>
23
24 namespace Dali
25 {
26 namespace Internal
27 {
28 /**
29  * Used to create and update a GPU memory buffer.
30  *
31  * The buffer can be used for storing vertex data, index arrays (indices)
32  * or pixel data (PBO).
33  *
34  * The buffer allows data to be stored in high-performance
35  * graphics memory on the server side and
36  * promotes efficient data transfer.
37  */
38 class GpuBuffer
39 {
40 public:
41   /**
42    * constructor
43    * @param[in] graphicsController the graphics controller
44    * @param[in] usage The type of buffer
45    */
46   GpuBuffer(Graphics::Controller& graphicsController, Graphics::BufferUsageFlags usage);
47
48   /**
49    * Destructor, non virtual as no virtual methods or inheritance
50    */
51   ~GpuBuffer() = default;
52
53   /**
54    *
55    * Creates or updates a buffer object and binds it to the target.
56    * @param graphicsController The graphics controller
57    * @param size Specifies the size in bytes of the buffer object's new data store.
58    * @param data pointer to the data to load
59    */
60   void UpdateDataBuffer(Graphics::Controller& graphicsController, uint32_t size, const void* data);
61
62   /**
63    * Get the size of the buffer
64    * @return size
65    */
66   [[nodiscard]] uint32_t GetBufferSize() const
67   {
68     return mSize;
69   }
70
71   [[nodiscard]] inline const Graphics::Buffer* GetGraphicsObject() const
72   {
73     return mGraphicsObject.get();
74   }
75
76   /**
77    * Destroy the graphics buffer and reset.
78    */
79   void Destroy();
80
81 private:
82   Graphics::UniquePtr<Graphics::Buffer> mGraphicsObject;
83   uint32_t                              mCapacity{0}; ///< buffer capacity
84   uint32_t                              mSize{0};     ///< buffer size
85   Graphics::BufferUsageFlags            mUsage;
86 };
87
88 } // namespace Internal
89 } // namespace Dali
90
91 #endif // DALI_INTERNAL_RENDERERS_GPU_BUFFER_H