99b6c38040ea24828dca0e4dfa3eb687ec272ad9
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / visual-base-impl.cpp
1 /*
2  * Copyright (c) 2022 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 "visual-base-impl.h"
20
21 // EXTERNAL HEADER
22 #include <dali-toolkit/public-api/dali-toolkit-common.h>
23 #include <dali/devel-api/rendering/renderer-devel.h>
24 #include <dali/devel-api/scripting/enum-helper.h>
25 #include <dali/integration-api/debug.h>
26 #include <dali/public-api/rendering/decorated-visual-renderer.h>
27 #include <dali/public-api/rendering/visual-renderer.h>
28
29 //INTERNAL HEARDER
30 #include <dali-toolkit/devel-api/visuals/color-visual-properties-devel.h>
31 #include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
32 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
33 #include <dali-toolkit/internal/helpers/property-helper.h>
34 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
35 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
36 #include <dali-toolkit/public-api/visuals/color-visual-properties.h>
37 #include <dali-toolkit/public-api/visuals/primitive-visual-properties.h>
38 #include <dali-toolkit/public-api/visuals/visual-properties.h>
39
40 namespace
41 {
42 #if defined(DEBUG_ENABLED)
43 Debug::Filter* gVisualBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_VISUAL_BASE");
44 #endif
45
46 // visual string constants contains OFFSET_SIZE_MODE instead
47 const char* const OFFSET_POLICY("offsetPolicy");
48 const char* const SIZE_POLICY("sizePolicy");
49
50 } // namespace
51
52 namespace Dali
53 {
54 namespace Toolkit
55 {
56 namespace Internal
57 {
58 namespace
59 {
60 DALI_ENUM_TO_STRING_TABLE_BEGIN(VISUAL_FITTING_MODE)
61   DALI_ENUM_TO_STRING_WITH_SCOPE(Visual::FittingMode, FIT_KEEP_ASPECT_RATIO)
62   DALI_ENUM_TO_STRING_WITH_SCOPE(Visual::FittingMode, FILL)
63   DALI_ENUM_TO_STRING_WITH_SCOPE(Visual::FittingMode, OVER_FIT_KEEP_ASPECT_RATIO)
64   DALI_ENUM_TO_STRING_WITH_SCOPE(Visual::FittingMode, CENTER)
65   DALI_ENUM_TO_STRING_WITH_SCOPE(Visual::FittingMode, FIT_WIDTH)
66   DALI_ENUM_TO_STRING_WITH_SCOPE(Visual::FittingMode, FIT_HEIGHT)
67 DALI_ENUM_TO_STRING_TABLE_END(VISUAL_FITTING_MODE)
68
69 /**
70  * @brief Check whether this visual type can use corner radius feature or not.
71  * @param type VisualType that want to checkup
72  * @return true if type can use corner radius feature.
73  */
74 static bool IsTypeAvailableForCornerRadius(Toolkit::Visual::Type type)
75 {
76   switch(static_cast<Toolkit::DevelVisual::Type>(type))
77   {
78     case Toolkit::Visual::Type::COLOR:
79     case Toolkit::Visual::Type::GRADIENT:
80     case Toolkit::Visual::Type::IMAGE:
81     case Toolkit::Visual::Type::SVG:
82     case Toolkit::Visual::Type::ANIMATED_IMAGE:
83     case Toolkit::DevelVisual::Type::ANIMATED_VECTOR_IMAGE:
84     {
85       return true;
86     }
87     default:
88     {
89       return false;
90     }
91   }
92 }
93
94 /**
95  * @brief Check whether this visual type can use borderline feature or not.
96  * @param type VisualType that want to checkup
97  * @return true if type can use borderline feature.
98  */
99 static bool IsTypeAvailableForBorderline(Toolkit::Visual::Type type)
100 {
101   switch(static_cast<Toolkit::DevelVisual::Type>(type))
102   {
103     case Toolkit::Visual::Type::COLOR:
104     case Toolkit::Visual::Type::GRADIENT:
105     case Toolkit::Visual::Type::IMAGE:
106     case Toolkit::Visual::Type::SVG:
107     case Toolkit::Visual::Type::ANIMATED_IMAGE:
108     case Toolkit::DevelVisual::Type::ANIMATED_VECTOR_IMAGE:
109     {
110       return true;
111     }
112     default:
113     {
114       return false;
115     }
116   }
117 }
118
119 } // namespace
120
121 Visual::Base::Base(VisualFactoryCache& factoryCache, FittingMode fittingMode, Toolkit::Visual::Type type)
122 : mImpl(new Impl(fittingMode, type)),
123   mFactoryCache(factoryCache)
124 {
125 }
126
127 Visual::Base::~Base()
128 {
129   delete mImpl;
130 }
131
132 void Visual::Base::Initialize()
133 {
134   // The Renderer should be created inside derived class here.
135   OnInitialize();
136
137   if(mImpl->mRenderer)
138   {
139     RegisterMixColor();
140     RegisterDecoration();
141
142     if(IsBorderlineRequired())
143     {
144       mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL);
145     }
146     else if(IsRoundedCornerRequired())
147     {
148       mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
149     }
150   }
151 }
152
153 void Visual::Base::SetCustomShader(const Property::Map& shaderMap)
154 {
155   if(mImpl->mCustomShader)
156   {
157     mImpl->mCustomShader->SetPropertyMap(shaderMap);
158   }
159   else
160   {
161     mImpl->mCustomShader = new Impl::CustomShader(shaderMap);
162   }
163
164   // Let derived class know
165   UpdateShader();
166 }
167
168 void Visual::Base::SetProperties(const Property::Map& propertyMap)
169 {
170   bool needUpdateShader = false;
171   for(size_t i = 0; i < propertyMap.Count(); ++i)
172   {
173     const KeyValuePair&    pair  = propertyMap.GetKeyValue(i);
174     const Property::Key&   key   = pair.first;
175     const Property::Value& value = pair.second;
176
177     Property::Key matchKey = key;
178     if(matchKey.type == Property::Key::STRING)
179     {
180       if(matchKey == CUSTOM_SHADER)
181       {
182         matchKey = Property::Key(Toolkit::Visual::Property::SHADER);
183       }
184       else if(matchKey == TRANSFORM)
185       {
186         matchKey = Property::Key(Toolkit::Visual::Property::TRANSFORM);
187       }
188       else if(matchKey == PREMULTIPLIED_ALPHA)
189       {
190         matchKey = Property::Key(Toolkit::Visual::Property::PREMULTIPLIED_ALPHA);
191       }
192       else if(matchKey == MIX_COLOR)
193       {
194         matchKey = Property::Key(Toolkit::Visual::Property::MIX_COLOR);
195       }
196       else if(matchKey == OPACITY)
197       {
198         matchKey = Property::Key(Toolkit::Visual::Property::OPACITY);
199       }
200       else if(matchKey == VISUAL_FITTING_MODE)
201       {
202         matchKey = Property::Key(Toolkit::DevelVisual::Property::VISUAL_FITTING_MODE);
203       }
204       else if(matchKey == BORDERLINE_WIDTH)
205       {
206         matchKey = Property::Key(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH);
207       }
208       else if(matchKey == BORDERLINE_COLOR)
209       {
210         matchKey = Property::Key(Toolkit::DevelVisual::Property::BORDERLINE_COLOR);
211       }
212       else if(matchKey == BORDERLINE_OFFSET)
213       {
214         matchKey = Property::Key(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET);
215       }
216       else if(matchKey == CORNER_RADIUS)
217       {
218         matchKey = Property::Key(Toolkit::DevelVisual::Property::CORNER_RADIUS);
219       }
220       else if(matchKey == CORNER_RADIUS_POLICY)
221       {
222         matchKey = Property::Key(Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY);
223       }
224     }
225
226     switch(matchKey.indexKey)
227     {
228       case Toolkit::Visual::Property::SHADER:
229       {
230         Property::Map shaderMap;
231         if(value.Get(shaderMap))
232         {
233           SetCustomShader(shaderMap);
234         }
235         break;
236       }
237
238       case Toolkit::Visual::Property::TRANSFORM:
239       {
240         Property::Map map;
241         if(value.Get(map))
242         {
243           mImpl->mTransform.SetPropertyMap(map);
244         }
245         break;
246       }
247
248       case Toolkit::Visual::Property::PREMULTIPLIED_ALPHA:
249       {
250         bool premultipliedAlpha = false;
251         if(value.Get(premultipliedAlpha))
252         {
253           EnablePreMultipliedAlpha(premultipliedAlpha);
254         }
255         break;
256       }
257
258       case Toolkit::Visual::Property::MIX_COLOR:
259       {
260         Vector4 mixColor;
261         if(value.Get(mixColor))
262         {
263           if(value.GetType() == Property::VECTOR4)
264           {
265             SetMixColor(mixColor);
266           }
267           else
268           {
269             Vector3 mixColor3(mixColor);
270             SetMixColor(mixColor3);
271           }
272         }
273         break;
274       }
275       case Toolkit::Visual::Property::OPACITY:
276       {
277         float opacity;
278         if(value.Get(opacity))
279         {
280           mImpl->mMixColor.a = opacity;
281           SetMixColor(mImpl->mMixColor);
282         }
283         break;
284       }
285       case Toolkit::DevelVisual::Property::VISUAL_FITTING_MODE:
286       {
287         Scripting::GetEnumerationProperty<Visual::FittingMode>(
288           value, VISUAL_FITTING_MODE_TABLE, VISUAL_FITTING_MODE_TABLE_COUNT, mImpl->mFittingMode);
289         break;
290       }
291       case Toolkit::DevelVisual::Property::BORDERLINE_WIDTH:
292       {
293         float width;
294         if(value.Get(width))
295         {
296           mImpl->mBorderlineWidth = width;
297         }
298
299         if(DALI_UNLIKELY(mImpl->mRenderer && IsTypeAvailableForBorderline(mImpl->mType)))
300         {
301           // Unusual case. SetProperty called after OnInitialize().
302           // Assume that DoAction call UPDATE_PROPERTY.
303           DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterBorderlineUniform();
304           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH, mImpl->mBorderlineWidth);
305
306           // Check whether we must update shader.
307           if(!mImpl->mAlwaysUsingBorderline && IsBorderlineRequired())
308           {
309             // Make Blend mode ON_WITHOUT_CULL for transparent mix color.
310             mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL);
311
312             // Change the shader must not be occured many times. we always have to use borderline feature.
313             mImpl->mAlwaysUsingBorderline = true;
314
315             // Change shader
316             if(!mImpl->mCustomShader)
317             {
318               needUpdateShader = true;
319             }
320           }
321         }
322         break;
323       }
324       case Toolkit::DevelVisual::Property::BORDERLINE_COLOR:
325       {
326         Vector4 color;
327         if(value.Get(color))
328         {
329           mImpl->mBorderlineColor = color;
330         }
331
332         if(DALI_UNLIKELY(mImpl->mRenderer && IsTypeAvailableForBorderline(mImpl->mType)))
333         {
334           // Unusual case. SetProperty called after OnInitialize().
335           // Assume that DoAction call UPDATE_PROPERTY.
336           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_COLOR, mImpl->mBorderlineColor);
337         }
338         break;
339       }
340       case Toolkit::DevelVisual::Property::BORDERLINE_OFFSET:
341       {
342         float offset;
343         if(value.Get(offset))
344         {
345           mImpl->mBorderlineOffset = offset;
346         }
347
348         if(DALI_UNLIKELY(mImpl->mRenderer && IsTypeAvailableForBorderline(mImpl->mType)))
349         {
350           // Unusual case. SetProperty called after OnInitialize().
351           // Assume that DoAction call UPDATE_PROPERTY.
352           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET, mImpl->mBorderlineOffset);
353         }
354         break;
355       }
356       case Toolkit::DevelVisual::Property::CORNER_RADIUS:
357       {
358         if(value.GetType() == Property::VECTOR4)
359         {
360           // If CORNER_RADIUS Property is Vector4,
361           // Each values mean the radius of
362           // (top-left, top-right, bottom-right, bottom-left)
363           Vector4 radius;
364           if(value.Get(radius))
365           {
366             mImpl->mCornerRadius = radius;
367           }
368         }
369         else
370         {
371           // If CORNER_RADIUS Property is float,
372           // Every corner radius have same value
373           float radius;
374           if(value.Get(radius))
375           {
376             mImpl->mCornerRadius = Vector4(radius, radius, radius, radius);
377           }
378         }
379
380         if(DALI_UNLIKELY(mImpl->mRenderer && IsTypeAvailableForCornerRadius(mImpl->mType)))
381         {
382           // Unusual case. SetProperty called after OnInitialize().
383           // Assume that DoAction call UPDATE_PROPERTY.
384           DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterCornerRadiusUniform();
385           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS, mImpl->mCornerRadius);
386
387           // Check whether we must update shader.
388           if(!mImpl->mAlwaysUsingCornerRadius && IsRoundedCornerRequired())
389           {
390             // Change the shader must not be occured many times. we always have to use corner radius feature.
391             mImpl->mAlwaysUsingCornerRadius = true;
392
393             if(!IsBorderlineRequired())
394             {
395               // If IsBorderlineRequired is true, BLEND_MODE is already BlendMode::ON_WITHOUT_CULL. So we don't overwrite it.
396               mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
397             }
398
399             // Change shader
400             if(!mImpl->mCustomShader)
401             {
402               needUpdateShader = true;
403             }
404           }
405         }
406
407         break;
408       }
409       case Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY:
410       {
411         int policy;
412         if(value.Get(policy))
413         {
414           switch(policy)
415           {
416             case Toolkit::Visual::Transform::Policy::RELATIVE:
417             case Toolkit::Visual::Transform::Policy::ABSOLUTE:
418             {
419               mImpl->mCornerRadiusPolicy = policy;
420               if(DALI_UNLIKELY(mImpl->mRenderer))
421               {
422                 // Unusual case. SetProperty called after OnInitialize().
423                 // Assume that DoAction call UPDATE_PROPERTY.
424                 mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy);
425               }
426               break;
427             }
428             default:
429             {
430               DALI_LOG_ERROR("Unsupported policy: %d\n", policy);
431               break;
432             }
433           }
434         }
435         break;
436       }
437     }
438   }
439
440   DoSetProperties(propertyMap);
441
442   if(DALI_UNLIKELY(needUpdateShader))
443   {
444     UpdateShader();
445   }
446 }
447
448 void Visual::Base::SetTransformAndSize(const Property::Map& transform, Size controlSize)
449 {
450   mImpl->mControlSize = controlSize;
451   mImpl->mTransform.UpdatePropertyMap(transform);
452
453 #if defined(DEBUG_ENABLED)
454   std::ostringstream oss;
455   oss << transform;
456   DALI_LOG_INFO(gVisualBaseLogFilter, Debug::General, "Visual::Base::SetTransformAndSize(%s) - [\e[1;32mtransform: %s  controlSize: (%3.1f, %3.1f)]\e[0m\n", GetName().c_str(), oss.str().c_str(), controlSize.x, controlSize.y);
457 #endif
458
459   OnSetTransform();
460 }
461
462 void Visual::Base::SetName(const std::string& name)
463 {
464   mImpl->mName = name;
465 }
466
467 const std::string& Visual::Base::GetName() const
468 {
469   return mImpl->mName;
470 }
471
472 float Visual::Base::GetHeightForWidth(float width)
473 {
474   float   aspectCorrectedHeight = 0.f;
475   Vector2 naturalSize;
476   GetNaturalSize(naturalSize);
477   if(naturalSize.width)
478   {
479     aspectCorrectedHeight = naturalSize.height * width / naturalSize.width;
480   }
481   return aspectCorrectedHeight;
482 }
483
484 float Visual::Base::GetWidthForHeight(float height)
485 {
486   float   aspectCorrectedWidth = 0.f;
487   Vector2 naturalSize;
488   GetNaturalSize(naturalSize);
489   if(naturalSize.height > 0.0f)
490   {
491     aspectCorrectedWidth = naturalSize.width * height / naturalSize.height;
492   }
493   return aspectCorrectedWidth;
494 }
495
496 void Visual::Base::GetNaturalSize(Vector2& naturalSize)
497 {
498   naturalSize = Vector2::ZERO;
499 }
500
501 void Visual::Base::DoAction(const Property::Index actionId, const Property::Value attributes)
502 {
503   OnDoAction(actionId, attributes);
504
505   // Check if action is valid for this visual type and perform action if possible
506   switch(actionId)
507   {
508     case DevelVisual::Action::UPDATE_PROPERTY:
509     {
510       const Property::Map* map = attributes.GetMap();
511       if(map)
512       {
513         SetProperties(*map);
514       }
515       break;
516     }
517   }
518 }
519
520 void Visual::Base::SetDepthIndex(int index)
521 {
522   mImpl->mDepthIndex = index;
523   if(mImpl->mRenderer)
524   {
525     mImpl->mRenderer.SetProperty(Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex);
526   }
527 }
528
529 int Visual::Base::GetDepthIndex() const
530 {
531   return mImpl->mDepthIndex;
532 }
533
534 void Visual::Base::SetOnScene(Actor& actor)
535 {
536   if(!IsOnScene())
537   {
538     // To display the actor correctly, renderer should not be added to actor until all required resources are ready.
539     // Thus the calling of actor.AddRenderer() should happen inside derived class as base class does not know the exact timing.
540     DoSetOnScene(actor);
541
542     if(mImpl->mRenderer)
543     {
544       mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, IsPreMultipliedAlphaEnabled());
545       mImpl->mRenderer.SetProperty(Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex);
546     }
547
548     mImpl->mFlags |= Impl::IS_ON_SCENE;
549   }
550 }
551
552 void Visual::Base::SetOffScene(Actor& actor)
553 {
554   if(IsOnScene())
555   {
556     DoSetOffScene(actor);
557     mImpl->mFlags &= ~Impl::IS_ON_SCENE;
558   }
559 }
560
561 void Visual::Base::CreatePropertyMap(Property::Map& map) const
562 {
563   if(mImpl->mRenderer)
564   {
565     // Update values from Renderer
566     mImpl->mMixColor   = mImpl->mRenderer.GetProperty<Vector3>(VisualRenderer::Property::VISUAL_MIX_COLOR);
567     mImpl->mMixColor.a = mImpl->mRenderer.GetProperty<float>(DevelRenderer::Property::OPACITY);
568
569     mImpl->mTransform.mOffset = mImpl->mRenderer.GetProperty<Vector2>(VisualRenderer::Property::TRANSFORM_OFFSET);
570     mImpl->mTransform.mSize   = mImpl->mRenderer.GetProperty<Vector2>(VisualRenderer::Property::TRANSFORM_SIZE);
571
572     if(IsTypeAvailableForCornerRadius(mImpl->mType))
573     {
574       mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
575     }
576     if(IsTypeAvailableForBorderline(mImpl->mType))
577     {
578       mImpl->mBorderlineWidth  = mImpl->mRenderer.GetProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
579       mImpl->mBorderlineColor  = mImpl->mRenderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR);
580       mImpl->mBorderlineOffset = mImpl->mRenderer.GetProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET);
581     }
582   }
583
584   DoCreatePropertyMap(map);
585
586   if(mImpl->mCustomShader)
587   {
588     mImpl->mCustomShader->CreatePropertyMap(map);
589   }
590
591   Property::Map transform;
592   mImpl->mTransform.GetPropertyMap(transform);
593   map.Insert(Toolkit::Visual::Property::TRANSFORM, transform);
594
595   bool premultipliedAlpha(IsPreMultipliedAlphaEnabled());
596   map.Insert(Toolkit::Visual::Property::PREMULTIPLIED_ALPHA, premultipliedAlpha);
597
598   // Note, Color and Primitive will also insert their own mix color into the map
599   // which is ok, because they have a different key value range, but uses same cached value anyway.
600   map.Insert(Toolkit::Visual::Property::MIX_COLOR, mImpl->mMixColor); // vec4
601   map.Insert(Toolkit::Visual::Property::OPACITY, mImpl->mMixColor.a);
602
603   auto fittingModeString = Scripting::GetLinearEnumerationName<FittingMode>(
604     mImpl->mFittingMode, VISUAL_FITTING_MODE_TABLE, VISUAL_FITTING_MODE_TABLE_COUNT);
605   map.Insert(Toolkit::DevelVisual::Property::VISUAL_FITTING_MODE, fittingModeString);
606
607   if(IsTypeAvailableForBorderline(mImpl->mType))
608   {
609     map.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, mImpl->mBorderlineWidth);
610     map.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, mImpl->mBorderlineColor);
611     map.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, mImpl->mBorderlineOffset);
612   }
613
614   if(IsTypeAvailableForCornerRadius(mImpl->mType))
615   {
616     map.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, mImpl->mCornerRadius);
617     map.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, static_cast<int>(mImpl->mCornerRadiusPolicy));
618   }
619 }
620
621 void Visual::Base::CreateInstancePropertyMap(Property::Map& map) const
622 {
623   DoCreateInstancePropertyMap(map);
624
625   if(mImpl->mCustomShader)
626   {
627     mImpl->mCustomShader->CreatePropertyMap(map);
628   }
629 }
630
631 void Visual::Base::EnablePreMultipliedAlpha(bool preMultiplied)
632 {
633   if(preMultiplied)
634   {
635     mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
636   }
637   else
638   {
639     mImpl->mFlags &= ~Impl::IS_PREMULTIPLIED_ALPHA;
640   }
641
642   if(mImpl->mRenderer)
643   {
644     mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, preMultiplied);
645     mImpl->mRenderer.SetProperty(VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA, preMultiplied);
646   }
647 }
648
649 bool Visual::Base::IsPreMultipliedAlphaEnabled() const
650 {
651   return mImpl->mFlags & Impl::IS_PREMULTIPLIED_ALPHA;
652 }
653
654 void Visual::Base::DoSetOffScene(Actor& actor)
655 {
656   actor.RemoveRenderer(mImpl->mRenderer);
657 }
658
659 bool Visual::Base::IsOnScene() const
660 {
661   return mImpl->mFlags & Impl::IS_ON_SCENE;
662 }
663
664 bool Visual::Base::IsRoundedCornerRequired() const
665 {
666   // If VisualType doesn't support rounded corner, always return false.
667   if(IsTypeAvailableForCornerRadius(mImpl->mType))
668   {
669     if(mImpl->mRenderer)
670     {
671       // Update values from Renderer
672       Property::Value value = mImpl->mRenderer.GetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS);
673       value.Get(mImpl->mCornerRadius);
674     }
675     return mImpl->mAlwaysUsingCornerRadius || !(mImpl->mCornerRadius == Vector4::ZERO);
676   }
677   return false;
678 }
679
680 bool Visual::Base::IsBorderlineRequired() const
681 {
682   // If VisualType doesn't support borderline, always return false.
683   if(IsTypeAvailableForBorderline(mImpl->mType))
684   {
685     if(mImpl->mRenderer)
686     {
687       // Update values from Renderer
688       Property::Value value = mImpl->mRenderer.GetProperty(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
689       value.Get(mImpl->mBorderlineWidth);
690     }
691     return mImpl->mAlwaysUsingBorderline || !EqualsZero(mImpl->mBorderlineWidth);
692   }
693   return false;
694 }
695
696 void Visual::Base::OnDoAction(const Property::Index actionId, const Property::Value& attributes)
697 {
698   // May be overriden by derived class
699 }
700
701 void Visual::Base::RegisterMixColor()
702 {
703   if(mImpl->mRenderer)
704   {
705     // All visual renderers now use same mix color / opacity properties.
706     mImpl->mRenderer.SetProperty(VisualRenderer::Property::VISUAL_MIX_COLOR, Vector3(mImpl->mMixColor));
707     mImpl->mRenderer.SetProperty(DevelRenderer::Property::OPACITY, mImpl->mMixColor.a);
708
709     float preMultipliedAlpha = 0.0f;
710     if(IsPreMultipliedAlphaEnabled())
711     {
712       preMultipliedAlpha = 1.0f;
713     }
714     mImpl->mRenderer.SetProperty(VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA, preMultipliedAlpha);
715   }
716 }
717
718 void Visual::Base::RegisterDecoration()
719 {
720   if(mImpl->mRenderer)
721   {
722     if(IsTypeAvailableForCornerRadius(mImpl->mType))
723     {
724       if(mImpl->mAlwaysUsingCornerRadius || !(mImpl->mCornerRadius == Vector4::ZERO))
725       {
726         DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterCornerRadiusUniform();
727         mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS, mImpl->mCornerRadius);
728         mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy);
729       }
730     }
731     if(IsTypeAvailableForBorderline(mImpl->mType))
732     {
733       if(mImpl->mAlwaysUsingBorderline || !EqualsZero(mImpl->mBorderlineWidth))
734       {
735         DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterBorderlineUniform();
736         mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH, mImpl->mBorderlineWidth);
737         mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_COLOR, mImpl->mBorderlineColor);
738         mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET, mImpl->mBorderlineOffset);
739       }
740     }
741   }
742 }
743
744 void Visual::Base::SetMixColor(const Vector4& color)
745 {
746   mImpl->mMixColor = color;
747
748   if(mImpl->mRenderer)
749   {
750     mImpl->mRenderer.SetProperty(VisualRenderer::Property::VISUAL_MIX_COLOR, Vector3(color));
751     mImpl->mRenderer.SetProperty(DevelRenderer::Property::OPACITY, color.a);
752   }
753 }
754
755 void Visual::Base::SetMixColor(const Vector3& color)
756 {
757   mImpl->mMixColor.r = color.r;
758   mImpl->mMixColor.g = color.g;
759   mImpl->mMixColor.b = color.b;
760
761   if(mImpl->mRenderer)
762   {
763     mImpl->mRenderer.SetProperty(VisualRenderer::Property::VISUAL_MIX_COLOR, color);
764   }
765 }
766
767 void Visual::Base::AddEventObserver(Visual::EventObserver& observer)
768 {
769   mImpl->mEventObserver = &observer;
770 }
771
772 void Visual::Base::RemoveEventObserver(Visual::EventObserver& observer)
773 {
774   mImpl->mEventObserver = NULL;
775 }
776
777 void Visual::Base::ResourceReady(Toolkit::Visual::ResourceStatus resourceStatus)
778 {
779   if(mImpl->mResourceStatus != resourceStatus)
780   {
781     mImpl->mResourceStatus = resourceStatus;
782
783     if(mImpl->mEventObserver)
784     {
785       // observer is currently a control impl
786       mImpl->mEventObserver->ResourceReady(*this);
787     }
788   }
789 }
790
791 bool Visual::Base::IsResourceReady() const
792 {
793   return (mImpl->mResourceStatus == Toolkit::Visual::ResourceStatus::READY ||
794           mImpl->mResourceStatus == Toolkit::Visual::ResourceStatus::FAILED);
795 }
796
797 bool Visual::Base::IsSynchronousLoadingRequired() const
798 {
799   return (mImpl->mFlags & Impl::IS_SYNCHRONOUS_RESOURCE_LOADING);
800 }
801
802 Toolkit::Visual::Type Visual::Base::GetType() const
803 {
804   return mImpl->mType;
805 }
806
807 Toolkit::Visual::ResourceStatus Visual::Base::GetResourceStatus() const
808 {
809   return mImpl->mResourceStatus;
810 }
811
812 Visual::FittingMode Visual::Base::GetFittingMode() const
813 {
814   return mImpl->mFittingMode;
815 }
816
817 Visual::Base& Visual::Base::GetVisualObject()
818 {
819   return *this;
820 }
821
822 Renderer Visual::Base::GetRenderer()
823 {
824   return mImpl->mRenderer;
825 }
826
827 Property::Index Visual::Base::GetIntKey(Property::Key key)
828 {
829   if(key.type == Property::Key::INDEX)
830   {
831     return key.indexKey;
832   }
833
834   if(key.stringKey == ANCHOR_POINT)
835   {
836     return Toolkit::Visual::Transform::Property::ANCHOR_POINT;
837   }
838   else if(key.stringKey == EXTRA_SIZE)
839   {
840     return Toolkit::DevelVisual::Transform::Property::EXTRA_SIZE;
841   }
842   else if(key.stringKey == MIX_COLOR)
843   {
844     return Toolkit::Visual::Property::MIX_COLOR;
845   }
846   else if(key.stringKey == OPACITY)
847   {
848     return Toolkit::Visual::Property::OPACITY;
849   }
850   else if(key.stringKey == OFFSET)
851   {
852     return Toolkit::Visual::Transform::Property::OFFSET;
853   }
854   else if(key.stringKey == OFFSET_POLICY)
855   {
856     return Toolkit::Visual::Transform::Property::OFFSET_POLICY;
857   }
858   else if(key.stringKey == ORIGIN)
859   {
860     return Toolkit::Visual::Transform::Property::ORIGIN;
861   }
862   else if(key.stringKey == PREMULTIPLIED_ALPHA)
863   {
864     return Toolkit::Visual::Property::PREMULTIPLIED_ALPHA;
865   }
866   else if(key.stringKey == CUSTOM_SHADER)
867   {
868     return Toolkit::Visual::Property::SHADER;
869   }
870   else if(key.stringKey == SIZE)
871   {
872     return Toolkit::Visual::Transform::Property::SIZE;
873   }
874   else if(key.stringKey == SIZE_POLICY)
875   {
876     return Toolkit::Visual::Transform::Property::SIZE_POLICY;
877   }
878   else if(key.stringKey == TRANSFORM)
879   {
880     return Toolkit::Visual::Property::TRANSFORM;
881   }
882   else if(key.stringKey == VISUAL_FITTING_MODE)
883   {
884     return Toolkit::DevelVisual::Property::VISUAL_FITTING_MODE;
885   }
886   else if(key.stringKey == CORNER_RADIUS)
887   {
888     return Toolkit::DevelVisual::Property::CORNER_RADIUS;
889   }
890   else if(key.stringKey == CORNER_RADIUS_POLICY)
891   {
892     return Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY;
893   }
894   else if(key.stringKey == BORDERLINE_WIDTH)
895   {
896     return Toolkit::DevelVisual::Property::BORDERLINE_WIDTH;
897   }
898   else if(key.stringKey == BORDERLINE_COLOR)
899   {
900     return Toolkit::DevelVisual::Property::BORDERLINE_COLOR;
901   }
902   else if(key.stringKey == BORDERLINE_OFFSET)
903   {
904     return Toolkit::DevelVisual::Property::BORDERLINE_OFFSET;
905   }
906
907   return Property::INVALID_INDEX;
908 }
909
910 Property::Index Visual::Base::GetPropertyIndex(Property::Key key)
911 {
912   switch(GetIntKey(key))
913   {
914     case Dali::Toolkit::Visual::Transform::Property::OFFSET:
915     {
916       return VisualRenderer::Property::TRANSFORM_OFFSET;
917     }
918     case Dali::Toolkit::Visual::Transform::Property::SIZE:
919     {
920       return VisualRenderer::Property::TRANSFORM_SIZE;
921     }
922     case Dali::Toolkit::Visual::Transform::Property::ORIGIN:
923     {
924       return VisualRenderer::Property::TRANSFORM_ORIGIN;
925     }
926     case Dali::Toolkit::Visual::Transform::Property::ANCHOR_POINT:
927     {
928       return VisualRenderer::Property::TRANSFORM_ANCHOR_POINT;
929     }
930     case Dali::Toolkit::Visual::Property::MIX_COLOR:
931     {
932       return VisualRenderer::Property::VISUAL_MIX_COLOR;
933     }
934     case Dali::Toolkit::Visual::Property::OPACITY:
935     {
936       return DevelRenderer::Property::OPACITY;
937     }
938     case Dali::Toolkit::Visual::Property::PREMULTIPLIED_ALPHA:
939     {
940       return VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA;
941     }
942     case Dali::Toolkit::DevelVisual::Property::CORNER_RADIUS:
943     {
944       return DecoratedVisualRenderer::Property::CORNER_RADIUS;
945     }
946     case Dali::Toolkit::DevelVisual::Property::BORDERLINE_WIDTH:
947     {
948       return DecoratedVisualRenderer::Property::BORDERLINE_WIDTH;
949     }
950     case Dali::Toolkit::DevelVisual::Property::BORDERLINE_COLOR:
951     {
952       return DecoratedVisualRenderer::Property::BORDERLINE_COLOR;
953     }
954     case Dali::Toolkit::DevelVisual::Property::BORDERLINE_OFFSET:
955     {
956       return DecoratedVisualRenderer::Property::BORDERLINE_OFFSET;
957     }
958   }
959
960   Property::Index index = mImpl->mRenderer.GetPropertyIndex(key);
961
962   if(index == Property::INVALID_INDEX)
963   {
964     // Is it a shader property?
965     Shader shader = mImpl->mRenderer.GetShader();
966     index         = shader.GetPropertyIndex(key);
967     if(index != Property::INVALID_INDEX)
968     {
969       // Yes - we should register it in the Renderer so it can be set / animated
970       // independently, as shaders are shared across multiple renderers.
971       std::string     keyName;
972       Property::Index keyIndex(Property::INVALID_KEY);
973       if(key.type == Property::Key::INDEX)
974       {
975         keyName  = shader.GetPropertyName(index);
976         keyIndex = key.indexKey;
977       }
978       else
979       {
980         keyName = key.stringKey;
981         // Leave keyIndex as INVALID_KEY - it can still be registered against the string key.
982       }
983       Property::Value value = shader.GetProperty(index);
984
985       // We already know that mRenderer didn't have property. So we can assume that it is unique.
986       index = mImpl->mRenderer.RegisterUniqueProperty(keyIndex, keyName, value);
987     }
988   }
989   return index;
990 }
991
992 void Visual::Base::SetupTransition(
993   Dali::Animation&                    transition,
994   Internal::TransitionData::Animator& animator,
995   Property::Index                     index,
996   Property::Value&                    initialValue,
997   Property::Value&                    targetValue)
998 {
999   if(index != Property::INVALID_INDEX)
1000   {
1001     if(mImpl->mRenderer)
1002     {
1003       if(animator.animate == false)
1004       {
1005         mImpl->mRenderer.SetProperty(index, targetValue);
1006       }
1007       else
1008       {
1009         if(animator.initialValue.GetType() != Property::NONE)
1010         {
1011           mImpl->mRenderer.SetProperty(index, initialValue);
1012         }
1013
1014         if(!transition)
1015         {
1016           transition = Dali::Animation::New(0.1f);
1017         }
1018
1019         transition.AnimateTo(Property(mImpl->mRenderer, index),
1020                              targetValue,
1021                              animator.alphaFunction,
1022                              TimePeriod(animator.timePeriodDelay,
1023                                         animator.timePeriodDuration));
1024       }
1025     }
1026   }
1027 }
1028
1029 void Visual::Base::AnimateProperty(
1030   Dali::Animation&                    transition,
1031   Internal::TransitionData::Animator& animator)
1032 {
1033 #if defined(DEBUG_ENABLED)
1034   if(gVisualBaseLogFilter->IsEnabledFor(Debug::General))
1035   {
1036     std::ostringstream oss;
1037     oss << "Visual::Base::AnimateProperty(Visual:" << mImpl->mName << " Property:" << animator.propertyKey << " Target: " << animator.targetValue << std::endl;
1038     DALI_LOG_INFO(gVisualBaseLogFilter, Debug::General, oss.str().c_str());
1039   }
1040 #endif
1041
1042   if(animator.propertyKey == Toolkit::Visual::Property::MIX_COLOR ||
1043      animator.propertyKey == MIX_COLOR ||
1044      (mImpl->mType == Toolkit::Visual::COLOR &&
1045       animator.propertyKey == ColorVisual::Property::MIX_COLOR) ||
1046      (mImpl->mType == Toolkit::Visual::PRIMITIVE &&
1047       animator.propertyKey == PrimitiveVisual::Property::MIX_COLOR))
1048   {
1049     AnimateMixColorProperty(transition, animator);
1050   }
1051   else if(animator.propertyKey == Toolkit::Visual::Property::OPACITY ||
1052           animator.propertyKey == OPACITY)
1053   {
1054     AnimateOpacityProperty(transition, animator);
1055   }
1056   else if(mImpl->mRenderer)
1057   {
1058     AnimateRendererProperty(transition, animator);
1059   }
1060 }
1061
1062 void Visual::Base::AnimateOpacityProperty(
1063   Dali::Animation&                    transition,
1064   Internal::TransitionData::Animator& animator)
1065 {
1066   float targetOpacity;
1067   if(animator.targetValue.Get(targetOpacity))
1068   {
1069     mImpl->mMixColor.a = targetOpacity;
1070   }
1071
1072   SetupTransition(transition, animator, DevelRenderer::Property::OPACITY, animator.initialValue, animator.targetValue);
1073 }
1074
1075 void Visual::Base::AnimateRendererProperty(
1076   Dali::Animation&                    transition,
1077   Internal::TransitionData::Animator& animator)
1078 {
1079   // Get actual renderer index (will convert transform keys into visualproperty indices)
1080   Property::Index index = GetPropertyIndex(animator.propertyKey);
1081
1082   if(index != Property::INVALID_INDEX)
1083   {
1084     if(animator.targetValue.GetType() != Property::NONE)
1085     {
1086       // Try writing target value into transform property map
1087       // if it's not a valid key, then it won't alter mTransform
1088       Property::Map map;
1089       if(animator.propertyKey.type == Property::Key::INDEX)
1090       {
1091         map.Add(animator.propertyKey.indexKey, animator.targetValue);
1092       }
1093       else
1094       {
1095         map.Add(animator.propertyKey.stringKey, animator.targetValue);
1096       }
1097
1098       mImpl->mTransform.UpdatePropertyMap(map);
1099     }
1100     SetupTransition(transition, animator, index, animator.initialValue, animator.targetValue);
1101   }
1102 }
1103
1104 void Visual::Base::AnimateMixColorProperty(
1105   Dali::Animation&                    transition,
1106   Internal::TransitionData::Animator& animator)
1107 {
1108   bool animateOpacity = false;
1109
1110   Property::Value initialOpacity;
1111   Property::Value targetOpacity;
1112   Property::Value initialMixColor;
1113   Property::Value targetMixColor;
1114
1115   Vector4 initialColor;
1116   if(animator.initialValue.Get(initialColor))
1117   {
1118     if(animator.initialValue.GetType() == Property::VECTOR4)
1119     {
1120       // if there is an initial color specifying alpha, test it
1121       initialOpacity = initialColor.a;
1122     }
1123     initialMixColor = Vector3(initialColor);
1124   }
1125
1126   // Set target value into data store
1127   if(animator.targetValue.GetType() != Property::NONE)
1128   {
1129     Vector4 mixColor;
1130     animator.targetValue.Get(mixColor);
1131     if(animator.targetValue.GetType() == Property::VECTOR4)
1132     {
1133       mImpl->mMixColor.a = mixColor.a;
1134       targetOpacity      = mixColor.a;
1135       animateOpacity     = true;
1136     }
1137
1138     mImpl->mMixColor.r = mixColor.r;
1139     mImpl->mMixColor.g = mixColor.g;
1140     mImpl->mMixColor.b = mixColor.b;
1141     targetMixColor     = Vector3(mixColor);
1142   }
1143
1144   SetupTransition(transition, animator, VisualRenderer::Property::VISUAL_MIX_COLOR, initialMixColor, targetMixColor);
1145
1146   if(animateOpacity)
1147   {
1148     SetupTransition(transition, animator, DevelRenderer::Property::OPACITY, initialOpacity, targetOpacity);
1149   }
1150 }
1151
1152 Dali::Property Visual::Base::GetPropertyObject(Dali::Property::Key key)
1153 {
1154   if(!mImpl->mRenderer)
1155   {
1156     Handle handle;
1157     return Dali::Property(handle, Property::INVALID_INDEX);
1158   }
1159
1160   switch(GetIntKey(key))
1161   {
1162     // Default animatable properties from VisualRenderer
1163     case Toolkit::Visual::Property::MIX_COLOR:
1164     {
1165       return Dali::Property(mImpl->mRenderer, VisualRenderer::Property::VISUAL_MIX_COLOR);
1166     }
1167     case Toolkit::Visual::Property::OPACITY:
1168     {
1169       return Dali::Property(mImpl->mRenderer, DevelRenderer::Property::OPACITY);
1170     }
1171     case Toolkit::Visual::Transform::Property::OFFSET:
1172     {
1173       return Dali::Property(mImpl->mRenderer, VisualRenderer::Property::TRANSFORM_OFFSET);
1174     }
1175     case Toolkit::Visual::Transform::Property::SIZE:
1176     {
1177       return Dali::Property(mImpl->mRenderer, VisualRenderer::Property::TRANSFORM_SIZE);
1178     }
1179
1180     // Default animatable properties from DecoratedVisualRenderer
1181     case Toolkit::DevelVisual::Property::CORNER_RADIUS:
1182     {
1183       if(IsTypeAvailableForCornerRadius(mImpl->mType))
1184       {
1185         const bool updateShader = !mImpl->mCustomShader && !IsRoundedCornerRequired();
1186
1187         // CornerRadius is animated now. we always have to use corner radius feature.
1188         mImpl->mAlwaysUsingCornerRadius = true;
1189
1190         if(updateShader)
1191         {
1192           // Update each values to renderer
1193           DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterCornerRadiusUniform();
1194           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS, mImpl->mCornerRadius);
1195           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy);
1196
1197           // Change shader
1198           UpdateShader();
1199         }
1200         if(!IsBorderlineRequired())
1201         {
1202           // If IsBorderlineRequired is true, BLEND_MODE is already BlendMode::ON_WITHOUT_CULL. So we don't overwrite it.
1203           mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
1204         }
1205         return Dali::Property(mImpl->mRenderer, DecoratedVisualRenderer::Property::CORNER_RADIUS);
1206       }
1207       break;
1208     }
1209     case Toolkit::DevelVisual::Property::BORDERLINE_WIDTH:
1210     case Toolkit::DevelVisual::Property::BORDERLINE_COLOR:
1211     case Toolkit::DevelVisual::Property::BORDERLINE_OFFSET:
1212     {
1213       if(IsTypeAvailableForBorderline(mImpl->mType))
1214       {
1215         const bool updateShader = !mImpl->mCustomShader && !IsBorderlineRequired();
1216
1217         // Borderline is animated now. we always have to use borderline feature.
1218         mImpl->mAlwaysUsingBorderline = true;
1219
1220         if(updateShader)
1221         {
1222           // Update each values to renderer
1223           DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterBorderlineUniform();
1224           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH, mImpl->mBorderlineWidth);
1225           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_COLOR, mImpl->mBorderlineColor);
1226           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET, mImpl->mBorderlineOffset);
1227
1228           // Change shader
1229           UpdateShader();
1230         }
1231         mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL);
1232
1233         return Dali::Property(mImpl->mRenderer, GetPropertyIndex(key));
1234       }
1235       break;
1236     }
1237     default:
1238     {
1239       // Special case for MIX_COLOR
1240       if(key.type == Property::Key::INDEX &&
1241          ((mImpl->mType == Toolkit::Visual::COLOR && key.indexKey == ColorVisual::Property::MIX_COLOR) ||
1242           (mImpl->mType == Toolkit::Visual::PRIMITIVE && key.indexKey == PrimitiveVisual::Property::MIX_COLOR)))
1243       {
1244         return Dali::Property(mImpl->mRenderer, VisualRenderer::Property::VISUAL_MIX_COLOR);
1245       }
1246
1247       // Special case for BLUR_RADIUS
1248       if(mImpl->mType == Toolkit::Visual::COLOR &&
1249          ((key.type == Property::Key::INDEX && key.indexKey == DevelColorVisual::Property::BLUR_RADIUS) ||
1250           (key.type == Property::Key::STRING && key.stringKey == BLUR_RADIUS_NAME)))
1251       {
1252         // Request to color-visual class
1253         return OnGetPropertyObject(key);
1254       }
1255     }
1256   }
1257
1258   // If it is not VisualRenderer property, check registered Renderer and Shader property.
1259   Property::Index index = GetPropertyIndex(key);
1260   if(index != Property::INVALID_INDEX)
1261   {
1262     return Dali::Property(mImpl->mRenderer, index);
1263   }
1264
1265   // We can't find the property in the base class.
1266   // Request to child class
1267   return OnGetPropertyObject(key);
1268 }
1269
1270 } // namespace Internal
1271
1272 } // namespace Toolkit
1273
1274 } // namespace Dali