[3.0] Text - TextClipper replaced by an Actor with the CLIPPING_MODE enabled. 54/103554/7
authorVictor Cebollada <v.cebollada@samsung.com>
Thu, 8 Dec 2016 14:52:47 +0000 (14:52 +0000)
committerVictor Cebollada <v.cebollada@samsung.com>
Mon, 12 Dec 2016 16:37:59 +0000 (16:37 +0000)
* Fixes issues with the inherited alpha channel.

Change-Id: I6a3f125d6de10d4d3d8673a6b340f05ae0edd3f6
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.h
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.h
dali-toolkit/internal/file.list
dali-toolkit/internal/text/clipping/text-clipper.cpp [deleted file]
dali-toolkit/internal/text/clipping/text-clipper.h [deleted file]

index 83744f3..f4c43e0 100644 (file)
@@ -1106,15 +1106,10 @@ int utcDaliTextEditorEvent02(void)
   application.SendNotification();
   application.Render();
 
-  // Check there are the expected number of children ( offscreen root actor, and the offscreen image view
-  DALI_TEST_EQUALS( editor.GetChildCount(), 2u, TEST_LOCATION );
+  // Check there are the expected number of children (the stencil).
+  DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
 
-  Actor offscreenRoot = editor.GetChildAt( 0u );
-  DALI_TEST_CHECK( offscreenRoot.IsLayer() );
-  DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
-
-  Actor offscreenImage = editor.GetChildAt( 1u );
-  DALI_TEST_CHECK( offscreenImage );
+  Actor stencil = editor.GetChildAt( 0u );
 
   // Create a tap event to touch the text editor.
   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
@@ -1124,11 +1119,11 @@ int utcDaliTextEditorEvent02(void)
   application.SendNotification();
   application.Render();
 
-  Actor layer = editor.GetChildAt( 2u );
+  Actor layer = editor.GetChildAt( 1u );
   DALI_TEST_CHECK( layer.IsLayer() );
 
   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
-  DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
+  DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
 
   // Now the text editor has the focus, so it can handle the key events.
   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
@@ -1140,16 +1135,13 @@ int utcDaliTextEditorEvent02(void)
 
   // Checks the cursor and the renderer have been created.
   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
-  DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 2u, TEST_LOCATION ); // The camera actor and the renderer
+  DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
 
   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
   DALI_TEST_CHECK( cursor );
 
-  CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
-  DALI_TEST_CHECK( camera );
-
-  // The offscreen root actor has a container with all the actors which contain the text renderers.
-  Actor container = offscreenRoot.GetChildAt( 1u );
+  // The stencil actor has a container with all the actors which contain the text renderers.
+  Actor container = stencil.GetChildAt( 0u );
   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
   {
     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
@@ -1223,7 +1215,7 @@ int utcDaliTextEditorEvent02(void)
   DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
 
   // Should not be a renderer.
-  DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor only.
+  DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
 
   END_TEST;
 }
@@ -1280,22 +1272,18 @@ int utcDaliTextEditorEvent03(void)
   application.SendNotification();
   application.Render();
 
-  // The offscreen root actor should have three actors: the camera, a renderer and the highlight actor.
-  Actor offscreenRoot = editor.GetChildAt( 0u );
-  DALI_TEST_CHECK( offscreenRoot.IsLayer() );
-
-  CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
-  DALI_TEST_CHECK( camera );
+  // The stencil actor should have two actors: the renderer and the highlight actor.
+  Actor stencil = editor.GetChildAt( 0u );
 
-  // The offscreen root actor has a container with all the actors which contain the text renderers.
-  Actor container = offscreenRoot.GetChildAt( 1u );
+  // The stencil actor has a container with all the actors which contain the text renderers.
+  Actor container = stencil.GetChildAt( 0u );
   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
   {
     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
     DALI_TEST_CHECK( renderer );
   }
 
-  Renderer highlight = offscreenRoot.GetChildAt( 2u ).GetRendererAt( 0u );
+  Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
   DALI_TEST_CHECK( highlight );
 
   END_TEST;
index 0335e4e..40d49a7 100644 (file)
@@ -520,7 +520,10 @@ int UtcDaliTextFieldSetPropertyP(void)
   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
 
   // Check exceed policy
-  // Set a different exceed policy is not implemented.
+  field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
+  DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
+  field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
+  DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
 
   // Check that the Alignment properties can be correctly set
   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
@@ -1330,15 +1333,11 @@ int utcDaliTextFieldEvent02(void)
   application.SendNotification();
   application.Render();
 
-  // Check there are the expected number of children ( offscreen root actor, and the offscreen image view
-  DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
+  // Check there are the expected number of children ( stencil ).
+  DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
 
-  Actor offscreenRoot = field.GetChildAt( 0u );
-  DALI_TEST_CHECK( offscreenRoot.IsLayer() );
-  DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
-
-  Actor offscreenImage = field.GetChildAt( 1u );
-  DALI_TEST_CHECK( offscreenImage );
+  Actor stencil = field.GetChildAt( 0u );
+  DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
 
   // Create a tap event to touch the text field.
   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
@@ -1348,11 +1347,11 @@ int utcDaliTextFieldEvent02(void)
   application.SendNotification();
   application.Render();
 
-  Actor layer = field.GetChildAt( 2u );
+  Actor layer = field.GetChildAt( 1u );
   DALI_TEST_CHECK( layer.IsLayer() );
 
   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
-  DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
+  DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
 
   // Now the text field has the focus, so it can handle the key events.
   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
@@ -1364,16 +1363,13 @@ int utcDaliTextFieldEvent02(void)
 
   // Checks the cursor and the renderer have been created.
   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
-  DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 2u, TEST_LOCATION ); // The camera actor and the renderer
+  DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
 
   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
   DALI_TEST_CHECK( cursor );
 
-  CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
-  DALI_TEST_CHECK( camera );
-
   // The offscreen root actor has a container with all the actors which contain the text renderers.
-  Actor container = offscreenRoot.GetChildAt( 1u );
+  Actor container = stencil.GetChildAt( 0u );
   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
   {
     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
@@ -1447,7 +1443,7 @@ int utcDaliTextFieldEvent02(void)
   DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
 
   // Should not be a renderer.
-  DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor only.
+  DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
 
   END_TEST;
 }
@@ -1494,22 +1490,18 @@ int utcDaliTextFieldEvent03(void)
   application.SendNotification();
   application.Render();
 
-  // The offscreen root actor should have three actors: the camera, a renderer and the highlight actor.
-  Actor offscreenRoot = field.GetChildAt( 1u );
-  DALI_TEST_CHECK( offscreenRoot.IsLayer() );
-
-  CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
-  DALI_TEST_CHECK( camera );
+  // The offscreen root actor should have two actors: the renderer and the highlight actor.
+  Actor stencil = field.GetChildAt( 0u );
 
   // The offscreen root actor has a container with all the actors which contain the text renderers.
-  Actor container = offscreenRoot.GetChildAt( 1u );
+  Actor container = stencil.GetChildAt( 0u );
   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
   {
     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
     DALI_TEST_CHECK( renderer );
   }
 
-  Renderer highlight = offscreenRoot.GetChildAt( 2u ).GetRendererAt( 0u );
+  Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
   DALI_TEST_CHECK( highlight );
 
   END_TEST;
@@ -1640,7 +1632,7 @@ int utcDaliTextFieldEvent05(void)
   SendPan(application, Gesture::Finished, pos);
   Wait(application, RENDER_FRAME_INTERVAL);
 
-  Actor offscreenRoot = field.GetChildAt( 1u );
+  Actor stencil = field.GetChildAt( 1u );
   END_TEST;
 }
 
index 8e74c70..d0d0836 100644 (file)
@@ -31,7 +31,9 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/text/rendering-backend.h>
+#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include <dali-toolkit/internal/text/rendering/text-backend.h>
 #include <dali-toolkit/internal/text/text-effects-style.h>
 #include <dali-toolkit/internal/text/text-font-style.h>
@@ -980,6 +982,24 @@ void TextEditor::OnInitialize()
   self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
   self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
   self.OnStageSignal().Connect( this, &TextEditor::OnStageConnect );
+
+  // Creates an extra control to be used as stencil buffer.
+  mStencil = Control::New();
+  mStencil.SetAnchorPoint( AnchorPoint::CENTER );
+  mStencil.SetParentOrigin( ParentOrigin::CENTER );
+
+  // Creates a background visual. Even if the color is transparent it updates the stencil.
+  Property::Map backGroundMap;
+  backGroundMap[Toolkit::Visual::Property::TYPE] = Visual::COLOR;
+  backGroundMap[ColorVisual::Property::MIX_COLOR] = Color::TRANSPARENT;
+
+  mStencil.SetProperty( Toolkit::Control::Property::BACKGROUND, backGroundMap );
+
+  // Enable the clipping property.
+  mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+  mStencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+
+  self.Add( mStencil );
 }
 
 void TextEditor::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
@@ -1042,7 +1062,6 @@ void TextEditor::OnRelayout( const Vector2& size, RelayoutContainer& container )
       mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
     }
 
-    EnableClipping( size );
     RenderText( updateTextType );
   }
 
@@ -1068,7 +1087,6 @@ void TextEditor::OnRelayout( const Vector2& size, RelayoutContainer& container )
 
 void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType )
 {
-  Actor self = Self();
   Actor renderableActor;
 
   if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
@@ -1091,39 +1109,19 @@ void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType )
 
     mRenderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
 
-    Actor clipRootActor;
-    if( mClipper )
-    {
-      clipRootActor = mClipper->GetRootActor();
-    }
+    // Make sure the actors are parented correctly with/without clipping
+    Actor self = mStencil ? mStencil : Self();
 
     for( std::vector<Actor>::const_iterator it = mClippingDecorationActors.begin(),
            endIt = mClippingDecorationActors.end();
          it != endIt;
          ++it )
     {
-      Actor actor = *it;
-
-      if( clipRootActor )
-      {
-        clipRootActor.Add( actor );
-      }
-      else
-      {
-        self.Add( actor );
-      }
+      self.Add( *it );
     }
     mClippingDecorationActors.clear();
 
-    // Make sure the actor is parented correctly with/without clipping
-    if( clipRootActor )
-    {
-      clipRootActor.Add( mRenderableActor );
-    }
-    else
-    {
-      self.Add( mRenderableActor );
-    }
+    self.Add( mRenderableActor );
   }
 }
 
@@ -1353,26 +1351,6 @@ void TextEditor::GetHandleImagePropertyValue(  Property::Value& value, Text::Han
   }
 }
 
-void TextEditor::EnableClipping( const Vector2& size )
-{
-  // Not worth to created clip actor if width or height is equal to zero.
-  if( size.width > Math::MACHINE_EPSILON_1000 && size.height > Math::MACHINE_EPSILON_1000 )
-  {
-    if( !mClipper )
-    {
-      Actor self = Self();
-
-      mClipper = Clipper::New( size );
-      self.Add( mClipper->GetRootActor() );
-      self.Add( mClipper->GetImageView() );
-    }
-    else if ( mClipper )
-    {
-      mClipper->Refresh( size );
-    }
-  }
-}
-
 void TextEditor::OnClipboardTextSelected( ClipboardEventNotifier& clipboard )
 {
   mController->PasteClipboardItemEvent();
@@ -1428,7 +1406,7 @@ TextEditor::TextEditor()
 
 TextEditor::~TextEditor()
 {
-  mClipper.Reset();
+  UnparentAndReset( mStencil );
 
   if( ( NULL != mIdleCallback ) && Adaptor::IsAvailable() )
   {
index 12bbe0d..0145262 100644 (file)
@@ -21,7 +21,6 @@
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/control-impl.h>
 #include <dali-toolkit/public-api/controls/text-controls/text-editor.h>
-#include <dali-toolkit/internal/text/clipping/text-clipper.h>
 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
 #include <dali-toolkit/internal/text/text-control-interface.h>
 #include <dali-toolkit/internal/text/text-editable-control-interface.h>
@@ -206,13 +205,6 @@ private: // Implementation
   void GetHandleImagePropertyValue(  Property::Value& value, Text::HandleType handleType, Text::HandleImageType handleImageType );
 
   /**
-   * @brief Enable or disable clipping.
-   *
-   * @param[in] size The area to clip within.
-   */
-  void EnableClipping( const Vector2& size );
-
-  /**
    * @brief Callback when keyboard is shown/hidden.
    *
    * @param[in] keyboardShown True if keyboard is shown.
@@ -265,7 +257,7 @@ private: // Data
   Text::ControllerPtr mController;
   Text::RendererPtr mRenderer;
   Text::DecoratorPtr mDecorator;
-  Text::ClipperPtr mClipper;
+  Toolkit::Control mStencil;
   std::vector<Actor> mClippingDecorationActors;   ///< Decoration actors which need clipping.
 
   Actor mRenderableActor;
index 4f8515f..e8e24cf 100644 (file)
@@ -30,7 +30,9 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/text/rendering-backend.h>
+#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include <dali-toolkit/internal/text/rendering/text-backend.h>
 #include <dali-toolkit/internal/text/text-effects-style.h>
 #include <dali-toolkit/internal/text/text-font-style.h>
@@ -270,7 +272,17 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr
       }
       case Toolkit::TextField::Property::EXCEED_POLICY:
       {
-        // TODO
+        impl.mExceedPolicy = value.Get<int>();
+
+        if( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == impl.mExceedPolicy )
+        {
+          impl.EnableClipping();
+        }
+        else
+        {
+          UnparentAndReset( impl.mStencil );
+        }
+        impl.RequestTextRelayout();
         break;
       }
       case Toolkit::TextField::Property::HORIZONTAL_ALIGNMENT:
@@ -1160,6 +1172,11 @@ void TextField::OnInitialize()
   self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
   self.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
   self.OnStageSignal().Connect( this, &TextField::OnStageConnect );
+
+  if( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy )
+  {
+    EnableClipping();
+  }
 }
 
 void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change )
@@ -1222,7 +1239,6 @@ void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
       mRenderer = Backend::Get().NewRenderer( mRenderingBackend );
     }
 
-    EnableClipping( size );
     RenderText( updateTextType );
   }
 
@@ -1248,7 +1264,6 @@ void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
 
   void TextField::RenderText( Text::Controller::UpdateTextType updateTextType )
 {
-  Actor self = Self();
   Actor renderableActor;
 
   if( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) )
@@ -1271,39 +1286,19 @@ void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
 
     mRenderableActor.SetPosition( scrollOffset.x, scrollOffset.y );
 
-    Actor clipRootActor;
-    if( mClipper )
-    {
-      clipRootActor = mClipper->GetRootActor();
-    }
+    // Make sure the actors are parented correctly with/without clipping
+    Actor self = mStencil ? mStencil : Self();
 
     for( std::vector<Actor>::const_iterator it = mClippingDecorationActors.begin(),
            endIt = mClippingDecorationActors.end();
          it != endIt;
          ++it )
     {
-      Actor actor = *it;
-
-      if( clipRootActor )
-      {
-        clipRootActor.Add( actor );
-      }
-      else
-      {
-        self.Add( actor );
-      }
+      self.Add( *it );
     }
     mClippingDecorationActors.clear();
 
-    // Make sure the actor is parented correctly with/without clipping
-    if( clipRootActor )
-    {
-      clipRootActor.Add( mRenderableActor );
-    }
-    else
-    {
-      self.Add( mRenderableActor );
-    }
+    self.Add( mRenderableActor );
   }
 }
 
@@ -1531,31 +1526,27 @@ void TextField::GetHandleImagePropertyValue(  Property::Value& value, Text::Hand
   }
 }
 
-void TextField::EnableClipping( const Vector2& size )
+void TextField::EnableClipping()
 {
-  if( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP == mExceedPolicy )
+  if( !mStencil )
   {
-    // Not worth to created clip actor if width or height is equal to zero.
-    if( size.width > Math::MACHINE_EPSILON_1000 && size.height > Math::MACHINE_EPSILON_1000 )
-    {
-      if( !mClipper )
-      {
-        Actor self = Self();
+    // Creates an extra control to be used as stencil buffer.
+    mStencil = Control::New();
+    mStencil.SetAnchorPoint( AnchorPoint::CENTER );
+    mStencil.SetParentOrigin( ParentOrigin::CENTER );
 
-        mClipper = Clipper::New( size );
-        self.Add( mClipper->GetRootActor() );
-        self.Add( mClipper->GetImageView() );
-      }
-      else if ( mClipper )
-      {
-        mClipper->Refresh( size );
-      }
-    }
-  }
-  else
-  {
-    // Note - this will automatically remove the root actor & the image view
-    mClipper.Reset();
+    // Creates a background visual. Even if the color is transparent it updates the stencil.
+    Property::Map backGroundMap;
+    backGroundMap[Toolkit::Visual::Property::TYPE] = Visual::COLOR;
+    backGroundMap[ColorVisual::Property::MIX_COLOR] = Color::TRANSPARENT;
+
+    mStencil.SetProperty( Toolkit::Control::Property::BACKGROUND, backGroundMap );
+
+    // Enable the clipping property.
+    mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+    mStencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+
+    Self().Add( mStencil );
   }
 }
 
@@ -1615,7 +1606,7 @@ TextField::TextField()
 
 TextField::~TextField()
 {
-  mClipper.Reset();
+  UnparentAndReset( mStencil );
 
   if( ( NULL != mIdleCallback ) && Adaptor::IsAvailable() )
   {
index 9762c70..9eed382 100644 (file)
@@ -21,7 +21,6 @@
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/control-impl.h>
 #include <dali-toolkit/public-api/controls/text-controls/text-field.h>
-#include <dali-toolkit/internal/text/clipping/text-clipper.h>
 #include <dali-toolkit/internal/text/decorator/text-decorator.h>
 #include <dali-toolkit/internal/text/text-control-interface.h>
 #include <dali-toolkit/internal/text/text-editable-control-interface.h>
@@ -212,10 +211,8 @@ private: // Implementation
 
   /**
    * @brief Enable or disable clipping.
-   *
-   * @param[in] size The area to clip within.
    */
-  void EnableClipping( const Vector2& size );
+  void EnableClipping();
 
   /**
    * @brief Callback when keyboard is shown/hidden.
@@ -271,7 +268,7 @@ private: // Data
   Text::ControllerPtr mController;
   Text::RendererPtr mRenderer;
   Text::DecoratorPtr mDecorator;
-  Text::ClipperPtr mClipper; ///< For EXCEED_POLICY_CLIP
+  Toolkit::Control mStencil; ///< For EXCEED_POLICY_CLIP
   std::vector<Actor> mClippingDecorationActors;   ///< Decoration actors which need clipping.
 
   Actor mRenderableActor;
index 2197afb..847d9b1 100644 (file)
@@ -90,7 +90,6 @@ toolkit_src_files = \
    $(toolkit_src_dir)/styling/style-manager-impl.cpp \
    $(toolkit_src_dir)/text/bidirectional-support.cpp \
    $(toolkit_src_dir)/text/character-set-conversion.cpp \
-   $(toolkit_src_dir)/text/clipping/text-clipper.cpp \
    $(toolkit_src_dir)/text/color-segmentation.cpp \
    $(toolkit_src_dir)/text/cursor-helper-functions.cpp \
    $(toolkit_src_dir)/text/glyph-metrics-helper.cpp \
diff --git a/dali-toolkit/internal/text/clipping/text-clipper.cpp b/dali-toolkit/internal/text/clipping/text-clipper.cpp
deleted file mode 100644 (file)
index 11a8fc9..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali-toolkit/internal/text/clipping/text-clipper.h>
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/common/stage.h>
-#include <dali/public-api/render-tasks/render-task-list.h>
-#include <dali/public-api/rendering/renderer.h>
-
-namespace
-{
-
-// Currently on desktop machines 2k x 2k is the maximum frame buffer size, on target is 4k x 4k.
-const float MAX_OFFSCREEN_RENDERING_SIZE = 2048.f;
-
-} // namespace
-
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Text
-{
-
-ClipperPtr Clipper::New( const Vector2& size )
-{
-  ClipperPtr clipper( new Clipper() );
-
-  // Second-phase init
-  clipper->Initialize( size );
-
-  return clipper;
-}
-
-Actor Clipper::GetRootActor() const
-{
-  return mOffscreenRootActor;
-}
-
-Actor Clipper::GetImageView() const
-{
-  return mImageView;
-}
-
-void Clipper::Refresh( const Vector2& size )
-{
-  const Size offscreenSize( std::min( MAX_OFFSCREEN_RENDERING_SIZE, size.width ),
-                            std::min( MAX_OFFSCREEN_RENDERING_SIZE, size.height ) );
-
-  const bool sizeChanged = offscreenSize != mCurrentOffscreenSize;
-
-  if( sizeChanged )
-  {
-    // Reconfigure camera for current size.
-    mOffscreenCameraActor.SetOrthographicProjection( offscreenSize );
-
-    // Recreate frame buffer for offscreen rendering when the size changes.
-    FrameBufferImage frameBufferImage = FrameBufferImage::New( offscreenSize.width,
-                                                               offscreenSize.height,
-                                                               Pixel::RGBA8888 );
-
-    mOffscreenRootActor.SetSize( size );
-
-    mImageView.SetSize( offscreenSize );
-    mImageView.SetImage( frameBufferImage );
-    mRenderTask.SetTargetFrameBuffer( frameBufferImage );
-
-    // Stores current sizPe to avoid create new Dali resources if text changes.
-    mCurrentOffscreenSize = offscreenSize;
-  }
-
-  mRenderTask.SetRefreshRate( RenderTask::REFRESH_ONCE );
-}
-
-void Clipper::Initialize( const Vector2& size )
-{
-  const Size offscreenSize( std::min( MAX_OFFSCREEN_RENDERING_SIZE, size.width ),
-                            std::min( MAX_OFFSCREEN_RENDERING_SIZE, size.height ) );
-
-  // Create a root actor and an image view for offscreen rendering.
-  mOffscreenRootActor = Layer::New();
-  mOffscreenRootActor.SetColorMode( USE_OWN_COLOR );
-  mOffscreenRootActor.SetInheritPosition( false );
-  mOffscreenRootActor.SetInheritScale( false );
-  mOffscreenRootActor.SetDepthTestDisabled( true );
-  mOffscreenRootActor.SetSize( offscreenSize );
-
-  mImageView = ImageView::New();
-  mImageView.SetParentOrigin( ParentOrigin::CENTER );
-  mImageView.SetScale( Vector3( 1.0f, -1.0f, 1.0f ) );
-  mImageView.SetSize( offscreenSize );
-
-  // Creates a new camera actor.
-  mOffscreenCameraActor = CameraActor::New();
-  mOffscreenCameraActor.SetParentOrigin( ParentOrigin::CENTER );
-  mOffscreenCameraActor.SetOrthographicProjection( offscreenSize );
-  mOffscreenRootActor.Add( mOffscreenCameraActor ); // camera to shoot the offscreen text
-
-  // Creates a new render task.
-  mRenderTask = Stage::GetCurrent().GetRenderTaskList().CreateTask();
-  mRenderTask.SetSourceActor( mOffscreenRootActor );
-  mRenderTask.SetClearColor( Color::TRANSPARENT );
-  mRenderTask.SetClearEnabled( true );
-  mRenderTask.SetExclusive( true );
-  mRenderTask.SetCameraActor( mOffscreenCameraActor );
-
-  // Creates a frame buffer for offscreen rendering
-  FrameBufferImage frameBufferImage = FrameBufferImage::New( offscreenSize.width,
-                                                             offscreenSize.height,
-                                                             Pixel::RGBA8888 );
-  mImageView.SetImage( frameBufferImage );
-  mRenderTask.SetTargetFrameBuffer( frameBufferImage );
-  mImageView.OnStageSignal().Connect(this, &Clipper::OnStageConnect);
-
-  // Stores current size to avoid create new Dali resources if text changes.
-  mCurrentOffscreenSize = offscreenSize;
-}
-
-void Clipper::OnStageConnect( Dali::Actor actor )
-{
-  Renderer renderer = mImageView.GetRendererAt(0);
-  renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB,    BlendFactor::ONE );
-  renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB,   BlendFactor::ONE_MINUS_SRC_ALPHA );
-  renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA,  BlendFactor::ONE );
-  renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ONE );
-}
-
-Clipper::Clipper()
-{
-}
-
-Clipper::~Clipper()
-{
-  if( Stage::IsInstalled() )
-  {
-    UnparentAndReset( mOffscreenRootActor );
-    UnparentAndReset( mImageView );
-
-    Stage::GetCurrent().GetRenderTaskList().RemoveTask( mRenderTask );
-  }
-}
-
-} // namespace Text
-
-} // namespace Toolkit
-
-} // namespace Dali
diff --git a/dali-toolkit/internal/text/clipping/text-clipper.h b/dali-toolkit/internal/text/clipping/text-clipper.h
deleted file mode 100644 (file)
index 5f5be4b..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_TEXT_CLIPPER_H__
-#define __DALI_TOOLKIT_INTERNAL_TEXT_CLIPPER_H__
-
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/actors/layer.h>
-#include <dali/public-api/actors/camera-actor.h>
-#include <dali/public-api/render-tasks/render-task.h>
-#include <dali-toolkit/public-api/controls/image-view/image-view.h>
-#include <dali/public-api/signals/connection-tracker.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Text
-{
-
-class Clipper;
-typedef IntrusivePtr<Clipper> ClipperPtr;
-
-/**
- * @brief A helper class for clipping actors using a FrameBufferImage.
- */
-class Clipper : public RefObject, public ConnectionTracker
-{
-public:
-
-  /**
-   * @brief Create a clipper.
-   *
-   * @param[in] size The size of the clipping region.
-   */
-  static ClipperPtr New( const Vector2& size );
-
-  /**
-   * @brief Children added to this actor will be clipped with the specified region.
-   *
-   * @note This is done by rendering to a FrameBufferImage which must then be displayed; see also GetImageView().
-   * @return The root actor.
-   */
-  Actor GetRootActor() const;
-
-  /**
-   * @brief This actor will display the resulting FrameBufferImage.
-   *
-   * @return The image view.
-   */
-  Actor GetImageView() const;
-
-  /**
-   * @brief Refresh the contents of the FrameBufferImage.
-   *
-   * @param[in] size The size of the clipping region.
-   */
-  void Refresh( const Vector2& size );
-
-private: // Implementation
-
-  /**
-   * @brief Second-phase init
-   *
-   * @param[in] size The size of the clipping region.
-   */
-  void Initialize( const Vector2& size );
-
-  /**
-   * The renderer is not created until the clipper actor is set on stage, only by then the blend function could be set.
-   *
-   * @param[in] actor The actor connected to stage.
-   */
-  void OnStageConnect( Dali::Actor actor );
-
-  /**
-   * Construct a new Clipper.
-   */
-  Clipper();
-
-  /**
-   * A reference counted object may only be deleted by calling Unreference()
-   */
-  virtual ~Clipper();
-
-private:
-
-  // Undefined copy constructor and assignment operators
-  Clipper(const Clipper&);
-  Clipper& operator=(const Clipper& rhs);
-
-private: // Data
-
-  Layer mOffscreenRootActor;
-  CameraActor mOffscreenCameraActor;
-  ImageView mImageView;
-  RenderTask mRenderTask;
-  Vector2 mCurrentOffscreenSize;
-};
-
-} // namespace Text
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_INTERNAL_TEXT_CLIPPER_H__