1 #ifndef DALI_INTERNAL_SCENE_GRAPH_NODE_DATA_PROVIDER_H
2 #define DALI_INTERNAL_SCENE_GRAPH_NODE_DATA_PROVIDER_H
5 * Copyright (c) 2020 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>
41 * Structure to store partial rendering cache data
43 struct PartialRenderingCacheInfo
45 Node* node{nullptr}; /// Node associated with the entry
46 const Renderer* renderer{nullptr}; /// Renderer object
47 const TextureSet* textureSet{nullptr}; /// TextureSet object
48 Matrix matrix{}; /// Model-view matrix
49 Vector4 color{}; /// Color
50 Vector3 size{}; /// Size
51 Vector3 updatedSize{}; /// Updated size
52 bool isOpaque{}; /// Opacity state
53 uint32_t depthIndex{0u}; /// Depth index
57 * Structure contains partial rendering data used in order to determine
58 * whether anything has changed and node has to be updated
60 struct PartialRenderingNodeData
63 * @brief Retrieves current PartialDataCacheInfo structure
64 * @return Current PartialDataCacheInfo structure
66 PartialRenderingCacheInfo& GetCurrentCacheInfo()
68 return mData[mCurrentIndex];
72 * @brief Tests whether cache changed since last frame
73 * @return True if changed
77 return 0 != memcmp( &mData[0], &mData[1], sizeof(PartialRenderingCacheInfo) );
81 * @brief Swaps cache buffers
85 mCurrentIndex = static_cast<uint8_t>((~mCurrentIndex) & 1);
88 PartialRenderingCacheInfo mData[2u]; /// Double-buffered data
89 uint8_t mCurrentIndex {0u}; /// Current buffer index
93 * An interface to provide partial rendering data
95 class PartialRenderingDataProvider
102 PartialRenderingDataProvider() = default;
107 virtual ~PartialRenderingDataProvider() = default;
110 * @brief Returns partial rendering data associated with the node.
111 * @return A valid pointer to the partial rendering data or nullptr
113 PartialRenderingNodeData& GetPartialRenderingData()
115 return mPartialRenderingData;
120 PartialRenderingNodeData mPartialRenderingData;
124 * An interface to provide data for a Renderer
126 class NodeDataProvider : UniformMapDataProvider, public PartialRenderingDataProvider
131 * Constructor. Nothing to do as a pure interface.
133 NodeDataProvider() = default;
136 * @param bufferIndex to use
137 * @return a reference to the model matrix
139 virtual const Matrix& GetModelMatrix( BufferIndex bufferIndex ) const = 0;
142 * @param bufferIndex to use
143 * @return a reference to the color
145 virtual const Vector4& GetRenderColor( BufferIndex bufferIndex ) const = 0;
148 * @copydoc Dali::Internal::SceneGraph::UniformMapDataProvider::GetUniformMapChanged()
150 bool GetUniformMapChanged( BufferIndex bufferIndex ) const override = 0;
153 * @copydoc Dali::Internal::SceneGraph::UniformMapDataProvider::GetUniformMap()
155 const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const override = 0;
159 * Virtual destructor, this is an interface, no deletion through this interface
161 ~NodeDataProvider() override = default;
168 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_DATA_PROVIDER_H