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)) || !mRendered);
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
89 bool mRendered{false}; /// Rendering state
93 * An interface to provide partial rendering data
95 class PartialRenderingDataProvider
101 PartialRenderingDataProvider() = default;
106 virtual ~PartialRenderingDataProvider() = default;
109 * @brief Returns partial rendering data associated with the node.
110 * @return A valid pointer to the partial rendering data or nullptr
112 PartialRenderingNodeData& GetPartialRenderingData()
114 return mPartialRenderingData;
118 PartialRenderingNodeData mPartialRenderingData;
122 * An interface to provide data for a Renderer
124 class NodeDataProvider : UniformMapDataProvider, public PartialRenderingDataProvider
128 * Constructor. Nothing to do as a pure interface.
130 NodeDataProvider() = default;
133 * @param bufferIndex to use
134 * @return a reference to the model matrix
136 virtual const Matrix& GetModelMatrix(BufferIndex bufferIndex) const = 0;
139 * @param bufferIndex to use
140 * @return a reference to the color
142 virtual const Vector4& GetRenderColor(BufferIndex bufferIndex) const = 0;
145 * @copydoc Dali::Internal::SceneGraph::UniformMapDataProvider::GetUniformMapChanged()
147 bool GetUniformMapChanged(BufferIndex bufferIndex) const override = 0;
150 * @copydoc Dali::Internal::SceneGraph::UniformMapDataProvider::GetUniformMap()
152 const CollectedUniformMap& GetUniformMap(BufferIndex bufferIndex) const override = 0;
156 * Virtual destructor, this is an interface, no deletion through this interface
158 ~NodeDataProvider() override = default;
161 } // namespace SceneGraph
162 } // namespace Internal
165 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_DATA_PROVIDER_H