X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Frendering%2Frenderer-impl.h;h=17818ab90fba7c4e1b44f381697c7e0d3830eed6;hb=596dfee38d336a562d1aeb7a889988d9de4c7eef;hp=db1e13d5e577d9e6888796cc50d8129f35593881;hpb=fe966ea4b744b888cdee5f1e2e1e3b1a67ff1046;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/rendering/renderer-impl.h b/dali/internal/event/rendering/renderer-impl.h index db1e13d..17818ab 100644 --- a/dali/internal/event/rendering/renderer-impl.h +++ b/dali/internal/event/rendering/renderer-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_RENDERER_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,16 @@ */ // INTERNAL INCLUDES -#include // DALI_ASSERT_ALWAYS -#include // Dali::IntrusivePtr -#include // Dali::Renderer -#include // Dali::Internal::Connectable -#include // Dali::Internal::ObjectConnector -#include // Dali::Internal::Object -#include // Dali::Internal::Material -#include // Dali::Internal::Geometry +#include +#include +#include // Dali::Internal::ObjectConnector +#include // Dali::Internal::Object +#include // Dali::Internal::Geometry +#include // Dali::Internal::TextureSet +#include // Dali::Render::Renderer::StencilParameters +#include // DALI_ASSERT_ALWAYS +#include // Dali::IntrusivePtr +#include // Dali::Renderer namespace Dali { @@ -37,17 +39,15 @@ namespace SceneGraph class Renderer; } - class Renderer; -typedef IntrusivePtr RendererPtr; +using RendererPtr = IntrusivePtr; /** - * Renderer is an object that can be used to show content by combining a Geometry with a material. + * Renderer is an object that can be used to show content by combining a Geometry with a shader and textures. */ class Renderer : public Object { public: - /** * Create a new Renderer. * @return A smart-pointer to the newly allocated Renderer. @@ -57,165 +57,235 @@ public: /** * @copydoc Dali::Renderer::SetGeometry() */ - void SetGeometry( Geometry& geometry ); + void SetGeometry(Geometry& geometry); /** * @copydoc Dali::Renderer::GetGeometry() */ - Geometry* GetGeometry() const; + GeometryPtr GetGeometry() const; + + /** + * @copydoc Dali::Renderer::SetTextures() + */ + void SetTextures(TextureSet& textureSet); + + /** + * @copydoc Dali::Renderer::GetTextures() + */ + TextureSetPtr GetTextures() const; /** - * @copydoc Dali::Renderer::SetMaterial() + * @copydoc Dali::Renderer::SetShader() */ - void SetMaterial( Material& material ); + void SetShader(Shader& shader); /** - * @copydoc Dali::Renderer::GetMaterial() + * @copydoc Dali::Renderer::GetShader() */ - Material* GetMaterial() const; + ShaderPtr GetShader() const; /** * @copydoc Dali::Renderer::SetDepthIndex() */ - void SetDepthIndex( int depthIndex ); + void SetDepthIndex(int32_t depthIndex); /** * @copydoc Dali::Renderer::GetDepthIndex() */ - int GetDepthIndex() const; + int32_t GetDepthIndex() const; /** - * @brief Get the scene graph object ( the node attachment ) - * - * @return the scene object + * @copydoc Dali::Renderer::SetBlendMode() */ - SceneGraph::Renderer* GetRendererSceneObject(); + void SetBlendMode(BlendMode::Type mode); -public: // Default property extensions from Object + /** + * @copydoc Dali::Renderer::GetBlendMode() + */ + BlendMode::Type GetBlendMode() const; /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyCount() + * @copydoc Dali::Renderer::SetBlendFunc() */ - virtual unsigned int GetDefaultPropertyCount() const; + void SetBlendFunc(BlendFactor::Type srcFactorRgba, BlendFactor::Type destFactorRgba); /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices() + * @copydoc Dali::Renderer::SetBlendFunc() */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; + void SetBlendFunc(BlendFactor::Type srcFactorRgb, BlendFactor::Type destFactorRgb, BlendFactor::Type srcFactorAlpha, BlendFactor::Type destFactorAlpha); /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyName() + * @copydoc Dali::Renderer::GetBlendFunc() */ - virtual const char* GetDefaultPropertyName(Property::Index index) const; + void GetBlendFunc(BlendFactor::Type& srcFactorRgb, BlendFactor::Type& destFactorRgb, BlendFactor::Type& srcFactorAlpha, BlendFactor::Type& destFactorAlpha) const; /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex() + * @brief Set same Blend Equation for the RGB and alpha */ - virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const; + void SetBlendEquation(DevelBlendEquation::Type equationRgba); /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable() + * @brief Set Blend Equation separately for the RGB and alpha */ - virtual bool IsDefaultPropertyWritable(Property::Index index) const; + void SetBlendEquation(DevelBlendEquation::Type equationRgb, DevelBlendEquation::Type equationAlpha); /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable() + * @brief Get Blend Equation of rgb and alpha */ - virtual bool IsDefaultPropertyAnimatable(Property::Index index) const; + void GetBlendEquation(DevelBlendEquation::Type& equationRgb, DevelBlendEquation::Type& equationAlpha) const; /** - * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput() + * @copydoc Dali::Renderer::SetIndexedDrawFirstElement */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; + void SetIndexedDrawFirstElement(uint32_t firstElement); /** - * @copydoc Dali::Internal::Object::GetDefaultPropertyType() + * @copydoc Dali::Renderer::SetIndexedDrawElementsCount */ - virtual Property::Type GetDefaultPropertyType(Property::Index index) const; + void SetIndexedDrawElementsCount(uint32_t elementsCount); /** - * @copydoc Dali::Internal::Object::SetDefaultProperty() + * @brief Set whether the Pre-multiplied Alpha Blending is required + * + * @param[in] preMultipled whether alpha is pre-multiplied. */ - virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue); + void EnablePreMultipliedAlpha(bool preMultipled); /** - * @copydoc Dali::Internal::Object::SetSceneGraphProperty() + * @brief Query whether alpha is pre-multiplied. + * + * @return True is alpha is pre-multiplied, false otherwise. */ - virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value ); + bool IsPreMultipliedAlphaEnabled() const; /** - * @copydoc Dali::Internal::Object::GetDefaultProperty() + * @brief Query whether Blend Equation Advanced is used in this renderer + * + * @return True is Blend Equation Advanced is used, false otherwise. + */ + bool IsAdvancedBlendEquationApplied() const; + + /** + * @brief Get the scene graph object + * + * @return the scene object */ - virtual Property::Value GetDefaultProperty( Property::Index index ) const; + const SceneGraph::Renderer& GetRendererSceneObject() const; + +public: // Default property extensions from Object + /** + * @copydoc Dali::Internal::Object::SetDefaultProperty() + */ + void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue) override; /** - * @copydoc Dali::Internal::Object::GetPropertyOwner() + * @copydoc Dali::Internal::Object::GetDefaultProperty() */ - virtual const SceneGraph::PropertyOwner* GetPropertyOwner() const; + Property::Value GetDefaultProperty(Property::Index index) const override; /** - * @copydoc Dali::Internal::Object::GetSceneObject() + * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue() */ - virtual const SceneGraph::PropertyOwner* GetSceneObject() const; + Property::Value GetDefaultPropertyCurrentValue(Property::Index index) const override; + + /** + * @copydoc Dali::Internal::Object::OnNotifyDefaultPropertyAnimation() + */ + void OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType) override; /** * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty() */ - virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const; + const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty(Property::Index index) const override; /** * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty() */ - virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const; + const PropertyInputImpl* GetSceneObjectInputProperty(Property::Index index) const override; /** - * @copydoc Dali::Internal::Object::GetPropertyComponentIndex() + * @brief Adds a draw command to the Renderer. + * DrawCommands override Renderer's default behaviour. + * + * @param[in] command Valid reference to a DrawCommand objects */ - virtual int GetPropertyComponentIndex( Property::Index index ) const; + void AddDrawCommand(const Dali::DevelRenderer::DrawCommand& command); -public: // Functions from Connectable +protected: // implementation /** - * @copydoc Dali::Internal::Connectable::OnStage() + * @brief Constructor. + * + * @param sceneObject the scene graph renderer */ - virtual bool OnStage() const; + Renderer(const SceneGraph::Renderer* sceneObject); /** - * @copydoc Dali::Internal::Connectable::Connect() + * A reference counted object may only be deleted by calling Unreference() */ - virtual void Connect(); + ~Renderer() override; + +private: + Renderer(const Renderer&) = delete; ///< Deleted copy constructor + Renderer& operator=(const Renderer&) = delete; ///< Deleted assignment operator /** - * @copydoc Dali::Internal::Connectable::Disconnect() + * @brief Retrieves the cached event side value of a default property. + * @param[in] index The index of the property + * @param[out] value Is set with the cached value of the property if found. + * @return True if value set, false otherwise. */ - virtual void Disconnect(); + bool GetCachedPropertyValue(Property::Index index, Property::Value& value) const; -private: // implementation - Renderer(); + /** + * @brief Retrieves the current value of a default property from the scene-graph. + * @param[in] index The index of the property + * @param[out] value Is set with the current scene-graph value of the property + * @return True if value set, false otherwise. + */ + bool GetCurrentPropertyValue(Property::Index index, Property::Value& value) const; - void Initialize(); + /** + * @brief Sets the blend color. + * @param[in] blendColor The blend color to set. + */ + void SetBlendColor(const Vector4& blendColor); -protected: /** - * A reference counted object may only be deleted by calling Unreference() + * @brief Retrieves the blend-color. + * @return A const reference to the blend-color */ - virtual ~Renderer(); + const Vector4& GetBlendColor() const; + +protected: + GeometryPtr mGeometry; ///< Intrusive pointer to the geometry used by this renderer + TextureSetPtr mTextureSet; ///< Intrusive pointer to the texture set used by this renderer + ShaderPtr mShader; ///< Intrusive pointer to the shader used by this renderer + + int32_t mDepthIndex; + + uint32_t mIndexedDrawFirstElement; ///< Offset of first element to draw from bound index buffer + uint32_t mIndexedDrawElementCount; ///< Number of elements to draw + + Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options + BlendingOptions mBlendingOptions; ///< Local copy of blending options bitmask -private: // unimplemented methods - Renderer( const Renderer& ); - Renderer& operator=( const Renderer& ); + float mOpacity; ///< Local copy of the opacity + DepthFunction::Type mDepthFunction : 4; ///< Local copy of the depth function + FaceCullingMode::Type mFaceCullingMode : 3; ///< Local copy of the mode of face culling + BlendMode::Type mBlendMode : 3; ///< Local copy of the mode of blending + DepthWriteMode::Type mDepthWriteMode : 3; ///< Local copy of the depth write mode + DepthTestMode::Type mDepthTestMode : 3; ///< Local copy of the depth test mode + DevelRenderer::Rendering::Type mRenderingBehavior : 2; ///< The rendering behavior + bool mPremultipledAlphaEnabled : 1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required -private: // data - SceneGraph::Renderer* mSceneObject; - ObjectConnector mGeometryConnector; ///< Connector that holds the geometry used by this renderer - ObjectConnector mMaterialConnector; ///< Connector that holds the material used by this renderer - int mDepthIndex; - int mOnStageCount; +private: + std::vector mDrawCommands; ///< list of draw commands }; } // namespace Internal // Helpers for public-api forwarding methods -inline Internal::Renderer& GetImplementation( Dali::Renderer& handle ) +inline Internal::Renderer& GetImplementation(Dali::Renderer& handle) { DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty"); @@ -224,7 +294,7 @@ inline Internal::Renderer& GetImplementation( Dali::Renderer& handle ) return static_cast(object); } -inline const Internal::Renderer& GetImplementation( const Dali::Renderer& handle ) +inline const Internal::Renderer& GetImplementation(const Dali::Renderer& handle) { DALI_ASSERT_ALWAYS(handle && "Renderer handle is empty");