Add Default Uniform : uActorColor
[platform/core/uifw/dali-core.git] / dali / internal / render / renderers / uniform-buffer-view-pool.h
1 #ifndef DALI_INTERNAL_UNIFORM_BUFFER_VIEW_POOL_H
2 #define DALI_INTERNAL_UNIFORM_BUFFER_VIEW_POOL_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-types.h>
23
24 // EXTERNAL INCLUDES
25 #include <stdint.h>
26 #include <stdlib.h>
27
28 namespace Dali::Internal::Render
29 {
30
31 class UniformBufferManager;
32 class UniformBufferView;
33 class UniformBuffer;
34
35 /**
36  * Class UniformBufferPoolView
37  *
38  * The class is responsible for managing the UniformBuffer memory.
39  * It is stack-based pool allocator. It doesn't own the UniformBuffer but
40  * it's mere view into the memory.
41  *
42  * The view may however request UniformBuffer to resize if there is a need
43  * to allocate memory beyond its current size.
44  *
45  * The UniformBuffer may be trimmed on Rollback().
46  *
47  * Rollback() operation moves allocation pointer to the very beginning
48  * of the UniformBuffer. The data stored in the UniformBuffer after
49  * Rollback() is considered invalid and shouldn't be used by the client side.
50  */
51 class UniformBufferViewPool
52 {
53   friend class UniformBufferManager;
54
55 private:
56
57   UniformBufferViewPool( UniformBufferManager& manager, uint32_t alignment );
58
59 public:
60
61   ~UniformBufferViewPool();
62
63   /**
64    * Rolls back allocation to the beginning of pool
65    */
66   void Rollback();
67
68   /**
69    * Creates view for next free chunk of UBO memory of specified size.
70    */
71   Graphics::UniquePtr<UniformBufferView> CreateUniformBufferView( size_t size );
72
73 private:
74
75   UniformBufferManager& mUboManager;
76   Graphics::UniquePtr<UniformBuffer> mUniformBufferStorage;
77
78   uint32_t mAlignment; // 1 for tightly packed emulated UBO
79   uint32_t mCurrentOffset;
80 };
81
82 } // namespace Dali::Internal::Render
83 #endif //DALI_INTERNAL_UNIFORM_BUFFER_VIEW_POOL_H