TextParameters object now contains only the specific parameters set dali-2014-wk20-release
authorRichard Underhill <r.underhill@partner.samsung.com>
Tue, 13 May 2014 13:47:32 +0000 (14:47 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 15 May 2014 11:40:55 +0000 (12:40 +0100)
[Issue#] N/A

[Problem] TextParameters contained Outline, Glow, DropShadow and Gradient
values even if some were not used.

[Cause]

[Solution] A container of Dali::Any objects describe the TextParameters

Change-Id: I73ff83b01b8e84df72f0fc3659e035c6a730d747
Signed-off-by: Richard Underhill <r.underhill@partner.samsung.com>
dali/internal/common/text-parameters.cpp
dali/internal/common/text-parameters.h
dali/internal/event/actor-attachments/text-attachment-impl.cpp
dali/internal/render/renderers/scene-graph-text-renderer.cpp

index 1ff5a13..8bf42b9 100644 (file)
@@ -27,20 +27,7 @@ namespace Internal
 {
 
 TextParameters::TextParameters()
-: mOutlineEnabled( false ),
-  mGlowEnabled( false ),
-  mDropShadowEnabled( false ),
-  mGradientEnabled( false ),
-  mOutlineColor( TextStyle::DEFAULT_OUTLINE_COLOR ),
-  mOutline( TextStyle::DEFAULT_OUTLINE_THICKNESS ),
-  mGlowColor( TextStyle::DEFAULT_GLOW_COLOR ),
-  mGlow( TextStyle::DEFAULT_GLOW_INTENSITY ),
-  mDropShadowColor( TextStyle::DEFAULT_SHADOW_COLOR ),
-  mDropShadow( TextStyle::DEFAULT_SHADOW_OFFSET ),
-  mDropShadowSize( TextStyle::DEFAULT_SHADOW_SIZE ),
-  mGradientColor( TextStyle::DEFAULT_GRADIENT_COLOR ),
-  mGradientStartPoint( TextStyle::DEFAULT_GRADIENT_START_POINT ),
-  mGradientEndPoint( TextStyle::DEFAULT_GRADIENT_END_POINT )
+: mFlags( 0 )
 {
 }
 
@@ -51,32 +38,272 @@ TextParameters::~TextParameters()
 
 void TextParameters::SetOutline( bool enable, const Vector4& color, const Vector2& thickness )
 {
-  mOutlineEnabled = enable;
-  mOutlineColor = color;
-  mOutline = thickness;
+  if ( mFlags & OUTLINE_ENABLED )
+  {
+    OutlineAttributes* attrPtr = AnyCast< OutlineAttributes >( &mParameters[ mFlags & TEXT_PARAMETER_MASK ] );
+    attrPtr->mOutlineColor = color;
+    attrPtr->mOutlineThickness = thickness;
+  }
+  else
+  {
+    OutlineAttributes attr;
+    attr.mOutlineColor = color;
+    attr.mOutlineThickness = thickness;
+    mParameters.push_back( attr );
+    mFlags |= ( ( mFlags & ~OUTLINE_INDEX ) | ( ( mParameters.size() - 1 ) & TEXT_PARAMETER_MASK ) | OUTLINE_ENABLED );
+  }
 }
 
 void TextParameters::SetGlow( bool enable, const Vector4& color, const float intensity)
 {
-  mGlowEnabled = enable;
-  mGlowColor = color;
-  mGlow = intensity;
+  if ( mFlags & GLOW_ENABLED )
+  {
+    GlowAttributes* attrPtr = AnyCast< GlowAttributes >( &mParameters[ ( mFlags >> GLOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+    attrPtr->mGlowColor = color;
+    attrPtr->mGlowIntensity = intensity;
+  }
+  else
+  {
+    GlowAttributes attr;
+    attr.mGlowColor = color;
+    attr.mGlowIntensity = intensity;
+    mParameters.push_back( attr );
+    mFlags |= ( ( mFlags & ~GLOW_INDEX ) | ( ( ( mParameters.size() - 1 ) & TEXT_PARAMETER_MASK ) << GLOW_INDEX_SHIFT ) | GLOW_ENABLED );
+  }
 }
 
 void TextParameters::SetShadow( bool enable, const Vector4& color, const Vector2& offset, const float size )
 {
-  mDropShadowEnabled = enable;
-  mDropShadowColor = color;
-  mDropShadow = offset;
-  mDropShadowSize = size;
+  if ( mFlags & DROP_SHADOW_ENABLED )
+  {
+    DropShadowAttributes* attrPtr = AnyCast< DropShadowAttributes >( &mParameters[ ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+    attrPtr->mDropShadowColor = color;
+    attrPtr->mDropShadowOffset = offset;
+    attrPtr->mDropShadowSize = size;
+  }
+  else
+  {
+    DropShadowAttributes attr;
+    attr.mDropShadowColor = color;
+    attr.mDropShadowOffset = offset;
+    attr.mDropShadowSize = size;
+    mParameters.push_back( attr );
+    mFlags |= ( ( mFlags & ~DROP_SHADOW_INDEX ) | ( ( ( mParameters.size() - 1 ) & TEXT_PARAMETER_MASK ) << DROP_SHADOW_INDEX_SHIFT ) | DROP_SHADOW_ENABLED );
+  }
 }
 
 void TextParameters::SetGradient( const Vector4& color, const Vector2& start, const Vector2& end )
 {
-  mGradientEnabled = end != start;
-  mGradientColor = color;
-  mGradientStartPoint = start;
-  mGradientEndPoint = end;
+  if ( mFlags & GRADIENT_EXISTS )
+  {
+    GradientAttributes* attrPtr = AnyCast< GradientAttributes >( &mParameters[ ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+    attrPtr->mGradientColor = color;
+    attrPtr->mGradientStartPoint = start;
+    attrPtr->mGradientEndPoint = end;
+  }
+  else
+  {
+    GradientAttributes attr;
+    attr.mGradientColor = color;
+    attr.mGradientStartPoint = start;
+    attr.mGradientEndPoint = end;
+    mParameters.push_back( attr );
+    mFlags |= ( ( mFlags & ~GRADIENT_INDEX ) | ( ( ( mParameters.size() - 1 ) & TEXT_PARAMETER_MASK ) << GRADIENT_INDEX_SHIFT ) | GRADIENT_EXISTS );
+  }
+
+  if ( end != start )
+  {
+    mFlags |= GRADIENT_ENABLED;
+  }
+  else
+  {
+    mFlags &=~GRADIENT_ENABLED;
+  }
+}
+
+void TextParameters::SetGradientColor( const Vector4& color )
+{
+  if ( mFlags & GRADIENT_EXISTS )
+  {
+    GradientAttributes* attrPtr = AnyCast< GradientAttributes >( &mParameters[ ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+    attrPtr->mGradientColor = color;
+  }
+  else
+  {
+    GradientAttributes attr;
+    attr.mGradientColor = color;
+    attr.mGradientStartPoint = TextStyle::DEFAULT_GRADIENT_START_POINT;
+    attr.mGradientEndPoint = TextStyle::DEFAULT_GRADIENT_END_POINT;
+    mParameters.push_back( attr );
+    mFlags |= ( ( mFlags & ~GRADIENT_INDEX ) | ( ( ( mParameters.size() - 1 ) & TEXT_PARAMETER_MASK ) << GRADIENT_INDEX_SHIFT ) | GRADIENT_EXISTS );
+  }
+}
+
+void TextParameters::SetGradientStartPoint( const Vector2& start )
+{
+  if ( mFlags & GRADIENT_EXISTS )
+  {
+    GradientAttributes* attrPtr = AnyCast< GradientAttributes >( &mParameters[ ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+    attrPtr->mGradientStartPoint = start;
+  }
+  else
+  {
+    GradientAttributes attr;
+    attr.mGradientStartPoint = start;
+    attr.mGradientEndPoint = TextStyle::DEFAULT_GRADIENT_END_POINT;
+    attr.mGradientColor = TextStyle::DEFAULT_GRADIENT_COLOR;
+    mParameters.push_back( attr );
+    mFlags |= ( ( mFlags & ~GRADIENT_INDEX ) | ( ( ( mParameters.size() - 1 ) & TEXT_PARAMETER_MASK ) << GRADIENT_INDEX_SHIFT ) | GRADIENT_EXISTS );
+  }
+}
+
+void TextParameters::SetGradientEndPoint( const Vector2& end )
+{
+  if ( mFlags & GRADIENT_EXISTS )
+  {
+    GradientAttributes* attrPtr = AnyCast< GradientAttributes >( &mParameters[ ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+    attrPtr->mGradientEndPoint = end;
+  }
+  else
+  {
+    GradientAttributes attr;
+    attr.mGradientEndPoint = end;
+    attr.mGradientStartPoint = TextStyle::DEFAULT_GRADIENT_START_POINT;
+    attr.mGradientColor = TextStyle::DEFAULT_GRADIENT_COLOR;
+    mParameters.push_back( attr );
+    mFlags |= ( ( mFlags & ~GRADIENT_INDEX ) | ( ( ( mParameters.size() - 1 ) & TEXT_PARAMETER_MASK ) << GRADIENT_INDEX_SHIFT ) | GRADIENT_EXISTS );
+  }
+}
+
+const Vector4& TextParameters::GetOutlineColor()
+{
+  if ( mFlags & OUTLINE_ENABLED )
+  {
+    const OutlineAttributes* attrPtr = AnyCast< OutlineAttributes >( &mParameters[ mFlags & TEXT_PARAMETER_MASK ] );
+    return attrPtr->mOutlineColor;
+  }
+  else
+  {
+    return TextStyle::DEFAULT_OUTLINE_COLOR;
+  }
+}
+
+const Vector2& TextParameters::GetOutlineThickness()
+{
+  if ( mFlags & OUTLINE_ENABLED )
+  {
+    const OutlineAttributes* attrPtr = AnyCast< OutlineAttributes >( &mParameters[ mFlags & TEXT_PARAMETER_MASK ] );
+    return attrPtr->mOutlineThickness;
+  }
+  else
+  {
+    return TextStyle::DEFAULT_OUTLINE_THICKNESS;
+  }
+}
+
+const Vector4& TextParameters::GetGlowColor()
+{
+  if ( mFlags & GLOW_ENABLED )
+  {
+    const GlowAttributes* attrPtr = AnyCast< GlowAttributes >( &mParameters[ ( mFlags >> GLOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+    return attrPtr->mGlowColor;
+  }
+  else
+  {
+    return TextStyle::DEFAULT_GLOW_COLOR;
+  }
+}
+
+float TextParameters::GetGlowIntensity()
+{
+  if ( mFlags & GLOW_ENABLED )
+  {
+    const GlowAttributes* attrPtr = AnyCast< GlowAttributes >( &mParameters[ ( mFlags >> GLOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+    return attrPtr->mGlowIntensity;
+  }
+  else
+  {
+    return TextStyle::DEFAULT_GLOW_INTENSITY;
+  }
+}
+
+const Vector4& TextParameters::GetDropShadowColor()
+{
+  if ( mFlags & DROP_SHADOW_ENABLED )
+  {
+    const DropShadowAttributes* attrPtr = AnyCast< DropShadowAttributes >( &mParameters[ ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+    return attrPtr->mDropShadowColor;
+  }
+  else
+  {
+    return TextStyle::DEFAULT_SHADOW_COLOR;
+  }
+}
+
+const Vector2& TextParameters::GetDropShadowOffset()
+{
+  if ( mFlags & DROP_SHADOW_ENABLED )
+  {
+
+    const DropShadowAttributes* attrPtr = AnyCast< DropShadowAttributes >( &mParameters[ ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+    return attrPtr->mDropShadowOffset;
+  }
+  else
+  {
+    return TextStyle::DEFAULT_SHADOW_OFFSET;
+  }
+}
+
+float TextParameters::GetDropShadowSize()
+{
+  if ( mFlags & DROP_SHADOW_ENABLED )
+  {
+    const DropShadowAttributes* attrPtr = AnyCast< DropShadowAttributes >( &mParameters[ ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+    return attrPtr->mDropShadowSize;
+  }
+  else
+  {
+    return TextStyle::DEFAULT_SHADOW_SIZE;
+  }
+}
+
+const Vector4& TextParameters::GetGradientColor()
+{
+  if ( mFlags & GRADIENT_EXISTS )
+  {
+    const GradientAttributes* attrPtr = AnyCast< GradientAttributes >( &mParameters[ ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+    return attrPtr->mGradientColor;
+  }
+  else
+  {
+    return TextStyle::DEFAULT_GRADIENT_COLOR;
+  }
+}
+
+const Vector2& TextParameters::GetGradientStartPoint()
+{
+  if ( mFlags & GRADIENT_EXISTS )
+  {
+    const GradientAttributes* attrPtr = AnyCast< GradientAttributes >( &mParameters[ ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+    return attrPtr->mGradientStartPoint;
+  }
+  else
+  {
+    return TextStyle::DEFAULT_GRADIENT_START_POINT;
+  }
+}
+
+const Vector2& TextParameters::GetGradientEndPoint()
+{
+  if ( mFlags & GRADIENT_EXISTS )
+  {
+    const GradientAttributes* attrPtr = AnyCast< GradientAttributes >( &mParameters[ ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ] );
+    return attrPtr->mGradientEndPoint;
+  }
+  else
+  {
+    return TextStyle::DEFAULT_GRADIENT_END_POINT;
+  }
 }
 
 } // namespace Internal
index 5999fa9..1d45988 100644 (file)
 #include <dali/public-api/math/vector2.h>
 #include <dali/public-api/math/vector4.h>
 
+#include <dali/public-api/object/any.h>
+#include <vector>
+
 namespace Dali
 {
 
 namespace Internal
 {
 
+
+  // Number of bits for an index mask - increase if more attributes are added...
+  const unsigned int TEXT_PARAMETER_BITS = 2;
+
+  // Set mask for this number of bits
+  const unsigned int TEXT_PARAMETER_MASK = ~( -1 << TEXT_PARAMETER_BITS );
+
+  // Shift values for attribute indices
+  const unsigned int OUTLINE_INDEX_SHIFT = 0;
+  const unsigned int GLOW_INDEX_SHIFT = OUTLINE_INDEX_SHIFT + TEXT_PARAMETER_BITS;
+  const unsigned int DROP_SHADOW_INDEX_SHIFT = GLOW_INDEX_SHIFT + TEXT_PARAMETER_BITS;
+  const unsigned int GRADIENT_INDEX_SHIFT = DROP_SHADOW_INDEX_SHIFT + TEXT_PARAMETER_BITS;
+  const unsigned int TEXT_PARAMETER_FLAGS = GRADIENT_INDEX_SHIFT + TEXT_PARAMETER_BITS;
+
+  // Position in flags for attribute index
+  const unsigned int OUTLINE_INDEX = 0;
+  const unsigned int GLOW_INDEX = TEXT_PARAMETER_MASK << GLOW_INDEX_SHIFT;
+  const unsigned int DROP_SHADOW_INDEX = TEXT_PARAMETER_MASK << DROP_SHADOW_INDEX_SHIFT;
+  const unsigned int GRADIENT_INDEX = TEXT_PARAMETER_MASK << GRADIENT_INDEX_SHIFT;
+
+  // Flag positions for attributes ( gradient has two as parameters can be set independently )
+  const unsigned int OUTLINE_ENABLED = 1 << TEXT_PARAMETER_FLAGS;
+  const unsigned int GLOW_ENABLED = 1 << ( TEXT_PARAMETER_FLAGS + 1 );
+  const unsigned int DROP_SHADOW_ENABLED = 1 << ( TEXT_PARAMETER_FLAGS + 2 );
+  const unsigned int GRADIENT_EXISTS = 1 << ( TEXT_PARAMETER_FLAGS + 3 );
+  const unsigned int GRADIENT_ENABLED = 1 << ( TEXT_PARAMETER_FLAGS + 4 );
+  const unsigned int ATTRIBUTE_END = GRADIENT_ENABLED;
+
 /**
  * class TextParameters internal class to encapsulate (and allow on demand allocation) of
  * text effect parameters like, outline, glow and shadow
@@ -34,6 +65,45 @@ namespace Internal
 class TextParameters
 {
 public:
+
+  /**
+   * @brief Outline attributes
+   */
+  struct OutlineAttributes
+  {
+    Vector4 mOutlineColor;
+    Vector2 mOutlineThickness;
+  };
+
+  /**
+   * @brief Glow attributes
+   */
+  struct GlowAttributes
+  {
+    Vector4 mGlowColor;
+    float mGlowIntensity;
+  };
+
+  /**
+   * @brief Drop Shadow attributes
+   */
+  struct DropShadowAttributes
+  {
+    Vector4 mDropShadowColor;
+    Vector2 mDropShadowOffset;
+    float   mDropShadowSize;
+  };
+
+  /**
+   * @brief Gradient attributes
+   */
+  struct GradientAttributes
+  {
+    Vector4 mGradientColor;
+    Vector2 mGradientStartPoint;
+    Vector2 mGradientEndPoint;
+  };
+
   /**
    * Constructor
    */
@@ -54,32 +124,173 @@ public:
   void SetShadow(bool enable, const Vector4& color, const Vector2& offset, const float size);
 
   /**
-   * Set Gradient parameters.
+   * @brief Set Gradient parameters.
    * @param[in] color The gradient color (end-point color)
    * @param[in] start The relative position of the gradient start point.
    * @param[in] end   The relative position of the gradient end point.
    */
   void SetGradient( const Vector4& color, const Vector2& start, const Vector2& end);
 
+  /**
+   * @brief Set Gradient color
+   *
+   * @param color Gradient color
+   */
+  void SetGradientColor( const Vector4& color );
+
+  /**
+   * @brief Set Gradient Start Point
+   *
+   * @param start Position of gradient start
+   */
+  void SetGradientStartPoint( const Vector2& start );
+
+  /**
+   * @brief Set Gradient End Point
+   *
+   * @param end Position of gradient end
+   */
+  void SetGradientEndPoint( const Vector2& end );
+
+  /**
+   * @brief Get the Gradient Color
+   *
+   * @return Gradient Color
+   */
+  const Vector4& GetOutlineColor();
+
+  /**
+   * @brief Get Outline Thickness
+   *
+   * @return Outline Thickness
+   */
+  const Vector2& GetOutlineThickness();
+
+  /**
+   * @brief Get Glow Color
+   *
+   * @return Glow Color
+   */
+  const Vector4& GetGlowColor();
+
+  /**
+   * @brief Get Glow Intensity
+   *
+   * @return Glow Intensity
+   */
+  float GetGlowIntensity();
+
+  /**
+   * @brief Get Drop Shadow Color
+   *
+   * @return Drop Shadow Color
+   */
+  const Vector4& GetDropShadowColor();
+
+  /**
+   * @brief Get Drop Shadow Offset
+   *
+   * @return Drop Shadow Offset
+   */
+  const Vector2& GetDropShadowOffset();
+
+  /**
+   * @brief Get Drop Shadow Size
+   *
+   * @return Drop Shadow Size
+   */
+  float GetDropShadowSize();
+
+  /**
+   * @brief Get Gradient Color
+   *
+   * @return Gradient Color
+   */
+  const Vector4& GetGradientColor();
+
+  /**
+   * @brief Get Gradient Start Point
+   *
+   * @return Position of Gradient Start Point
+   */
+  const Vector2& GetGradientStartPoint();
+
+  /**
+   * @brief Get Gradient End Point
+   *
+   * @return Position of Gradient End Point
+   */
+  const Vector2& GetGradientEndPoint();
+
+  /**
+   * @brief Get if Outline is enabled
+   *
+   * @return true if enabled, false if not
+   */
+  const bool IsOutlineEnabled() const
+  {
+    return ( ( mFlags & OUTLINE_ENABLED ) != 0 );
+  }
+
+  /**
+   * @brief Get if Glow is enabled
+   *
+   * @return true if enabled, false if not
+   */
+  const bool IsGlowEnabled() const
+  {
+    return ( ( mFlags & GLOW_ENABLED ) != 0 );
+  }
+
+  /**
+   * @brief Get if Drop Shadow is enabled
+   *
+   * @return true if enabled, false if not
+   */
+  const bool IsDropShadowEnabled() const
+  {
+    return ( ( mFlags & DROP_SHADOW_ENABLED ) != 0 );
+  }
+
+  /**
+   * @brief Get if Gradient is enabled
+   *
+   * @return true if enabled, false if not
+   */
+  const bool IsGradientEnabled() const
+  {
+    return ( ( mFlags & GRADIENT_ENABLED ) != 0 );
+  }
+
+  /**
+   * @brief Enable Gradient
+   *
+   * @param enable Set gradient enabled flag to enable
+   */
+  void SetGradientEnabled( bool enable )
+  {
+    if ( enable )
+    {
+      mFlags |= GRADIENT_ENABLED;
+    }
+    else
+    {
+      mFlags &=~GRADIENT_ENABLED;
+    }
+  }
+
 private: // unimplemented copy constructor and assignment operator
   TextParameters( const TextParameters& copy );
   TextParameters& operator=(const TextParameters& rhs);
 
-public: // Attributes
-  bool    mOutlineEnabled : 1;
-  bool    mGlowEnabled : 1;
-  bool    mDropShadowEnabled : 1;
-  bool    mGradientEnabled : 1;
-  Vector4 mOutlineColor;
-  Vector2 mOutline;
-  Vector4 mGlowColor;
-  float   mGlow;
-  Vector4 mDropShadowColor;
-  Vector2 mDropShadow;
-  float   mDropShadowSize;
-  Vector4 mGradientColor;
-  Vector2 mGradientStartPoint;
-  Vector2 mGradientEndPoint;
+  std::vector< Dali::Any > mParameters;         // container for any used attributes
+
+#if ( ATTRIBUTE_END > 0x8000 )
+  unsigned int mFlags;                          // flags for used attributes, packed with position in container
+#else
+  unsigned short mFlags;                        // might be rendered irrelevant by alignment / packing
+#endif
+
 }; // class TextParameters
 
 } // namespace Internal
index f380c53..2e640c7 100644 (file)
@@ -113,9 +113,9 @@ void TextAttachment::SetGradientColor( const Vector4& color )
 {
   AllocateTextParameters();
 
-  if( mTextParameters->mGradientColor != color )
+  if( mTextParameters->GetGradientColor() != color )
   {
-    mTextParameters->mGradientColor = color;
+    mTextParameters->SetGradientColor( color );
 
     SetGradientColorMessage( mStage->GetUpdateInterface(), *mSceneObject, color );
   }
@@ -123,23 +123,16 @@ void TextAttachment::SetGradientColor( const Vector4& color )
 
 const Vector4& TextAttachment::GetGradientColor() const
 {
-  if( mTextParameters )
-  {
-    return mTextParameters->mGradientColor;
-  }
-  else
-  {
-    return TextStyle::DEFAULT_GRADIENT_COLOR;
-  }
+  return mTextParameters->GetGradientColor();
 }
 
 void TextAttachment::SetGradientStartPoint( const Vector2& position )
 {
   AllocateTextParameters();
 
-  if( mTextParameters->mGradientStartPoint != position )
+  if( mTextParameters->GetGradientStartPoint() != position )
   {
-    mTextParameters->mGradientStartPoint = position;
+    mTextParameters->SetGradientStartPoint( position );
 
     SetGradientStartPointMessage( mStage->GetUpdateInterface(), *mSceneObject, position );
   }
@@ -147,23 +140,16 @@ void TextAttachment::SetGradientStartPoint( const Vector2& position )
 
 const Vector2& TextAttachment::GetGradientStartPoint() const
 {
-  if( mTextParameters )
-  {
-    return mTextParameters->mGradientStartPoint;
-  }
-  else
-  {
-    return TextStyle::DEFAULT_GRADIENT_START_POINT;
-  }
+  return mTextParameters->GetGradientStartPoint();
 }
 
 void TextAttachment::SetGradientEndPoint( const Vector2& position )
 {
   AllocateTextParameters();
 
-  if( mTextParameters->mGradientEndPoint != position )
+  if( mTextParameters->GetGradientEndPoint() != position )
   {
-    mTextParameters->mGradientEndPoint = position;
+    mTextParameters->SetGradientEndPoint( position );
 
     SetGradientEndPointMessage( mStage->GetUpdateInterface(), *mSceneObject, position );
   }
@@ -171,14 +157,7 @@ void TextAttachment::SetGradientEndPoint( const Vector2& position )
 
 const Vector2& TextAttachment::GetGradientEndPoint() const
 {
-  if( mTextParameters )
-  {
-    return mTextParameters->mGradientEndPoint;
-  }
-  else
-  {
-    return TextStyle::DEFAULT_GRADIENT_END_POINT;
-  }
+    return mTextParameters->GetGradientEndPoint();
 }
 
 void TextAttachment::SetSmoothEdge( float smoothEdge )
@@ -206,7 +185,7 @@ void TextAttachment::SetOutline( bool enable, const Vector4& color, const Vector
 {
   AllocateTextParameters();
 
-  if (enable != mTextParameters->mOutlineEnabled || color != mTextParameters->mOutlineColor || thickness != mTextParameters->mOutline)
+  if (enable != mTextParameters->IsOutlineEnabled() || color != mTextParameters->GetOutlineColor() || thickness != mTextParameters->GetOutlineThickness() )
   {
     mTextParameters->SetOutline( enable, color, thickness );
 
@@ -216,35 +195,20 @@ void TextAttachment::SetOutline( bool enable, const Vector4& color, const Vector
 
 bool TextAttachment::GetOutline() const
 {
-  bool result( false );
-
-  if( mTextParameters )
-  {
-    result = mTextParameters->mOutlineEnabled;
-  }
-
-  return result;
+  return mTextParameters->IsOutlineEnabled();
 }
 
 void TextAttachment::GetOutlineParams( Vector4& color, Vector2& thickness ) const
 {
-  if( mTextParameters )
-  {
-    color = mTextParameters->mOutlineColor;
-    thickness = mTextParameters->mOutline;
-  }
-  else
-  {
-    color = TextStyle::DEFAULT_OUTLINE_COLOR;
-    thickness = TextStyle::DEFAULT_OUTLINE_THICKNESS;
-  }
+  color = mTextParameters->GetOutlineColor();
+  thickness = mTextParameters->GetOutlineThickness();
 }
 
 void TextAttachment::SetGlow( bool enable, const Vector4& color, float intensity )
 {
   AllocateTextParameters();
 
-  if (enable != mTextParameters->mGlowEnabled || color != mTextParameters->mGlowColor || fabsf(intensity - mTextParameters->mGlow) > Math::MACHINE_EPSILON_1000)
+  if (enable != mTextParameters->IsGlowEnabled() || color != mTextParameters->GetGlowColor() || fabsf(intensity - mTextParameters->GetGlowIntensity() ) > Math::MACHINE_EPSILON_1000)
   {
     mTextParameters->SetGlow( enable, color, intensity );
 
@@ -254,38 +218,23 @@ void TextAttachment::SetGlow( bool enable, const Vector4& color, float intensity
 
 bool TextAttachment::GetGlow() const
 {
-  bool result( false );
-
-  if( mTextParameters )
-  {
-    result = mTextParameters->mGlowEnabled;
-  }
-
-  return result;
+  return mTextParameters->IsGlowEnabled();
 }
 
 void TextAttachment::GetGlowParams( Vector4& color, float&  intensity) const
 {
-  if( mTextParameters )
-  {
-    color = mTextParameters->mGlowColor;
-    intensity = mTextParameters->mGlow;
-  }
-  else
-  {
-    color = TextStyle::DEFAULT_GLOW_COLOR;
-    intensity = TextStyle::DEFAULT_GLOW_INTENSITY;
-  }
+    color = mTextParameters->GetGlowColor();
+    intensity = mTextParameters->GetGlowIntensity();
 }
 
 void TextAttachment::SetShadow(bool enable, const Vector4& color, const Vector2& offset, const float size)
 {
   AllocateTextParameters();
 
-  if (enable != mTextParameters->mDropShadowEnabled ||
-      color != mTextParameters->mDropShadowColor ||
-      offset != mTextParameters->mDropShadow ||
-      fabsf(size - mTextParameters->mDropShadowSize) > Math::MACHINE_EPSILON_1 )
+  if (enable != mTextParameters->IsDropShadowEnabled() ||
+      color != mTextParameters->GetDropShadowColor() ||
+      offset != mTextParameters->GetDropShadowOffset() ||
+      fabsf(size - mTextParameters->GetDropShadowSize() ) > Math::MACHINE_EPSILON_1 )
   {
     mTextParameters->SetShadow( enable, color, offset, size );
 
@@ -306,30 +255,14 @@ void TextAttachment::SetShadow(bool enable, const Vector4& color, const Vector2&
 
 bool TextAttachment::GetShadow() const
 {
-  bool result( false );
-
-  if( mTextParameters )
-  {
-    result = mTextParameters->mDropShadowEnabled;
-  }
-
-  return result;
+  return mTextParameters->IsDropShadowEnabled();
 }
 
 void TextAttachment::GetShadowParams( Vector4& color, Vector2& offset, float& size ) const
 {
-  if( mTextParameters )
-  {
-    color = mTextParameters->mDropShadowColor;
-    offset = mTextParameters->mDropShadow;
-    size = mTextParameters->mDropShadowSize;
-  }
-  else
-  {
-    color = TextStyle::DEFAULT_SHADOW_COLOR;
-    offset = TextStyle::DEFAULT_SHADOW_OFFSET;
-    size = TextStyle::DEFAULT_SHADOW_SIZE;
-  }
+  color = mTextParameters->GetDropShadowColor();
+  offset = mTextParameters->GetDropShadowOffset();
+  size = mTextParameters->GetDropShadowSize();
 }
 
 void TextAttachment::SetTextColor(const Vector4& color)
index 18cc3da..248b99b 100644 (file)
@@ -201,24 +201,21 @@ void TextRenderer::SetFontSize( float pixelSize )
 void TextRenderer::SetGradientColor( const Vector4& color )
 {
   AllocateTextParameters();
-
-  mTextParameters->mGradientColor = color;
+  mTextParameters->SetGradientColor( color );
 }
 
 void TextRenderer::SetGradientStartPoint( const Vector2& position )
 {
   AllocateTextParameters();
-
-  mTextParameters->mGradientStartPoint = position;
-  mTextParameters->mGradientEnabled = mTextParameters->mGradientEndPoint != mTextParameters->mGradientStartPoint;
+  mTextParameters->SetGradientStartPoint( position );
+  mTextParameters->SetGradientEnabled( mTextParameters->GetGradientEndPoint() != mTextParameters->GetGradientStartPoint() );
 }
 
 void TextRenderer::SetGradientEndPoint( const Vector2& position )
 {
   AllocateTextParameters();
-
-  mTextParameters->mGradientEndPoint = position;
-  mTextParameters->mGradientEnabled = mTextParameters->mGradientEndPoint != mTextParameters->mGradientStartPoint;
+  mTextParameters->SetGradientEndPoint( position );
+  mTextParameters->SetGradientEnabled( mTextParameters->GetGradientEndPoint() != mTextParameters->GetGradientStartPoint() );
 }
 
 void TextRenderer::SetTextColor( const Vector4& color )
@@ -329,9 +326,9 @@ void TextRenderer::DoRender( BufferIndex bufferIndex, const Matrix& modelViewMat
   ShaderSubTypes shaderType( SHADER_DEFAULT );
   if( mTextParameters )
   {
-    if( mTextParameters->mOutlineEnabled )
+    if( mTextParameters->IsOutlineEnabled() )
     {
-      if( mTextParameters->mGlowEnabled )
+      if( mTextParameters->IsGlowEnabled() )
       {
         shaderType = SHADER_GRADIENT_OUTLINE_GLOW;
       }
@@ -340,11 +337,11 @@ void TextRenderer::DoRender( BufferIndex bufferIndex, const Matrix& modelViewMat
         shaderType = SHADER_GRADIENT_OUTLINE;
       }
     }
-    else if( mTextParameters->mGlowEnabled )
+    else if( mTextParameters->IsGlowEnabled() )
     {
       shaderType = SHADER_GRADIENT_GLOW;
     }
-    else if( mTextParameters->mDropShadowEnabled )
+    else if( mTextParameters->IsDropShadowEnabled() )
     {
       shaderType = SHADER_GRADIENT_SHADOW;
     }
@@ -386,23 +383,25 @@ void TextRenderer::DoRender( BufferIndex bufferIndex, const Matrix& modelViewMat
 
   if( mTextParameters )
   {
-    if( mTextParameters->mOutlineEnabled )
+    if( mTextParameters->IsOutlineEnabled() )
     {
       const int outlineLoc = program.GetUniformLocation( Program::UNIFORM_OUTLINE );
       const int outlineColorLoc = program.GetUniformLocation( Program::UNIFORM_OUTLINE_COLOR );
 
       if( Program::UNIFORM_UNKNOWN != outlineLoc && Program::UNIFORM_UNKNOWN != outlineColorLoc )
       {
-        float outlineWidth = mTextParameters->mOutline[1] + smoothWidth;
-        float outlineStart = mTextParameters->mOutline[0];
-        float outlineEnd = min( 1.0f, mTextParameters->mOutline[0] + outlineWidth );
+        const Vector2& outline = mTextParameters->GetOutlineThickness();
+        const Vector4& outlineColor = mTextParameters->GetOutlineColor();
+        float outlineWidth = outline[1] + smoothWidth;
+        float outlineStart = outline[0];
+        float outlineEnd = min( 1.0f, outlineStart + outlineWidth );
 
         program.SetUniform2f(outlineLoc, outlineStart, outlineEnd);
-        program.SetUniform4f(outlineColorLoc, mTextParameters->mOutlineColor.r, mTextParameters->mOutlineColor.g, mTextParameters->mOutlineColor.b, mTextParameters->mOutlineColor.a);
+        program.SetUniform4f(outlineColorLoc, outlineColor.r, outlineColor.g, outlineColor.b, outlineColor.a);
       }
     }
 
-    if( mTextParameters->mGlowEnabled )
+    if( mTextParameters->IsGlowEnabled() )
     {
       const int glowLoc = program.GetUniformLocation( Program::UNIFORM_GLOW );
       const int glowColorLoc = program.GetUniformLocation( Program::UNIFORM_GLOW_COLOR );
@@ -410,12 +409,13 @@ void TextRenderer::DoRender( BufferIndex bufferIndex, const Matrix& modelViewMat
       if( Program::UNIFORM_UNKNOWN != glowLoc && Program::UNIFORM_UNKNOWN != glowColorLoc )
       {
         // if mGlow is > mSmoothing we get an inverted glyph, so clamp the value
-        program.SetUniform1f(glowLoc, std::min(mTextParameters->mGlow, mSmoothing));
-        program.SetUniform4f(glowColorLoc, mTextParameters->mGlowColor.r, mTextParameters->mGlowColor.g, mTextParameters->mGlowColor.b, mTextParameters->mGlowColor.a);
+        program.SetUniform1f(glowLoc, std::min(mTextParameters->GetGlowIntensity(), mSmoothing));
+        const Vector4& glowColor = mTextParameters->GetGlowColor();
+        program.SetUniform4f(glowColorLoc, glowColor.r, glowColor.g, glowColor.b, glowColor.a);
       }
     }
 
-    if( mTextParameters->mDropShadowEnabled )
+    if( mTextParameters->IsDropShadowEnabled() )
     {
       const int shadowLoc = program.GetUniformLocation( Program::UNIFORM_SHADOW );
       const int shadowColorLoc = program.GetUniformLocation( Program::UNIFORM_SHADOW_COLOR );
@@ -424,10 +424,11 @@ void TextRenderer::DoRender( BufferIndex bufferIndex, const Matrix& modelViewMat
       if( Program::UNIFORM_UNKNOWN != shadowLoc && Program::UNIFORM_UNKNOWN != shadowColorLoc && Program::UNIFORM_UNKNOWN != shadowSmoothingLoc )
       {
         // convert shadow offset from tile to atlas coordinates
-        const Vector2 offset( mTextParameters->mDropShadow / mTexture->GetWidth());
-        float shadowSmoothing = std::max(0.0f, smoothing - mTextParameters->mDropShadowSize );
+        const Vector2& offset( mTextParameters->GetDropShadowOffset() / mTexture->GetWidth());
+        float shadowSmoothing = std::max(0.0f, smoothing - mTextParameters->GetDropShadowSize() );
         program.SetUniform2f(shadowLoc, offset.x, offset.y);
-        program.SetUniform4f(shadowColorLoc, mTextParameters->mDropShadowColor.r, mTextParameters->mDropShadowColor.g, mTextParameters->mDropShadowColor.b, mTextParameters->mDropShadowColor.a);
+        const Vector4& dropShadowColor = mTextParameters->GetDropShadowColor();
+        program.SetUniform4f(shadowColorLoc, dropShadowColor.r, dropShadowColor.g, dropShadowColor.b, dropShadowColor.a);
         program.SetUniform2f( shadowSmoothingLoc, std::max(0.0f, shadowSmoothing - smoothWidth), std::min(1.0f, shadowSmoothing + smoothWidth) );
       }
     }
@@ -451,9 +452,9 @@ void TextRenderer::DoRender( BufferIndex bufferIndex, const Matrix& modelViewMat
 
     if( mTextParameters )
     {
-      startPoint = mTextParameters->mGradientStartPoint;
-      projection = mTextParameters->mGradientEndPoint - startPoint;
-      if( mTextParameters->mGradientEnabled ) // same as: mGradientEndPoint != mGradientStartPoint
+      startPoint = mTextParameters->GetGradientStartPoint();
+      projection = mTextParameters->GetGradientEndPoint() - startPoint;
+      if( mTextParameters->IsGradientEnabled() ) // same as: mGradientEndPoint != mGradientStartPoint
       {
         projection /= projection.LengthSquared();
 
@@ -463,7 +464,7 @@ void TextRenderer::DoRender( BufferIndex bufferIndex, const Matrix& modelViewMat
 
         if( Program::UNIFORM_UNKNOWN != gradientColorLoc && Program::UNIFORM_UNKNOWN != textSizeLoc )
         {
-          const Vector4& color = mTextParameters->mGradientColor;
+          const Vector4& color = mTextParameters->GetGradientColor();
           program.SetUniform4f( gradientColorLoc, color.r, color.g, color.b, color.a );
           program.SetUniform2f( textSizeLoc, mInvTextSize.width, mInvTextSize.height );
         }