[dali_2.3.19] Merge branch 'devel/master'
[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           if(mImpl->mDecorationData != nullptr || !Dali::EqualsZero(width))
297           {
298             mImpl->SetBorderlineWidth(width);
299           }
300         }
301
302         if(DALI_UNLIKELY(mImpl->mRenderer && IsTypeAvailableForBorderline(mImpl->mType)))
303         {
304           // Unusual case. SetProperty called after OnInitialize().
305           // Assume that DoAction call UPDATE_PROPERTY.
306           DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterBorderlineUniform();
307           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH, mImpl->GetBorderlineWidth());
308
309           // Check whether we must update shader.
310           if(!mImpl->mAlwaysUsingBorderline && IsBorderlineRequired())
311           {
312             // Required to change shader mean, we didn't setup BORDERLINE_COLOR and BORDERLINE_OFFSET into mRenderer before. Set property now.
313             mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_COLOR, mImpl->GetBorderlineColor());
314             mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET, mImpl->GetBorderlineOffset());
315
316             // Make Blend mode ON_WITHOUT_CULL for transparent mix color.
317             mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL);
318
319             // Change the shader must not be occured many times. we always have to use borderline feature.
320             mImpl->mAlwaysUsingBorderline = true;
321
322             // Change shader
323             if(!mImpl->mCustomShader)
324             {
325               needUpdateShader = true;
326             }
327           }
328         }
329         break;
330       }
331       case Toolkit::DevelVisual::Property::BORDERLINE_COLOR:
332       {
333         Vector4 color;
334         if(value.Get(color))
335         {
336           if(mImpl->mDecorationData != nullptr || color != Vector4::ZERO)
337           {
338             mImpl->SetBorderlineColor(color);
339           }
340         }
341
342         if(DALI_UNLIKELY(mImpl->mRenderer && IsTypeAvailableForBorderline(mImpl->mType)))
343         {
344           // Unusual case. SetProperty called after OnInitialize().
345           // Assume that DoAction call UPDATE_PROPERTY.
346           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_COLOR, mImpl->GetBorderlineColor());
347         }
348         break;
349       }
350       case Toolkit::DevelVisual::Property::BORDERLINE_OFFSET:
351       {
352         float offset;
353         if(value.Get(offset))
354         {
355           if(mImpl->mDecorationData != nullptr || !Dali::EqualsZero(offset))
356           {
357             mImpl->SetBorderlineOffset(offset);
358           }
359         }
360
361         if(DALI_UNLIKELY(mImpl->mRenderer && IsTypeAvailableForBorderline(mImpl->mType)))
362         {
363           // Unusual case. SetProperty called after OnInitialize().
364           // Assume that DoAction call UPDATE_PROPERTY.
365           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET, mImpl->GetBorderlineOffset());
366         }
367         break;
368       }
369       case Toolkit::DevelVisual::Property::CORNER_RADIUS:
370       {
371         if(value.GetType() == Property::VECTOR4)
372         {
373           // If CORNER_RADIUS Property is Vector4,
374           // Each values mean the radius of
375           // (top-left, top-right, bottom-right, bottom-left)
376           Vector4 radius;
377           if(value.Get(radius))
378           {
379             if(mImpl->mDecorationData != nullptr || radius != Vector4::ZERO)
380             {
381               mImpl->SetCornerRadius(radius);
382             }
383           }
384         }
385         else
386         {
387           // If CORNER_RADIUS Property is float,
388           // Every corner radius have same value
389           float radius;
390           if(value.Get(radius))
391           {
392             if(mImpl->mDecorationData != nullptr || !Dali::EqualsZero(radius))
393             {
394               mImpl->SetCornerRadius(Vector4(radius, radius, radius, radius));
395             }
396           }
397         }
398
399         if(DALI_UNLIKELY(mImpl->mRenderer && IsTypeAvailableForCornerRadius(mImpl->mType)))
400         {
401           // Unusual case. SetProperty called after OnInitialize().
402           // Assume that DoAction call UPDATE_PROPERTY.
403           DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterCornerRadiusUniform();
404           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS, mImpl->GetCornerRadius());
405
406           // Check whether we must update shader.
407           if(!mImpl->mAlwaysUsingCornerRadius && IsRoundedCornerRequired())
408           {
409             // Required to change shader mean, we didn't setup CORNER_RADIUS_POLICY into mRenderer before. Set property now.
410             mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, static_cast<float>(mImpl->GetCornerRadiusPolicy()));
411
412             // Change the shader must not be occured many times. we always have to use corner radius feature.
413             mImpl->mAlwaysUsingCornerRadius = true;
414
415             if(!IsBorderlineRequired())
416             {
417               // If IsBorderlineRequired is true, BLEND_MODE is already BlendMode::ON_WITHOUT_CULL. So we don't overwrite it.
418               mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
419             }
420
421             // Change shader
422             if(!mImpl->mCustomShader)
423             {
424               needUpdateShader = true;
425             }
426           }
427         }
428
429         break;
430       }
431       case Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY:
432       {
433         int policy;
434         if(value.Get(policy))
435         {
436           switch(policy)
437           {
438             case Toolkit::Visual::Transform::Policy::RELATIVE:
439             case Toolkit::Visual::Transform::Policy::ABSOLUTE:
440             {
441               mImpl->SetCornerRadiusPolicy(policy);
442               if(DALI_UNLIKELY(mImpl->mRenderer))
443               {
444                 // Unusual case. SetProperty called after OnInitialize().
445                 // Assume that DoAction call UPDATE_PROPERTY.
446                 mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, static_cast<float>(mImpl->GetCornerRadiusPolicy()));
447               }
448               break;
449             }
450             default:
451             {
452               DALI_LOG_ERROR("Unsupported policy: %d\n", policy);
453               break;
454             }
455           }
456         }
457         break;
458       }
459     }
460   }
461
462   DoSetProperties(propertyMap);
463
464   if(DALI_UNLIKELY(needUpdateShader))
465   {
466     UpdateShader();
467   }
468 }
469
470 void Visual::Base::SetTransformAndSize(const Property::Map& transform, Size controlSize)
471 {
472   mImpl->mControlSize = controlSize;
473   mImpl->mTransform.UpdatePropertyMap(transform);
474
475 #if defined(DEBUG_ENABLED)
476   std::ostringstream oss;
477   oss << transform;
478   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);
479 #endif
480
481   OnSetTransform();
482 }
483
484 void Visual::Base::SetName(const std::string& name)
485 {
486   mImpl->mName = name;
487 }
488
489 const std::string& Visual::Base::GetName() const
490 {
491   return mImpl->mName;
492 }
493
494 float Visual::Base::GetHeightForWidth(float width)
495 {
496   float   aspectCorrectedHeight = 0.f;
497   Vector2 naturalSize;
498   GetNaturalSize(naturalSize);
499   if(naturalSize.width > 0.0f)
500   {
501     aspectCorrectedHeight = naturalSize.height * width / naturalSize.width;
502   }
503   return aspectCorrectedHeight;
504 }
505
506 float Visual::Base::GetWidthForHeight(float height)
507 {
508   float   aspectCorrectedWidth = 0.f;
509   Vector2 naturalSize;
510   GetNaturalSize(naturalSize);
511   if(naturalSize.height > 0.0f)
512   {
513     aspectCorrectedWidth = naturalSize.width * height / naturalSize.height;
514   }
515   return aspectCorrectedWidth;
516 }
517
518 void Visual::Base::GetNaturalSize(Vector2& naturalSize)
519 {
520   naturalSize = Vector2::ZERO;
521 }
522
523 void Visual::Base::DoAction(const Property::Index actionId, const Property::Value attributes)
524 {
525   OnDoAction(actionId, attributes);
526
527   // Check if action is valid for this visual type and perform action if possible
528   switch(actionId)
529   {
530     case DevelVisual::Action::UPDATE_PROPERTY:
531     {
532       const Property::Map* map = attributes.GetMap();
533       if(map)
534       {
535         SetProperties(*map);
536       }
537       break;
538     }
539   }
540 }
541
542 void Visual::Base::DoActionExtension(const Dali::Property::Index actionId, const Dali::Any attributes)
543 {
544   OnDoActionExtension(actionId, attributes);
545 }
546
547 void Visual::Base::SetDepthIndex(int index)
548 {
549   mImpl->mDepthIndex = index;
550   if(mImpl->mRenderer)
551   {
552     mImpl->mRenderer.SetProperty(Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex);
553   }
554 }
555
556 int Visual::Base::GetDepthIndex() const
557 {
558   return mImpl->mDepthIndex;
559 }
560
561 void Visual::Base::SetOnScene(Actor& actor)
562 {
563   if(!IsOnScene())
564   {
565     // To display the actor correctly, renderer should not be added to actor until all required resources are ready.
566     // Thus the calling of actor.AddRenderer() should happen inside derived class as base class does not know the exact timing.
567     DoSetOnScene(actor);
568
569     if(mImpl->mRenderer)
570     {
571       mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, IsPreMultipliedAlphaEnabled());
572       mImpl->mRenderer.SetProperty(Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex);
573     }
574
575     mImpl->mFlags |= Impl::IS_ON_SCENE;
576   }
577 }
578
579 void Visual::Base::SetOffScene(Actor& actor)
580 {
581   if(IsOnScene())
582   {
583     DoSetOffScene(actor);
584     mImpl->mFlags &= ~Impl::IS_ON_SCENE;
585   }
586 }
587
588 void Visual::Base::CreatePropertyMap(Property::Map& map) const
589 {
590   if(mImpl->mRenderer)
591   {
592     // Update values from Renderer
593     mImpl->mMixColor   = mImpl->mRenderer.GetProperty<Vector3>(VisualRenderer::Property::VISUAL_MIX_COLOR);
594     mImpl->mMixColor.a = mImpl->mRenderer.GetProperty<float>(DevelRenderer::Property::OPACITY);
595
596     mImpl->mTransform.mOffset = mImpl->mRenderer.GetProperty<Vector2>(VisualRenderer::Property::TRANSFORM_OFFSET);
597     mImpl->mTransform.mSize   = mImpl->mRenderer.GetProperty<Vector2>(VisualRenderer::Property::TRANSFORM_SIZE);
598
599     if(IsRoundedCornerRequired())
600     {
601       mImpl->SetCornerRadius(mImpl->mRenderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS));
602     }
603     if(IsBorderlineRequired())
604     {
605       mImpl->SetBorderlineWidth(mImpl->mRenderer.GetProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH));
606       mImpl->SetBorderlineColor(mImpl->mRenderer.GetProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR));
607       mImpl->SetBorderlineOffset(mImpl->mRenderer.GetProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET));
608     }
609   }
610
611   DoCreatePropertyMap(map);
612
613   if(mImpl->mCustomShader)
614   {
615     mImpl->mCustomShader->CreatePropertyMap(map);
616   }
617
618   Property::Map transform;
619   mImpl->mTransform.GetPropertyMap(transform);
620   map.Insert(Toolkit::Visual::Property::TRANSFORM, transform);
621
622   bool premultipliedAlpha(IsPreMultipliedAlphaEnabled());
623   map.Insert(Toolkit::Visual::Property::PREMULTIPLIED_ALPHA, premultipliedAlpha);
624
625   // Note, Color and Primitive will also insert their own mix color into the map
626   // which is ok, because they have a different key value range, but uses same cached value anyway.
627   map.Insert(Toolkit::Visual::Property::MIX_COLOR, mImpl->mMixColor); // vec4
628   map.Insert(Toolkit::Visual::Property::OPACITY, mImpl->mMixColor.a);
629
630   auto fittingModeString = Scripting::GetLinearEnumerationName<FittingMode>(
631     mImpl->mFittingMode, VISUAL_FITTING_MODE_TABLE, VISUAL_FITTING_MODE_TABLE_COUNT);
632   map.Insert(Toolkit::DevelVisual::Property::VISUAL_FITTING_MODE, fittingModeString);
633
634   if(IsTypeAvailableForBorderline(mImpl->mType))
635   {
636     map.Insert(Toolkit::DevelVisual::Property::BORDERLINE_WIDTH, mImpl->GetBorderlineWidth());
637     map.Insert(Toolkit::DevelVisual::Property::BORDERLINE_COLOR, mImpl->GetBorderlineColor());
638     map.Insert(Toolkit::DevelVisual::Property::BORDERLINE_OFFSET, mImpl->GetBorderlineOffset());
639   }
640
641   if(IsTypeAvailableForCornerRadius(mImpl->mType))
642   {
643     map.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS, mImpl->GetCornerRadius());
644     map.Insert(Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, mImpl->GetCornerRadiusPolicy());
645   }
646 }
647
648 void Visual::Base::CreateInstancePropertyMap(Property::Map& map) const
649 {
650   DoCreateInstancePropertyMap(map);
651
652   if(mImpl->mCustomShader)
653   {
654     mImpl->mCustomShader->CreatePropertyMap(map);
655   }
656 }
657
658 void Visual::Base::EnablePreMultipliedAlpha(bool preMultiplied)
659 {
660   if(preMultiplied)
661   {
662     mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
663   }
664   else
665   {
666     mImpl->mFlags &= ~Impl::IS_PREMULTIPLIED_ALPHA;
667   }
668
669   if(mImpl->mRenderer)
670   {
671     mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, preMultiplied);
672     mImpl->mRenderer.SetProperty(VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA, preMultiplied);
673   }
674 }
675
676 bool Visual::Base::IsPreMultipliedAlphaEnabled() const
677 {
678   return mImpl->mFlags & Impl::IS_PREMULTIPLIED_ALPHA;
679 }
680
681 void Visual::Base::DoSetOffScene(Actor& actor)
682 {
683   actor.RemoveRenderer(mImpl->mRenderer);
684 }
685
686 bool Visual::Base::IsOnScene() const
687 {
688   return mImpl->mFlags & Impl::IS_ON_SCENE;
689 }
690
691 bool Visual::Base::IsRoundedCornerRequired() const
692 {
693   // If VisualType doesn't support rounded corner, always return false.
694   if(IsTypeAvailableForCornerRadius(mImpl->mType))
695   {
696     if(mImpl->mRenderer)
697     {
698       // Update values from Renderer
699       Property::Value value = mImpl->mRenderer.GetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS);
700
701       Vector4 retValue = Vector4::ZERO;
702       if(value.Get(retValue))
703       {
704         if(mImpl->mDecorationData != nullptr || retValue != Vector4::ZERO)
705         {
706           mImpl->SetCornerRadius(retValue);
707         }
708       }
709     }
710     return mImpl->mAlwaysUsingCornerRadius || !(mImpl->GetCornerRadius() == Vector4::ZERO);
711   }
712   return false;
713 }
714
715 bool Visual::Base::IsBorderlineRequired() const
716 {
717   // If VisualType doesn't support borderline, always return false.
718   if(IsTypeAvailableForBorderline(mImpl->mType))
719   {
720     if(mImpl->mRenderer)
721     {
722       // Update values from Renderer
723       Property::Value value = mImpl->mRenderer.GetProperty(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
724
725       float retValue = 0.0f;
726       if(value.Get(retValue))
727       {
728         if(mImpl->mDecorationData != nullptr || !Dali::EqualsZero(retValue))
729         {
730           mImpl->SetBorderlineWidth(retValue);
731         }
732       }
733     }
734     return mImpl->mAlwaysUsingBorderline || !EqualsZero(mImpl->GetBorderlineWidth());
735   }
736   return false;
737 }
738
739 void Visual::Base::OnDoAction(const Property::Index actionId, const Property::Value& attributes)
740 {
741   // May be overriden by derived class
742 }
743
744 void Visual::Base::OnDoActionExtension(const Property::Index actionId, const Dali::Any attributes)
745 {
746   // May be overriden by derived class
747 }
748
749 void Visual::Base::RegisterMixColor()
750 {
751   if(mImpl->mRenderer)
752   {
753     // All visual renderers now use same mix color / opacity properties.
754     mImpl->mRenderer.SetProperty(VisualRenderer::Property::VISUAL_MIX_COLOR, Vector3(mImpl->mMixColor));
755     mImpl->mRenderer.SetProperty(DevelRenderer::Property::OPACITY, mImpl->mMixColor.a);
756
757     float preMultipliedAlpha = 0.0f;
758     if(IsPreMultipliedAlphaEnabled())
759     {
760       preMultipliedAlpha = 1.0f;
761     }
762     mImpl->mRenderer.SetProperty(VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA, preMultipliedAlpha);
763   }
764 }
765
766 void Visual::Base::RegisterDecoration()
767 {
768   if(mImpl->mRenderer)
769   {
770     if(IsTypeAvailableForCornerRadius(mImpl->mType))
771     {
772       if(mImpl->mAlwaysUsingCornerRadius || !(mImpl->GetCornerRadius() == Vector4::ZERO))
773       {
774         DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterCornerRadiusUniform();
775         mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS, mImpl->GetCornerRadius());
776         mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, static_cast<float>(mImpl->GetCornerRadiusPolicy()));
777       }
778     }
779     if(IsTypeAvailableForBorderline(mImpl->mType))
780     {
781       if(mImpl->mAlwaysUsingBorderline || !EqualsZero(mImpl->GetBorderlineWidth()))
782       {
783         DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterBorderlineUniform();
784         mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH, mImpl->GetBorderlineWidth());
785         mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_COLOR, mImpl->GetBorderlineColor());
786         mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET, mImpl->GetBorderlineOffset());
787       }
788     }
789   }
790 }
791
792 void Visual::Base::SetMixColor(const Vector4& color)
793 {
794   mImpl->mMixColor = color;
795
796   if(mImpl->mRenderer)
797   {
798     mImpl->mRenderer.SetProperty(VisualRenderer::Property::VISUAL_MIX_COLOR, Vector3(color));
799     mImpl->mRenderer.SetProperty(DevelRenderer::Property::OPACITY, color.a);
800   }
801 }
802
803 void Visual::Base::SetMixColor(const Vector3& color)
804 {
805   mImpl->mMixColor.r = color.r;
806   mImpl->mMixColor.g = color.g;
807   mImpl->mMixColor.b = color.b;
808
809   if(mImpl->mRenderer)
810   {
811     mImpl->mRenderer.SetProperty(VisualRenderer::Property::VISUAL_MIX_COLOR, color);
812   }
813 }
814
815 void Visual::Base::AddEventObserver(Visual::EventObserver& observer)
816 {
817   mImpl->mEventObserver = &observer;
818 }
819
820 void Visual::Base::RemoveEventObserver(Visual::EventObserver& observer)
821 {
822   mImpl->mEventObserver = NULL;
823 }
824
825 void Visual::Base::ResourceReady(Toolkit::Visual::ResourceStatus resourceStatus)
826 {
827   if(mImpl->mResourceStatus != resourceStatus)
828   {
829     mImpl->mResourceStatus = resourceStatus;
830
831     if(mImpl->mEventObserver)
832     {
833       // observer is currently a control impl
834       mImpl->mEventObserver->ResourceReady(*this);
835     }
836   }
837 }
838
839 bool Visual::Base::IsResourceReady() const
840 {
841   return (mImpl->mResourceStatus == Toolkit::Visual::ResourceStatus::READY ||
842           mImpl->mResourceStatus == Toolkit::Visual::ResourceStatus::FAILED);
843 }
844
845 bool Visual::Base::IsSynchronousLoadingRequired() const
846 {
847   return (mImpl->mFlags & Impl::IS_SYNCHRONOUS_RESOURCE_LOADING);
848 }
849
850 Toolkit::Visual::Type Visual::Base::GetType() const
851 {
852   return mImpl->mType;
853 }
854
855 Toolkit::Visual::ResourceStatus Visual::Base::GetResourceStatus() const
856 {
857   return mImpl->mResourceStatus;
858 }
859
860 Visual::FittingMode Visual::Base::GetFittingMode() const
861 {
862   return mImpl->mFittingMode;
863 }
864
865 Visual::Base& Visual::Base::GetVisualObject()
866 {
867   return *this;
868 }
869
870 Renderer Visual::Base::GetRenderer()
871 {
872   return mImpl->mRenderer;
873 }
874
875 Property::Index Visual::Base::GetIntKey(Property::Key key)
876 {
877   if(key.type == Property::Key::INDEX)
878   {
879     return key.indexKey;
880   }
881
882   if(key.stringKey == ANCHOR_POINT)
883   {
884     return Toolkit::Visual::Transform::Property::ANCHOR_POINT;
885   }
886   else if(key.stringKey == EXTRA_SIZE)
887   {
888     return Toolkit::DevelVisual::Transform::Property::EXTRA_SIZE;
889   }
890   else if(key.stringKey == MIX_COLOR)
891   {
892     return Toolkit::Visual::Property::MIX_COLOR;
893   }
894   else if(key.stringKey == OPACITY)
895   {
896     return Toolkit::Visual::Property::OPACITY;
897   }
898   else if(key.stringKey == OFFSET)
899   {
900     return Toolkit::Visual::Transform::Property::OFFSET;
901   }
902   else if(key.stringKey == OFFSET_POLICY)
903   {
904     return Toolkit::Visual::Transform::Property::OFFSET_POLICY;
905   }
906   else if(key.stringKey == ORIGIN)
907   {
908     return Toolkit::Visual::Transform::Property::ORIGIN;
909   }
910   else if(key.stringKey == PREMULTIPLIED_ALPHA)
911   {
912     return Toolkit::Visual::Property::PREMULTIPLIED_ALPHA;
913   }
914   else if(key.stringKey == CUSTOM_SHADER)
915   {
916     return Toolkit::Visual::Property::SHADER;
917   }
918   else if(key.stringKey == SIZE)
919   {
920     return Toolkit::Visual::Transform::Property::SIZE;
921   }
922   else if(key.stringKey == SIZE_POLICY)
923   {
924     return Toolkit::Visual::Transform::Property::SIZE_POLICY;
925   }
926   else if(key.stringKey == TRANSFORM)
927   {
928     return Toolkit::Visual::Property::TRANSFORM;
929   }
930   else if(key.stringKey == VISUAL_FITTING_MODE)
931   {
932     return Toolkit::DevelVisual::Property::VISUAL_FITTING_MODE;
933   }
934   else if(key.stringKey == CORNER_RADIUS)
935   {
936     return Toolkit::DevelVisual::Property::CORNER_RADIUS;
937   }
938   else if(key.stringKey == CORNER_RADIUS_POLICY)
939   {
940     return Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY;
941   }
942   else if(key.stringKey == BORDERLINE_WIDTH)
943   {
944     return Toolkit::DevelVisual::Property::BORDERLINE_WIDTH;
945   }
946   else if(key.stringKey == BORDERLINE_COLOR)
947   {
948     return Toolkit::DevelVisual::Property::BORDERLINE_COLOR;
949   }
950   else if(key.stringKey == BORDERLINE_OFFSET)
951   {
952     return Toolkit::DevelVisual::Property::BORDERLINE_OFFSET;
953   }
954
955   return Property::INVALID_INDEX;
956 }
957
958 Property::Index Visual::Base::GetPropertyIndex(Property::Key key)
959 {
960   switch(GetIntKey(key))
961   {
962     case Dali::Toolkit::Visual::Transform::Property::OFFSET:
963     {
964       return VisualRenderer::Property::TRANSFORM_OFFSET;
965     }
966     case Dali::Toolkit::Visual::Transform::Property::SIZE:
967     {
968       return VisualRenderer::Property::TRANSFORM_SIZE;
969     }
970     case Dali::Toolkit::Visual::Transform::Property::ORIGIN:
971     {
972       return VisualRenderer::Property::TRANSFORM_ORIGIN;
973     }
974     case Dali::Toolkit::Visual::Transform::Property::ANCHOR_POINT:
975     {
976       return VisualRenderer::Property::TRANSFORM_ANCHOR_POINT;
977     }
978     case Dali::Toolkit::Visual::Property::MIX_COLOR:
979     {
980       return VisualRenderer::Property::VISUAL_MIX_COLOR;
981     }
982     case Dali::Toolkit::Visual::Property::OPACITY:
983     {
984       return DevelRenderer::Property::OPACITY;
985     }
986     case Dali::Toolkit::Visual::Property::PREMULTIPLIED_ALPHA:
987     {
988       return VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA;
989     }
990     case Dali::Toolkit::DevelVisual::Property::CORNER_RADIUS:
991     {
992       return DecoratedVisualRenderer::Property::CORNER_RADIUS;
993     }
994     case Dali::Toolkit::DevelVisual::Property::BORDERLINE_WIDTH:
995     {
996       return DecoratedVisualRenderer::Property::BORDERLINE_WIDTH;
997     }
998     case Dali::Toolkit::DevelVisual::Property::BORDERLINE_COLOR:
999     {
1000       return DecoratedVisualRenderer::Property::BORDERLINE_COLOR;
1001     }
1002     case Dali::Toolkit::DevelVisual::Property::BORDERLINE_OFFSET:
1003     {
1004       return DecoratedVisualRenderer::Property::BORDERLINE_OFFSET;
1005     }
1006   }
1007
1008   Property::Index index = mImpl->mRenderer.GetPropertyIndex(key);
1009
1010   if(index == Property::INVALID_INDEX)
1011   {
1012     // Is it a shader property?
1013     Shader shader = mImpl->mRenderer.GetShader();
1014     index         = shader.GetPropertyIndex(key);
1015     if(index != Property::INVALID_INDEX)
1016     {
1017       // Yes - we should register it in the Renderer so it can be set / animated
1018       // independently, as shaders are shared across multiple renderers.
1019       std::string     keyName;
1020       Property::Index keyIndex(Property::INVALID_KEY);
1021       if(key.type == Property::Key::INDEX)
1022       {
1023         keyName  = shader.GetPropertyName(index);
1024         keyIndex = key.indexKey;
1025       }
1026       else
1027       {
1028         keyName = key.stringKey;
1029         // Leave keyIndex as INVALID_KEY - it can still be registered against the string key.
1030       }
1031       Property::Value value = shader.GetProperty(index);
1032
1033       // We already know that mRenderer didn't have property. So we can assume that it is unique.
1034       index = mImpl->mRenderer.RegisterUniqueProperty(keyIndex, keyName, value);
1035     }
1036   }
1037   return index;
1038 }
1039
1040 void Visual::Base::SetupTransition(
1041   Dali::Animation&                    transition,
1042   Internal::TransitionData::Animator& animator,
1043   Property::Index                     index,
1044   Property::Value&                    initialValue,
1045   Property::Value&                    targetValue)
1046 {
1047   if(index != Property::INVALID_INDEX)
1048   {
1049     if(mImpl->mRenderer)
1050     {
1051       if(animator.animate == false)
1052       {
1053         mImpl->mRenderer.SetProperty(index, targetValue);
1054       }
1055       else
1056       {
1057         if(animator.initialValue.GetType() != Property::NONE)
1058         {
1059           mImpl->mRenderer.SetProperty(index, initialValue);
1060         }
1061
1062         if(!transition)
1063         {
1064           transition = Dali::Animation::New(0.1f);
1065         }
1066
1067         transition.AnimateTo(Property(mImpl->mRenderer, index),
1068                              targetValue,
1069                              animator.alphaFunction,
1070                              TimePeriod(animator.timePeriodDelay,
1071                                         animator.timePeriodDuration));
1072       }
1073     }
1074   }
1075 }
1076
1077 void Visual::Base::AnimateProperty(
1078   Dali::Animation&                    transition,
1079   Internal::TransitionData::Animator& animator)
1080 {
1081 #if defined(DEBUG_ENABLED)
1082   if(gVisualBaseLogFilter->IsEnabledFor(Debug::General))
1083   {
1084     std::ostringstream oss;
1085     oss << "Visual::Base::AnimateProperty(Visual:" << mImpl->mName << " Property:" << animator.propertyKey << " Target: " << animator.targetValue << std::endl;
1086     DALI_LOG_INFO(gVisualBaseLogFilter, Debug::General, oss.str().c_str());
1087   }
1088 #endif
1089
1090   if(animator.propertyKey == Toolkit::Visual::Property::MIX_COLOR ||
1091      animator.propertyKey == MIX_COLOR ||
1092      (mImpl->mType == Toolkit::Visual::COLOR &&
1093       animator.propertyKey == ColorVisual::Property::MIX_COLOR) ||
1094      (mImpl->mType == Toolkit::Visual::PRIMITIVE &&
1095       animator.propertyKey == PrimitiveVisual::Property::MIX_COLOR))
1096   {
1097     AnimateMixColorProperty(transition, animator);
1098   }
1099   else if(animator.propertyKey == Toolkit::Visual::Property::OPACITY ||
1100           animator.propertyKey == OPACITY)
1101   {
1102     AnimateOpacityProperty(transition, animator);
1103   }
1104   else if(mImpl->mRenderer)
1105   {
1106     AnimateRendererProperty(transition, animator);
1107   }
1108 }
1109
1110 void Visual::Base::AnimateOpacityProperty(
1111   Dali::Animation&                    transition,
1112   Internal::TransitionData::Animator& animator)
1113 {
1114   float targetOpacity;
1115   if(animator.targetValue.Get(targetOpacity))
1116   {
1117     mImpl->mMixColor.a = targetOpacity;
1118   }
1119
1120   SetupTransition(transition, animator, DevelRenderer::Property::OPACITY, animator.initialValue, animator.targetValue);
1121 }
1122
1123 void Visual::Base::AnimateRendererProperty(
1124   Dali::Animation&                    transition,
1125   Internal::TransitionData::Animator& animator)
1126 {
1127   // Get actual renderer index (will convert transform keys into visualproperty indices)
1128   Property::Index index = GetPropertyIndex(animator.propertyKey);
1129
1130   if(index != Property::INVALID_INDEX)
1131   {
1132     if(animator.targetValue.GetType() != Property::NONE)
1133     {
1134       // Try writing target value into transform property map
1135       // if it's not a valid key, then it won't alter mTransform
1136       Property::Map map;
1137       if(animator.propertyKey.type == Property::Key::INDEX)
1138       {
1139         map.Add(animator.propertyKey.indexKey, animator.targetValue);
1140       }
1141       else
1142       {
1143         map.Add(animator.propertyKey.stringKey, animator.targetValue);
1144       }
1145
1146       mImpl->mTransform.UpdatePropertyMap(map);
1147     }
1148     SetupTransition(transition, animator, index, animator.initialValue, animator.targetValue);
1149   }
1150 }
1151
1152 void Visual::Base::AnimateMixColorProperty(
1153   Dali::Animation&                    transition,
1154   Internal::TransitionData::Animator& animator)
1155 {
1156   bool animateOpacity = false;
1157
1158   Property::Value initialOpacity;
1159   Property::Value targetOpacity;
1160   Property::Value initialMixColor;
1161   Property::Value targetMixColor;
1162
1163   Vector4 initialColor;
1164   if(animator.initialValue.Get(initialColor))
1165   {
1166     if(animator.initialValue.GetType() == Property::VECTOR4)
1167     {
1168       // if there is an initial color specifying alpha, test it
1169       initialOpacity = initialColor.a;
1170     }
1171     initialMixColor = Vector3(initialColor);
1172   }
1173
1174   // Set target value into data store
1175   if(animator.targetValue.GetType() != Property::NONE)
1176   {
1177     Vector4 mixColor;
1178     animator.targetValue.Get(mixColor);
1179     if(animator.targetValue.GetType() == Property::VECTOR4)
1180     {
1181       mImpl->mMixColor.a = mixColor.a;
1182       targetOpacity      = mixColor.a;
1183       animateOpacity     = true;
1184     }
1185
1186     mImpl->mMixColor.r = mixColor.r;
1187     mImpl->mMixColor.g = mixColor.g;
1188     mImpl->mMixColor.b = mixColor.b;
1189     targetMixColor     = Vector3(mixColor);
1190   }
1191
1192   SetupTransition(transition, animator, VisualRenderer::Property::VISUAL_MIX_COLOR, initialMixColor, targetMixColor);
1193
1194   if(animateOpacity)
1195   {
1196     SetupTransition(transition, animator, DevelRenderer::Property::OPACITY, initialOpacity, targetOpacity);
1197   }
1198 }
1199
1200 Dali::Property Visual::Base::GetPropertyObject(Dali::Property::Key key)
1201 {
1202   if(!mImpl->mRenderer)
1203   {
1204     Handle handle;
1205     return Dali::Property(handle, Property::INVALID_INDEX);
1206   }
1207
1208   switch(GetIntKey(key))
1209   {
1210     // Default animatable properties from VisualRenderer
1211     case Toolkit::Visual::Property::MIX_COLOR:
1212     {
1213       return Dali::Property(mImpl->mRenderer, VisualRenderer::Property::VISUAL_MIX_COLOR);
1214     }
1215     case Toolkit::Visual::Property::OPACITY:
1216     {
1217       return Dali::Property(mImpl->mRenderer, DevelRenderer::Property::OPACITY);
1218     }
1219     case Toolkit::Visual::Transform::Property::OFFSET:
1220     {
1221       return Dali::Property(mImpl->mRenderer, VisualRenderer::Property::TRANSFORM_OFFSET);
1222     }
1223     case Toolkit::Visual::Transform::Property::SIZE:
1224     {
1225       return Dali::Property(mImpl->mRenderer, VisualRenderer::Property::TRANSFORM_SIZE);
1226     }
1227
1228     // Default animatable properties from DecoratedVisualRenderer
1229     case Toolkit::DevelVisual::Property::CORNER_RADIUS:
1230     {
1231       if(IsTypeAvailableForCornerRadius(mImpl->mType))
1232       {
1233         const bool updateShader = !mImpl->mCustomShader && !IsRoundedCornerRequired();
1234
1235         // CornerRadius is animated now. we always have to use corner radius feature.
1236         mImpl->mAlwaysUsingCornerRadius = true;
1237
1238         if(updateShader)
1239         {
1240           // Update each values to renderer
1241           DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterCornerRadiusUniform();
1242           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS, mImpl->GetCornerRadius());
1243           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::CORNER_RADIUS_POLICY, static_cast<float>(mImpl->GetCornerRadiusPolicy()));
1244
1245           // Change shader
1246           UpdateShader();
1247         }
1248         if(!IsBorderlineRequired())
1249         {
1250           // If IsBorderlineRequired is true, BLEND_MODE is already BlendMode::ON_WITHOUT_CULL. So we don't overwrite it.
1251           mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
1252         }
1253         return Dali::Property(mImpl->mRenderer, DecoratedVisualRenderer::Property::CORNER_RADIUS);
1254       }
1255       break;
1256     }
1257     case Toolkit::DevelVisual::Property::BORDERLINE_WIDTH:
1258     case Toolkit::DevelVisual::Property::BORDERLINE_COLOR:
1259     case Toolkit::DevelVisual::Property::BORDERLINE_OFFSET:
1260     {
1261       if(IsTypeAvailableForBorderline(mImpl->mType))
1262       {
1263         const bool updateShader = !mImpl->mCustomShader && !IsBorderlineRequired();
1264
1265         // Borderline is animated now. we always have to use borderline feature.
1266         mImpl->mAlwaysUsingBorderline = true;
1267
1268         if(updateShader)
1269         {
1270           // Update each values to renderer
1271           DownCast<DecoratedVisualRenderer>(mImpl->mRenderer).RegisterBorderlineUniform();
1272           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH, mImpl->GetBorderlineWidth());
1273           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_COLOR, mImpl->GetBorderlineColor());
1274           mImpl->mRenderer.SetProperty(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET, mImpl->GetBorderlineOffset());
1275
1276           // Change shader
1277           UpdateShader();
1278         }
1279         mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON_WITHOUT_CULL);
1280
1281         return Dali::Property(mImpl->mRenderer, GetPropertyIndex(key));
1282       }
1283       break;
1284     }
1285     default:
1286     {
1287       // Special case for MIX_COLOR
1288       if(key.type == Property::Key::INDEX &&
1289          ((mImpl->mType == Toolkit::Visual::COLOR && key.indexKey == ColorVisual::Property::MIX_COLOR) ||
1290           (mImpl->mType == Toolkit::Visual::PRIMITIVE && key.indexKey == PrimitiveVisual::Property::MIX_COLOR)))
1291       {
1292         return Dali::Property(mImpl->mRenderer, VisualRenderer::Property::VISUAL_MIX_COLOR);
1293       }
1294
1295       // Special case for BLUR_RADIUS
1296       if(mImpl->mType == Toolkit::Visual::COLOR &&
1297          ((key.type == Property::Key::INDEX && key.indexKey == DevelColorVisual::Property::BLUR_RADIUS) ||
1298           (key.type == Property::Key::STRING && key.stringKey == BLUR_RADIUS_NAME)))
1299       {
1300         // Request to color-visual class
1301         return OnGetPropertyObject(key);
1302       }
1303     }
1304   }
1305
1306   // If it is not VisualRenderer property, check registered Renderer and Shader property.
1307   Property::Index index = GetPropertyIndex(key);
1308   if(index != Property::INVALID_INDEX)
1309   {
1310     return Dali::Property(mImpl->mRenderer, index);
1311   }
1312
1313   // We can't find the property in the base class.
1314   // Request to child class
1315   return OnGetPropertyObject(key);
1316 }
1317
1318 } // namespace Internal
1319
1320 } // namespace Toolkit
1321
1322 } // namespace Dali