1 #ifndef DALI_INTERNAL_SCENE_GRAPH_NODE_DATA_PROVIDER_H
2 #define DALI_INTERNAL_SCENE_GRAPH_NODE_DATA_PROVIDER_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <dali/internal/render/data-providers/uniform-map-data-provider.h>
22 #include <dali/public-api/math/matrix.h>
39 * Structure to store partial rendering cache data
41 struct PartialRenderingCacheInfo
43 Node* node{nullptr}; /// Node associated with the entry
44 const Renderer* renderer{nullptr}; /// Renderer object
45 const TextureSet* textureSet{nullptr}; /// TextureSet object
46 Matrix matrix{}; /// Model-view matrix
47 Vector4 color{}; /// Color
48 Vector3 size{}; /// Size
49 Vector3 updatedSize{}; /// Updated size
50 bool isOpaque{}; /// Opacity state
51 uint32_t depthIndex{0u}; /// Depth index
55 * Structure contains partial rendering data used in order to determine
56 * whether anything has changed and node has to be updated
58 struct PartialRenderingNodeData
61 * @brief Retrieves current PartialDataCacheInfo structure
62 * @return Current PartialDataCacheInfo structure
64 PartialRenderingCacheInfo& GetCurrentCacheInfo()
66 return mData[mCurrentIndex];
70 * @brief Tests whether cache changed since last frame
71 * @return True if changed
75 return 0 != memcmp(&mData[0], &mData[1], sizeof(PartialRenderingCacheInfo));
79 * @brief Swaps cache buffers
83 mCurrentIndex = static_cast<uint8_t>((~mCurrentIndex) & 1);
86 PartialRenderingCacheInfo mData[2u]; /// Double-buffered data
87 uint8_t mCurrentIndex{0u}; /// Current buffer index
88 bool mVisible{true}; /// Visible state
92 * An interface to provide partial rendering data
94 class PartialRenderingDataProvider
100 PartialRenderingDataProvider() = default;
105 virtual ~PartialRenderingDataProvider() = default;
108 * @brief Returns partial rendering data associated with the node.
109 * @return A valid pointer to the partial rendering data or nullptr
111 PartialRenderingNodeData& GetPartialRenderingData()
113 return mPartialRenderingData;
117 PartialRenderingNodeData mPartialRenderingData;
121 * An interface to provide data for a Renderer
123 class NodeDataProvider : UniformMapDataProvider, public PartialRenderingDataProvider
127 * Constructor. Nothing to do as a pure interface.
129 NodeDataProvider() = default;
132 * @param bufferIndex to use
133 * @return a reference to the model matrix
135 virtual const Matrix& GetModelMatrix(BufferIndex bufferIndex) const = 0;
138 * @param bufferIndex to use
139 * @return a reference to the color
141 virtual const Vector4& GetRenderColor(BufferIndex bufferIndex) const = 0;
144 * @copydoc Dali::Internal::SceneGraph::UniformMapDataProvider::GetUniformMapChanged()
146 bool GetUniformMapChanged(BufferIndex bufferIndex) const override = 0;
149 * @copydoc Dali::Internal::SceneGraph::UniformMapDataProvider::GetUniformMap()
151 const CollectedUniformMap& GetUniformMap(BufferIndex bufferIndex) const override = 0;
155 * Virtual destructor, this is an interface, no deletion through this interface
157 ~NodeDataProvider() override = default;
160 } // namespace SceneGraph
161 } // namespace Internal
164 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_DATA_PROVIDER_H