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