Clamp text shadow offset to limit clipping and/or bleeding of the shadow 02/17702/1
authorJavon Prince <javon.prince@samsung.com>
Thu, 6 Mar 2014 11:05:15 +0000 (11:05 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Fri, 7 Mar 2014 14:02:10 +0000 (14:02 +0000)
[Issue#] P140304-04522

[Problem] If the shadow offset value is too large artifacts can be seen.

[Cause] Range of values is relative to the font point size.

[Solution] Clamp the shadow offset value internally.

Change-Id: Idb26ac962b08fc302988d1ea101962e637ed1e44
Signed-off-by: Paul Wisbey <p.wisbey@samsung.com>
dali/internal/event/actor-attachments/text-attachment-impl.cpp

index e9b4389..5374c7d 100644 (file)
@@ -291,11 +291,15 @@ void TextAttachment::SetShadow(bool enable, const Vector4& color, const Vector2&
 
     const float unitPointSize( 64.0f );
     const float unitsToPixels( mFont->GetUnitsToPixels());
+    const float fontPointSize( mFont->GetPointSize() );
 
     float shadowSize( (size * 0.25f) / unitsToPixels );
 
-    Vector2 shadowOffset( offset * ( unitPointSize / mFont->GetPointSize() ) );
-
+    Vector2 shadowOffset( offset );
+    Vector2 maxOffset( fontPointSize / 4.5f, fontPointSize / 4.5f );
+    shadowOffset = Min( shadowOffset, maxOffset );
+    shadowOffset = Max( shadowOffset, -maxOffset );
+    shadowOffset *= unitPointSize / fontPointSize;
     SetDropShadowMessage( mStage->GetUpdateInterface(), *mSceneObject, enable, color, shadowOffset, shadowSize );
   }
 }