From 7eacfe2a5e6e543acaf4b113378c422f86782a00 Mon Sep 17 00:00:00 2001 From: David Steele Date: Mon, 2 Mar 2015 12:14:57 +0000 Subject: [PATCH] Refactored old API from RenderableActor into ImageActor. As part of the mesh rework, have moved blend/culling/shader effect setters & getters from RenderableActor to ImageActor. Change-Id: I88087e3d188978ce5cc78d877b8649e40c6c7980 --- .../actor-attachments/image-attachment-impl.cpp | 199 ++++++++++++++++++- .../actor-attachments/image-attachment-impl.h | 106 ++++++++++ .../renderable-attachment-impl.cpp | 180 +---------------- .../actor-attachments/renderable-attachment-impl.h | 103 ---------- dali/internal/event/actors/image-actor-impl.cpp | 100 ++++++++++ dali/internal/event/actors/image-actor-impl.h | 99 ++++++++++ .../event/actors/renderable-actor-impl.cpp | 98 +--------- dali/internal/event/actors/renderable-actor-impl.h | 102 ---------- dali/public-api/actors/image-actor.cpp | 143 ++++++++++++++ dali/public-api/actors/image-actor.h | 215 +++++++++++++++++++++ dali/public-api/actors/renderable-actor.cpp | 139 ------------- dali/public-api/actors/renderable-actor.h | 211 -------------------- 12 files changed, 858 insertions(+), 837 deletions(-) diff --git a/dali/internal/event/actor-attachments/image-attachment-impl.cpp b/dali/internal/event/actor-attachments/image-attachment-impl.cpp index 04b04e0..cf221b8 100644 --- a/dali/internal/event/actor-attachments/image-attachment-impl.cpp +++ b/dali/internal/event/actor-attachments/image-attachment-impl.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include namespace Dali { @@ -50,7 +52,15 @@ ImageAttachment::ImageAttachment( Stage& stage ) mStyle(Dali::ImageActor::STYLE_QUAD), mBorder(0.45,0.45,0.1,0.1), mIsPixelAreaSet(false), - mBorderInPixels(false) + mBorderInPixels(false), + + + mBlendingOptions(), + mSamplerBitfield( ImageSampler::PackBitfield( FilterMode::DEFAULT, FilterMode::DEFAULT ) ), + mSortModifier( 0.0f ), + mCullFaceMode( CullNone ), + mBlendingMode( BlendingMode::AUTO ), + mShaderEffect() { mImageConnectable.Set( NULL, false ); } @@ -127,8 +137,183 @@ SceneGraph::ImageAttachment* ImageAttachment::CreateSceneObject() return SceneGraph::ImageAttachment::New( 0u ); } +const SceneGraph::RenderableAttachment& ImageAttachment::GetSceneObject() const +{ + DALI_ASSERT_DEBUG( mSceneObject != NULL ); + return *mSceneObject; +} + + +void ImageAttachment::SetSortModifier(float modifier) +{ + // Cache for actor-side getters + mSortModifier = modifier; + + // attachment is being used in a separate thread; queue a message to set the value & base value + SetSortModifierMessage( mStage->GetUpdateInterface(), GetSceneObject(), modifier ); +} + +float ImageAttachment::GetSortModifier() const +{ + // mSortModifier is not animatable; this is the most up-to-date value. + return mSortModifier; +} + +void ImageAttachment::SetCullFace( CullFaceMode mode ) +{ + // Cache for actor-side getters + mCullFaceMode = mode; + + // attachment is being used in a separate thread; queue a message to set the value + SetCullFaceMessage( mStage->GetUpdateInterface(), GetSceneObject(), mode ); +} + +CullFaceMode ImageAttachment::GetCullFace() const +{ + // mCullFaceMode is not animatable; this is the most up-to-date value. + return mCullFaceMode; +} + +void ImageAttachment::SetBlendMode( BlendingMode::Type mode ) +{ + mBlendingMode = mode; + + // attachment is being used in a separate thread; queue a message to set the value + SetBlendingModeMessage( mStage->GetUpdateInterface(), GetSceneObject(), mode ); +} + +BlendingMode::Type ImageAttachment::GetBlendMode() const +{ + return mBlendingMode; +} + +void ImageAttachment::SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb, + BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha ) +{ + // Cache for actor-side getters + mBlendingOptions.SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); + + // attachment is being used in a separate thread; queue a message to set the value + SetBlendingOptionsMessage( mStage->GetUpdateInterface(), GetSceneObject(), mBlendingOptions.GetBitmask() ); +} + +void ImageAttachment::GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb, + BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const +{ + // These are not animatable, the cached values are up-to-date. + srcFactorRgb = mBlendingOptions.GetBlendSrcFactorRgb(); + destFactorRgb = mBlendingOptions.GetBlendDestFactorRgb(); + srcFactorAlpha = mBlendingOptions.GetBlendSrcFactorAlpha(); + destFactorAlpha = mBlendingOptions.GetBlendDestFactorAlpha(); +} + +void ImageAttachment::SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha ) +{ + mBlendingOptions.SetBlendEquation( equationRgb, equationAlpha ); + + // attachment is being used in a separate thread; queue a message to set the value + SetBlendingOptionsMessage( mStage->GetUpdateInterface(), GetSceneObject(), mBlendingOptions.GetBitmask() ); +} + +void ImageAttachment::GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const +{ + // These are not animatable, the cached values are up-to-date. + equationRgb = mBlendingOptions.GetBlendEquationRgb(); + equationAlpha = mBlendingOptions.GetBlendEquationAlpha(); +} + +void ImageAttachment::SetBlendColor( const Vector4& color ) +{ + if( mBlendingOptions.SetBlendColor( color ) ) + { + // attachment is being used in a separate thread; queue a message to set the value + SetBlendColorMessage( mStage->GetUpdateInterface(), GetSceneObject(), color ); + } +} + +const Vector4& ImageAttachment::GetBlendColor() const +{ + const Vector4* optionalColor = mBlendingOptions.GetBlendColor(); + if( optionalColor ) + { + return *optionalColor; + } + + return Vector4::ZERO; +} + +void ImageAttachment::SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter ) +{ + mSamplerBitfield = ImageSampler::PackBitfield( minFilter, magFilter ); + + SetSamplerMessage( mStage->GetUpdateInterface(), GetSceneObject(), mSamplerBitfield ); +} + +void ImageAttachment::GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const +{ + minFilter = ImageSampler::GetMinifyFilterMode( mSamplerBitfield ); + magFilter = ImageSampler::GetMagnifyFilterMode( mSamplerBitfield ); +} + + +void ImageAttachment::SetShaderEffect(ShaderEffect& effect) +{ + if ( OnStage() ) + { + if ( mShaderEffect ) + { + mShaderEffect->Disconnect(); + } + + mShaderEffect.Reset( &effect ); + + const SceneGraph::Shader& shader = dynamic_cast( *mShaderEffect->GetSceneObject() ); + + ApplyShaderMessage( mStage->GetUpdateInterface(), GetSceneObject(), shader ); + + mShaderEffect->Connect(); + } + else + { + mShaderEffect = ShaderEffectPtr(&effect); + } + // Effects can only be applied when the Node is connected to scene-graph +} + +ShaderEffectPtr ImageAttachment::GetShaderEffect() const +{ + return mShaderEffect; +} + +void ImageAttachment::RemoveShaderEffect() +{ + if ( OnStage() ) + { + RemoveShaderMessage( mStage->GetUpdateInterface(), GetSceneObject() ); + + // Notify shader effect + if (mShaderEffect) + { + mShaderEffect->Disconnect(); + } + } + + mShaderEffect.Reset(); +} + + void ImageAttachment::OnStageConnection2() { + if ( mShaderEffect ) + { + const SceneGraph::Shader& shader = dynamic_cast( *mShaderEffect->GetSceneObject() ); + + ApplyShaderMessage( mStage->GetUpdateInterface(), GetSceneObject(), shader ); + + // Notify shader effect + mShaderEffect->Connect(); + } + mImageConnectable.OnStageConnect(); // Provide resource ID when scene-graph attachment is connected @@ -142,17 +327,19 @@ void ImageAttachment::OnStageConnection2() void ImageAttachment::OnStageDisconnection2() { + // Notify shader effect + if ( mShaderEffect ) + { + mShaderEffect->Disconnect(); + } + // Remove resource ID when scene-graph attachment is disconnected SetTextureIdMessage( mStage->GetUpdateInterface(), *mSceneObject, 0u ); mImageConnectable.OnStageDisconnect(); } -const SceneGraph::RenderableAttachment& ImageAttachment::GetSceneObject() const -{ - DALI_ASSERT_DEBUG( mSceneObject != NULL ); - return *mSceneObject; -} + } // namespace Internal diff --git a/dali/internal/event/actor-attachments/image-attachment-impl.h b/dali/internal/event/actor-attachments/image-attachment-impl.h index 965ebbf..bd9bea6 100644 --- a/dali/internal/event/actor-attachments/image-attachment-impl.h +++ b/dali/internal/event/actor-attachments/image-attachment-impl.h @@ -20,10 +20,14 @@ // INTERNAL INCLUDES #include +#include +#include +#include #include #include #include #include +#include namespace Dali { @@ -130,6 +134,100 @@ public: return mBorder; } + + /** + * Set the depth-sort modifier for the renderable. + * This modifies the back-to-front distance calculation, when rendering with transparency. + * This is useful for ordering transparent objects that are positioned close to each other. + * @param[in] modifier The depth-sort modifier. + */ + void SetSortModifier(float modifier); + + /** + * From Renderable; Retrieve the depth-sort modifier for the renderable. + * @return The depth-sort modifier. + */ + float GetSortModifier() const; + + /** + * Set the face-culling mode for this attachment. + * @param[in] mode The culling mode. + */ + void SetCullFace(CullFaceMode mode); + + /** + * Retrieve the face-culling mode for this attachment. + * @return mode The culling mode. + */ + CullFaceMode GetCullFace() const; + + /** + * @copydoc Dali::RenderableActor::SetBlendMode() + */ + void SetBlendMode( BlendingMode::Type mode ); + + /** + * @copydoc Dali::RenderableActor::GetBlendMode() + */ + BlendingMode::Type GetBlendMode() const; + + /** + * @copydoc Dali::RenderableActor::SetBlendFunc() + */ + void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb, + BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha ); + + /** + * @copydoc Dali::RenderableActor::GetBlendFunc() + */ + void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb, + BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const; + + /** + * @copydoc Dali::RenderableActor::SetBlendEquation() + */ + void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha ); + + /** + * @copydoc Dali::RenderableActor::GetBlendEquation() + */ + void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const; + + /** + * @copydoc Dali::RenderableActor::SetBlendColor() + */ + void SetBlendColor( const Vector4& color ); + + /** + * @copydoc Dali::RenderableActor::GetBlendColor() + */ + const Vector4& GetBlendColor() const; + + /** + * @copydoc Dali::RenderableActor::SetFilterMode() + */ + void SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter ); + + /** + * @copydoc Dali::RenderableActor::GetFilterMode() + */ + void GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const; + + /** + * @copydoc Dali::RenderableActor::SetShaderEffect + */ + void SetShaderEffect(ShaderEffect& effect); + + /** + * @copydoc Dali::RenderableActor::GetShaderEffect + */ + ShaderEffectPtr GetShaderEffect() const; + + /** + * @copydoc Dali::RenderableActor::RemoveShaderEffect + */ + void RemoveShaderEffect(); + private: /** @@ -181,6 +279,14 @@ private: bool mIsPixelAreaSet : 1; bool mBorderInPixels : 1; + + BlendingOptions mBlendingOptions; + unsigned int mSamplerBitfield; + float mSortModifier; + CullFaceMode mCullFaceMode:3; ///< cullface mode, 3 bits enough for 4 values + BlendingMode::Type mBlendingMode:2; ///< blending mode, 2 bits enough for 3 values + + ShaderEffectPtr mShaderEffect; ///< Optional referenced shader effect }; } // namespace Internal diff --git a/dali/internal/event/actor-attachments/renderable-attachment-impl.cpp b/dali/internal/event/actor-attachments/renderable-attachment-impl.cpp index 80a2a27..c7ff95e 100644 --- a/dali/internal/event/actor-attachments/renderable-attachment-impl.cpp +++ b/dali/internal/event/actor-attachments/renderable-attachment-impl.cpp @@ -20,7 +20,6 @@ // INTERNAL INCLUDES #include -#include #include using Dali::Internal::SceneGraph::Shader; @@ -32,13 +31,7 @@ namespace Internal { RenderableAttachment::RenderableAttachment( Stage& stage ) -: ActorAttachment( stage ), - mShaderEffect(), - mBlendingOptions(), - mSamplerBitfield( ImageSampler::PackBitfield( FilterMode::DEFAULT, FilterMode::DEFAULT ) ), - mSortModifier( 0.0f ), - mCullFaceMode( CullNone ), - mBlendingMode( BlendingMode::AUTO ) +: ActorAttachment( stage ) { } @@ -46,186 +39,15 @@ RenderableAttachment::~RenderableAttachment() { } -void RenderableAttachment::SetSortModifier(float modifier) -{ - // Cache for actor-side getters - mSortModifier = modifier; - - // attachment is being used in a separate thread; queue a message to set the value & base value - SetSortModifierMessage( mStage->GetUpdateInterface(), GetSceneObject(), modifier ); -} - -float RenderableAttachment::GetSortModifier() const -{ - // mSortModifier is not animatable; this is the most up-to-date value. - return mSortModifier; -} - -void RenderableAttachment::SetCullFace( CullFaceMode mode ) -{ - // Cache for actor-side getters - mCullFaceMode = mode; - - // attachment is being used in a separate thread; queue a message to set the value - SetCullFaceMessage( mStage->GetUpdateInterface(), GetSceneObject(), mode ); -} - -CullFaceMode RenderableAttachment::GetCullFace() const -{ - // mCullFaceMode is not animatable; this is the most up-to-date value. - return mCullFaceMode; -} - -void RenderableAttachment::SetBlendMode( BlendingMode::Type mode ) -{ - mBlendingMode = mode; - - // attachment is being used in a separate thread; queue a message to set the value - SetBlendingModeMessage( mStage->GetUpdateInterface(), GetSceneObject(), mode ); -} - -BlendingMode::Type RenderableAttachment::GetBlendMode() const -{ - return mBlendingMode; -} - -void RenderableAttachment::SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb, - BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha ) -{ - // Cache for actor-side getters - mBlendingOptions.SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); - - // attachment is being used in a separate thread; queue a message to set the value - SetBlendingOptionsMessage( mStage->GetUpdateInterface(), GetSceneObject(), mBlendingOptions.GetBitmask() ); -} - -void RenderableAttachment::GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb, - BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const -{ - // These are not animatable, the cached values are up-to-date. - srcFactorRgb = mBlendingOptions.GetBlendSrcFactorRgb(); - destFactorRgb = mBlendingOptions.GetBlendDestFactorRgb(); - srcFactorAlpha = mBlendingOptions.GetBlendSrcFactorAlpha(); - destFactorAlpha = mBlendingOptions.GetBlendDestFactorAlpha(); -} - -void RenderableAttachment::SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha ) -{ - mBlendingOptions.SetBlendEquation( equationRgb, equationAlpha ); - - // attachment is being used in a separate thread; queue a message to set the value - SetBlendingOptionsMessage( mStage->GetUpdateInterface(), GetSceneObject(), mBlendingOptions.GetBitmask() ); -} - -void RenderableAttachment::GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const -{ - // These are not animatable, the cached values are up-to-date. - equationRgb = mBlendingOptions.GetBlendEquationRgb(); - equationAlpha = mBlendingOptions.GetBlendEquationAlpha(); -} - -void RenderableAttachment::SetBlendColor( const Vector4& color ) -{ - if( mBlendingOptions.SetBlendColor( color ) ) - { - // attachment is being used in a separate thread; queue a message to set the value - SetBlendColorMessage( mStage->GetUpdateInterface(), GetSceneObject(), color ); - } -} - -const Vector4& RenderableAttachment::GetBlendColor() const -{ - const Vector4* optionalColor = mBlendingOptions.GetBlendColor(); - if( optionalColor ) - { - return *optionalColor; - } - - return Vector4::ZERO; -} - -void RenderableAttachment::SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter ) -{ - mSamplerBitfield = ImageSampler::PackBitfield( minFilter, magFilter ); - - SetSamplerMessage( mStage->GetUpdateInterface(), GetSceneObject(), mSamplerBitfield ); -} - -void RenderableAttachment::GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const -{ - minFilter = ImageSampler::GetMinifyFilterMode( mSamplerBitfield ); - magFilter = ImageSampler::GetMagnifyFilterMode( mSamplerBitfield ); -} - -void RenderableAttachment::SetShaderEffect(ShaderEffect& effect) -{ - if ( OnStage() ) - { - if ( mShaderEffect ) - { - mShaderEffect->Disconnect(); - } - - mShaderEffect.Reset( &effect ); - - const Shader& shader = dynamic_cast( *mShaderEffect->GetSceneObject() ); - - ApplyShaderMessage( mStage->GetUpdateInterface(), GetSceneObject(), shader ); - - mShaderEffect->Connect(); - } - else - { - mShaderEffect = ShaderEffectPtr(&effect); - } - // Effects can only be applied when the Node is connected to scene-graph -} - -ShaderEffectPtr RenderableAttachment::GetShaderEffect() const -{ - return mShaderEffect; -} - -void RenderableAttachment::RemoveShaderEffect() -{ - if ( OnStage() ) - { - RemoveShaderMessage( mStage->GetUpdateInterface(), GetSceneObject() ); - - // Notify shader effect - if (mShaderEffect) - { - mShaderEffect->Disconnect(); - } - } - - mShaderEffect.Reset(); -} void RenderableAttachment::OnStageConnection() { - if ( mShaderEffect ) - { - const Shader& shader = dynamic_cast( *mShaderEffect->GetSceneObject() ); - - ApplyShaderMessage( mStage->GetUpdateInterface(), GetSceneObject(), shader ); - - // Notify shader effect - mShaderEffect->Connect(); - } - // For derived classes OnStageConnection2(); } void RenderableAttachment::OnStageDisconnection() { - // Notify shader effect - if ( mShaderEffect ) - { - mShaderEffect->Disconnect(); - } - // For derived classes OnStageDisconnection2(); } diff --git a/dali/internal/event/actor-attachments/renderable-attachment-impl.h b/dali/internal/event/actor-attachments/renderable-attachment-impl.h index c2755e8..7ecc53d 100644 --- a/dali/internal/event/actor-attachments/renderable-attachment-impl.h +++ b/dali/internal/event/actor-attachments/renderable-attachment-impl.h @@ -20,11 +20,7 @@ // INTERNAL INCLUDES #include -#include -#include -#include #include -#include namespace Dali { @@ -44,98 +40,7 @@ class RenderableAttachment : public ActorAttachment { public: - /** - * Set the depth-sort modifier for the renderable. - * This modifies the back-to-front distance calculation, when rendering with transparency. - * This is useful for ordering transparent objects that are positioned close to each other. - * @param[in] modifier The depth-sort modifier. - */ - void SetSortModifier(float modifier); - - /** - * From Renderable; Retrieve the depth-sort modifier for the renderable. - * @return The depth-sort modifier. - */ - float GetSortModifier() const; - - /** - * Set the face-culling mode for this attachment. - * @param[in] mode The culling mode. - */ - void SetCullFace(CullFaceMode mode); - - /** - * Retrieve the face-culling mode for this attachment. - * @return mode The culling mode. - */ - CullFaceMode GetCullFace() const; - - /** - * @copydoc Dali::RenderableActor::SetBlendMode() - */ - void SetBlendMode( BlendingMode::Type mode ); - /** - * @copydoc Dali::RenderableActor::GetBlendMode() - */ - BlendingMode::Type GetBlendMode() const; - - /** - * @copydoc Dali::RenderableActor::SetBlendFunc() - */ - void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb, - BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha ); - - /** - * @copydoc Dali::RenderableActor::GetBlendFunc() - */ - void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb, - BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const; - - /** - * @copydoc Dali::RenderableActor::SetBlendEquation() - */ - void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha ); - - /** - * @copydoc Dali::RenderableActor::GetBlendEquation() - */ - void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const; - - /** - * @copydoc Dali::RenderableActor::SetBlendColor() - */ - void SetBlendColor( const Vector4& color ); - - /** - * @copydoc Dali::RenderableActor::GetBlendColor() - */ - const Vector4& GetBlendColor() const; - - /** - * @copydoc Dali::RenderableActor::SetFilterMode() - */ - void SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter ); - - /** - * @copydoc Dali::RenderableActor::GetFilterMode() - */ - void GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const; - - /** - * @copydoc Dali::RenderableActor::SetShaderEffect - */ - void SetShaderEffect(ShaderEffect& effect); - - /** - * @copydoc Dali::RenderableActor::GetShaderEffect - */ - ShaderEffectPtr GetShaderEffect() const; - - /** - * @copydoc Dali::RenderableActor::RemoveShaderEffect - */ - void RemoveShaderEffect(); protected: @@ -192,14 +97,6 @@ private: private: // Data, cached for actor-thread getters - ShaderEffectPtr mShaderEffect; ///< Optional referenced shader effect - BlendingOptions mBlendingOptions; - unsigned int mSamplerBitfield; - float mSortModifier; - CullFaceMode mCullFaceMode:3; ///< cullface mode, 3 bits enough for 4 values - BlendingMode::Type mBlendingMode:2; ///< blending mode, 2 bits enough for 3 values - - }; } // namespace Internal diff --git a/dali/internal/event/actors/image-actor-impl.cpp b/dali/internal/event/actors/image-actor-impl.cpp index 08f98b5..52969e2 100644 --- a/dali/internal/event/actors/image-actor-impl.cpp +++ b/dali/internal/event/actors/image-actor-impl.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -494,6 +495,105 @@ Property::Value ImageActor::GetDefaultProperty( Property::Index index ) const return ret; } + +void ImageActor::SetSortModifier(float modifier) +{ + mImageAttachment->SetSortModifier(modifier); +} + +float ImageActor::GetSortModifier() const +{ + return mImageAttachment->GetSortModifier(); +} + +void ImageActor::SetCullFace(CullFaceMode mode) +{ + mImageAttachment->SetCullFace( mode ); +} + +CullFaceMode ImageActor::GetCullFace() const +{ + return mImageAttachment->GetCullFace(); +} + +void ImageActor::SetBlendMode( BlendingMode::Type mode ) +{ + mImageAttachment->SetBlendMode( mode ); +} + +BlendingMode::Type ImageActor::GetBlendMode() const +{ + return mImageAttachment->GetBlendMode(); +} + +void ImageActor::SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba ) +{ + mImageAttachment->SetBlendFunc( srcFactorRgba, destFactorRgba, srcFactorRgba, destFactorRgba ); +} + +void ImageActor::SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb, + BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha ) +{ + mImageAttachment->SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); +} + +void ImageActor::GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb, + BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const +{ + mImageAttachment->GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); +} + +void ImageActor::SetBlendEquation( BlendingEquation::Type equationRgba ) +{ + mImageAttachment->SetBlendEquation( equationRgba, equationRgba ); +} + +void ImageActor::SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha ) +{ + mImageAttachment->SetBlendEquation( equationRgb, equationAlpha ); +} + +void ImageActor::GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const +{ + mImageAttachment->GetBlendEquation( equationRgb, equationAlpha ); +} + +void ImageActor::SetBlendColor( const Vector4& color ) +{ + mImageAttachment->SetBlendColor( color ); +} + +const Vector4& ImageActor::GetBlendColor() const +{ + return mImageAttachment->GetBlendColor(); +} + +void ImageActor::SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter ) +{ + mImageAttachment->SetFilterMode( minFilter, magFilter ); +} + +void ImageActor::GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const +{ + return mImageAttachment->GetFilterMode( minFilter, magFilter ); +} + +void ImageActor::SetShaderEffect(ShaderEffect& effect) +{ + mImageAttachment->SetShaderEffect( effect ); +} + +ShaderEffectPtr ImageActor::GetShaderEffect() const +{ + return mImageAttachment->GetShaderEffect(); +} + +void ImageActor::RemoveShaderEffect() +{ + return mImageAttachment->RemoveShaderEffect(); +} + + } // namespace Internal } // namespace Dali diff --git a/dali/internal/event/actors/image-actor-impl.h b/dali/internal/event/actors/image-actor-impl.h index 75c09ea..b7cdf13 100644 --- a/dali/internal/event/actors/image-actor-impl.h +++ b/dali/internal/event/actors/image-actor-impl.h @@ -129,6 +129,105 @@ public: */ ImageAttachment& GetImageAttachment(); + + /** + * @copydoc Dali::RenderableActor::SetSortModifier() + */ + void SetSortModifier(float modifier); + + /** + * @copydoc Dali::RenderableActor::GetSortModifier() + */ + float GetSortModifier() const; + + /** + * @copydoc Dali::RenderableActor::SetCullFace() + */ + void SetCullFace(CullFaceMode mode); + + /** + * @copydoc Dali::RenderableActor::GetCullFace() + */ + CullFaceMode GetCullFace() const; + + /** + * @copydoc Dali::RenderableActor::SetBlendMode() + */ + void SetBlendMode( BlendingMode::Type mode ); + + /** + * @copydoc Dali::RenderableActor::GetBlendMode() + */ + BlendingMode::Type GetBlendMode() const; + + /** + * @copydoc Dali::RenderableActor::SetBlendFunc() + */ + void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba ); + + /** + * @copydoc Dali::RenderableActor::SetBlendFunc() + */ + void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb, + BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha ); + + /** + * @copydoc Dali::RenderableActor::GetBlendFunc() + */ + void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb, + BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const; + + /** + * @copydoc Dali::RenderableActor::SetBlendEquation() + */ + void SetBlendEquation( BlendingEquation::Type equationRgba ); + + /** + * @copydoc Dali::RenderableActor::SetBlendEquation() + */ + void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha ); + + /** + * @copydoc Dali::RenderableActor::GetBlendEquation() + */ + void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const; + + /** + * @copydoc Dali::RenderableActor::SetBlendColor() + */ + void SetBlendColor( const Vector4& color ); + + /** + * @copydoc Dali::RenderableActor::GetBlendColor() + */ + const Vector4& GetBlendColor() const; + + /** + * @copydoc Dali::RenderableActor::SetFilterMode() + */ + void SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter ); + + /** + * @copydoc Dali::RenderableActor::GetFilterMode() + */ + void GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const; + +public: + /** + * @copydoc Actor::SetShaderEffect + */ + virtual void SetShaderEffect(ShaderEffect& effect); + + /** + * @copydoc Actor::GetShaderEffect + */ + virtual ShaderEffectPtr GetShaderEffect() const; + + /** + * @copydoc Actor::RemoveShaderEffect + */ + virtual void RemoveShaderEffect(); + public: // Default property extensions from Object /** diff --git a/dali/internal/event/actors/renderable-actor-impl.cpp b/dali/internal/event/actors/renderable-actor-impl.cpp index dfaed7a..9eec34a 100644 --- a/dali/internal/event/actors/renderable-actor-impl.cpp +++ b/dali/internal/event/actors/renderable-actor-impl.cpp @@ -20,7 +20,7 @@ // INTERNAL INCLUDES #include -#include + #include namespace // unnamed namespace @@ -48,88 +48,6 @@ namespace Dali namespace Internal { -void RenderableActor::SetSortModifier(float modifier) -{ - GetRenderableAttachment().SetSortModifier(modifier); -} - -float RenderableActor::GetSortModifier() const -{ - return GetRenderableAttachment().GetSortModifier(); -} - -void RenderableActor::SetCullFace(CullFaceMode mode) -{ - GetRenderableAttachment().SetCullFace( mode ); -} - -CullFaceMode RenderableActor::GetCullFace() const -{ - return GetRenderableAttachment().GetCullFace(); -} - -void RenderableActor::SetBlendMode( BlendingMode::Type mode ) -{ - GetRenderableAttachment().SetBlendMode( mode ); -} - -BlendingMode::Type RenderableActor::GetBlendMode() const -{ - return GetRenderableAttachment().GetBlendMode(); -} - -void RenderableActor::SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba ) -{ - GetRenderableAttachment().SetBlendFunc( srcFactorRgba, destFactorRgba, srcFactorRgba, destFactorRgba ); -} - -void RenderableActor::SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb, - BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha ) -{ - GetRenderableAttachment().SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); -} - -void RenderableActor::GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb, - BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const -{ - GetRenderableAttachment().GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); -} - -void RenderableActor::SetBlendEquation( BlendingEquation::Type equationRgba ) -{ - GetRenderableAttachment().SetBlendEquation( equationRgba, equationRgba ); -} - -void RenderableActor::SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha ) -{ - GetRenderableAttachment().SetBlendEquation( equationRgb, equationAlpha ); -} - -void RenderableActor::GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const -{ - GetRenderableAttachment().GetBlendEquation( equationRgb, equationAlpha ); -} - -void RenderableActor::SetBlendColor( const Vector4& color ) -{ - GetRenderableAttachment().SetBlendColor( color ); -} - -const Vector4& RenderableActor::GetBlendColor() const -{ - return GetRenderableAttachment().GetBlendColor(); -} - -void RenderableActor::SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter ) -{ - GetRenderableAttachment().SetFilterMode( minFilter, magFilter ); -} - -void RenderableActor::GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const -{ - return GetRenderableAttachment().GetFilterMode( minFilter, magFilter ); -} - RenderableActor::RenderableActor() : Actor( Actor::RENDERABLE ) { @@ -139,20 +57,6 @@ RenderableActor::~RenderableActor() { } -void RenderableActor::SetShaderEffect(ShaderEffect& effect) -{ - GetRenderableAttachment().SetShaderEffect( effect ); -} - -ShaderEffectPtr RenderableActor::GetShaderEffect() const -{ - return GetRenderableAttachment().GetShaderEffect(); -} - -void RenderableActor::RemoveShaderEffect() -{ - return GetRenderableAttachment().RemoveShaderEffect(); -} } // namespace Internal diff --git a/dali/internal/event/actors/renderable-actor-impl.h b/dali/internal/event/actors/renderable-actor-impl.h index 025166e..b6b038a 100644 --- a/dali/internal/event/actors/renderable-actor-impl.h +++ b/dali/internal/event/actors/renderable-actor-impl.h @@ -37,92 +37,7 @@ class RenderableAttachment; */ class RenderableActor : public Actor { -public: - - /** - * @copydoc Dali::RenderableActor::SetSortModifier() - */ - void SetSortModifier(float modifier); - - /** - * @copydoc Dali::RenderableActor::GetSortModifier() - */ - float GetSortModifier() const; - - /** - * @copydoc Dali::RenderableActor::SetCullFace() - */ - void SetCullFace(CullFaceMode mode); - - /** - * @copydoc Dali::RenderableActor::GetCullFace() - */ - CullFaceMode GetCullFace() const; - - /** - * @copydoc Dali::RenderableActor::SetBlendMode() - */ - void SetBlendMode( BlendingMode::Type mode ); - - /** - * @copydoc Dali::RenderableActor::GetBlendMode() - */ - BlendingMode::Type GetBlendMode() const; - - /** - * @copydoc Dali::RenderableActor::SetBlendFunc() - */ - void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba ); - - /** - * @copydoc Dali::RenderableActor::SetBlendFunc() - */ - void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb, - BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha ); - - /** - * @copydoc Dali::RenderableActor::GetBlendFunc() - */ - void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb, - BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const; - - /** - * @copydoc Dali::RenderableActor::SetBlendEquation() - */ - void SetBlendEquation( BlendingEquation::Type equationRgba ); - - /** - * @copydoc Dali::RenderableActor::SetBlendEquation() - */ - void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha ); - - /** - * @copydoc Dali::RenderableActor::GetBlendEquation() - */ - void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const; - - /** - * @copydoc Dali::RenderableActor::SetBlendColor() - */ - void SetBlendColor( const Vector4& color ); - - /** - * @copydoc Dali::RenderableActor::GetBlendColor() - */ - const Vector4& GetBlendColor() const; - - /** - * @copydoc Dali::RenderableActor::SetFilterMode() - */ - void SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter ); - - /** - * @copydoc Dali::RenderableActor::GetFilterMode() - */ - void GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const; - protected: - /** * Protected constructor; only derived classes are instantiatable. */ @@ -133,23 +48,6 @@ protected: */ virtual ~RenderableActor(); -public: // from Actor, in future not virtual. Accessible also from RenderableActor - - /** - * @copydoc Actor::SetShaderEffect - */ - virtual void SetShaderEffect(ShaderEffect& effect); - - /** - * @copydoc Actor::GetShaderEffect - */ - virtual ShaderEffectPtr GetShaderEffect() const; - - /** - * @copydoc Actor::RemoveShaderEffect - */ - virtual void RemoveShaderEffect(); - private: /** diff --git a/dali/public-api/actors/image-actor.cpp b/dali/public-api/actors/image-actor.cpp index 5d80724..a7b2e08 100644 --- a/dali/public-api/actors/image-actor.cpp +++ b/dali/public-api/actors/image-actor.cpp @@ -21,6 +21,7 @@ // INTERNAL INCLUDES #include #include +#include #include namespace Dali @@ -134,9 +135,151 @@ Vector4 ImageActor::GetNinePatchBorder() const return GetImplementation(*this).GetNinePatchBorder(); } +void ImageActor::SetSortModifier(float modifier) +{ + GetImplementation(*this).SetSortModifier(modifier); +} + +float ImageActor::GetSortModifier() const +{ + return GetImplementation(*this).GetSortModifier(); +} + +void ImageActor::SetCullFace(const CullFaceMode mode) +{ + GetImplementation(*this).SetCullFace(mode); +} + +CullFaceMode ImageActor::GetCullFace() const +{ + return GetImplementation(*this).GetCullFace(); +} + +void ImageActor::SetBlendMode( BlendingMode::Type mode ) +{ + GetImplementation(*this).SetBlendMode( mode ); +} + +BlendingMode::Type ImageActor::GetBlendMode() const +{ + return GetImplementation(*this).GetBlendMode(); +} + +void ImageActor::SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba ) +{ + GetImplementation(*this).SetBlendFunc( srcFactorRgba, destFactorRgba ); +} + +void ImageActor::SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb, + BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha ) +{ + GetImplementation(*this).SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); +} + +void ImageActor::GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb, + BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const +{ + GetImplementation(*this).GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); +} + +void ImageActor::SetBlendEquation( BlendingEquation::Type equationRgba ) +{ + GetImplementation(*this).SetBlendEquation( equationRgba ); +} + +void ImageActor::SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha ) +{ + GetImplementation(*this).SetBlendEquation( equationRgb, equationAlpha ); +} + +void ImageActor::GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const +{ + GetImplementation(*this).GetBlendEquation( equationRgb, equationAlpha ); +} + +void ImageActor::SetBlendColor( const Vector4& color ) +{ + GetImplementation(*this).SetBlendColor( color ); +} + +const Vector4& ImageActor::GetBlendColor() const +{ + return GetImplementation(*this).GetBlendColor(); +} + +void ImageActor::SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter ) +{ + GetImplementation(*this).SetFilterMode( minFilter, magFilter ); +} + +void ImageActor::GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const +{ + GetImplementation(*this).GetFilterMode( minFilter, magFilter ); +} + +void ImageActor::SetShaderEffect(ShaderEffect effect) +{ + GetImplementation(*this).SetShaderEffect(GetImplementation(effect)); +} + +ShaderEffect ImageActor::GetShaderEffect() const +{ + Internal::ShaderEffectPtr internal = GetImplementation(*this).GetShaderEffect(); + + return ShaderEffect(internal.Get()); +} + +void ImageActor::RemoveShaderEffect() +{ + GetImplementation(*this).RemoveShaderEffect(); +} + + ImageActor::ImageActor(Internal::ImageActor* internal) : RenderableActor(internal) { } +void SetShaderEffectRecursively( Actor actor, ShaderEffect effect ) +{ + // only do something if the actor and effect are valid + if( actor && effect ) + { + // first remove from this actor + ImageActor imageActor = ImageActor::DownCast( actor ); + if( imageActor ) + { + imageActor.SetShaderEffect( effect ); + } + // then all children recursively + const unsigned int count = actor.GetChildCount(); + for( unsigned int index = 0; index < count; ++index ) + { + Actor child( actor.GetChildAt( index ) ); + SetShaderEffectRecursively( child, effect ); + } + } +} + +void RemoveShaderEffectRecursively( Actor actor ) +{ + // only do something if the actor is valid + if( actor ) + { + // first remove from this actor + ImageActor imageActor = ImageActor::DownCast( actor ); + if( imageActor ) + { + imageActor.RemoveShaderEffect(); + } + // then all children recursively + const unsigned int count = actor.GetChildCount(); + for( unsigned int index = 0; index < count; ++index ) + { + Actor child( actor.GetChildAt( index ) ); + RemoveShaderEffectRecursively( child ); + } + } +} + } // namespace Dali diff --git a/dali/public-api/actors/image-actor.h b/dali/public-api/actors/image-actor.h index 18e1932..67cce8a 100644 --- a/dali/public-api/actors/image-actor.h +++ b/dali/public-api/actors/image-actor.h @@ -329,11 +329,226 @@ public: */ Vector4 GetNinePatchBorder() const; + + /** + * @brief Allows modification of an actors position in the depth sort algorithm. + * + * The offset can be altered for each coplanar actor hence allowing an order of painting. + * @pre The Actor has been initialized. + * @param [in] depthOffset the offset to be given to the actor. Positive values pushing it further back. + */ + void SetSortModifier(float depthOffset); + + /** + * @brief Retrieves the offset used to modify an actors position in the depth sort algorithm. + * + * The offset can be altered for each coplanar actor hence allowing an order of painting. + * @pre The Actor has been initialized. + * @return the offset that has been given to the actor. Positive values pushing it further back. + */ + float GetSortModifier() const; + + /** + * @brief Set the face-culling mode for this actor. + * + * @param[in] mode The culling mode. + */ + void SetCullFace(CullFaceMode mode); + + /** + * @brief Retrieve the face-culling mode for this actor. + * + * @return mode The culling mode. + */ + CullFaceMode GetCullFace() const; + + /** + * @brief Sets the blending mode. + * + * Possible values are: BlendingMode::OFF, BlendingMode::AUTO and BlendingMode::ON. Default is BlendingMode::AUTO. + * + * If blending is disabled (BlendingMode::OFF) fade in and fade out animations do not work. + * + *
    + *
  • \e OFF Blending is disabled. + *
  • \e AUTO Blending is enabled only if the renderable actor has alpha channel. + *
  • \e ON Blending is enabled. + *
+ * + * @param[in] mode The blending mode. + */ + void SetBlendMode( BlendingMode::Type mode ); + + /** + * @brief Retrieves the blending mode. + * + * @return The blending mode, one of BlendingMode::OFF, BlendingMode::AUTO or BlendingMode::ON. + */ + BlendingMode::Type GetBlendMode() const; + + /** + * @brief Specify the pixel arithmetic used when the actor is blended. + * + * @param[in] srcFactorRgba Specifies how the red, green, blue, and alpha source blending factors are computed. + * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR, + * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR, + * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE. + * + * @param[in] destFactorRgba Specifies how the red, green, blue, and alpha destination blending factors are computed. + * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR, + * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR, + * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA. + */ + void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba ); + + /** + * @brief Specify the pixel arithmetic used when the actor is blended. + * + * @param[in] srcFactorRgb Specifies how the red, green, and blue source blending factors are computed. + * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR, + * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR, + * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE. + * + * @param[in] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed. + * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR, + * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR, + * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA. + * + * @param[in] srcFactorAlpha Specifies how the alpha source blending factor is computed. + * The options are the same as for srcFactorRgb. + * + * @param[in] destFactorAlpha Specifies how the alpha source blending factor is computed. + * The options are the same as for destFactorRgb. + */ + void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb, + BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha ); + + /** + * @brief Query the pixel arithmetic used when the actor is blended. + * + * @param[out] srcFactorRgb Specifies how the red, green, blue, and alpha source blending factors are computed. + * @param[out] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed. + * @param[out] srcFactorAlpha Specifies how the red, green, blue, and alpha source blending factors are computed. + * @param[out] destFactorAlpha Specifies how the red, green, blue, and alpha destination blending factors are computed. + */ + void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb, + BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const; + + /** + * @brief Specify the equation used when the actor is blended. + * + * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT. + * @param[in] equationRgba The equation used for combining red, green, blue, and alpha components. + */ + void SetBlendEquation( BlendingEquation::Type equationRgba ); + + /** + * @brief Specify the equation used when the actor is blended. + * + * @param[in] equationRgb The equation used for combining red, green, and blue components. + * @param[in] equationAlpha The equation used for combining the alpha component. + * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT. + */ + void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha ); + + /** + * @brief Query the equation used when the actor is blended. + * + * @param[out] equationRgb The equation used for combining red, green, and blue components. + * @param[out] equationAlpha The equation used for combining the alpha component. + */ + void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const; + + /** + * @brief Specify the color used when the actor is blended; the default is Vector4::ZERO. + * + * @param[in] color The blend color. + */ + void SetBlendColor( const Vector4& color ); + + /** + * @brief Query the color used when the actor is blended. + * + * @return The blend color. + */ + const Vector4& GetBlendColor() const; + + /** + * @brief Sets the filtering mode. + * + * Possible values are: FilterMode::NEAREST and FilterMode::LINEAR. Default is FilterMode::LINEAR. + * + *
    + *
  • \e NEAREST Use nearest filtering + *
  • \e LINEAR Use linear filtering + *
+ * + * @param[in] minFilter The minification filtering mode. + * @param[in] magFilter The magnification filtering mode. + */ + void SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter ); + + /** + * @brief Retrieves the filtering mode. + * + * @param[out] minFilter The return minification value + * @param[out] magFilter The return magnification value + */ + void GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter) const; + + /** + * @brief Sets the shader effect for the RenderableActor. + * + * Shader effects provide special effects like ripple and bend. + * Setting a shader effect removes any shader effect previously set by SetShaderEffect. + * @pre The actor has been initialized. + * @pre effect has been initialized. + * @param [in] effect The shader effect. + */ + void SetShaderEffect( ShaderEffect effect ); + + /** + * @brief Retrieve the custom shader effect for the RenderableActor. + * If default shader is used an empty handle is returned. + * + * @pre The Actor has been initialized. + * @return The shader effect + */ + ShaderEffect GetShaderEffect() const; + + /** + * @brief Removes the current shader effect. + * + * @pre The Actor has been initialized. + */ + void RemoveShaderEffect(); + + public: // Not intended for application developers explicit DALI_INTERNAL ImageActor(Internal::ImageActor*); }; + +/** + * @brief Sets the shader effect for all ImageActors in a tree of Actors. + * + * @see ImageActor::SetShaderEffect + * + * @param [in] actor root of a tree of actors. + * @param [in] effect The shader effect. + */ +DALI_IMPORT_API void SetShaderEffectRecursively( Actor actor, ShaderEffect effect ); + +/** + * @brief Removes the shader effect from all ImageActors in a tree of Actors. + * + * @see ImageActor::RemoveShaderEffect + * + * @param [in] actor root of a tree of actors. + */ +DALI_IMPORT_API void RemoveShaderEffectRecursively( Actor actor ); + } // namespace Dali #endif // __DALI_IMAGE_ACTOR_H__ diff --git a/dali/public-api/actors/renderable-actor.cpp b/dali/public-api/actors/renderable-actor.cpp index 6c007c6..42761dc 100644 --- a/dali/public-api/actors/renderable-actor.cpp +++ b/dali/public-api/actors/renderable-actor.cpp @@ -51,150 +51,11 @@ RenderableActor& RenderableActor::operator=(const RenderableActor& rhs) return *this; } -void RenderableActor::SetSortModifier(float modifier) -{ - GetImplementation(*this).SetSortModifier(modifier); -} - -float RenderableActor::GetSortModifier() const -{ - return GetImplementation(*this).GetSortModifier(); -} - -void RenderableActor::SetCullFace(const CullFaceMode mode) -{ - GetImplementation(*this).SetCullFace(mode); -} - -CullFaceMode RenderableActor::GetCullFace() const -{ - return GetImplementation(*this).GetCullFace(); -} - -void RenderableActor::SetBlendMode( BlendingMode::Type mode ) -{ - GetImplementation(*this).SetBlendMode( mode ); -} - -BlendingMode::Type RenderableActor::GetBlendMode() const -{ - return GetImplementation(*this).GetBlendMode(); -} - -void RenderableActor::SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba ) -{ - GetImplementation(*this).SetBlendFunc( srcFactorRgba, destFactorRgba ); -} - -void RenderableActor::SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb, - BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha ) -{ - GetImplementation(*this).SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); -} - -void RenderableActor::GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb, - BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const -{ - GetImplementation(*this).GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha ); -} - -void RenderableActor::SetBlendEquation( BlendingEquation::Type equationRgba ) -{ - GetImplementation(*this).SetBlendEquation( equationRgba ); -} - -void RenderableActor::SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha ) -{ - GetImplementation(*this).SetBlendEquation( equationRgb, equationAlpha ); -} - -void RenderableActor::GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const -{ - GetImplementation(*this).GetBlendEquation( equationRgb, equationAlpha ); -} - -void RenderableActor::SetBlendColor( const Vector4& color ) -{ - GetImplementation(*this).SetBlendColor( color ); -} - -const Vector4& RenderableActor::GetBlendColor() const -{ - return GetImplementation(*this).GetBlendColor(); -} - -void RenderableActor::SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter ) -{ - GetImplementation(*this).SetFilterMode( minFilter, magFilter ); -} - -void RenderableActor::GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const -{ - GetImplementation(*this).GetFilterMode( minFilter, magFilter ); -} - -void RenderableActor::SetShaderEffect(ShaderEffect effect) -{ - GetImplementation(*this).SetShaderEffect(GetImplementation(effect)); -} - -ShaderEffect RenderableActor::GetShaderEffect() const -{ - Internal::ShaderEffectPtr internal = GetImplementation(*this).GetShaderEffect(); - - return ShaderEffect(internal.Get()); -} - -void RenderableActor::RemoveShaderEffect() -{ - GetImplementation(*this).RemoveShaderEffect(); -} RenderableActor::RenderableActor(Internal::RenderableActor* internal) : Actor(internal) { } -void SetShaderEffectRecursively( Actor actor, ShaderEffect effect ) -{ - // only do something if the actor and effect are valid - if( actor && effect ) - { - // first remove from this actor - RenderableActor renderable = RenderableActor::DownCast( actor ); - if( renderable ) - { - renderable.SetShaderEffect( effect ); - } - // then all children recursively - const unsigned int count = actor.GetChildCount(); - for( unsigned int index = 0; index < count; ++index ) - { - Actor child( actor.GetChildAt( index ) ); - SetShaderEffectRecursively( child, effect ); - } - } -} - -void RemoveShaderEffectRecursively( Actor actor ) -{ - // only do something if the actor is valid - if( actor ) - { - // first remove from this actor - RenderableActor renderable = RenderableActor::DownCast( actor ); - if( renderable ) - { - renderable.RemoveShaderEffect(); - } - // then all children recursively - const unsigned int count = actor.GetChildCount(); - for( unsigned int index = 0; index < count; ++index ) - { - Actor child( actor.GetChildAt( index ) ); - RemoveShaderEffectRecursively( child ); - } - } -} } // namespace Dali diff --git a/dali/public-api/actors/renderable-actor.h b/dali/public-api/actors/renderable-actor.h index 9294453..3f89456 100644 --- a/dali/public-api/actors/renderable-actor.h +++ b/dali/public-api/actors/renderable-actor.h @@ -91,199 +91,6 @@ public: */ RenderableActor& operator=(const RenderableActor& rhs); - /** - * @brief Allows modification of an actors position in the depth sort algorithm. - * - * The offset can be altered for each coplanar actor hence allowing an order of painting. - * @pre The Actor has been initialized. - * @param [in] depthOffset the offset to be given to the actor. Positive values pushing it further back. - */ - void SetSortModifier(float depthOffset); - - /** - * @brief Retrieves the offset used to modify an actors position in the depth sort algorithm. - * - * The offset can be altered for each coplanar actor hence allowing an order of painting. - * @pre The Actor has been initialized. - * @return the offset that has been given to the actor. Positive values pushing it further back. - */ - float GetSortModifier() const; - - /** - * @brief Set the face-culling mode for this actor. - * - * @param[in] mode The culling mode. - */ - void SetCullFace(CullFaceMode mode); - - /** - * @brief Retrieve the face-culling mode for this actor. - * - * @return mode The culling mode. - */ - CullFaceMode GetCullFace() const; - - /** - * @brief Sets the blending mode. - * - * Possible values are: BlendingMode::OFF, BlendingMode::AUTO and BlendingMode::ON. Default is BlendingMode::AUTO. - * - * If blending is disabled (BlendingMode::OFF) fade in and fade out animations do not work. - * - *
    - *
  • \e OFF Blending is disabled. - *
  • \e AUTO Blending is enabled only if the renderable actor has alpha channel. - *
  • \e ON Blending is enabled. - *
- * - * @param[in] mode The blending mode. - */ - void SetBlendMode( BlendingMode::Type mode ); - - /** - * @brief Retrieves the blending mode. - * - * @return The blending mode, one of BlendingMode::OFF, BlendingMode::AUTO or BlendingMode::ON. - */ - BlendingMode::Type GetBlendMode() const; - - /** - * @brief Specify the pixel arithmetic used when the actor is blended. - * - * @param[in] srcFactorRgba Specifies how the red, green, blue, and alpha source blending factors are computed. - * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR, - * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR, - * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE. - * - * @param[in] destFactorRgba Specifies how the red, green, blue, and alpha destination blending factors are computed. - * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR, - * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR, - * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA. - */ - void SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba ); - - /** - * @brief Specify the pixel arithmetic used when the actor is blended. - * - * @param[in] srcFactorRgb Specifies how the red, green, and blue source blending factors are computed. - * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR, - * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR, - * GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA, and GL_SRC_ALPHA_SATURATE. - * - * @param[in] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed. - * The options are BlendingFactor::ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR, - * SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR, - * GL_CONSTANT_ALPHA, and GL_ONE_MINUS_CONSTANT_ALPHA. - * - * @param[in] srcFactorAlpha Specifies how the alpha source blending factor is computed. - * The options are the same as for srcFactorRgb. - * - * @param[in] destFactorAlpha Specifies how the alpha source blending factor is computed. - * The options are the same as for destFactorRgb. - */ - void SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb, - BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha ); - - /** - * @brief Query the pixel arithmetic used when the actor is blended. - * - * @param[out] srcFactorRgb Specifies how the red, green, blue, and alpha source blending factors are computed. - * @param[out] destFactorRgb Specifies how the red, green, blue, and alpha destination blending factors are computed. - * @param[out] srcFactorAlpha Specifies how the red, green, blue, and alpha source blending factors are computed. - * @param[out] destFactorAlpha Specifies how the red, green, blue, and alpha destination blending factors are computed. - */ - void GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb, - BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const; - - /** - * @brief Specify the equation used when the actor is blended. - * - * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT. - * @param[in] equationRgba The equation used for combining red, green, blue, and alpha components. - */ - void SetBlendEquation( BlendingEquation::Type equationRgba ); - - /** - * @brief Specify the equation used when the actor is blended. - * - * @param[in] equationRgb The equation used for combining red, green, and blue components. - * @param[in] equationAlpha The equation used for combining the alpha component. - * The options are BlendingEquation::ADD, SUBTRACT, or REVERSE_SUBTRACT. - */ - void SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha ); - - /** - * @brief Query the equation used when the actor is blended. - * - * @param[out] equationRgb The equation used for combining red, green, and blue components. - * @param[out] equationAlpha The equation used for combining the alpha component. - */ - void GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const; - - /** - * @brief Specify the color used when the actor is blended; the default is Vector4::ZERO. - * - * @param[in] color The blend color. - */ - void SetBlendColor( const Vector4& color ); - - /** - * @brief Query the color used when the actor is blended. - * - * @return The blend color. - */ - const Vector4& GetBlendColor() const; - - /** - * @brief Sets the filtering mode. - * - * Possible values are: FilterMode::NEAREST and FilterMode::LINEAR. Default is FilterMode::LINEAR. - * - *
    - *
  • \e NEAREST Use nearest filtering - *
  • \e LINEAR Use linear filtering - *
- * - * @param[in] minFilter The minification filtering mode. - * @param[in] magFilter The magnification filtering mode. - */ - void SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter ); - - /** - * @brief Retrieves the filtering mode. - * - * @param[out] minFilter The return minification value - * @param[out] magFilter The return magnification value - */ - void GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter) const; - - /** - * @brief Sets the shader effect for the RenderableActor. - * - * Shader effects provide special effects like ripple and bend. - * Setting a shader effect removes any shader effect previously set by SetShaderEffect. - * @pre The actor has been initialized. - * @pre effect has been initialized. - * @param [in] effect The shader effect. - */ - void SetShaderEffect( ShaderEffect effect ); - - /** - * @brief Retrieve the custom shader effect for the RenderableActor. - * If default shader is used an empty handle is returned. - * - * @pre The Actor has been initialized. - * @return The shader effect - */ - ShaderEffect GetShaderEffect() const; - - /** - * @brief Removes the current shader effect. - * - * @pre The Actor has been initialized. - */ - void RemoveShaderEffect(); - public: // Not intended for application developers /** @@ -294,24 +101,6 @@ public: // Not intended for application developers explicit DALI_INTERNAL RenderableActor(Internal::RenderableActor* actor); }; -/** - * @brief Sets the shader effect for all RenderableActors in a tree of Actors. - * - * @see RenderableActor::SetShaderEffect - * - * @param [in] actor root of a tree of actors. - * @param [in] effect The shader effect. - */ -DALI_IMPORT_API void SetShaderEffectRecursively( Actor actor, ShaderEffect effect ); - -/** - * @brief Removes the shader effect from all RenderableActors in a tree of Actors. - * - * @see RenderableActor::RemoveShaderEffect - * - * @param [in] actor root of a tree of actors. - */ -DALI_IMPORT_API void RemoveShaderEffectRecursively( Actor actor ); } // namespace Dali -- 2.7.4