1 #ifndef DALI_INTERNAL_VISUAL_RENDERER_H
2 #define DALI_INTERNAL_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/renderer-impl.h> // Dali::Internal::Renderer
23 #include <dali/public-api/rendering/visual-renderer.h> // Dali::VisualRenderer
35 using VisualRendererPtr = IntrusivePtr<VisualRenderer>;
38 * VisualRenderer is a Renderer that has additional default properties for toolkit
40 class VisualRenderer : public Renderer
44 * Create a new VisualRenderer.
45 * @return A smart-pointer to the newly allocated VisualRenderer.
47 static VisualRendererPtr New();
50 * @brief Get the scene graph object
52 * @return the scene object
54 const SceneGraph::Renderer& GetVisualRendererSceneObject() const;
56 public: // Default property extensions from Object
58 * @copydoc Dali::Internal::Object::SetDefaultProperty()
60 void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) override;
63 * @copydoc Dali::Internal::Object::GetDefaultProperty()
65 Property::Value GetDefaultProperty(Property::Index index) const override;
68 * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
70 Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override;
73 * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation()
75 void OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType) override;
78 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
80 const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty(Property::Index index) const override;
83 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
85 const PropertyInputImpl* GetSceneObjectInputProperty(Property::Index index) const override;
87 protected: // implementation
91 * @param sceneObject the scene graph renderer
93 VisualRenderer(const SceneGraph::Renderer* sceneObject);
96 * @brief Retrieves the current value of a default property from the scene-graph.
97 * @param[in] index The index of the property
98 * @param[out] value Is set with the current scene-graph value of the property
99 * @return True if value set, false otherwise.
101 bool GetCurrentPropertyValue(Property::Index index, Property::Value& value) const;
104 * @brief Ensure that properties are mapped to uniforms
106 void AddUniformMappings();
110 * A reference counted object may only be deleted by calling Unreference()
112 ~VisualRenderer() override;
115 VisualRenderer(const VisualRenderer&) = delete;
116 VisualRenderer& operator=(const VisualRenderer&) = delete;
119 struct VisualPropertyCache
121 Vector2 mTransformOffset{Vector2::ZERO};
122 Vector2 mTransformSize{Vector2::ONE};
123 Vector2 mTransformOrigin{Vector2::ZERO};
124 Vector2 mTransformAnchorPoint{Vector2::ZERO};
125 Vector4 mTransformOffsetSizeMode{Vector2::ZERO};
126 Vector2 mExtraSize{Vector2::ZERO};
127 Vector3 mMixColor{Vector3::ONE};
128 float mPreMultipliedAlpha{0.0f};
132 VisualPropertyCache mPropertyCache;
135 } // namespace Internal
137 // Helpers for public-api forwarding methods
138 inline Internal::VisualRenderer& GetImplementation(Dali::VisualRenderer& handle)
140 DALI_ASSERT_ALWAYS(handle && "VisualRenderer handle is empty");
142 BaseObject& object = handle.GetBaseObject();
144 return static_cast<Internal::VisualRenderer&>(object);
147 inline const Internal::VisualRenderer& GetImplementation(const Dali::VisualRenderer& handle)
149 DALI_ASSERT_ALWAYS(handle && "VisualRenderer handle is empty");
151 const BaseObject& object = handle.GetBaseObject();
153 return static_cast<const Internal::VisualRenderer&>(object);
158 #endif // DALI_INTERNAL_VISUAL_RENDERER_H