2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/event/rendering/renderer-impl.h> // Dali::Internal::Renderer
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
24 #include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
25 #include <dali/internal/event/common/property-input-impl.h>
26 #include <dali/internal/render/renderers/render-geometry.h>
27 #include <dali/internal/update/manager/update-manager.h>
28 #include <dali/internal/update/rendering/scene-graph-renderer.h>
39 * |name |type |writable|animatable|constraint-input|enum for index-checking|
41 DALI_PROPERTY_TABLE_BEGIN
42 DALI_PROPERTY( "depthIndex", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_INDEX )
43 DALI_PROPERTY( "faceCullingMode", INTEGER, true, false, false, Dali::Renderer::Property::FACE_CULLING_MODE )
44 DALI_PROPERTY( "blendMode", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_MODE )
45 DALI_PROPERTY( "blendEquationRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_RGB )
46 DALI_PROPERTY( "blendEquationAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_EQUATION_ALPHA )
47 DALI_PROPERTY( "blendFactorSrcRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB )
48 DALI_PROPERTY( "blendFactorDestRgb", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB )
49 DALI_PROPERTY( "blendFactorSrcAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA )
50 DALI_PROPERTY( "blendFactorDestAlpha", INTEGER, true, false, false, Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA )
51 DALI_PROPERTY( "blendColor", VECTOR4, true, false, false, Dali::Renderer::Property::BLEND_COLOR )
52 DALI_PROPERTY( "blendPreMultipliedAlpha", BOOLEAN, true, false, false, Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA )
53 DALI_PROPERTY( "indexRangeFirst", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_FIRST )
54 DALI_PROPERTY( "indexRangeCount", INTEGER, true, false, false, Dali::Renderer::Property::INDEX_RANGE_COUNT )
55 DALI_PROPERTY( "depthWriteMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_WRITE_MODE )
56 DALI_PROPERTY( "depthFunction", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_FUNCTION )
57 DALI_PROPERTY( "depthTestMode", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_TEST_MODE )
58 DALI_PROPERTY( "stencilFunction", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION )
59 DALI_PROPERTY( "stencilFunctionMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_MASK )
60 DALI_PROPERTY( "stencilFunctionReference", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE )
61 DALI_PROPERTY( "stencilMask", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_MASK )
62 DALI_PROPERTY( "stencilMode", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_MODE )
63 DALI_PROPERTY( "stencilOperationOnFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL )
64 DALI_PROPERTY( "stencilOperationOnZFail", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL )
65 DALI_PROPERTY( "stencilOperationOnZPass", INTEGER, true, false, false, Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS )
66 DALI_PROPERTY( "writeToColorBuffer", BOOLEAN, true, false, false, Dali::Renderer::Property::WRITE_TO_COLOR_BUFFER )
67 DALI_PROPERTY_TABLE_END( DEFAULT_RENDERER_PROPERTY_START_INDEX )
69 const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> RENDERER_IMPL = { DEFAULT_PROPERTY_DETAILS };
73 return Dali::BaseHandle();
76 TypeRegistration mType( typeid( Dali::Renderer ), typeid( Dali::Handle ), Create );
78 } // unnamed namespace
80 RendererPtr Renderer::New()
82 RendererPtr rendererPtr( new Renderer() );
83 rendererPtr->Initialize();
87 void Renderer::SetGeometry( Geometry& geometry )
89 mGeometry = &geometry;
91 const Render::Geometry* geometrySceneObject = geometry.GetRenderObject();
92 SetGeometryMessage( GetEventThreadServices(), *mSceneObject, *geometrySceneObject );
95 Geometry* Renderer::GetGeometry() const
97 return mGeometry.Get();
100 void Renderer::SetTextures( TextureSet& textureSet )
102 mTextureSetConnector.Set( textureSet, OnStage() );
103 const SceneGraph::TextureSet* textureSetSceneObject = textureSet.GetTextureSetSceneObject();
104 SetTexturesMessage( GetEventThreadServices(), *mSceneObject, *textureSetSceneObject );
107 TextureSet* Renderer::GetTextures() const
109 return mTextureSetConnector.Get().Get();
112 void Renderer::SetShader( Shader& shader )
115 SceneGraph::Shader& sceneGraphShader = *shader.GetShaderSceneObject();
116 SceneGraph::SetShaderMessage( GetEventThreadServices(), *mSceneObject, sceneGraphShader );
119 Shader* Renderer::GetShader() const
121 return mShader.Get();
124 void Renderer::SetDepthIndex( int depthIndex )
126 if ( mDepthIndex != depthIndex )
128 mDepthIndex = depthIndex;
129 SetDepthIndexMessage( GetEventThreadServices(), *mSceneObject, depthIndex );
133 int Renderer::GetDepthIndex() const
138 void Renderer::SetFaceCullingMode( FaceCullingMode::Type cullingMode )
140 if( mFaceCullingMode != cullingMode )
142 mFaceCullingMode = cullingMode;
144 SetFaceCullingModeMessage( GetEventThreadServices(), *mSceneObject, mFaceCullingMode );
148 FaceCullingMode::Type Renderer::GetFaceCullingMode()
150 return mFaceCullingMode;
153 void Renderer::SetBlendMode( BlendMode::Type mode )
155 if( mBlendMode != mode )
159 SetBlendModeMessage( GetEventThreadServices(), *mSceneObject, mBlendMode );
163 BlendMode::Type Renderer::GetBlendMode() const
168 void Renderer::SetBlendFunc( BlendFactor::Type srcFactorRgba, BlendFactor::Type destFactorRgba )
170 mBlendingOptions.SetBlendFunc( srcFactorRgba, destFactorRgba, srcFactorRgba, destFactorRgba );
171 SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
174 void Renderer::SetBlendFunc( BlendFactor::Type srcFactorRgb,
175 BlendFactor::Type destFactorRgb,
176 BlendFactor::Type srcFactorAlpha,
177 BlendFactor::Type destFactorAlpha )
179 mBlendingOptions.SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
180 SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
183 void Renderer::GetBlendFunc( BlendFactor::Type& srcFactorRgb,
184 BlendFactor::Type& destFactorRgb,
185 BlendFactor::Type& srcFactorAlpha,
186 BlendFactor::Type& destFactorAlpha ) const
188 srcFactorRgb = mBlendingOptions.GetBlendSrcFactorRgb();
189 destFactorRgb = mBlendingOptions.GetBlendDestFactorRgb();
190 srcFactorAlpha = mBlendingOptions.GetBlendSrcFactorAlpha();
191 destFactorAlpha = mBlendingOptions.GetBlendDestFactorAlpha();
194 void Renderer::SetBlendEquation( BlendEquation::Type equationRgba )
196 mBlendingOptions.SetBlendEquation( equationRgba, equationRgba );
197 SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
200 void Renderer::SetBlendEquation( BlendEquation::Type equationRgb,
201 BlendEquation::Type equationAlpha )
203 mBlendingOptions.SetBlendEquation( equationRgb, equationAlpha );
204 SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
207 void Renderer::GetBlendEquation( BlendEquation::Type& equationRgb,
208 BlendEquation::Type& equationAlpha ) const
210 // These are not animatable, the cached values are up-to-date.
211 equationRgb = mBlendingOptions.GetBlendEquationRgb();
212 equationAlpha = mBlendingOptions.GetBlendEquationAlpha();
215 void Renderer::SetBlendColor( const Vector4& color )
219 mBlendColor = new Vector4();
221 if( *mBlendColor != color )
223 *mBlendColor = color;
224 SetBlendColorMessage( GetEventThreadServices(), *mSceneObject, *mBlendColor );
228 Vector4 Renderer::GetBlendColor() const
234 return Color::TRANSPARENT; // GL default
237 void Renderer::SetIndexedDrawFirstElement( size_t firstElement )
239 if( firstElement != mIndexedDrawFirstElement )
241 mIndexedDrawFirstElement = firstElement;
242 SetIndexedDrawFirstElementMessage( GetEventThreadServices(), *mSceneObject, mIndexedDrawFirstElement );
246 void Renderer::SetIndexedDrawElementsCount( size_t elementsCount )
248 if( elementsCount != mIndexedDrawElementCount )
250 mIndexedDrawElementCount = elementsCount;
251 SetIndexedDrawElementsCountMessage( GetEventThreadServices(), *mSceneObject, mIndexedDrawElementCount );
256 void Renderer::EnablePreMultipliedAlpha( bool preMultipled )
258 if( mPremultipledAlphaEnabled != preMultipled )
262 SetBlendFunc( BlendFactor::ONE, BlendFactor::ONE_MINUS_SRC_ALPHA, BlendFactor::ONE, BlendFactor::ONE );
264 mPremultipledAlphaEnabled = preMultipled;
265 SetEnablePreMultipliedAlphaMessage( GetEventThreadServices(), *mSceneObject, mPremultipledAlphaEnabled );
269 bool Renderer::IsPreMultipliedAlphaEnabled() const
271 return mPremultipledAlphaEnabled;
274 SceneGraph::Renderer* Renderer::GetRendererSceneObject()
279 unsigned int Renderer::GetDefaultPropertyCount() const
281 return RENDERER_IMPL.GetDefaultPropertyCount();
284 void Renderer::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
286 RENDERER_IMPL.GetDefaultPropertyIndices( indices );
289 const char* Renderer::GetDefaultPropertyName(Property::Index index) const
291 return RENDERER_IMPL.GetDefaultPropertyName( index );
294 Property::Index Renderer::GetDefaultPropertyIndex( const std::string& name ) const
296 return RENDERER_IMPL.GetDefaultPropertyIndex( name );
299 bool Renderer::IsDefaultPropertyWritable( Property::Index index ) const
301 return RENDERER_IMPL.IsDefaultPropertyWritable( index );
304 bool Renderer::IsDefaultPropertyAnimatable( Property::Index index ) const
306 return RENDERER_IMPL.IsDefaultPropertyAnimatable( index );
309 bool Renderer::IsDefaultPropertyAConstraintInput( Property::Index index ) const
311 return RENDERER_IMPL.IsDefaultPropertyAConstraintInput( index );
314 Property::Type Renderer::GetDefaultPropertyType( Property::Index index ) const
316 return RENDERER_IMPL.GetDefaultPropertyType( index );
319 void Renderer::SetDefaultProperty( Property::Index index,
320 const Property::Value& propertyValue )
324 case Dali::Renderer::Property::DEPTH_INDEX:
326 SetDepthIndex( propertyValue.Get<int>() );
329 case Dali::Renderer::Property::FACE_CULLING_MODE:
332 if( propertyValue.Get( faceCullingMode ) )
334 SetFaceCullingMode( FaceCullingMode::Type( faceCullingMode ) );
338 case Dali::Renderer::Property::BLEND_MODE:
341 if( propertyValue.Get( blendingMode ) )
343 SetBlendMode( BlendMode::Type( blendingMode ) );
347 case Dali::Renderer::Property::BLEND_EQUATION_RGB:
349 int blendingEquation;
350 if( propertyValue.Get( blendingEquation ) )
352 BlendEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
353 mBlendingOptions.SetBlendEquation( static_cast<BlendEquation::Type>( blendingEquation ), alphaEquation );
354 SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
358 case Dali::Renderer::Property::BLEND_EQUATION_ALPHA:
360 int blendingEquation;
361 if( propertyValue.Get( blendingEquation ) )
363 BlendEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb();
364 mBlendingOptions.SetBlendEquation( rgbEquation, static_cast<BlendEquation::Type>( blendingEquation ) );
365 SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
369 case Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB:
372 if( propertyValue.Get( blendingFactor ) )
374 BlendFactor::Type srcFactorRgb;
375 BlendFactor::Type destFactorRgb;
376 BlendFactor::Type srcFactorAlpha;
377 BlendFactor::Type destFactorAlpha;
378 GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
379 SetBlendFunc( static_cast<BlendFactor::Type>( blendingFactor ),
386 case Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB:
389 if( propertyValue.Get( blendingFactor ) )
391 BlendFactor::Type srcFactorRgb;
392 BlendFactor::Type destFactorRgb;
393 BlendFactor::Type srcFactorAlpha;
394 BlendFactor::Type destFactorAlpha;
395 GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
396 SetBlendFunc( srcFactorRgb,
397 static_cast<BlendFactor::Type>( blendingFactor ),
403 case Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA:
406 if( propertyValue.Get( blendingFactor ) )
408 BlendFactor::Type srcFactorRgb;
409 BlendFactor::Type destFactorRgb;
410 BlendFactor::Type srcFactorAlpha;
411 BlendFactor::Type destFactorAlpha;
412 GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
413 SetBlendFunc( srcFactorRgb,
415 static_cast<BlendFactor::Type>( blendingFactor ),
420 case Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA:
423 if( propertyValue.Get( blendingFactor ) )
425 BlendFactor::Type srcFactorRgb;
426 BlendFactor::Type destFactorRgb;
427 BlendFactor::Type srcFactorAlpha;
428 BlendFactor::Type destFactorAlpha;
429 GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
430 SetBlendFunc( srcFactorRgb,
433 static_cast<BlendFactor::Type>( blendingFactor ) );
437 case Dali::Renderer::Property::BLEND_COLOR:
440 if( propertyValue.Get( blendColor ) )
442 SetBlendColor( blendColor );
446 case Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA:
449 if( propertyValue.Get( preMultipled ) )
451 EnablePreMultipliedAlpha( preMultipled );
455 case Dali::Renderer::Property::INDEX_RANGE_FIRST:
458 if( propertyValue.Get( firstElement ) )
460 SetIndexedDrawFirstElement( firstElement );
464 case Dali::Renderer::Property::INDEX_RANGE_COUNT:
467 if( propertyValue.Get( elementsCount ) )
469 SetIndexedDrawElementsCount( elementsCount );
473 case Dali::Renderer::Property::DEPTH_WRITE_MODE:
476 propertyValue.Get( value );
477 DepthWriteMode::Type mode = static_cast<DepthWriteMode::Type>(value);
478 if( mode != mDepthWriteMode )
480 mDepthWriteMode = mode;
481 SetDepthWriteModeMessage( GetEventThreadServices(), *mSceneObject, mode );
485 case Dali::Renderer::Property::DEPTH_FUNCTION:
488 propertyValue.Get( value );
489 DepthFunction::Type depthFunction = static_cast<DepthFunction::Type>(value);
490 if( depthFunction != mDepthFunction )
492 mDepthFunction = depthFunction;
493 SetDepthFunctionMessage( GetEventThreadServices(), *mSceneObject, depthFunction );
497 case Dali::Renderer::Property::DEPTH_TEST_MODE:
500 propertyValue.Get( value );
501 DepthTestMode::Type mode = static_cast<DepthTestMode::Type>(value);
502 if( mode != mDepthTestMode )
504 mDepthTestMode = mode;
505 SetDepthTestModeMessage( GetEventThreadServices(), *mSceneObject, mode );
509 case Dali::Renderer::Property::STENCIL_MODE:
512 propertyValue.Get( value );
513 StencilMode::Type stencilMode = static_cast<StencilMode::Type>( value );
514 if( stencilMode != mStencilParameters.stencilMode )
516 mStencilParameters.stencilMode = stencilMode;
517 SetStencilModeMessage( GetEventThreadServices(), *mSceneObject, stencilMode );
521 case Dali::Renderer::Property::STENCIL_FUNCTION:
524 propertyValue.Get( value );
525 StencilFunction::Type stencilFunction = static_cast<StencilFunction::Type>( value );
526 if( stencilFunction != mStencilParameters.stencilFunction )
528 mStencilParameters.stencilFunction = stencilFunction;
529 SetStencilFunctionMessage( GetEventThreadServices(), *mSceneObject, stencilFunction );
533 case Dali::Renderer::Property::STENCIL_FUNCTION_MASK:
535 int stencilFunctionMask;
536 if( propertyValue.Get( stencilFunctionMask ) )
538 if( stencilFunctionMask != mStencilParameters.stencilFunctionMask )
540 mStencilParameters.stencilFunctionMask = stencilFunctionMask;
541 SetStencilFunctionMaskMessage( GetEventThreadServices(), *mSceneObject, stencilFunctionMask );
546 case Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE:
548 int stencilFunctionReference;
549 if( propertyValue.Get( stencilFunctionReference ) )
551 if( stencilFunctionReference != mStencilParameters.stencilFunctionReference )
553 mStencilParameters.stencilFunctionReference = stencilFunctionReference;
554 SetStencilFunctionReferenceMessage( GetEventThreadServices(), *mSceneObject, stencilFunctionReference );
559 case Dali::Renderer::Property::STENCIL_MASK:
562 if( propertyValue.Get( stencilMask ) )
564 if( stencilMask != mStencilParameters.stencilMask )
566 mStencilParameters.stencilMask = stencilMask;
567 SetStencilMaskMessage( GetEventThreadServices(), *mSceneObject, stencilMask );
572 case Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL:
575 propertyValue.Get( value );
576 StencilOperation::Type stencilOperation = static_cast<StencilOperation::Type>( value );
577 if( stencilOperation != mStencilParameters.stencilOperationOnFail )
579 mStencilParameters.stencilOperationOnFail = stencilOperation;
580 SetStencilOperationOnFailMessage( GetEventThreadServices(), *mSceneObject, stencilOperation );
584 case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL:
587 propertyValue.Get( value );
588 StencilOperation::Type stencilOperation = static_cast<StencilOperation::Type>( value );
589 if( stencilOperation != mStencilParameters.stencilOperationOnZFail )
591 mStencilParameters.stencilOperationOnZFail = stencilOperation;
592 SetStencilOperationOnZFailMessage( GetEventThreadServices(), *mSceneObject, stencilOperation );
596 case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS:
599 propertyValue.Get( value );
600 StencilOperation::Type stencilOperation = static_cast<StencilOperation::Type>( value );
601 if( stencilOperation != mStencilParameters.stencilOperationOnZPass )
603 mStencilParameters.stencilOperationOnZPass = stencilOperation;
604 SetStencilOperationOnZPassMessage( GetEventThreadServices(), *mSceneObject, stencilOperation );
608 case Dali::Renderer::Property::WRITE_TO_COLOR_BUFFER:
610 bool writeToColorBuffer;
611 if( propertyValue.Get( writeToColorBuffer ) )
613 if( mWriteToColorBuffer != writeToColorBuffer )
615 mWriteToColorBuffer = writeToColorBuffer;
616 SetWriteToColorBufferMessage( GetEventThreadServices(), *mSceneObject, writeToColorBuffer );
624 void Renderer::SetSceneGraphProperty( Property::Index index,
625 const PropertyMetadata& entry,
626 const Property::Value& value )
628 RENDERER_IMPL.SetSceneGraphProperty( GetEventThreadServices(), this, index, entry, value );
629 OnPropertySet(index, value);
632 Property::Value Renderer::GetDefaultProperty( Property::Index index ) const
634 Property::Value value;
637 case Dali::Renderer::Property::DEPTH_INDEX:
639 value = GetDepthIndex();
642 case Dali::Renderer::Property::FACE_CULLING_MODE:
644 value = mFaceCullingMode;
647 case Dali::Renderer::Property::BLEND_MODE:
652 case Dali::Renderer::Property::BLEND_EQUATION_RGB:
654 value = static_cast<int>( mBlendingOptions.GetBlendEquationRgb() );
657 case Dali::Renderer::Property::BLEND_EQUATION_ALPHA:
659 value = static_cast<int>( mBlendingOptions.GetBlendEquationAlpha() );
662 case Dali::Renderer::Property::BLEND_FACTOR_SRC_RGB:
664 BlendFactor::Type srcFactorRgb;
665 BlendFactor::Type destFactorRgb;
666 BlendFactor::Type srcFactorAlpha;
667 BlendFactor::Type destFactorAlpha;
668 GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
669 value = static_cast<int>( srcFactorRgb );
672 case Dali::Renderer::Property::BLEND_FACTOR_DEST_RGB:
674 BlendFactor::Type srcFactorRgb;
675 BlendFactor::Type destFactorRgb;
676 BlendFactor::Type srcFactorAlpha;
677 BlendFactor::Type destFactorAlpha;
678 GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
679 value = static_cast<int>( destFactorRgb );
682 case Dali::Renderer::Property::BLEND_FACTOR_SRC_ALPHA:
684 BlendFactor::Type srcFactorRgb;
685 BlendFactor::Type destFactorRgb;
686 BlendFactor::Type srcFactorAlpha;
687 BlendFactor::Type destFactorAlpha;
688 GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
689 value = static_cast<int>( srcFactorAlpha );
692 case Dali::Renderer::Property::BLEND_FACTOR_DEST_ALPHA:
694 BlendFactor::Type srcFactorRgb;
695 BlendFactor::Type destFactorRgb;
696 BlendFactor::Type srcFactorAlpha;
697 BlendFactor::Type destFactorAlpha;
698 GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
699 value = static_cast<int>( destFactorAlpha );
702 case Dali::Renderer::Property::BLEND_COLOR:
706 value = *mBlendColor;
710 value = Color::TRANSPARENT;
714 case Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA:
716 value = IsPreMultipliedAlphaEnabled();
719 case Dali::Renderer::Property::INDEX_RANGE_FIRST:
721 value = static_cast<int>( mIndexedDrawFirstElement );
724 case Dali::Renderer::Property::INDEX_RANGE_COUNT:
726 value = static_cast<int>( mIndexedDrawElementCount );
729 case Dali::Renderer::Property::DEPTH_WRITE_MODE:
731 value = mDepthWriteMode;
734 case Dali::Renderer::Property::DEPTH_FUNCTION:
736 value = mDepthFunction;
739 case Dali::Renderer::Property::DEPTH_TEST_MODE:
741 value = mDepthTestMode;
744 case Dali::Renderer::Property::STENCIL_FUNCTION:
746 value = mStencilParameters.stencilFunction;
749 case Dali::Renderer::Property::STENCIL_FUNCTION_MASK:
751 value = mStencilParameters.stencilFunctionMask;
754 case Dali::Renderer::Property::STENCIL_FUNCTION_REFERENCE:
756 value = mStencilParameters.stencilFunctionReference;
759 case Dali::Renderer::Property::STENCIL_MASK:
761 value = mStencilParameters.stencilMask;
764 case Dali::Renderer::Property::STENCIL_MODE:
766 value = mStencilParameters.stencilMode;
769 case Dali::Renderer::Property::STENCIL_OPERATION_ON_FAIL:
771 value = mStencilParameters.stencilOperationOnFail;
774 case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_FAIL:
776 value = mStencilParameters.stencilOperationOnZFail;
779 case Dali::Renderer::Property::STENCIL_OPERATION_ON_Z_PASS:
781 value = mStencilParameters.stencilOperationOnZPass;
784 case Dali::Renderer::Property::WRITE_TO_COLOR_BUFFER:
786 value = mWriteToColorBuffer;
793 const SceneGraph::PropertyOwner* Renderer::GetPropertyOwner() const
798 const SceneGraph::PropertyOwner* Renderer::GetSceneObject() const
803 const SceneGraph::PropertyBase* Renderer::GetSceneObjectAnimatableProperty( Property::Index index ) const
805 DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" );
806 const SceneGraph::PropertyBase* property = NULL;
810 property = RENDERER_IMPL.GetRegisteredSceneGraphProperty(
812 &Renderer::FindAnimatableProperty,
813 &Renderer::FindCustomProperty,
820 const PropertyInputImpl* Renderer::GetSceneObjectInputProperty( Property::Index index ) const
822 const PropertyInputImpl* property = NULL;
826 const SceneGraph::PropertyBase* baseProperty =
827 RENDERER_IMPL.GetRegisteredSceneGraphProperty( this,
828 &Renderer::FindAnimatableProperty,
829 &Renderer::FindCustomProperty,
831 property = static_cast<const PropertyInputImpl*>( baseProperty );
837 int Renderer::GetPropertyComponentIndex( Property::Index index ) const
839 return Property::INVALID_COMPONENT_INDEX;
842 bool Renderer::OnStage() const
844 return mOnStageCount > 0;
847 void Renderer::Connect()
849 if( mOnStageCount == 0 )
851 mTextureSetConnector.OnStageConnect();
856 void Renderer::Disconnect()
859 if( mOnStageCount == 0 )
861 mTextureSetConnector.OnStageDisconnect();
866 : mSceneObject (NULL ),
870 mIndexedDrawFirstElement( 0 ),
871 mIndexedDrawElementCount( 0 ),
872 mStencilParameters( StencilMode::AUTO, StencilFunction::ALWAYS, 0xFF, 0x00, 0xFF, StencilOperation::KEEP, StencilOperation::KEEP, StencilOperation::KEEP ),
874 mDepthFunction( DepthFunction::LESS ),
875 mFaceCullingMode( FaceCullingMode::NONE ),
876 mBlendMode( BlendMode::AUTO ),
877 mDepthWriteMode( DepthWriteMode::AUTO ),
878 mDepthTestMode( DepthTestMode::AUTO ),
879 mWriteToColorBuffer( true ),
880 mPremultipledAlphaEnabled( false )
884 void Renderer::Initialize()
886 EventThreadServices& eventThreadServices = GetEventThreadServices();
887 SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
889 mSceneObject = SceneGraph::Renderer::New();
890 AddMessage( updateManager, updateManager.GetRendererOwner(), *mSceneObject );
892 eventThreadServices.RegisterObject( this );
895 Renderer::~Renderer()
897 if( EventThreadServices::IsCoreRunning() )
899 EventThreadServices& eventThreadServices = GetEventThreadServices();
900 SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
901 RemoveMessage( updateManager, updateManager.GetRendererOwner(), *mSceneObject );
903 eventThreadServices.UnregisterObject( this );
907 } // namespace Internal