1 #ifndef DALI_INTERNAL_SCENE_GRAPH_VISUAL_RENDERER_H
2 #define DALI_INTERNAL_SCENE_GRAPH_VISUAL_RENDERER_H
5 * Copyright (c) 2023 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 <stdint.h> ///< For size_t
24 #include <dali/internal/update/nodes/node-helper.h> ///< For property wrapper macro
25 #include <dali/internal/update/rendering/scene-graph-visual-renderer-property.h>
27 namespace Dali::Internal::SceneGraph::VisualRenderer
29 struct AnimatableVisualProperties
31 AnimatableVisualProperties()
32 : mTransformOffset(Vector2::ZERO),
33 mTransformSize(Vector2::ONE),
34 mTransformOrigin(Vector2::ZERO),
35 mTransformAnchorPoint(Vector2::ZERO),
36 mTransformOffsetSizeMode(Vector4::ZERO),
37 mExtraSize(Vector2::ZERO),
38 mMixColor(Vector3::ONE),
39 mPreMultipliedAlpha(0.0f),
40 mExtendedPropertiesDeleteFunction(nullptr)
44 ~AnimatableVisualProperties()
46 if(mExtendedProperties && mExtendedPropertiesDeleteFunction)
48 mExtendedPropertiesDeleteFunction(mExtendedProperties);
54 * @copydoc Dali::Internal::SceneGraph::Renderer::ResetToBaseValues
56 void ResetToBaseValues(BufferIndex updateBufferIndex);
59 * @copydoc Dali::Internal::SceneGraph::Renderer::MarkAsDirty
65 * @brief Cached coefficient value when we calculate visual transformed update size.
66 * It can reduce complexity of calculate the vertex position.
68 * Vector2 vertexPosition = (XA * aPosition + XB) * originalSize + (CA * aPosition + CB)
70 struct VisualTransformedUpdateSizeCoefficientCache : public VisualRendererCoefficientCacheBase
72 VisualTransformedUpdateSizeCoefficientCache()
73 : VisualRendererCoefficientCacheBase(),
74 coefXA(Vector2::ZERO),
75 coefXB(Vector2::ZERO),
76 coefCA(Vector2::ZERO),
81 ~VisualTransformedUpdateSizeCoefficientCache() override = default;
89 public: // Default properties
90 // Define a base offset for the following wrappers. The wrapper macros calculate offsets from the previous
91 // element such that each wrapper type generates a compile time offset to the CoefficientCache data.
92 BASE(VisualTransformedUpdateSizeCoefficientCache, mCoefficient); ///< Coefficient value to calculate visual transformed update size by VisualProperties more faster.
94 PROPERTY_WRAPPER(mCoefficient, VisualRendererProperty, Vector2, mTransformOffset);
95 PROPERTY_WRAPPER(mTransformOffset, VisualRendererProperty, Vector2, mTransformSize);
96 PROPERTY_WRAPPER(mTransformSize, VisualRendererProperty, Vector2, mTransformOrigin);
97 PROPERTY_WRAPPER(mTransformOrigin, VisualRendererProperty, Vector2, mTransformAnchorPoint);
98 PROPERTY_WRAPPER(mTransformAnchorPoint, VisualRendererProperty, Vector4, mTransformOffsetSizeMode);
99 PROPERTY_WRAPPER(mTransformOffsetSizeMode, VisualRendererProperty, Vector2, mExtraSize);
101 // Properties that don't give any effort to coefficient.
102 AnimatableProperty<Vector3> mMixColor;
103 AnimatableProperty<float> mPreMultipliedAlpha;
105 public: // Extended properties
106 void* mExtendedProperties{nullptr}; // Enable derived class to extend properties further
107 void (*mExtendedPropertiesDeleteFunction)(void*){nullptr}; // Derived class's custom delete functor
110 struct AnimatableDecoratedVisualProperties
112 AnimatableDecoratedVisualProperties()
113 : mBorderlineWidth(0.0f),
114 mBorderlineOffset(0.0f),
116 mBorderlineColor(Color::BLACK),
117 mCornerRadius(Vector4::ZERO),
118 mCornerRadiusPolicy(1.0f)
121 ~AnimatableDecoratedVisualProperties()
125 public: // Public API
126 // Delete function of AnimatableDecoratedVisualProperties* converted as void*
127 static void DeleteFunction(void* data)
129 delete static_cast<AnimatableDecoratedVisualProperties*>(data);
133 * @copydoc Dali::Internal::SceneGraph::Renderer::ResetToBaseValues
135 void ResetToBaseValues(BufferIndex updateBufferIndex);
138 * @copydoc Dali::Internal::SceneGraph::Renderer::MarkAsDirty
144 * @brief Cached coefficient value when we calculate visual transformed update size.
145 * It can reduce complexity of calculate the vertex position.
147 * Vector2 vertexPosition += Vector2(D, D) * aPosition
149 struct DecoratedVisualTransformedUpdateSizeCoefficientCache : public VisualRendererCoefficientCacheBase
151 DecoratedVisualTransformedUpdateSizeCoefficientCache()
152 : VisualRendererCoefficientCacheBase(),
157 ~DecoratedVisualTransformedUpdateSizeCoefficientCache() override = default;
162 public: // Default properties
163 // Define a base offset for the following wrappers. The wrapper macros calculate offsets from the previous
164 // element such that each wrapper type generates a compile time offset to the CoefficientCache data.
165 BASE(DecoratedVisualTransformedUpdateSizeCoefficientCache, mCoefficient); ///< Coefficient value to calculate visual transformed update size by VisualProperties more faster.
167 PROPERTY_WRAPPER(mCoefficient, VisualRendererProperty, float, mBorderlineWidth);
168 PROPERTY_WRAPPER(mBorderlineWidth, VisualRendererProperty, float, mBorderlineOffset);
169 PROPERTY_WRAPPER(mBorderlineOffset, VisualRendererProperty, float, mBlurRadius);
171 // Properties that don't give any effort to coefficient.
172 AnimatableProperty<Vector4> mBorderlineColor;
173 AnimatableProperty<Vector4> mCornerRadius;
174 AnimatableProperty<float> mCornerRadiusPolicy;
176 } // namespace Dali::Internal::SceneGraph::VisualRenderer
178 #endif // DALI_INTERNAL_SCENE_GRAPH_VISUAL_RENDERER_H