2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 #include <dali/internal/event/actor-attachments/renderable-attachment-impl.h>
21 #include <dali/internal/event/common/stage-impl.h>
22 #include <dali/internal/update/node-attachments/scene-graph-renderable-attachment.h>
23 #include <dali/internal/render/renderers/scene-graph-renderer.h>
31 RenderableAttachment::RenderableAttachment( Stage& stage )
32 : ActorAttachment( stage ),
33 mSortModifier( 0.0f ),
34 mCullFaceMode( CullNone ),
35 mBlendingMode( BlendingMode::AUTO )
39 RenderableAttachment::~RenderableAttachment()
43 void RenderableAttachment::SetSortModifier(float modifier)
45 // Cache for actor-side getters
46 mSortModifier = modifier;
48 // attachment is being used in a separate thread; queue a message to set the value & base value
49 SetSortModifierMessage( mStage->GetUpdateInterface(), GetSceneObject(), modifier );
52 float RenderableAttachment::GetSortModifier() const
54 // mSortModifier is not animatable; this is the most up-to-date value.
58 void RenderableAttachment::SetCullFace( CullFaceMode mode )
60 // Cache for actor-side getters
63 // attachment is being used in a separate thread; queue a message to set the value
64 SetCullFaceMessage( mStage->GetUpdateInterface(), GetSceneObject(), mode );
67 CullFaceMode RenderableAttachment::GetCullFace() const
69 // mCullFaceMode is not animatable; this is the most up-to-date value.
73 void RenderableAttachment::SetBlendMode( BlendingMode::Type mode )
77 // attachment is being used in a separate thread; queue a message to set the value
78 SetBlendingModeMessage( mStage->GetUpdateInterface(), GetSceneObject(), mode );
81 BlendingMode::Type RenderableAttachment::GetBlendMode() const
86 void RenderableAttachment::SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
87 BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha )
89 // Cache for actor-side getters
90 mBlendingOptions.SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
92 // attachment is being used in a separate thread; queue a message to set the value
93 SetBlendingOptionsMessage( mStage->GetUpdateInterface(), GetSceneObject(), mBlendingOptions.GetBitmask() );
96 void RenderableAttachment::GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
97 BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const
99 // These are not animatable, the cached values are up-to-date.
100 srcFactorRgb = mBlendingOptions.GetBlendSrcFactorRgb();
101 destFactorRgb = mBlendingOptions.GetBlendDestFactorRgb();
102 srcFactorAlpha = mBlendingOptions.GetBlendSrcFactorAlpha();
103 destFactorAlpha = mBlendingOptions.GetBlendDestFactorAlpha();
106 void RenderableAttachment::SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha )
108 mBlendingOptions.SetBlendEquation( equationRgb, equationAlpha );
110 // attachment is being used in a separate thread; queue a message to set the value
111 SetBlendingOptionsMessage( mStage->GetUpdateInterface(), GetSceneObject(), mBlendingOptions.GetBitmask() );
114 void RenderableAttachment::GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const
116 // These are not animatable, the cached values are up-to-date.
117 equationRgb = mBlendingOptions.GetBlendEquationRgb();
118 equationAlpha = mBlendingOptions.GetBlendEquationAlpha();
121 void RenderableAttachment::SetBlendColor( const Vector4& color )
123 if( mBlendingOptions.SetBlendColor( color ) )
125 // attachment is being used in a separate thread; queue a message to set the value
126 SetBlendColorMessage( mStage->GetUpdateInterface(), GetSceneObject(), color );
130 const Vector4& RenderableAttachment::GetBlendColor() const
132 const Vector4* optionalColor = mBlendingOptions.GetBlendColor();
135 return *optionalColor;
138 return Vector4::ZERO;
141 void RenderableAttachment::OnStageConnection()
143 // For derived classes
144 OnStageConnection2();
147 void RenderableAttachment::OnStageDisconnection()
149 // For derived classes
150 OnStageDisconnection2();
153 } // namespace Internal