Remove Geometry scene object
[platform/core/uifw/dali-core.git] / dali / internal / event / rendering / renderer-impl.cpp
1 /*
2  * Copyright (c) 2015 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/public-api/object/type-registry.h>
23 #include <dali/devel-api/rendering/renderer.h> // Dali::Renderer
24 #include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
25 #include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
26 #include <dali/internal/event/common/property-input-impl.h>
27 #include <dali/internal/update/rendering/scene-graph-renderer.h>
28 #include <dali/internal/update/manager/update-manager.h>
29 #include <dali/internal/render/renderers/render-geometry.h>
30
31 namespace Dali
32 {
33 namespace Internal
34 {
35
36 namespace
37 {
38
39 /**
40  *            |name                              |type     |writable|animatable|constraint-input|enum for index-checking|
41  */
42 DALI_PROPERTY_TABLE_BEGIN
43 DALI_PROPERTY( "depthIndex",                      INTEGER,   true, false,  false, Dali::Renderer::Property::DEPTH_INDEX )
44 DALI_PROPERTY( "faceCullingMode",                 INTEGER,   true, false,  false, Dali::Renderer::Property::FACE_CULLING_MODE )
45 DALI_PROPERTY( "blendingMode",                    INTEGER,   true, false,  false, Dali::Renderer::Property::BLENDING_MODE )
46 DALI_PROPERTY( "blendEquationRgb",                INTEGER,   true, false,  false, Dali::Renderer::Property::BLEND_EQUATION_RGB )
47 DALI_PROPERTY( "blendEquationAlpha",              INTEGER,   true, false,  false, Dali::Renderer::Property::BLEND_EQUATION_ALPHA )
48 DALI_PROPERTY( "sourceBlendFactorRgb",            INTEGER,   true, false,  false, Dali::Renderer::Property::BLENDING_SRC_FACTOR_RGB )
49 DALI_PROPERTY( "destinationBlendFactorRgb",       INTEGER,   true, false,  false, Dali::Renderer::Property::BLENDING_DEST_FACTOR_RGB )
50 DALI_PROPERTY( "sourceBlendFactorAlpha",          INTEGER,   true, false,  false, Dali::Renderer::Property::BLENDING_SRC_FACTOR_ALPHA )
51 DALI_PROPERTY( "destinationBlendFactorAlpha",     INTEGER,   true, false,  false, Dali::Renderer::Property::BLENDING_DEST_FACTOR_ALPHA )
52 DALI_PROPERTY( "blendingColor",                   VECTOR4,   true, false,  false, Dali::Renderer::Property::BLENDING_COLOR )
53 DALI_PROPERTY( "blendPreMultipliedAlpha",         BOOLEAN,   true, false,  false, Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA )
54 DALI_PROPERTY( "indexRangeFirst",                 INTEGER,   true, false,  false, Dali::Renderer::Property::INDEX_RANGE_FIRST )
55 DALI_PROPERTY( "indexRangeCount",                 INTEGER,   true, false,  false, Dali::Renderer::Property::INDEX_RANGE_COUNT )
56 DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX )
57
58 const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> RENDERER_IMPL = { DEFAULT_PROPERTY_DETAILS };
59
60 BaseHandle Create()
61 {
62   return Dali::BaseHandle();
63 }
64
65 TypeRegistration mType( typeid( Dali::Renderer ), typeid( Dali::Handle ), Create );
66
67 } // unnamed namespace
68
69 RendererPtr Renderer::New()
70 {
71   RendererPtr rendererPtr( new Renderer() );
72   rendererPtr->Initialize();
73   return rendererPtr;
74 }
75
76 void Renderer::SetGeometry( Geometry& geometry )
77 {
78   mGeometry = &geometry;
79
80   const Render::Geometry* geometrySceneObject = geometry.GetRenderObject();
81   SetGeometryMessage( GetEventThreadServices(), *mSceneObject, *geometrySceneObject );
82 }
83
84 Geometry* Renderer::GetGeometry() const
85 {
86   return mGeometry.Get();
87 }
88
89 void Renderer::SetTextures( TextureSet& textureSet )
90 {
91   mTextureSetConnector.Set( textureSet, OnStage() );
92   const SceneGraph::TextureSet* textureSetSceneObject = textureSet.GetTextureSetSceneObject();
93   SetTexturesMessage( GetEventThreadServices(), *mSceneObject, *textureSetSceneObject );
94 }
95
96 TextureSet* Renderer::GetTextures() const
97 {
98   return mTextureSetConnector.Get().Get();
99 }
100
101 void Renderer::SetShader( Shader& shader )
102 {
103   mShader = &shader;
104   SceneGraph::Shader& sceneGraphShader = *shader.GetShaderSceneObject();
105   SceneGraph::SetShaderMessage( GetEventThreadServices(), *mSceneObject, sceneGraphShader );
106 }
107
108 Shader* Renderer::GetShader() const
109 {
110   return mShader.Get();
111 }
112
113 void Renderer::SetDepthIndex( int depthIndex )
114 {
115   if ( mDepthIndex != depthIndex )
116   {
117     mDepthIndex = depthIndex;
118     SetDepthIndexMessage( GetEventThreadServices(), *mSceneObject, depthIndex );
119   }
120 }
121
122 int Renderer::GetDepthIndex() const
123 {
124   return mDepthIndex;
125 }
126
127 void Renderer::SetFaceCullingMode( Dali::Renderer::FaceCullingMode cullingMode )
128 {
129   if( mFaceCullingMode != cullingMode )
130   {
131     mFaceCullingMode = cullingMode;
132
133     SetFaceCullingModeMessage( GetEventThreadServices(), *mSceneObject, mFaceCullingMode );
134   }
135 }
136
137 Dali::Renderer::FaceCullingMode Renderer::GetFaceCullingMode()
138 {
139   return mFaceCullingMode;
140 }
141
142 void Renderer::SetBlendMode( BlendingMode::Type mode )
143 {
144   if( mBlendingMode != mode )
145   {
146     mBlendingMode = mode;
147
148     SetBlendingModeMessage( GetEventThreadServices(), *mSceneObject, mBlendingMode );
149   }
150 }
151
152 BlendingMode::Type Renderer::GetBlendMode() const
153 {
154   return mBlendingMode;
155 }
156
157 void Renderer::SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba )
158 {
159   mBlendingOptions.SetBlendFunc( srcFactorRgba, destFactorRgba, srcFactorRgba, destFactorRgba );
160   SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
161 }
162
163 void Renderer::SetBlendFunc( BlendingFactor::Type srcFactorRgb,
164                              BlendingFactor::Type destFactorRgb,
165                              BlendingFactor::Type srcFactorAlpha,
166                              BlendingFactor::Type destFactorAlpha )
167 {
168   mBlendingOptions.SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
169   SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
170 }
171
172 void Renderer::GetBlendFunc( BlendingFactor::Type& srcFactorRgb,
173                              BlendingFactor::Type& destFactorRgb,
174                              BlendingFactor::Type& srcFactorAlpha,
175                              BlendingFactor::Type& destFactorAlpha ) const
176 {
177   srcFactorRgb    = mBlendingOptions.GetBlendSrcFactorRgb();
178   destFactorRgb   = mBlendingOptions.GetBlendDestFactorRgb();
179   srcFactorAlpha  = mBlendingOptions.GetBlendSrcFactorAlpha();
180   destFactorAlpha = mBlendingOptions.GetBlendDestFactorAlpha();
181 }
182
183 void Renderer::SetBlendEquation( BlendingEquation::Type equationRgba )
184 {
185   mBlendingOptions.SetBlendEquation( equationRgba, equationRgba );
186   SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
187 }
188
189 void Renderer::SetBlendEquation( BlendingEquation::Type equationRgb,
190                                  BlendingEquation::Type equationAlpha )
191 {
192   mBlendingOptions.SetBlendEquation( equationRgb, equationAlpha );
193   SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
194 }
195
196 void Renderer::GetBlendEquation( BlendingEquation::Type& equationRgb,
197                                  BlendingEquation::Type& equationAlpha ) const
198 {
199   // These are not animatable, the cached values are up-to-date.
200   equationRgb   = mBlendingOptions.GetBlendEquationRgb();
201   equationAlpha = mBlendingOptions.GetBlendEquationAlpha();
202 }
203
204 void Renderer::SetBlendColor( const Vector4& color )
205 {
206   if( !mBlendColor )
207   {
208     mBlendColor = new Vector4();
209   }
210   if( *mBlendColor != color )
211   {
212     *mBlendColor = color;
213     SetBlendColorMessage( GetEventThreadServices(), *mSceneObject, *mBlendColor );
214   }
215 }
216
217 Vector4 Renderer::GetBlendColor() const
218 {
219   if( mBlendColor )
220   {
221     return *mBlendColor;
222   }
223   return Color::TRANSPARENT; // GL default
224 }
225
226 void Renderer::SetIndexedDrawFirstElement( size_t firstElement )
227 {
228   if( firstElement != mIndexedDrawFirstElement )
229   {
230     mIndexedDrawFirstElement = firstElement;
231     SetIndexedDrawFirstElementMessage( GetEventThreadServices(), *mSceneObject, mIndexedDrawFirstElement );
232   }
233 }
234
235 void Renderer::SetIndexedDrawElementsCount( size_t elementsCount )
236 {
237   if( elementsCount != mIndexedDrawElementCount )
238   {
239     mIndexedDrawElementCount = elementsCount;
240     SetIndexedDrawElementsCountMessage( GetEventThreadServices(), *mSceneObject, mIndexedDrawElementCount );
241   }
242 }
243
244
245 void Renderer::EnablePreMultipliedAlpha( bool preMultipled )
246 {
247   if(  mPremultipledAlphaEnabled != preMultipled )
248   {
249     if( preMultipled )
250     {
251       SetBlendFunc( BlendingFactor::ONE, BlendingFactor::ONE_MINUS_SRC_ALPHA, BlendingFactor::ONE, BlendingFactor::ONE );
252     }
253     mPremultipledAlphaEnabled = preMultipled;
254     SetEnablePreMultipliedAlphaMessage( GetEventThreadServices(), *mSceneObject, mPremultipledAlphaEnabled );
255   }
256 }
257
258 bool Renderer::IsPreMultipliedAlphaEnabled() const
259 {
260   return mPremultipledAlphaEnabled;
261 }
262
263 SceneGraph::Renderer* Renderer::GetRendererSceneObject()
264 {
265   return mSceneObject;
266 }
267
268 unsigned int Renderer::GetDefaultPropertyCount() const
269 {
270   return RENDERER_IMPL.GetDefaultPropertyCount();
271 }
272
273 void Renderer::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
274 {
275   RENDERER_IMPL.GetDefaultPropertyIndices( indices );
276 }
277
278 const char* Renderer::GetDefaultPropertyName(Property::Index index) const
279 {
280   return RENDERER_IMPL.GetDefaultPropertyName( index );
281 }
282
283 Property::Index Renderer::GetDefaultPropertyIndex( const std::string& name ) const
284 {
285   return RENDERER_IMPL.GetDefaultPropertyIndex( name );
286 }
287
288 bool Renderer::IsDefaultPropertyWritable( Property::Index index ) const
289 {
290   return RENDERER_IMPL.IsDefaultPropertyWritable( index );
291 }
292
293 bool Renderer::IsDefaultPropertyAnimatable( Property::Index index ) const
294 {
295   return RENDERER_IMPL.IsDefaultPropertyAnimatable( index );
296 }
297
298 bool Renderer::IsDefaultPropertyAConstraintInput( Property::Index index ) const
299 {
300   return RENDERER_IMPL.IsDefaultPropertyAConstraintInput( index );
301 }
302
303 Property::Type Renderer::GetDefaultPropertyType( Property::Index index ) const
304 {
305   return RENDERER_IMPL.GetDefaultPropertyType( index );
306 }
307
308 void Renderer::SetDefaultProperty( Property::Index index,
309                                    const Property::Value& propertyValue )
310 {
311   switch( index )
312   {
313     case Dali::Renderer::Property::DEPTH_INDEX:
314     {
315       SetDepthIndex( propertyValue.Get<int>() );
316       break;
317     }
318     case Dali::Renderer::Property::FACE_CULLING_MODE:
319     {
320       int faceCullingMode;
321       if( propertyValue.Get( faceCullingMode ) )
322       {
323         SetFaceCullingMode( Dali::Renderer::FaceCullingMode( faceCullingMode ) );
324       }
325       break;
326     }
327     case Dali::Renderer::Property::BLENDING_MODE:
328     {
329       int blendingMode;
330       if( propertyValue.Get( blendingMode ) )
331       {
332         SetBlendMode( BlendingMode::Type( blendingMode ) );
333       }
334       break;
335     }
336     case Dali::Renderer::Property::BLEND_EQUATION_RGB:
337     {
338       int blendingEquation;
339       if( propertyValue.Get( blendingEquation ) )
340       {
341         BlendingEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
342         mBlendingOptions.SetBlendEquation( static_cast<BlendingEquation::Type>( blendingEquation ), alphaEquation );
343         SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
344       }
345       break;
346     }
347     case Dali::Renderer::Property::BLEND_EQUATION_ALPHA:
348     {
349       int blendingEquation;
350       if( propertyValue.Get( blendingEquation ) )
351       {
352         BlendingEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb();
353         mBlendingOptions.SetBlendEquation( rgbEquation, static_cast<BlendingEquation::Type>( blendingEquation ) );
354         SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
355       }
356       break;
357     }
358     case Dali::Renderer::Property::BLENDING_SRC_FACTOR_RGB:
359     {
360       int blendingFactor;
361       if( propertyValue.Get( blendingFactor ) )
362       {
363         BlendingFactor::Type srcFactorRgb;
364         BlendingFactor::Type destFactorRgb;
365         BlendingFactor::Type srcFactorAlpha;
366         BlendingFactor::Type destFactorAlpha;
367         GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
368         SetBlendFunc( static_cast<BlendingFactor::Type>( blendingFactor ),
369             destFactorRgb,
370             srcFactorAlpha,
371             destFactorAlpha );
372       }
373       break;
374     }
375     case Dali::Renderer::Property::BLENDING_DEST_FACTOR_RGB:
376     {
377       int blendingFactor;
378       if( propertyValue.Get( blendingFactor ) )
379       {
380         BlendingFactor::Type srcFactorRgb;
381         BlendingFactor::Type destFactorRgb;
382         BlendingFactor::Type srcFactorAlpha;
383         BlendingFactor::Type destFactorAlpha;
384         GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
385         SetBlendFunc( srcFactorRgb,
386             static_cast<BlendingFactor::Type>( blendingFactor ),
387             srcFactorAlpha,
388             destFactorAlpha );
389       }
390       break;
391     }
392     case Dali::Renderer::Property::BLENDING_SRC_FACTOR_ALPHA:
393     {
394       int blendingFactor;
395       if( propertyValue.Get( blendingFactor ) )
396       {
397         BlendingFactor::Type srcFactorRgb;
398         BlendingFactor::Type destFactorRgb;
399         BlendingFactor::Type srcFactorAlpha;
400         BlendingFactor::Type destFactorAlpha;
401         GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
402         SetBlendFunc( srcFactorRgb,
403             destFactorRgb,
404             static_cast<BlendingFactor::Type>( blendingFactor ),
405             destFactorAlpha );
406       }
407       break;
408     }
409     case Dali::Renderer::Property::BLENDING_DEST_FACTOR_ALPHA:
410     {
411       int blendingFactor;
412       if( propertyValue.Get( blendingFactor ) )
413       {
414         BlendingFactor::Type srcFactorRgb;
415         BlendingFactor::Type destFactorRgb;
416         BlendingFactor::Type srcFactorAlpha;
417         BlendingFactor::Type destFactorAlpha;
418         GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
419         SetBlendFunc( srcFactorRgb,
420             destFactorRgb,
421             srcFactorAlpha,
422             static_cast<BlendingFactor::Type>( blendingFactor ) );
423       }
424       break;
425     }
426     case Dali::Renderer::Property::BLENDING_COLOR:
427     {
428       Vector4 blendColor;
429       if( propertyValue.Get( blendColor ) )
430       {
431         SetBlendColor( blendColor );
432       }
433       break;
434     }
435     case Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA:
436     {
437       bool preMultipled;
438       if( propertyValue.Get( preMultipled ) )
439       {
440         EnablePreMultipliedAlpha( preMultipled );
441       }
442       break;
443     }
444     case Dali::Renderer::Property::INDEX_RANGE_FIRST:
445     {
446       int firstElement;
447       if( propertyValue.Get( firstElement ) )
448       {
449         SetIndexedDrawFirstElement( firstElement );
450       }
451       break;
452     }
453     case Dali::Renderer::Property::INDEX_RANGE_COUNT:
454     {
455       int elementsCount;
456       if( propertyValue.Get( elementsCount ) )
457       {
458         SetIndexedDrawElementsCount( elementsCount );
459       }
460       break;
461     }
462   }
463 }
464
465 void Renderer::SetSceneGraphProperty( Property::Index index,
466                                       const PropertyMetadata& entry,
467                                       const Property::Value& value )
468 {
469   RENDERER_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
470   OnPropertySet(index, value);
471 }
472
473 Property::Value Renderer::GetDefaultProperty( Property::Index index ) const
474 {
475   Property::Value value;
476   switch( index )
477   {
478     case Dali::Renderer::Property::DEPTH_INDEX:
479     {
480       value = GetDepthIndex();
481       break;
482     }
483     case Dali::Renderer::Property::FACE_CULLING_MODE:
484     {
485       value = mFaceCullingMode;
486       break;
487     }
488     case Dali::Renderer::Property::BLENDING_MODE:
489     {
490       value = mBlendingMode;
491       break;
492     }
493     case Dali::Renderer::Property::BLEND_EQUATION_RGB:
494     {
495       value = static_cast<int>( mBlendingOptions.GetBlendEquationRgb() );
496       break;
497     }
498     case Dali::Renderer::Property::BLEND_EQUATION_ALPHA:
499     {
500       value = static_cast<int>( mBlendingOptions.GetBlendEquationAlpha() );
501       break;
502     }
503     case Dali::Renderer::Property::BLENDING_SRC_FACTOR_RGB:
504     {
505       BlendingFactor::Type srcFactorRgb;
506       BlendingFactor::Type destFactorRgb;
507       BlendingFactor::Type srcFactorAlpha;
508       BlendingFactor::Type destFactorAlpha;
509       GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
510       value = static_cast<int>( srcFactorRgb );
511       break;
512     }
513     case Dali::Renderer::Property::BLENDING_DEST_FACTOR_RGB:
514     {
515       BlendingFactor::Type srcFactorRgb;
516       BlendingFactor::Type destFactorRgb;
517       BlendingFactor::Type srcFactorAlpha;
518       BlendingFactor::Type destFactorAlpha;
519       GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
520       value = static_cast<int>( destFactorRgb );
521       break;
522     }
523     case Dali::Renderer::Property::BLENDING_SRC_FACTOR_ALPHA:
524     {
525       BlendingFactor::Type srcFactorRgb;
526       BlendingFactor::Type destFactorRgb;
527       BlendingFactor::Type srcFactorAlpha;
528       BlendingFactor::Type destFactorAlpha;
529       GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
530       value = static_cast<int>( srcFactorAlpha );
531       break;
532     }
533     case Dali::Renderer::Property::BLENDING_DEST_FACTOR_ALPHA:
534     {
535       BlendingFactor::Type srcFactorRgb;
536       BlendingFactor::Type destFactorRgb;
537       BlendingFactor::Type srcFactorAlpha;
538       BlendingFactor::Type destFactorAlpha;
539       GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
540       value = static_cast<int>( destFactorAlpha );
541       break;
542     }
543     case Dali::Renderer::Property::BLENDING_COLOR:
544     {
545       if( mBlendColor )
546       {
547         value = *mBlendColor;
548       }
549       else
550       {
551         value = Color::TRANSPARENT;
552       }
553       break;
554     }
555     case Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA:
556     {
557       value = IsPreMultipliedAlphaEnabled();
558       break;
559     }
560     case Dali::Renderer::Property::INDEX_RANGE_FIRST:
561     {
562       value = static_cast<int>( mIndexedDrawFirstElement );
563       break;
564     }
565     case Dali::Renderer::Property::INDEX_RANGE_COUNT:
566     {
567       value = static_cast<int>( mIndexedDrawElementCount );
568       break;
569     }
570   }
571   return value;
572 }
573
574 const SceneGraph::PropertyOwner* Renderer::GetPropertyOwner() const
575 {
576   return mSceneObject;
577 }
578
579 const SceneGraph::PropertyOwner* Renderer::GetSceneObject() const
580 {
581   return mSceneObject;
582 }
583
584 const SceneGraph::PropertyBase* Renderer::GetSceneObjectAnimatableProperty( Property::Index index ) const
585 {
586   DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" );
587   const SceneGraph::PropertyBase* property = NULL;
588
589   if( OnStage() )
590   {
591     property = RENDERER_IMPL.GetRegisteredSceneGraphProperty(
592       this,
593       &Renderer::FindAnimatableProperty,
594       &Renderer::FindCustomProperty,
595       index );
596   }
597
598   return property;
599 }
600
601 const PropertyInputImpl* Renderer::GetSceneObjectInputProperty( Property::Index index ) const
602 {
603   const PropertyInputImpl* property = NULL;
604
605   if( OnStage() )
606   {
607     const SceneGraph::PropertyBase* baseProperty =
608       RENDERER_IMPL.GetRegisteredSceneGraphProperty( this,
609                                                      &Renderer::FindAnimatableProperty,
610                                                      &Renderer::FindCustomProperty,
611                                                      index );
612     property = static_cast<const PropertyInputImpl*>( baseProperty );
613   }
614
615   return property;
616 }
617
618 int Renderer::GetPropertyComponentIndex( Property::Index index ) const
619 {
620   return Property::INVALID_COMPONENT_INDEX;
621 }
622
623 bool Renderer::OnStage() const
624 {
625   return mOnStageCount > 0;
626 }
627
628 void Renderer::Connect()
629 {
630   if( mOnStageCount == 0 )
631   {
632     OnStageConnectMessage( GetEventThreadServices(), *mSceneObject );
633     mTextureSetConnector.OnStageConnect();
634   }
635   ++mOnStageCount;
636 }
637
638 void Renderer::Disconnect()
639 {
640   --mOnStageCount;
641   if( mOnStageCount == 0 )
642   {
643     OnStageDisconnectMessage( GetEventThreadServices(), *mSceneObject);
644     mTextureSetConnector.OnStageDisconnect();
645   }
646 }
647
648 Renderer::Renderer()
649 : mSceneObject (NULL ),
650   mBlendColor( NULL ),
651   mDepthIndex( 0 ),
652   mOnStageCount( 0 ),
653   mIndexedDrawFirstElement( 0 ),
654   mIndexedDrawElementCount( 0 ),
655   mFaceCullingMode( Dali::Renderer::NONE ),
656   mBlendingMode( Dali::BlendingMode::AUTO ),
657   mBlendingOptions(),
658   mPremultipledAlphaEnabled( false )
659 {
660 }
661
662 void Renderer::Initialize()
663 {
664   EventThreadServices& eventThreadServices = GetEventThreadServices();
665   SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
666
667   mSceneObject = SceneGraph::Renderer::New();
668   AddMessage( updateManager, updateManager.GetRendererOwner(), *mSceneObject );
669
670   eventThreadServices.RegisterObject( this );
671 }
672
673 Renderer::~Renderer()
674 {
675   if( EventThreadServices::IsCoreRunning() )
676   {
677     EventThreadServices& eventThreadServices = GetEventThreadServices();
678     SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
679     RemoveMessage( updateManager, updateManager.GetRendererOwner(), *mSceneObject );
680
681     eventThreadServices.UnregisterObject( this );
682   }
683 }
684
685 } // namespace Internal
686 } // namespace Dali