1 #ifndef DALI_INTERNAL_DECORATED_VISUAL_RENDERER_H
2 #define DALI_INTERNAL_DECORATED_VISUAL_RENDERER_H
5 * Copyright (c) 2022 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.
22 #include <dali/internal/event/rendering/visual-renderer-impl.h> // Dali::Internal::VisualRenderer
23 #include <dali/public-api/rendering/decorated-visual-renderer.h> // Dali::DecoratedVisualRenderer
34 class DecoratedVisualRenderer;
35 using DecoratedVisualRendererPtr = IntrusivePtr<DecoratedVisualRenderer>;
38 * DecoratedVisualRenderer is a VisualRenderer that has additional default properties for toolkit
40 class DecoratedVisualRenderer : public VisualRenderer
44 * Create a new DecoratedVisualRenderer.
45 * @return A smart-pointer to the newly allocated DecoratedVisualRenderer.
47 static DecoratedVisualRendererPtr New();
49 public: // Default property extensions from Object
51 * @copydoc Dali::Internal::Object::SetDefaultProperty()
53 void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) override;
56 * @copydoc Dali::Internal::Object::GetDefaultProperty()
58 Property::Value GetDefaultProperty(Property::Index index) const override;
61 * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
63 Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override;
66 * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
68 void OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType) override;
71 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
73 const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty(Property::Index index) const override;
76 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
78 const PropertyInputImpl* GetSceneObjectInputProperty(Property::Index index) const override;
82 * @copydoc Dali::DecoratedVisualRenderer::RegisterCornerRadiusUniform()
84 void RegisterCornerRadiusUniform();
87 * @copydoc Dali::DecoratedVisualRenderer::RegisterBorderlineUniform()
89 void RegisterBorderlineUniform();
92 * @copydoc Dali::DecoratedVisualRenderer::RegisterBlurRadiusUniform()
94 void RegisterBlurRadiusUniform();
96 protected: // implementation
100 * @param sceneObject the scene graph renderer
102 DecoratedVisualRenderer(const SceneGraph::Renderer* sceneObject);
105 * @brief Retrieves the current value of a default property from the scene-graph.
106 * @param[in] index The index of the property
107 * @param[out] value Is set with the current scene-graph value of the property
108 * @return True if value set, false otherwise.
110 bool GetCurrentPropertyValue(Property::Index index, Property::Value& value) const;
113 * @brief Add the uniforms for DecoratedVisualRendererUseType.
114 * If that flag didn't appended yet, It will add the uniforms map
116 * @param[in] newFlag one of DecoratedVisualRendererUseType
118 void AddUniformFlag(uint8_t newAddFlag);
122 * A reference counted object may only be deleted by calling Unreference()
124 ~DecoratedVisualRenderer() override;
127 DecoratedVisualRenderer(const DecoratedVisualRenderer&) = delete;
128 DecoratedVisualRenderer& operator=(const DecoratedVisualRenderer&) = delete;
131 enum DecoratedVisualRendererUseType
133 DECORATED_VISUAL_RENDERER_USE_CORNER_RADIUS = 1,
134 DECORATED_VISUAL_RENDERER_USE_BORDERLINE = 2,
135 DECORATED_VISUAL_RENDERER_USE_BLUR_RADIUS = 4,
138 struct DecoratedVisualPropertyCache
140 Vector4 mCornerRadius{Vector4::ZERO};
141 float mCornerRadiusPolicy{1.0f};
142 float mBorderlineWidth{0.0f};
143 Vector4 mBorderlineColor{Color::BLACK};
144 float mBorderlineOffset{0.0f};
145 float mBlurRadius{0.0f};
149 DecoratedVisualPropertyCache mDecoratedPropertyCache;
151 uint8_t mAddUniformFlag : 4;
154 } // namespace Internal
156 // Helpers for public-api forwarding methods
157 inline Internal::DecoratedVisualRenderer& GetImplementation(Dali::DecoratedVisualRenderer& handle)
159 DALI_ASSERT_ALWAYS(handle && "DecoratedVisualRenderer handle is empty");
161 BaseObject& object = handle.GetBaseObject();
163 return static_cast<Internal::DecoratedVisualRenderer&>(object);
166 inline const Internal::DecoratedVisualRenderer& GetImplementation(const Dali::DecoratedVisualRenderer& handle)
168 DALI_ASSERT_ALWAYS(handle && "DecoratedVisualRenderer handle is empty");
170 const BaseObject& object = handle.GetBaseObject();
172 return static_cast<const Internal::DecoratedVisualRenderer&>(object);
177 #endif // DALI_INTERNAL_DECORATED_VISUAL_RENDERER_H