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