1 #ifndef DALI_INTERNAL_RENDERER_H
2 #define DALI_INTERNAL_RENDERER_H
5 * Copyright (c) 2015 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/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
23 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
24 #include <dali/devel-api/rendering/renderer.h> // Dali::Renderer
25 #include <dali/internal/common/blending-options.h>
26 #include <dali/internal/event/common/connectable.h> // Dali::Internal::Connectable
27 #include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
28 #include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
29 #include <dali/internal/event/rendering/material-impl.h> // Dali::Internal::Material
30 #include <dali/internal/event/rendering/geometry-impl.h> // Dali::Internal::Geometry
43 typedef IntrusivePtr<Renderer> RendererPtr;
46 * Renderer is an object that can be used to show content by combining a Geometry with a material.
48 class Renderer : public Object
53 * Create a new Renderer.
54 * @return A smart-pointer to the newly allocated Renderer.
56 static RendererPtr New();
59 * @copydoc Dali::Renderer::SetGeometry()
61 void SetGeometry( Geometry& geometry );
64 * @copydoc Dali::Renderer::GetGeometry()
66 Geometry* GetGeometry() const;
69 * @copydoc Dali::Renderer::SetMaterial()
71 void SetMaterial( Material& material );
74 * @copydoc Dali::Renderer::GetMaterial()
76 Material* GetMaterial() const;
79 * @copydoc Dali::Renderer::SetDepthIndex()
81 void SetDepthIndex( int depthIndex );
84 * @copydoc Dali::Renderer::GetDepthIndex()
86 int GetDepthIndex() const;
89 * @copydoc Dali::Renderer::SetFaceCullingMode()
91 void SetFaceCullingMode( Dali::Renderer::FaceCullingMode cullingMode );
94 * @copydoc Dali::Renderer::GetFaceCullingMode()
96 Dali::Renderer::FaceCullingMode GetFaceCullingMode();
99 * @copydoc Dali::Renderer::SetBlendMode()
101 void SetBlendMode( BlendingMode::Type mode );
104 * @copydoc Dali::Renderer::GetBlendMode()
106 BlendingMode::Type GetBlendMode() const;
109 * @copydoc Dali::Renderer::SetBlendFunc()
111 void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba );
114 * @copydoc Dali::Renderer::SetBlendFunc()
116 void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
117 BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha );
120 * @copydoc Dali::Renderer::GetBlendFunc()
122 void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
123 BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const;
126 * @copydoc Dali::Renderer::SetBlendEquation()
128 void SetBlendEquation( BlendingEquation::Type equationRgba );
131 * @copydoc Dali::Renderer::SetBlendEquation()
133 void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha );
136 * @copydoc Dali::Renderer::GetBlendEquation()
138 void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const;
141 * @copydoc Dali::Renderer::SetBlendColor()
143 void SetBlendColor( const Vector4& color );
146 * @copydoc Dali::Renderer::GetBlendColor()
148 Vector4 GetBlendColor() const;
151 * @brief Set whether the Pre-multiplied Alpha Blending is required
153 * @param[in] preMultipled whether alpha is pre-multiplied.
155 void EnablePreMultipliedAlpha( bool preMultipled );
158 * @brief Query whether alpha is pre-multiplied.
160 * @return True is alpha is pre-multiplied, false otherwise.
162 bool IsPreMultipliedAlphaEnabled() const;
165 * @brief Get the scene graph object ( the node attachment )
167 * @return the scene object
169 SceneGraph::Renderer* GetRendererSceneObject();
171 public: // Default property extensions from Object
174 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
176 virtual unsigned int GetDefaultPropertyCount() const;
179 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
181 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
184 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
186 virtual const char* GetDefaultPropertyName(Property::Index index) const;
189 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
191 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
194 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
196 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
199 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
201 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
204 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
206 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
209 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
211 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
214 * @copydoc Dali::Internal::Object::SetDefaultProperty()
216 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
219 * @copydoc Dali::Internal::Object::SetSceneGraphProperty()
221 virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
224 * @copydoc Dali::Internal::Object::GetDefaultProperty()
226 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
229 * @copydoc Dali::Internal::Object::GetPropertyOwner()
231 virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const;
234 * @copydoc Dali::Internal::Object::GetSceneObject()
236 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
239 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
241 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
244 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
246 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
249 * @copydoc Dali::Internal::Object::GetPropertyComponentIndex()
251 virtual int GetPropertyComponentIndex( Property::Index index ) const;
253 public: // Functions from Connectable
255 * @copydoc Dali::Internal::Connectable::OnStage()
257 virtual bool OnStage() const;
260 * @copydoc Dali::Internal::Connectable::Connect()
262 virtual void Connect();
265 * @copydoc Dali::Internal::Connectable::Disconnect()
267 virtual void Disconnect();
269 private: // implementation
276 * A reference counted object may only be deleted by calling Unreference()
280 private: // unimplemented methods
281 Renderer( const Renderer& );
282 Renderer& operator=( const Renderer& );
285 SceneGraph::Renderer* mSceneObject;
286 Vector4* mBlendColor; ///< Local copy of blend color, pointer only as its rarely used
287 ObjectConnector<Geometry> mGeometryConnector; ///< Connector that holds the geometry used by this renderer
288 ObjectConnector<Material> mMaterialConnector; ///< Connector that holds the material used by this renderer
293 Dali::Renderer::FaceCullingMode mFaceCullingMode; ///< Local copy of face culling mode
294 BlendingMode::Type mBlendingMode; ///< Local copy of blending mode
295 BlendingOptions mBlendingOptions; ///< Local copy of blending options bitmask
296 bool mPremultipledAlphaEnabled; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
300 } // namespace Internal
302 // Helpers for public-api forwarding methods
303 inline Internal::Renderer& GetImplementation( Dali::Renderer& handle )
305 DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
307 BaseObject& object = handle.GetBaseObject();
309 return static_cast<Internal::Renderer&>(object);
312 inline const Internal::Renderer& GetImplementation( const Dali::Renderer& handle )
314 DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");
316 const BaseObject& object = handle.GetBaseObject();
318 return static_cast<const Internal::Renderer&>(object);
323 #endif // DALI_INTERNAL_RENDERER_H