2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/event/actor-attachments/renderable-attachment-impl.h>
22 #include <dali/internal/event/common/stage-impl.h>
23 #include <dali/internal/update/node-attachments/scene-graph-renderable-attachment.h>
24 #include <dali/internal/render/renderers/scene-graph-renderer.h>
32 RenderableAttachment::RenderableAttachment( Stage& stage )
33 : ActorAttachment( stage ),
34 mSortModifier( 0.0f ),
35 mCullFaceMode( CullNone ),
36 mBlendingMode( BlendingMode::AUTO )
40 RenderableAttachment::~RenderableAttachment()
44 void RenderableAttachment::SetSortModifier(float modifier)
46 // Cache for actor-side getters
47 mSortModifier = modifier;
49 // attachment is being used in a separate thread; queue a message to set the value & base value
50 SetSortModifierMessage( mStage->GetUpdateInterface(), GetSceneObject(), modifier );
53 float RenderableAttachment::GetSortModifier() const
55 // mSortModifier is not animatable; this is the most up-to-date value.
59 void RenderableAttachment::SetCullFace( CullFaceMode mode )
61 // Cache for actor-side getters
64 // attachment is being used in a separate thread; queue a message to set the value
65 SetCullFaceMessage( mStage->GetUpdateInterface(), GetSceneObject(), mode );
68 CullFaceMode RenderableAttachment::GetCullFace() const
70 // mCullFaceMode is not animatable; this is the most up-to-date value.
74 void RenderableAttachment::SetBlendMode( BlendingMode::Type mode )
78 // attachment is being used in a separate thread; queue a message to set the value
79 SetBlendingModeMessage( mStage->GetUpdateInterface(), GetSceneObject(), mode );
82 BlendingMode::Type RenderableAttachment::GetBlendMode() const
87 void RenderableAttachment::SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
88 BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha )
90 // Cache for actor-side getters
91 mBlendingOptions.SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
93 // attachment is being used in a separate thread; queue a message to set the value
94 SetBlendingOptionsMessage( mStage->GetUpdateInterface(), GetSceneObject(), mBlendingOptions.GetBitmask() );
97 void RenderableAttachment::GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
98 BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const
100 // These are not animatable, the cached values are up-to-date.
101 srcFactorRgb = mBlendingOptions.GetBlendSrcFactorRgb();
102 destFactorRgb = mBlendingOptions.GetBlendDestFactorRgb();
103 srcFactorAlpha = mBlendingOptions.GetBlendSrcFactorAlpha();
104 destFactorAlpha = mBlendingOptions.GetBlendDestFactorAlpha();
107 void RenderableAttachment::SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha )
109 mBlendingOptions.SetBlendEquation( equationRgb, equationAlpha );
111 // attachment is being used in a separate thread; queue a message to set the value
112 SetBlendingOptionsMessage( mStage->GetUpdateInterface(), GetSceneObject(), mBlendingOptions.GetBitmask() );
115 void RenderableAttachment::GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const
117 // These are not animatable, the cached values are up-to-date.
118 equationRgb = mBlendingOptions.GetBlendEquationRgb();
119 equationAlpha = mBlendingOptions.GetBlendEquationAlpha();
122 void RenderableAttachment::SetBlendColor( const Vector4& color )
124 if( mBlendingOptions.SetBlendColor( color ) )
126 // attachment is being used in a separate thread; queue a message to set the value
127 SetBlendColorMessage( mStage->GetUpdateInterface(), GetSceneObject(), color );
131 const Vector4& RenderableAttachment::GetBlendColor() const
133 const Vector4* optionalColor = mBlendingOptions.GetBlendColor();
136 return *optionalColor;
139 return Vector4::ZERO;
142 void RenderableAttachment::OnStageConnection()
144 // For derived classes
145 OnStageConnection2();
148 void RenderableAttachment::OnStageDisconnection()
150 // For derived classes
151 OnStageDisconnection2();
154 } // namespace Internal