Clean up the code to build successfully on macOS
[platform/core/uifw/dali-core.git] / dali / internal / event / rendering / renderer-impl.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/event/rendering/renderer-impl.h> // Dali::Internal::Renderer
20
21 // INTERNAL INCLUDES
22 #include <dali/devel-api/scripting/scripting.h>
23 #include <dali/public-api/object/type-registry.h>
24 #include <dali/internal/event/common/property-helper.h>    // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
25 #include <dali/internal/event/common/property-input-impl.h>
26 #include <dali/internal/render/renderers/render-geometry.h>
27 #include <dali/internal/update/manager/update-manager.h>
28 #include <dali/internal/update/rendering/scene-graph-renderer.h>
29
30 namespace Dali
31 {
32 namespace Internal
33 {
34
35 namespace
36 {
37
38 /**
39  * Properties: |name                              |type     |writable|animatable|constraint-input|enum for index-checking|
40  */
41 DALI_PROPERTY_TABLE_BEGIN
42 DALI_PROPERTY( "depthIndex",                      INTEGER,   true, false,  false, Dali::Renderer::Property::DEPTH_INDEX )
43 DALI_PROPERTY( "faceCullingMode",                 INTEGER,   true, false,  false, Dali::Renderer::Property::FACE_CULLING_MODE )
44 DALI_PROPERTY( "blendMode",                       INTEGER,   true, false,  false, Dali::Renderer::Property::BLEND_MODE )
45 DALI_PROPERTY( "blendEquationRgb",                INTEGER,   true, false,  false, Dali::Renderer::Property::BLEND_EQUATION_RGB )
46 DALI_PROPERTY( "blendEquationAlpha",              INTEGER,   true, false,  false, Dali::Renderer::Property::BLEND_EQUATION_ALPHA )
47 DALI_PROPERTY( "blendFactorSrcRgb",               INTEGER,   true, false,  false, Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB )
48 DALI_PROPERTY( "blendFactorDestRgb",              INTEGER,   true, false,  false, Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB )
49 DALI_PROPERTY( "blendFactorSrcAlpha",             INTEGER,   true, false,  false, Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA )
50 DALI_PROPERTY( "blendFactorDestAlpha",            INTEGER,   true, false,  false, Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA )
51 DALI_PROPERTY( "blendColor",                      VECTOR4,   true, false,  false, Dali::Renderer::Property::BLEND_COLOR )
52 DALI_PROPERTY( "blendPreMultipliedAlpha",         BOOLEAN,   true, false,  false, Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA )
53 DALI_PROPERTY( "indexRangeFirst",                 INTEGER,   true, false,  false, Dali::Renderer::Property::INDEX_RANGE_FIRST )
54 DALI_PROPERTY( "indexRangeCount",                 INTEGER,   true, false,  false, Dali::Renderer::Property::INDEX_RANGE_COUNT )
55 DALI_PROPERTY( "depthWriteMode",                  INTEGER,   true, false,  false, Dali::Renderer::Property::DEPTH_WRITE_MODE )
56 DALI_PROPERTY( "depthFunction",                   INTEGER,   true, false,  false, Dali::Renderer::Property::DEPTH_FUNCTION )
57 DALI_PROPERTY( "depthTestMode",                   INTEGER,   true, false,  false, Dali::Renderer::Property::DEPTH_TEST_MODE )
58 DALI_PROPERTY( "renderMode",                      INTEGER,   true, false,  false, Dali::Renderer::Property::RENDER_MODE )
59 DALI_PROPERTY( "stencilFunction",                 INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_FUNCTION )
60 DALI_PROPERTY( "stencilFunctionMask",             INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_FUNCTION_MASK )
61 DALI_PROPERTY( "stencilFunctionReference",        INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE )
62 DALI_PROPERTY( "stencilMask",                     INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_MASK )
63 DALI_PROPERTY( "stencilOperationOnFail",          INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL )
64 DALI_PROPERTY( "stencilOperationOnZFail",         INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL )
65 DALI_PROPERTY( "stencilOperationOnZPass",         INTEGER,   true, false,  false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS )
66 DALI_PROPERTY( "opacity",                         FLOAT,     true, true,   true,  Dali::DevelRenderer::Property::OPACITY )
67 DALI_PROPERTY( "renderingBehavior",               INTEGER,   true, false,  false, Dali::DevelRenderer::Property::RENDERING_BEHAVIOR )
68 DALI_PROPERTY_TABLE_END( DEFAULT_RENDERER_PROPERTY_START_INDEX, RendererDefaultProperties )
69
70 // Property string to enumeration tables:
71
72 DALI_ENUM_TO_STRING_TABLE_BEGIN( FACE_CULLING_MODE )
73 DALI_ENUM_TO_STRING_WITH_SCOPE( FaceCullingMode, NONE )
74 DALI_ENUM_TO_STRING_WITH_SCOPE( FaceCullingMode, FRONT )
75 DALI_ENUM_TO_STRING_WITH_SCOPE( FaceCullingMode, BACK )
76 DALI_ENUM_TO_STRING_WITH_SCOPE( FaceCullingMode, FRONT_AND_BACK )
77 DALI_ENUM_TO_STRING_TABLE_END( FACE_CULLING_MODE )
78
79 DALI_ENUM_TO_STRING_TABLE_BEGIN( BLEND_MODE )
80 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendMode, OFF )
81 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendMode, AUTO )
82 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendMode, ON )
83 DALI_ENUM_TO_STRING_TABLE_END( BLEND_MODE )
84
85 DALI_ENUM_TO_STRING_TABLE_BEGIN( BLEND_EQUATION )
86 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendEquation, ADD )
87 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendEquation, SUBTRACT )
88 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendEquation, REVERSE_SUBTRACT )
89 DALI_ENUM_TO_STRING_TABLE_END( BLEND_EQUATION )
90
91 DALI_ENUM_TO_STRING_TABLE_BEGIN( BLEND_FACTOR )
92 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ZERO )
93 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ONE )
94 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, SRC_COLOR )
95 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ONE_MINUS_SRC_COLOR )
96 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, SRC_ALPHA )
97 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ONE_MINUS_SRC_ALPHA )
98 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, DST_ALPHA )
99 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ONE_MINUS_DST_ALPHA )
100 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, DST_COLOR )
101 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ONE_MINUS_DST_COLOR )
102 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, SRC_ALPHA_SATURATE )
103 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, CONSTANT_COLOR )
104 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ONE_MINUS_CONSTANT_COLOR )
105 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, CONSTANT_ALPHA )
106 DALI_ENUM_TO_STRING_WITH_SCOPE( BlendFactor, ONE_MINUS_CONSTANT_ALPHA )
107 DALI_ENUM_TO_STRING_TABLE_END( BLEND_FACTOR )
108
109 DALI_ENUM_TO_STRING_TABLE_BEGIN( DEPTH_WRITE_MODE )
110 DALI_ENUM_TO_STRING_WITH_SCOPE( DepthWriteMode, OFF )
111 DALI_ENUM_TO_STRING_WITH_SCOPE( DepthWriteMode, AUTO )
112 DALI_ENUM_TO_STRING_WITH_SCOPE( DepthWriteMode, ON )
113 DALI_ENUM_TO_STRING_TABLE_END( DEPTH_WRITE_MODE )
114
115 DALI_ENUM_TO_STRING_TABLE_BEGIN( DEPTH_TEST_MODE )
116 DALI_ENUM_TO_STRING_WITH_SCOPE( DepthTestMode, OFF )
117 DALI_ENUM_TO_STRING_WITH_SCOPE( DepthTestMode, AUTO )
118 DALI_ENUM_TO_STRING_WITH_SCOPE( DepthTestMode, ON )
119 DALI_ENUM_TO_STRING_TABLE_END( DEPTH_TEST_MODE )
120
121 DALI_ENUM_TO_STRING_TABLE_BEGIN( DEPTH_FUNCTION )
122 DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, NEVER )
123 DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, ALWAYS )
124 DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, LESS )
125 DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, GREATER )
126 DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, EQUAL )
127 DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, NOT_EQUAL )
128 DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, LESS_EQUAL )
129 DALI_ENUM_TO_STRING_WITH_SCOPE( DepthFunction, GREATER_EQUAL )
130 DALI_ENUM_TO_STRING_TABLE_END( DEPTH_FUNCTION )
131
132 DALI_ENUM_TO_STRING_TABLE_BEGIN( STENCIL_FUNCTION )
133 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, NEVER )
134 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, LESS )
135 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, EQUAL )
136 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, LESS_EQUAL )
137 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, GREATER )
138 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, NOT_EQUAL )
139 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, GREATER_EQUAL )
140 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilFunction, ALWAYS )
141 DALI_ENUM_TO_STRING_TABLE_END( STENCIL_FUNCTION )
142
143 DALI_ENUM_TO_STRING_TABLE_BEGIN( RENDER_MODE )
144 DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, NONE )
145 DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, AUTO )
146 DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, COLOR )
147 DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, STENCIL )
148 DALI_ENUM_TO_STRING_WITH_SCOPE( RenderMode, COLOR_STENCIL )
149 DALI_ENUM_TO_STRING_TABLE_END( RENDER_MODE )
150
151 DALI_ENUM_TO_STRING_TABLE_BEGIN( STENCIL_OPERATION )
152 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, ZERO )
153 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, KEEP )
154 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, REPLACE )
155 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, INCREMENT )
156 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, DECREMENT )
157 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, INVERT )
158 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, INCREMENT_WRAP )
159 DALI_ENUM_TO_STRING_WITH_SCOPE( StencilOperation, DECREMENT_WRAP )
160 DALI_ENUM_TO_STRING_TABLE_END( STENCIL_OPERATION )
161
162 DALI_ENUM_TO_STRING_TABLE_BEGIN( RENDERING_BEHAVIOR )
163 DALI_ENUM_TO_STRING_WITH_SCOPE( DevelRenderer::Rendering, IF_REQUIRED )
164 DALI_ENUM_TO_STRING_WITH_SCOPE( DevelRenderer::Rendering, CONTINUOUSLY )
165 DALI_ENUM_TO_STRING_TABLE_END( RENDERING_BEHAVIOR )
166
167 BaseHandle Create()
168 {
169   return Dali::BaseHandle();
170 }
171
172 TypeRegistration mType( typeid( Dali::Renderer ), typeid( Dali::Handle ), Create, RendererDefaultProperties );
173
174 } // unnamed namespace
175
176 RendererPtr Renderer::New()
177 {
178   // create scene object first so it's guaranteed to exist for the event side
179   auto sceneObject = SceneGraph::Renderer::New();
180   OwnerPointer< SceneGraph::Renderer > transferOwnership( sceneObject );
181   // pass the pointer to base for message passing
182   RendererPtr rendererPtr( new Renderer( sceneObject ) );
183   // transfer scene object ownership to update manager
184   EventThreadServices& eventThreadServices = rendererPtr->GetEventThreadServices();
185   SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
186   AddRendererMessage( updateManager, transferOwnership );
187
188   eventThreadServices.RegisterObject( rendererPtr.Get() );
189   return rendererPtr;
190 }
191
192 void Renderer::SetGeometry( Geometry& geometry )
193 {
194   mGeometry = &geometry;
195
196   const Render::Geometry* geometrySceneObject = geometry.GetRenderObject();
197   SetGeometryMessage( GetEventThreadServices(), GetRendererSceneObject(), *geometrySceneObject );
198 }
199
200 GeometryPtr Renderer::GetGeometry() const
201 {
202   return mGeometry;
203 }
204
205 void Renderer::SetTextures( TextureSet& textureSet )
206 {
207   mTextureSet = &textureSet;
208   const SceneGraph::TextureSet* textureSetSceneObject = textureSet.GetTextureSetSceneObject();
209   SetTexturesMessage( GetEventThreadServices(), GetRendererSceneObject(), *textureSetSceneObject );
210 }
211
212 TextureSetPtr Renderer::GetTextures() const
213 {
214   return mTextureSet;
215 }
216
217 void Renderer::SetShader( Shader& shader )
218 {
219   mShader = &shader;
220   const SceneGraph::Shader& sceneGraphShader = shader.GetShaderSceneObject();
221   SceneGraph::SetShaderMessage( GetEventThreadServices(), GetRendererSceneObject(), sceneGraphShader );
222 }
223
224 ShaderPtr Renderer::GetShader() const
225 {
226   return mShader;
227 }
228
229 void Renderer::SetDepthIndex( int32_t depthIndex )
230 {
231   if ( mDepthIndex != depthIndex )
232   {
233     mDepthIndex = depthIndex;
234     SetDepthIndexMessage( GetEventThreadServices(), GetRendererSceneObject(), depthIndex );
235   }
236 }
237
238 int32_t Renderer::GetDepthIndex() const
239 {
240   return mDepthIndex;
241 }
242
243 void Renderer::SetBlendMode( BlendMode::Type mode )
244 {
245   if( mBlendMode != mode )
246   {
247     mBlendMode = mode;
248
249     SetBlendModeMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendMode );
250   }
251 }
252
253 BlendMode::Type Renderer::GetBlendMode() const
254 {
255   return mBlendMode;
256 }
257
258 void Renderer::SetBlendFunc( BlendFactor::Type srcFactorRgba, BlendFactor::Type destFactorRgba )
259 {
260   mBlendingOptions.SetBlendFunc( srcFactorRgba, destFactorRgba, srcFactorRgba, destFactorRgba );
261   SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
262 }
263
264 void Renderer::SetBlendFunc( BlendFactor::Type srcFactorRgb,
265                              BlendFactor::Type destFactorRgb,
266                              BlendFactor::Type srcFactorAlpha,
267                              BlendFactor::Type destFactorAlpha )
268 {
269   mBlendingOptions.SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
270   SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
271 }
272
273 void Renderer::GetBlendFunc( BlendFactor::Type& srcFactorRgb,
274                              BlendFactor::Type& destFactorRgb,
275                              BlendFactor::Type& srcFactorAlpha,
276                              BlendFactor::Type& destFactorAlpha ) const
277 {
278   srcFactorRgb    = mBlendingOptions.GetBlendSrcFactorRgb();
279   destFactorRgb   = mBlendingOptions.GetBlendDestFactorRgb();
280   srcFactorAlpha  = mBlendingOptions.GetBlendSrcFactorAlpha();
281   destFactorAlpha = mBlendingOptions.GetBlendDestFactorAlpha();
282 }
283
284 void Renderer::SetBlendEquation( BlendEquation::Type equationRgba )
285 {
286   mBlendingOptions.SetBlendEquation( equationRgba, equationRgba );
287   SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
288 }
289
290 void Renderer::SetBlendEquation( BlendEquation::Type equationRgb,
291                                  BlendEquation::Type equationAlpha )
292 {
293   mBlendingOptions.SetBlendEquation( equationRgb, equationAlpha );
294   SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
295 }
296
297 void Renderer::GetBlendEquation( BlendEquation::Type& equationRgb,
298                                  BlendEquation::Type& equationAlpha ) const
299 {
300   // These are not animatable, the cached values are up-to-date.
301   equationRgb   = mBlendingOptions.GetBlendEquationRgb();
302   equationAlpha = mBlendingOptions.GetBlendEquationAlpha();
303 }
304
305 void Renderer::SetIndexedDrawFirstElement( uint32_t firstElement )
306 {
307   if( firstElement != mIndexedDrawFirstElement )
308   {
309     mIndexedDrawFirstElement = firstElement;
310     SetIndexedDrawFirstElementMessage( GetEventThreadServices(), GetRendererSceneObject(), mIndexedDrawFirstElement );
311   }
312 }
313
314 void Renderer::SetIndexedDrawElementsCount( uint32_t elementsCount )
315 {
316   if( elementsCount != mIndexedDrawElementCount )
317   {
318     mIndexedDrawElementCount = elementsCount;
319     SetIndexedDrawElementsCountMessage( GetEventThreadServices(), GetRendererSceneObject(), mIndexedDrawElementCount );
320   }
321 }
322
323
324 void Renderer::EnablePreMultipliedAlpha( bool preMultipled )
325 {
326   if(  mPremultipledAlphaEnabled != preMultipled )
327   {
328     if( preMultipled )
329     {
330       SetBlendFunc( BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA );
331     }
332     else
333     {
334       SetBlendFunc( BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA );
335     }
336     mPremultipledAlphaEnabled = preMultipled;
337     SetEnablePreMultipliedAlphaMessage( GetEventThreadServices(), GetRendererSceneObject(), mPremultipledAlphaEnabled );
338   }
339 }
340
341 bool Renderer::IsPreMultipliedAlphaEnabled() const
342 {
343   return mPremultipledAlphaEnabled;
344 }
345
346 const SceneGraph::Renderer& Renderer::GetRendererSceneObject() const
347 {
348   return static_cast<const SceneGraph::Renderer&>( GetSceneObject() );
349 }
350
351 void Renderer::SetDefaultProperty( Property::Index index,
352                                    const Property::Value& propertyValue )
353 {
354   switch( index )
355   {
356     case Dali::Renderer::Property::DEPTH_INDEX:
357     {
358       SetDepthIndex( propertyValue.Get<int32_t>() );
359       break;
360     }
361     case Dali::Renderer::Property::FACE_CULLING_MODE:
362     {
363       FaceCullingMode::Type convertedValue = mFaceCullingMode;
364       if( Scripting::GetEnumerationProperty< FaceCullingMode::Type >( propertyValue, FACE_CULLING_MODE_TABLE, FACE_CULLING_MODE_TABLE_COUNT, convertedValue ) )
365       {
366         mFaceCullingMode = convertedValue;
367         SetFaceCullingModeMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
368       }
369       break;
370     }
371     case Dali::Renderer::Property::BLEND_MODE:
372     {
373       BlendMode::Type convertedValue = mBlendMode;
374       if( Scripting::GetEnumerationProperty< BlendMode::Type >( propertyValue, BLEND_MODE_TABLE, BLEND_MODE_TABLE_COUNT, convertedValue ) )
375       {
376         SetBlendMode( convertedValue );
377       }
378       break;
379     }
380     case Dali::Renderer::Property::BLEND_EQUATION_RGB:
381     {
382       BlendEquation::Type convertedValue = mBlendingOptions.GetBlendEquationRgb();
383
384       if( Scripting::GetEnumerationProperty< BlendEquation::Type >( propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue ) )
385       {
386         BlendEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
387         mBlendingOptions.SetBlendEquation( convertedValue, alphaEquation );
388         SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
389       }
390       break;
391     }
392     case Dali::Renderer::Property::BLEND_EQUATION_ALPHA:
393     {
394       BlendEquation::Type convertedValue = mBlendingOptions.GetBlendEquationAlpha();
395
396       if( Scripting::GetEnumerationProperty< BlendEquation::Type >( propertyValue, BLEND_EQUATION_TABLE, BLEND_EQUATION_TABLE_COUNT, convertedValue ) )
397       {
398         BlendEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb();
399         mBlendingOptions.SetBlendEquation( rgbEquation, convertedValue );
400         SetBlendingOptionsMessage( GetEventThreadServices(), GetRendererSceneObject(), mBlendingOptions.GetBitmask() );
401       }
402       break;
403     }
404     case Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB:
405     {
406       BlendFactor::Type sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha;
407       GetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
408
409       if( Scripting::GetEnumerationProperty< BlendFactor::Type >( propertyValue, BLEND_FACTOR_TABLE, BLEND_FACTOR_TABLE_COUNT, sourceFactorRgb ) )
410       {
411         SetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
412       }
413       break;
414     }
415     case Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB:
416     {
417       BlendFactor::Type sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha;
418       GetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
419
420       if( Scripting::GetEnumerationProperty< BlendFactor::Type >( propertyValue, BLEND_FACTOR_TABLE, BLEND_FACTOR_TABLE_COUNT, destinationFactorRgb ) )
421       {
422         SetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
423       }
424       break;
425     }
426     case Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA:
427     {
428       BlendFactor::Type sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha;
429       GetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
430
431       if( Scripting::GetEnumerationProperty< BlendFactor::Type >( propertyValue, BLEND_FACTOR_TABLE, BLEND_FACTOR_TABLE_COUNT, sourceFactorAlpha ) )
432       {
433         SetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
434       }
435       break;
436     }
437     case Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA:
438     {
439       BlendFactor::Type sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha;
440       GetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
441
442       if( Scripting::GetEnumerationProperty< BlendFactor::Type >( propertyValue, BLEND_FACTOR_TABLE, BLEND_FACTOR_TABLE_COUNT, destinationFactorAlpha ) )
443       {
444         SetBlendFunc( sourceFactorRgb, destinationFactorRgb, sourceFactorAlpha, destinationFactorAlpha );
445       }
446       break;
447     }
448     case Dali::Renderer::Property::BLEND_COLOR:
449     {
450       Vector4 blendColor;
451       if( propertyValue.Get( blendColor ) )
452       {
453         SetBlendColor( blendColor );
454       }
455       break;
456     }
457     case Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA:
458     {
459       bool preMultipled;
460       if( propertyValue.Get( preMultipled ) )
461       {
462         EnablePreMultipliedAlpha( preMultipled );
463       }
464       break;
465     }
466     case Dali::Renderer::Property::INDEX_RANGE_FIRST:
467     {
468       int32_t firstElement;
469       if( propertyValue.Get( firstElement ) )
470       {
471         SetIndexedDrawFirstElement( firstElement );
472       }
473       break;
474     }
475     case Dali::Renderer::Property::INDEX_RANGE_COUNT:
476     {
477       int32_t elementsCount;
478       if( propertyValue.Get( elementsCount ) )
479       {
480         SetIndexedDrawElementsCount( elementsCount );
481       }
482       break;
483     }
484     case Dali::Renderer::Property::DEPTH_WRITE_MODE:
485     {
486       DepthWriteMode::Type convertedValue = mDepthWriteMode;
487       if( Scripting::GetEnumerationProperty< DepthWriteMode::Type >( propertyValue, DEPTH_WRITE_MODE_TABLE, DEPTH_WRITE_MODE_TABLE_COUNT, convertedValue ) )
488       {
489         mDepthWriteMode = convertedValue;
490         SetDepthWriteModeMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
491       }
492       break;
493     }
494     case Dali::Renderer::Property::DEPTH_FUNCTION:
495     {
496       DepthFunction::Type convertedValue = mDepthFunction;
497       if( Scripting::GetEnumerationProperty< DepthFunction::Type >( propertyValue, DEPTH_FUNCTION_TABLE, DEPTH_FUNCTION_TABLE_COUNT, convertedValue ) )
498       {
499         mDepthFunction = convertedValue;
500         SetDepthFunctionMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
501       }
502       break;
503     }
504     case Dali::Renderer::Property::DEPTH_TEST_MODE:
505     {
506       DepthTestMode::Type convertedValue = mDepthTestMode;
507       if( Scripting::GetEnumerationProperty< DepthTestMode::Type >( propertyValue, DEPTH_TEST_MODE_TABLE, DEPTH_TEST_MODE_TABLE_COUNT, convertedValue ) )
508       {
509         mDepthTestMode = convertedValue;
510         SetDepthTestModeMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
511       }
512       break;
513     }
514     case Dali::Renderer::Property::RENDER_MODE:
515     {
516       RenderMode::Type convertedValue = mStencilParameters.renderMode;
517       if( Scripting::GetEnumerationProperty< RenderMode::Type >( propertyValue, RENDER_MODE_TABLE, RENDER_MODE_TABLE_COUNT, convertedValue ) )
518       {
519         mStencilParameters.renderMode = convertedValue;
520         SetRenderModeMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
521       }
522       break;
523     }
524     case Dali::Renderer::Property::STENCIL_FUNCTION:
525     {
526       StencilFunction::Type convertedValue = mStencilParameters.stencilFunction;
527       if( Scripting::GetEnumerationProperty< StencilFunction::Type >( propertyValue, STENCIL_FUNCTION_TABLE, STENCIL_FUNCTION_TABLE_COUNT, convertedValue ) )
528       {
529         mStencilParameters.stencilFunction = convertedValue;
530         SetStencilFunctionMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
531       }
532       break;
533     }
534     case Dali::Renderer::Property::STENCIL_FUNCTION_MASK:
535     {
536       int32_t stencilFunctionMask;
537       if( propertyValue.Get( stencilFunctionMask ) )
538       {
539         if( stencilFunctionMask != mStencilParameters.stencilFunctionMask )
540         {
541           mStencilParameters.stencilFunctionMask = stencilFunctionMask;
542           SetStencilFunctionMaskMessage( GetEventThreadServices(), GetRendererSceneObject(), stencilFunctionMask );
543         }
544       }
545       break;
546     }
547     case Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE:
548     {
549       int32_t stencilFunctionReference;
550       if( propertyValue.Get( stencilFunctionReference ) )
551       {
552         if( stencilFunctionReference != mStencilParameters.stencilFunctionReference )
553         {
554           mStencilParameters.stencilFunctionReference = stencilFunctionReference;
555           SetStencilFunctionReferenceMessage( GetEventThreadServices(), GetRendererSceneObject(), stencilFunctionReference );
556         }
557       }
558       break;
559     }
560     case Dali::Renderer::Property::STENCIL_MASK:
561     {
562       int32_t stencilMask;
563       if( propertyValue.Get( stencilMask ) )
564       {
565         if( stencilMask != mStencilParameters.stencilMask )
566         {
567           mStencilParameters.stencilMask = stencilMask;
568           SetStencilMaskMessage( GetEventThreadServices(), GetRendererSceneObject(), stencilMask );
569         }
570       }
571       break;
572     }
573     case Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL:
574     {
575       StencilOperation::Type convertedValue = mStencilParameters.stencilOperationOnFail;
576       if( Scripting::GetEnumerationProperty< StencilOperation::Type >( propertyValue, STENCIL_OPERATION_TABLE, STENCIL_OPERATION_TABLE_COUNT, convertedValue ) )
577       {
578         mStencilParameters.stencilOperationOnFail = convertedValue;
579         SetStencilOperationOnFailMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
580       }
581       break;
582     }
583     case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL:
584     {
585       StencilOperation::Type convertedValue = mStencilParameters.stencilOperationOnZFail;
586       if( Scripting::GetEnumerationProperty< StencilOperation::Type >( propertyValue, STENCIL_OPERATION_TABLE, STENCIL_OPERATION_TABLE_COUNT, convertedValue ) )
587       {
588         mStencilParameters.stencilOperationOnZFail = convertedValue;
589         SetStencilOperationOnZFailMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
590       }
591       break;
592     }
593     case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS:
594     {
595       StencilOperation::Type convertedValue = mStencilParameters.stencilOperationOnZPass;
596       if( Scripting::GetEnumerationProperty< StencilOperation::Type >( propertyValue, STENCIL_OPERATION_TABLE, STENCIL_OPERATION_TABLE_COUNT, convertedValue ) )
597       {
598         mStencilParameters.stencilOperationOnZPass = convertedValue;
599         SetStencilOperationOnZPassMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
600       }
601       break;
602     }
603     case Dali::DevelRenderer::Property::OPACITY:
604     {
605       float opacity;
606       if( propertyValue.Get( opacity ) )
607       {
608         if( !Equals( mOpacity, opacity ) )
609         {
610           mOpacity = opacity;
611           BakeOpacityMessage( GetEventThreadServices(), GetRendererSceneObject(), mOpacity );
612         }
613       }
614       break;
615     }
616     case DevelRenderer::Property::RENDERING_BEHAVIOR:
617     {
618       DevelRenderer::Rendering::Type convertedValue = mRenderingBehavior;
619       if( Scripting::GetEnumerationProperty< DevelRenderer::Rendering::Type >( propertyValue, RENDERING_BEHAVIOR_TABLE, RENDERING_BEHAVIOR_TABLE_COUNT, convertedValue ) )
620       {
621         mRenderingBehavior = convertedValue;
622         SetRenderingBehaviorMessage( GetEventThreadServices(), GetRendererSceneObject(), convertedValue );
623       }
624       break;
625     }
626   }
627 }
628
629 Property::Value Renderer::GetDefaultProperty( Property::Index index ) const
630 {
631   Property::Value value;
632
633   if( ! GetCachedPropertyValue( index, value ) )
634   {
635     // If property value is not stored in the event-side, then it must be a scene-graph only property
636     GetCurrentPropertyValue( index, value );
637   }
638
639   return value;
640 }
641
642 Property::Value Renderer::GetDefaultPropertyCurrentValue( Property::Index index ) const
643 {
644   Property::Value value;
645
646   if( ! GetCurrentPropertyValue( index, value ) )
647   {
648     // If unable to retrieve scene-graph property value, then it must be an event-side only property
649     GetCachedPropertyValue( index, value );
650   }
651
652   return value;
653 }
654
655 void Renderer::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
656 {
657   switch( animationType )
658   {
659     case Animation::TO:
660     case Animation::BETWEEN:
661     {
662       switch( index )
663       {
664         case Dali::DevelRenderer::Property::OPACITY:
665         {
666           value.Get( mOpacity );
667           break;
668         }
669       }
670       break;
671     }
672
673     case Animation::BY:
674     {
675       switch( index )
676       {
677         case Dali::DevelRenderer::Property::OPACITY:
678         {
679           AdjustValue< float >( mOpacity, value );
680           break;
681         }
682       }
683       break;
684     }
685   }
686 }
687
688 const SceneGraph::PropertyBase* Renderer::GetSceneObjectAnimatableProperty( Property::Index index ) const
689 {
690   const SceneGraph::PropertyBase* property = nullptr;
691
692   if( index == DevelRenderer::Property::OPACITY )
693   {
694     property = &GetRendererSceneObject().mOpacity;
695   }
696   if( !property )
697   {
698     // not our property, ask base
699     property = Object::GetSceneObjectAnimatableProperty( index );
700   }
701
702   return property;
703 }
704
705 const PropertyInputImpl* Renderer::GetSceneObjectInputProperty( Property::Index index ) const
706 {
707   // reuse animatable property getter, Object::GetSceneObjectInputProperty does the same so no need to call that0
708   return GetSceneObjectAnimatableProperty( index );
709 }
710
711 Renderer::Renderer( const SceneGraph::Renderer* sceneObject )
712 : Object( sceneObject ),
713   mDepthIndex( 0 ),
714   mIndexedDrawFirstElement( 0 ),
715   mIndexedDrawElementCount( 0 ),
716   mStencilParameters( RenderMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP ),
717   mBlendingOptions(),
718   mOpacity( 1.0f ),
719   mDepthFunction( DepthFunction::LESS ),
720   mFaceCullingMode( FaceCullingMode::NONE ),
721   mBlendMode( BlendMode::AUTO ),
722   mDepthWriteMode( DepthWriteMode::AUTO ),
723   mDepthTestMode( DepthTestMode::AUTO ),
724   mRenderingBehavior( DevelRenderer::Rendering::IF_REQUIRED ),
725   mPremultipledAlphaEnabled( false )
726 {
727 }
728
729 void Renderer::SetBlendColor( const Vector4& blendColor )
730 {
731   mBlendingOptions.SetBlendColor( blendColor );
732   SetBlendColorMessage( GetEventThreadServices(), GetRendererSceneObject(), GetBlendColor() );
733 }
734
735 const Vector4& Renderer::GetBlendColor() const
736 {
737   const Vector4* blendColor = mBlendingOptions.GetBlendColor();
738   if( blendColor )
739   {
740     return *blendColor;
741   }
742   return Color::TRANSPARENT; // GL default
743 }
744
745 Renderer::~Renderer()
746 {
747   if( EventThreadServices::IsCoreRunning() )
748   {
749     EventThreadServices& eventThreadServices = GetEventThreadServices();
750     SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
751     RemoveRendererMessage( updateManager, GetRendererSceneObject() );
752
753     eventThreadServices.UnregisterObject( this );
754   }
755 }
756
757 bool Renderer::GetCachedPropertyValue( Property::Index index, Property::Value& value ) const
758 {
759   bool valueSet = true;
760
761   switch( index )
762   {
763     case Dali::Renderer::Property::DEPTH_INDEX:
764     {
765       value = GetDepthIndex();
766       break;
767     }
768     case Dali::Renderer::Property::FACE_CULLING_MODE:
769     {
770       value = mFaceCullingMode;
771       break;
772     }
773     case Dali::Renderer::Property::BLEND_MODE:
774     {
775       value = mBlendMode;
776       break;
777     }
778     case Dali::Renderer::Property::BLEND_EQUATION_RGB:
779     {
780       value = static_cast<int32_t>( mBlendingOptions.GetBlendEquationRgb() );
781       break;
782     }
783     case Dali::Renderer::Property::BLEND_EQUATION_ALPHA:
784     {
785       value = static_cast<int32_t>( mBlendingOptions.GetBlendEquationAlpha() );
786       break;
787     }
788     case Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB:
789     {
790       BlendFactor::Type srcFactorRgb;
791       BlendFactor::Type destFactorRgb;
792       BlendFactor::Type srcFactorAlpha;
793       BlendFactor::Type destFactorAlpha;
794       GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
795       value = static_cast<int32_t>( srcFactorRgb );
796       break;
797     }
798     case Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB:
799     {
800       BlendFactor::Type srcFactorRgb;
801       BlendFactor::Type destFactorRgb;
802       BlendFactor::Type srcFactorAlpha;
803       BlendFactor::Type destFactorAlpha;
804       GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
805       value = static_cast<int32_t>( destFactorRgb );
806       break;
807     }
808     case Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA:
809     {
810       BlendFactor::Type srcFactorRgb;
811       BlendFactor::Type destFactorRgb;
812       BlendFactor::Type srcFactorAlpha;
813       BlendFactor::Type destFactorAlpha;
814       GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
815       value = static_cast<int32_t>( srcFactorAlpha );
816       break;
817     }
818     case Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA:
819     {
820       BlendFactor::Type srcFactorRgb;
821       BlendFactor::Type destFactorRgb;
822       BlendFactor::Type srcFactorAlpha;
823       BlendFactor::Type destFactorAlpha;
824       GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
825       value = static_cast<int32_t>( destFactorAlpha );
826       break;
827     }
828     case Dali::Renderer::Property::BLEND_COLOR:
829     {
830       value = GetBlendColor();
831       break;
832     }
833     case Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA:
834     {
835       value = IsPreMultipliedAlphaEnabled();
836       break;
837     }
838     case Dali::Renderer::Property::INDEX_RANGE_FIRST:
839     {
840       value = static_cast<int32_t>( mIndexedDrawFirstElement );
841       break;
842     }
843     case Dali::Renderer::Property::INDEX_RANGE_COUNT:
844     {
845       value = static_cast<int32_t>( mIndexedDrawElementCount );
846       break;
847     }
848     case Dali::Renderer::Property::DEPTH_WRITE_MODE:
849     {
850       value = mDepthWriteMode;
851       break;
852     }
853     case Dali::Renderer::Property::DEPTH_FUNCTION:
854     {
855       value = mDepthFunction;
856       break;
857     }
858     case Dali::Renderer::Property::DEPTH_TEST_MODE:
859     {
860       value = mDepthTestMode;
861       break;
862     }
863     case Dali::Renderer::Property::STENCIL_FUNCTION:
864     {
865       value = mStencilParameters.stencilFunction;
866       break;
867     }
868     case Dali::Renderer::Property::STENCIL_FUNCTION_MASK:
869     {
870       value = mStencilParameters.stencilFunctionMask;
871       break;
872     }
873     case Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE:
874     {
875       value = mStencilParameters.stencilFunctionReference;
876       break;
877     }
878     case Dali::Renderer::Property::STENCIL_MASK:
879     {
880       value = mStencilParameters.stencilMask;
881       break;
882     }
883     case Dali::Renderer::Property::RENDER_MODE:
884     {
885       value = mStencilParameters.renderMode;
886       break;
887     }
888     case Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL:
889     {
890       value = mStencilParameters.stencilOperationOnFail;
891       break;
892     }
893     case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL:
894     {
895       value = mStencilParameters.stencilOperationOnZFail;
896       break;
897     }
898     case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS:
899     {
900       value = mStencilParameters.stencilOperationOnZPass;
901       break;
902     }
903     case Dali::DevelRenderer::Property::OPACITY:
904     {
905       value = mOpacity;
906       break;
907     }
908     case Dali::DevelRenderer::Property::RENDERING_BEHAVIOR:
909     {
910       value = mRenderingBehavior;
911       break;
912     }
913     default:
914     {
915       // Must be a scene-graph only property
916       valueSet = false;
917       break;
918     }
919   }
920
921   return valueSet;
922 }
923
924 bool Renderer::GetCurrentPropertyValue( Property::Index index, Property::Value& value  ) const
925 {
926   bool valueSet = true;
927   const SceneGraph::Renderer& sceneObject = GetRendererSceneObject();
928
929   switch( index )
930   {
931     case Dali::Renderer::Property::DEPTH_INDEX:
932     {
933       value = sceneObject.GetDepthIndex();
934       break;
935     }
936     case Dali::Renderer::Property::FACE_CULLING_MODE:
937     {
938       value = sceneObject.GetFaceCullingMode();
939       break;
940     }
941     case Dali::Renderer::Property::BLEND_MODE:
942     {
943       value = sceneObject.GetBlendMode();
944       break;
945     }
946     case Dali::Renderer::Property::BLEND_EQUATION_RGB:
947     {
948       uint32_t bitMask = sceneObject.GetBlendingOptions();
949       BlendingOptions blendingOptions;
950       blendingOptions.SetBitmask( bitMask );
951       value = static_cast<int32_t>( blendingOptions.GetBlendEquationRgb() );
952       break;
953     }
954     case Dali::Renderer::Property::BLEND_EQUATION_ALPHA:
955     {
956       uint32_t bitMask = sceneObject.GetBlendingOptions();
957       BlendingOptions blendingOptions;
958       blendingOptions.SetBitmask( bitMask );
959       value = static_cast<int32_t>( blendingOptions.GetBlendEquationAlpha() );
960       break;
961     }
962     case Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB:
963     {
964       uint32_t bitMask = sceneObject.GetBlendingOptions();
965       BlendingOptions blendingOptions;
966       blendingOptions.SetBitmask( bitMask );
967       value = static_cast<int32_t>( blendingOptions.GetBlendSrcFactorRgb() );
968       break;
969     }
970     case Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB:
971     {
972       uint32_t bitMask = sceneObject.GetBlendingOptions();
973       BlendingOptions blendingOptions;
974       blendingOptions.SetBitmask( bitMask );
975       value = static_cast<int32_t>( blendingOptions.GetBlendDestFactorRgb() );
976       break;
977     }
978     case Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA:
979     {
980       uint32_t bitMask = sceneObject.GetBlendingOptions();
981       BlendingOptions blendingOptions;
982       blendingOptions.SetBitmask( bitMask );
983       value = static_cast<int32_t>( blendingOptions.GetBlendSrcFactorAlpha() );
984       break;
985     }
986     case Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA:
987     {
988       uint32_t bitMask = sceneObject.GetBlendingOptions();
989       BlendingOptions blendingOptions;
990       blendingOptions.SetBitmask( bitMask );
991       value = static_cast<int32_t>( blendingOptions.GetBlendDestFactorAlpha() );
992       break;
993     }
994     case Dali::Renderer::Property::BLEND_COLOR:
995     {
996       value = sceneObject.GetBlendColor();
997       break;
998     }
999     case Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA:
1000     {
1001       value = sceneObject.IsPreMultipliedAlphaEnabled();
1002       break;
1003     }
1004     case Dali::Renderer::Property::INDEX_RANGE_FIRST:
1005     {
1006       value = static_cast<int32_t>( sceneObject.GetIndexedDrawFirstElement() );
1007       break;
1008     }
1009     case Dali::Renderer::Property::INDEX_RANGE_COUNT:
1010     {
1011       value = static_cast<int32_t>( sceneObject.GetIndexedDrawElementsCount() );
1012       break;
1013     }
1014     case Dali::Renderer::Property::DEPTH_WRITE_MODE:
1015     {
1016       value = sceneObject.GetDepthWriteMode();
1017       break;
1018     }
1019     case Dali::Renderer::Property::DEPTH_FUNCTION:
1020     {
1021       value = sceneObject.GetDepthFunction();
1022       break;
1023     }
1024     case Dali::Renderer::Property::DEPTH_TEST_MODE:
1025     {
1026       value = sceneObject.GetDepthTestMode();
1027       break;
1028     }
1029     case Dali::Renderer::Property::STENCIL_FUNCTION:
1030     {
1031       Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
1032       value = stencilParameters.stencilFunction;
1033       break;
1034     }
1035     case Dali::Renderer::Property::STENCIL_FUNCTION_MASK:
1036     {
1037       Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
1038       value = stencilParameters.stencilFunctionMask;
1039       break;
1040     }
1041     case Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE:
1042     {
1043       Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
1044       value = stencilParameters.stencilFunctionReference;
1045       break;
1046     }
1047     case Dali::Renderer::Property::STENCIL_MASK:
1048     {
1049       Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
1050       value = stencilParameters.stencilMask;
1051       break;
1052     }
1053     case Dali::Renderer::Property::RENDER_MODE:
1054     {
1055       Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
1056       value = stencilParameters.renderMode;
1057       break;
1058     }
1059     case Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL:
1060     {
1061       Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
1062       value = stencilParameters.stencilOperationOnFail;
1063       break;
1064     }
1065     case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL:
1066     {
1067       Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
1068       value = stencilParameters.stencilOperationOnZFail;
1069       break;
1070     }
1071     case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS:
1072     {
1073       Render::Renderer::StencilParameters stencilParameters = sceneObject.GetStencilParameters();
1074       value = stencilParameters.stencilOperationOnZPass;
1075       break;
1076     }
1077     case Dali::DevelRenderer::Property::OPACITY:
1078     {
1079       value = sceneObject.GetOpacity( GetEventThreadServices().GetEventBufferIndex() );
1080       break;
1081     }
1082     case Dali::DevelRenderer::Property::RENDERING_BEHAVIOR:
1083     {
1084       value = sceneObject.GetRenderingBehavior();
1085       break;
1086     }
1087     default:
1088     {
1089       // Must be an event-side only property
1090       valueSet = false;
1091       break;
1092     }
1093   }
1094
1095   return valueSet;
1096 }
1097
1098 void Renderer::AddDrawCommand( const Dali::DevelRenderer::DrawCommand& command )
1099 {
1100   if(!mDrawCommands.capacity())
1101   {
1102     mDrawCommands.reserve(8);
1103   }
1104
1105   mDrawCommands.emplace_back( command );
1106
1107   Dali::Internal::SceneGraph::SetDrawCommandsMessage( GetEventThreadServices(),
1108                                                       GetRendererSceneObject(),
1109                                                       mDrawCommands.data(),
1110                                                       uint32_t(mDrawCommands.size())
1111
1112   );
1113 }
1114
1115
1116 } // namespace Internal
1117
1118 } // namespace Dali