Cleanup of Visual::Base::SetSize 82/96982/7
authorDavid Steele <david.steele@partner.samsung.com>
Thu, 10 Nov 2016 16:07:46 +0000 (16:07 +0000)
committerDavid Steele <david.steele@partner.samsung.com>
Thu, 17 Nov 2016 11:21:44 +0000 (11:21 +0000)
Removed SetSize/GetSize from Visual::Base
Added SetTransformAndSize() which should be called from either parent
control's OnSizeSet or OnRelayout.
Added method Visual::Base::Impl::Data::GetVisualSize() to calculate event side
size of visual from transform and control size.

Changed SvgVisual::New() to remove incorrect ImageSize. Instead, uses new visual
size.

Updated Internal::Control::OnSizeSet to ensure that the background visual has
a size set to fill the control

Test Harness
------------
Fixed the event thread callback stub to ensure a 30 second timeout instead of
waiting indefinitely.
Updated test cases to ensure that GetClosestImageSize() is set for visuals under
test that require a size in order to pretend to load something; updated test cases
to ensure that ImageView's added to Stage have a size (to pretend to load something)
Updated dummy-control to handle OnRelayout, and to call SetTransformAndSize on all
registered visuals.

Change-Id: I932293adbd117c242704074229c317a51f9a55c0
Signed-off-by: David Steele <david.steele@samsung.com>
36 files changed:
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-harness.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-event-thread-callback.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-event-thread-callback.h
automated-tests/src/dali-toolkit/utc-Dali-AsyncImageLoader.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp
automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp
automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp
dali-toolkit/devel-api/visual-factory/visual-base.cpp
dali-toolkit/devel-api/visual-factory/visual-base.h
dali-toolkit/internal/controls/image-view/image-view-impl.cpp
dali-toolkit/internal/visuals/color/color-visual.cpp
dali-toolkit/internal/visuals/color/color-visual.h
dali-toolkit/internal/visuals/gradient/gradient-visual.cpp
dali-toolkit/internal/visuals/gradient/gradient-visual.h
dali-toolkit/internal/visuals/image/batch-image-visual.cpp
dali-toolkit/internal/visuals/image/batch-image-visual.h
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/mesh/mesh-visual.cpp
dali-toolkit/internal/visuals/mesh/mesh-visual.h
dali-toolkit/internal/visuals/primitive/primitive-visual.cpp
dali-toolkit/internal/visuals/primitive/primitive-visual.h
dali-toolkit/internal/visuals/svg/svg-visual.cpp
dali-toolkit/internal/visuals/svg/svg-visual.h
dali-toolkit/internal/visuals/text/text-visual.cpp
dali-toolkit/internal/visuals/text/text-visual.h
dali-toolkit/internal/visuals/visual-base-data-impl.cpp
dali-toolkit/internal/visuals/visual-base-data-impl.h
dali-toolkit/internal/visuals/visual-base-impl.cpp
dali-toolkit/internal/visuals/visual-base-impl.h
dali-toolkit/internal/visuals/visual-factory-impl.cpp
dali-toolkit/internal/visuals/wireframe/wireframe-visual.cpp
dali-toolkit/internal/visuals/wireframe/wireframe-visual.h
dali-toolkit/public-api/controls/control-impl.cpp

index 6fcc10d..ae4132b 100644 (file)
@@ -19,6 +19,8 @@
 
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/align-enums.h>
 
 namespace Dali
 {
 
 namespace Dali
 {
@@ -88,11 +90,23 @@ DummyControlImpl::~DummyControlImpl()
 void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual )
 {
   Control::RegisterVisual( index, visual );
 void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual )
 {
   Control::RegisterVisual( index, visual );
+
+  VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
+  if( iter == mRegisteredVisualIndices.end() )
+  {
+    mRegisteredVisualIndices.push_back(index);
+  }
 }
 
 void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual, bool enabled )
 {
   Control::RegisterVisual( index, visual, enabled );
 }
 
 void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual, bool enabled )
 {
   Control::RegisterVisual( index, visual, enabled );
+
+  VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
+  if( iter == mRegisteredVisualIndices.end() )
+  {
+    mRegisteredVisualIndices.push_back(index);
+  }
 }
 
 void DummyControlImpl::UnregisterVisual( Property::Index index )
 }
 
 void DummyControlImpl::UnregisterVisual( Property::Index index )
@@ -115,6 +129,7 @@ bool DummyControlImpl::IsVisualEnabled( Property::Index index )
   return Control::IsVisualEnabled( index );
 }
 
   return Control::IsVisualEnabled( index );
 }
 
+
 Animation DummyControlImpl::CreateTransition( const Toolkit::TransitionData& transition )
 {
   return Control::CreateTransition( transition );
 Animation DummyControlImpl::CreateTransition( const Toolkit::TransitionData& transition )
 {
   return Control::CreateTransition( transition );
@@ -189,6 +204,24 @@ bool DummyControlImplOverride::OnKeyEvent(const KeyEvent& event) { keyEventCalle
 void DummyControlImplOverride::OnKeyInputFocusGained() { keyInputFocusGained = true; }
 void DummyControlImplOverride::OnKeyInputFocusLost() { keyInputFocusLost = true; }
 
 void DummyControlImplOverride::OnKeyInputFocusGained() { keyInputFocusGained = true; }
 void DummyControlImplOverride::OnKeyInputFocusLost() { keyInputFocusLost = true; }
 
+void DummyControlImplOverride::OnRelayout( const Vector2& size, RelayoutContainer& container )
+{
+  Property::Map transformMap;
+  transformMap
+    .Add( Toolkit::VisualProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
+    .Add( Toolkit::VisualProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
+    .Add( Toolkit::VisualProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
+    .Add( Toolkit::VisualProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
+    .Add( Toolkit::VisualProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
+
+  for( VisualIndices::iterator iter = mRegisteredVisualIndices.begin(); iter != mRegisteredVisualIndices.end() ; ++iter )
+  {
+    Visual::Base visual = GetVisual(*iter);
+    visual.SetTransformAndSize( transformMap, size );
+  }
+}
+
+
 DummyControl DummyControl::New( bool override )
 {
   DummyControl control;
 DummyControl DummyControl::New( bool override )
 {
   DummyControl control;
index 04847d1..95b4126 100644 (file)
@@ -84,6 +84,8 @@ public:
   void CustomSlot1( Actor actor );
 
   bool mCustomSlot1Called;
   void CustomSlot1( Actor actor );
 
   bool mCustomSlot1Called;
+  typedef std::vector<Property::Index> VisualIndices;
+  VisualIndices mRegisteredVisualIndices;
 
 protected:
 
 
 protected:
 
@@ -135,6 +137,7 @@ private: // From CustomActorImpl
   virtual bool OnKeyEvent(const KeyEvent& event);
   virtual void OnKeyInputFocusGained();
   virtual void OnKeyInputFocusLost();
   virtual bool OnKeyEvent(const KeyEvent& event);
   virtual void OnKeyInputFocusGained();
   virtual void OnKeyInputFocusLost();
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
 
 public:
 
 
 public:
 
index 332ddaa..76b391b 100644 (file)
@@ -329,8 +329,9 @@ void Usage(const char* program)
   printf("Usage: \n"
          "   %s <testcase name>\t\t Execute a test case\n"
          "   %s \t\t Execute all test cases in parallel\n"
   printf("Usage: \n"
          "   %s <testcase name>\t\t Execute a test case\n"
          "   %s \t\t Execute all test cases in parallel\n"
-         "   %s -r\t\t Execute all test cases in parallel, rerunning failed test cases\n",
-         program, program, program);
+         "   %s -r\t\t Execute all test cases in parallel, rerunning failed test cases\n"
+         "   %s -s\t\t Execute all test cases serially\n",
+         program, program, program, program);
 }
 
 } // namespace
 }
 
 } // namespace
index f77cdde..b809b87 100644 (file)
 #include <cstddef>
 #include <semaphore.h>
 #include <math.h>
 #include <cstddef>
 #include <semaphore.h>
 #include <math.h>
+#include <ctime>
 #include <climits>
 #include <climits>
+#include <cstdio>
+#include <unistd.h>
 
 namespace Dali
 {
 
 namespace Dali
 {
@@ -63,14 +66,18 @@ void EventThreadCallback::Trigger()
   }
 }
 
   }
 }
 
-void EventThreadCallback::WaitingForTrigger(unsigned int count)
+bool EventThreadCallback::WaitingForTrigger(unsigned int count, unsigned int seconds)
 {
   if(  mImpl->triggeredCount >= count )
   {
 {
   if(  mImpl->triggeredCount >= count )
   {
-    return;
+    return true;
   }
   }
+  struct timespec now;
+  clock_gettime( CLOCK_REALTIME, &now );
+  now.tv_sec += seconds;
   mImpl->expectedCount = count;
   mImpl->expectedCount = count;
-  sem_wait( &(mImpl->mySemaphore) );
+  int error = sem_timedwait( &(mImpl->mySemaphore), &now );
+  return error != 0;
 }
 
 CallbackBase* EventThreadCallback::GetCallback()
 }
 
 CallbackBase* EventThreadCallback::GetCallback()
@@ -84,3 +91,46 @@ EventThreadCallback* EventThreadCallback::Get()
 }
 
 }
 }
 
 }
+
+namespace Test
+{
+
+bool WaitForEventThreadTrigger( int triggerCount )
+{
+  bool success = true;
+  const int TEST_TIMEOUT(30);
+
+  struct timespec startTime;
+  struct timespec now;
+  clock_gettime( CLOCK_REALTIME, &startTime );
+  now.tv_sec = startTime.tv_sec;
+  now.tv_nsec = startTime.tv_nsec;
+
+  Dali::EventThreadCallback* eventTrigger = NULL;
+  while( eventTrigger == NULL )
+  {
+    eventTrigger = Dali::EventThreadCallback::Get();
+    clock_gettime( CLOCK_REALTIME, &now );
+    if( now.tv_sec - startTime.tv_sec > TEST_TIMEOUT )
+    {
+      success = false;
+      break;
+    }
+    usleep(10);
+  }
+  if( eventTrigger != NULL )
+  {
+    Dali::CallbackBase* callback = eventTrigger->GetCallback();
+    eventTrigger->WaitingForTrigger( triggerCount, TEST_TIMEOUT - (now.tv_sec - startTime.tv_sec) );
+    Dali::CallbackBase::Execute( *callback );
+  }
+
+  clock_gettime( CLOCK_REALTIME, &now );
+  if( now.tv_sec > startTime.tv_sec + 1 )
+  {
+    fprintf(stderr, "WaitForEventThreadTrigger took %ld seconds\n", now.tv_sec - startTime.tv_sec );
+  }
+  return success;
+}
+
+}
index d67ca24..a0303be 100644 (file)
@@ -36,7 +36,7 @@ public:
 
   void Trigger();
 
 
   void Trigger();
 
-  void WaitingForTrigger(unsigned int count);
+  bool WaitingForTrigger(unsigned int count, unsigned int seconds );
 
   CallbackBase* GetCallback();
 
 
   CallbackBase* GetCallback();
 
@@ -58,4 +58,19 @@ private:
 
 }
 
 
 }
 
+namespace Test
+{
+
+/**
+ * Wait for the tested code to create an event trigger, then
+ * wait for triggerCount Trigger calls to occur, and execute the trigger
+ * callback afterwards.
+ *
+ * Will wait for a maximum of 30s before failing the test and returning.
+ */
+bool WaitForEventThreadTrigger( int triggerCount );
+
+}
+
+
 #endif /* __DALI_TOOLKIT_EVENT_THREAD_CALLBACK_H__ */
 #endif /* __DALI_TOOLKIT_EVENT_THREAD_CALLBACK_H__ */
index 74dcc73..6e99e48 100644 (file)
@@ -174,12 +174,7 @@ int UtcDaliAsyncImageLoaderLoadAndLoadedSignal(void)
   uint32_t id02 = loader.Load( gImage_50_RGBA, ImageDimensions( 25, 25 ) );
   uint32_t id03 = loader.Load( gImage_128_RGB, ImageDimensions( 100, 100 ), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, true );
 
   uint32_t id02 = loader.Load( gImage_50_RGBA, ImageDimensions( 25, 25 ) );
   uint32_t id03 = loader.Load( gImage_128_RGB, ImageDimensions( 100, 100 ), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, true );
 
-  EventThreadCallback* eventTrigger = EventThreadCallback::Get();
-  CallbackBase* callback = eventTrigger->GetCallback();
-
-  eventTrigger->WaitingForTrigger( 3 );// waiting until all three images are loaded
-
-  CallbackBase::Execute( *callback );
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
 
   application.SendNotification();
   application.Render();
 
   application.SendNotification();
   application.Render();
@@ -205,12 +200,7 @@ int UtcDaliAsyncImageLoaderCancel(void)
   uint32_t id02 = loader.Load( gImage_50_RGBA, ImageDimensions( 25, 25 ) );
   uint32_t id03 = loader.Load( gImage_128_RGB, ImageDimensions( 100, 100 ), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, true );
 
   uint32_t id02 = loader.Load( gImage_50_RGBA, ImageDimensions( 25, 25 ) );
   uint32_t id03 = loader.Load( gImage_128_RGB, ImageDimensions( 100, 100 ), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, true );
 
-  EventThreadCallback* eventTrigger = EventThreadCallback::Get();
-  CallbackBase* callback = eventTrigger->GetCallback();
-
-  eventTrigger->WaitingForTrigger( 3 ); // waiting until images are loaded
-
-  CallbackBase::Execute( *callback );
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
 
   application.SendNotification();
   application.Render();
 
   application.SendNotification();
   application.Render();
@@ -248,4 +238,3 @@ int UtcDaliAsyncImageLoaderCancelAll(void)
 
   END_TEST;
 }
 
   END_TEST;
 }
-
index 5fe744f..0bee5e5 100644 (file)
@@ -207,12 +207,7 @@ int UtcDaliImageAtlasUploadP(void)
   Vector4 textureRect3;
   atlas.Upload( textureRect3, gImage_128_RGB, ImageDimensions(128, 128) );
 
   Vector4 textureRect3;
   atlas.Upload( textureRect3, gImage_128_RGB, ImageDimensions(128, 128) );
 
-  EventThreadCallback* eventTrigger = EventThreadCallback::Get();
-  CallbackBase* callback = eventTrigger->GetCallback();
-
-  eventTrigger->WaitingForTrigger( 3 );// waiting until all three images are loaded
-
-  CallbackBase::Execute( *callback );
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
 
   application.SendNotification();
   application.Render(RENDER_FRAME_INTERVAL);
 
   application.SendNotification();
   application.Render(RENDER_FRAME_INTERVAL);
@@ -262,8 +257,6 @@ int UtcDaliImageAtlasUploadWithObserver01(void)
   TestApplication application;
   ImageAtlas atlas = ImageAtlas::New( 200, 200 );
 
   TestApplication application;
   ImageAtlas atlas = ImageAtlas::New( 200, 200 );
 
-  EventThreadCallback* eventTrigger = EventThreadCallback::Get();
-  CallbackBase* callback = eventTrigger->GetCallback();
 
   gCountOfTestFuncCall = 0;
   TestUploadObserver uploadObserver;
 
   gCountOfTestFuncCall = 0;
   TestUploadObserver uploadObserver;
@@ -276,8 +269,7 @@ int UtcDaliImageAtlasUploadWithObserver01(void)
   atlas.Upload( textureRect3, gImage_128_RGB, ImageDimensions(128, 128), FittingMode::DEFAULT, true, &uploadObserver );
 
   // waiting until all three images are loaded and uploaded to atlas
   atlas.Upload( textureRect3, gImage_128_RGB, ImageDimensions(128, 128), FittingMode::DEFAULT, true, &uploadObserver );
 
   // waiting until all three images are loaded and uploaded to atlas
-  eventTrigger->WaitingForTrigger( 3 );
-  CallbackBase::Execute( *callback );
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
   application.SendNotification();
   application.Render(RENDER_FRAME_INTERVAL);
 
   application.SendNotification();
   application.Render(RENDER_FRAME_INTERVAL);
 
@@ -292,9 +284,6 @@ int UtcDaliImageAtlasUploadWithObserver02(void)
   TestApplication application;
   ImageAtlas atlas = ImageAtlas::New( 200, 200 );
 
   TestApplication application;
   ImageAtlas atlas = ImageAtlas::New( 200, 200 );
 
-  EventThreadCallback* eventTrigger = EventThreadCallback::Get();
-  CallbackBase* callback = eventTrigger->GetCallback();
-
   gCountOfTestFuncCall = 0;
   TestUploadObserver* uploadObserver = new TestUploadObserver;
 
   gCountOfTestFuncCall = 0;
   TestUploadObserver* uploadObserver = new TestUploadObserver;
 
@@ -309,8 +298,8 @@ int UtcDaliImageAtlasUploadWithObserver02(void)
   delete uploadObserver;
 
  // waiting until all three images are loaded and uploaded to atlas
   delete uploadObserver;
 
  // waiting until all three images are loaded and uploaded to atlas
-  eventTrigger->WaitingForTrigger( 3 );
-  CallbackBase::Execute( *callback );
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
+
   application.Render(RENDER_FRAME_INTERVAL);
   application.SendNotification();
 
   application.Render(RENDER_FRAME_INTERVAL);
   application.SendNotification();
 
@@ -382,20 +371,19 @@ int UtcDaliImageAtlasImageView(void)
 
   ImageView imageView1 = ImageView::New( gImage_34_RGBA, ImageDimensions(34, 34) );
   ImageView imageView2 = ImageView::New( gImage_50_RGBA, ImageDimensions(50, 50) );
 
   ImageView imageView1 = ImageView::New( gImage_34_RGBA, ImageDimensions(34, 34) );
   ImageView imageView2 = ImageView::New( gImage_50_RGBA, ImageDimensions(50, 50) );
-  Stage::GetCurrent().Add( imageView1 );
-  Stage::GetCurrent().Add( imageView2 );
 
 
-  EventThreadCallback* eventTrigger = EventThreadCallback::Get();
-  while( eventTrigger == NULL) // waiting uintil the ImageAtlas is created by ImageAtlasManager
-  {
-    usleep(10);
-    eventTrigger = EventThreadCallback::Get();
-  }
-  CallbackBase* callback = eventTrigger->GetCallback();
+  // ImageView doesn't do size negotiation properly: it only listens to OnSizeSet:
+  imageView1.SetSize( 100, 100 );
+  imageView2.SetSize( 100, 100 );
+  imageView1.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+  imageView2.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
 
 
-  eventTrigger->WaitingForTrigger( 2 );// waiting until both images are loaded
+  application.GetPlatform().SetClosestImageSize(  Vector2(34, 34) );
+  Stage::GetCurrent().Add( imageView1 );
+  application.GetPlatform().SetClosestImageSize(  Vector2(50, 50) );
+  Stage::GetCurrent().Add( imageView2 );
 
 
-  CallbackBase::Execute( *callback );
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
 
   application.SendNotification();
   application.Render(RENDER_FRAME_INTERVAL);
 
   application.SendNotification();
   application.Render(RENDER_FRAME_INTERVAL);
@@ -426,10 +414,10 @@ int UtcDaliImageAtlasImageView(void)
   application.SendNotification();
   application.Render(RENDER_FRAME_INTERVAL);
   ImageView imageView3 = ImageView::New( gImage_128_RGB, ImageDimensions(100, 100) );
   application.SendNotification();
   application.Render(RENDER_FRAME_INTERVAL);
   ImageView imageView3 = ImageView::New( gImage_128_RGB, ImageDimensions(100, 100) );
+  application.GetPlatform().SetClosestImageSize(  Vector2(100, 100) );
   Stage::GetCurrent().Add( imageView3 );
 
   Stage::GetCurrent().Add( imageView3 );
 
-  eventTrigger->WaitingForTrigger( 3 ); // waiting for the third image loaded
-  CallbackBase::Execute( *callback );
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
 
   application.SendNotification();
   application.Render(RENDER_FRAME_INTERVAL);
 
   application.SendNotification();
   application.Render(RENDER_FRAME_INTERVAL);
index 12c3f17..420578b 100644 (file)
@@ -393,6 +393,7 @@ int UtcDaliImageViewAsyncLoadingWithAltasing(void)
   callStack.Reset();
   callStack.Enable(true);
 
   callStack.Reset();
   callStack.Enable(true);
 
+  application.GetPlatform().SetClosestImageSize(Vector2(34, 34));
   BitmapLoader::ResetLatestCreated();
   ImageView imageView = ImageView::New( gImage_34_RGBA, ImageDimensions( 34, 34 ) );
 
   BitmapLoader::ResetLatestCreated();
   ImageView imageView = ImageView::New( gImage_34_RGBA, ImageDimensions( 34, 34 ) );
 
@@ -411,16 +412,10 @@ int UtcDaliImageViewAsyncLoadingWithAltasing(void)
   loader = BitmapLoader::GetLatestCreated();
   DALI_TEST_CHECK( loader );
 
   loader = BitmapLoader::GetLatestCreated();
   DALI_TEST_CHECK( loader );
 
-  // worker thread is created
-  EventThreadCallback* eventTrigger = EventThreadCallback::Get();
-  DALI_TEST_CHECK( eventTrigger );
-
   loader.WaitForLoading();// waiting until the image to be loaded
   DALI_TEST_CHECK( loader.IsLoaded() );
 
   loader.WaitForLoading();// waiting until the image to be loaded
   DALI_TEST_CHECK( loader.IsLoaded() );
 
-  eventTrigger->WaitingForTrigger( 1 );
-  CallbackBase* callback = eventTrigger->GetCallback();
-  CallbackBase::Execute( *callback );
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
 
   application.SendNotification();
   application.Render(16);
 
   application.SendNotification();
   application.Render(16);
index c0bb0b1..814af17 100644 (file)
@@ -42,6 +42,18 @@ const char* TEST_RESOURCE_LOCATION = TEST_RESOURCE_DIR "/";
 
 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
 
 
 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
 
+Property::Map DefaultTransform()
+{
+  Property::Map transformMap;
+  transformMap
+    .Add( Toolkit::VisualProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
+    .Add( Toolkit::VisualProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
+    .Add( Toolkit::VisualProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
+    .Add( Toolkit::VisualProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
+    .Add( Toolkit::VisualProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
+  return transformMap;
+}
+
 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
 {
   if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
 {
   if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
@@ -173,24 +185,25 @@ int UtcDaliVisualSize(void)
   tet_infoline( "UtcDaliVisualGetNaturalSize" );
 
   VisualFactory factory = VisualFactory::Get();
   tet_infoline( "UtcDaliVisualGetNaturalSize" );
 
   VisualFactory factory = VisualFactory::Get();
-  Vector2 visualSize( 20.f, 30.f );
+  Vector2 controlSize( 20.f, 30.f );
   Vector2 naturalSize;
 
   // color colorVisual
   Dali::Property::Map map;
   map[ Visual::Property::TYPE ] = Visual::COLOR;
   map[ ColorVisual::Property::MIX_COLOR ] = Color::MAGENTA;
   Vector2 naturalSize;
 
   // color colorVisual
   Dali::Property::Map map;
   map[ Visual::Property::TYPE ] = Visual::COLOR;
   map[ ColorVisual::Property::MIX_COLOR ] = Color::MAGENTA;
+
   Visual::Base colorVisual = factory.CreateVisual( map );
   Visual::Base colorVisual = factory.CreateVisual( map );
-  colorVisual.SetSize( visualSize );
-  DALI_TEST_EQUALS( colorVisual.GetSize(), visualSize, TEST_LOCATION );
+  colorVisual.SetTransformAndSize(DefaultTransform(), controlSize );
+
   colorVisual.GetNaturalSize(naturalSize);
   DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
 
   // image visual
   Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
   Visual::Base imageVisual = factory.CreateVisual( image );
   colorVisual.GetNaturalSize(naturalSize);
   DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
 
   // image visual
   Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
   Visual::Base imageVisual = factory.CreateVisual( image );
-  imageVisual.SetSize( visualSize );
-  DALI_TEST_EQUALS( imageVisual.GetSize(), visualSize, TEST_LOCATION );
+  imageVisual.SetTransformAndSize(DefaultTransform(), controlSize );
+
   imageVisual.GetNaturalSize(naturalSize);
   DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 200.f), TEST_LOCATION );
 
   imageVisual.GetNaturalSize(naturalSize);
   DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 200.f), TEST_LOCATION );
 
@@ -203,8 +216,7 @@ int UtcDaliVisualSize(void)
   map[ BorderVisual::Property::COLOR  ] = Color::RED;
   map[ BorderVisual::Property::SIZE   ] = borderSize;
   Visual::Base borderVisual = factory.CreateVisual( map );
   map[ BorderVisual::Property::COLOR  ] = Color::RED;
   map[ BorderVisual::Property::SIZE   ] = borderSize;
   Visual::Base borderVisual = factory.CreateVisual( map );
-  borderVisual.SetSize( visualSize );
-  DALI_TEST_EQUALS( borderVisual.GetSize(), visualSize, TEST_LOCATION );
+  borderVisual.SetTransformAndSize(DefaultTransform(), controlSize );
   borderVisual.GetNaturalSize(naturalSize);
   DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
 
   borderVisual.GetNaturalSize(naturalSize);
   DALI_TEST_EQUALS( naturalSize, Vector2::ZERO, TEST_LOCATION );
 
@@ -221,15 +233,13 @@ int UtcDaliVisualSize(void)
   stopColors.PushBack( Color::GREEN );
   propertyMap.Insert(GradientVisual::Property::STOP_COLOR,   stopColors);
   Visual::Base gradientVisual = factory.CreateVisual(propertyMap);
   stopColors.PushBack( Color::GREEN );
   propertyMap.Insert(GradientVisual::Property::STOP_COLOR,   stopColors);
   Visual::Base gradientVisual = factory.CreateVisual(propertyMap);
-  gradientVisual.SetSize( visualSize );
-  DALI_TEST_EQUALS( gradientVisual.GetSize(), visualSize, TEST_LOCATION );
+  gradientVisual.SetTransformAndSize(DefaultTransform(), controlSize );
   gradientVisual.GetNaturalSize(naturalSize);
   DALI_TEST_EQUALS( naturalSize, Vector2::ZERO,TEST_LOCATION );
 
   // svg visual
   Visual::Base svgVisual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
   gradientVisual.GetNaturalSize(naturalSize);
   DALI_TEST_EQUALS( naturalSize, Vector2::ZERO,TEST_LOCATION );
 
   // svg visual
   Visual::Base svgVisual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions() );
-  svgVisual.SetSize( visualSize );
-  DALI_TEST_EQUALS( svgVisual.GetSize(), visualSize, TEST_LOCATION );
+  svgVisual.SetTransformAndSize(DefaultTransform(), controlSize );
   svgVisual.GetNaturalSize(naturalSize);
   // TEST_SVG_FILE:
   //  <svg width="100" height="100">
   svgVisual.GetNaturalSize(naturalSize);
   // TEST_SVG_FILE:
   //  <svg width="100" height="100">
@@ -239,7 +249,6 @@ int UtcDaliVisualSize(void)
 
   // svg visual with a size
   Visual::Base svgVisual2 = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions(200, 200) );
 
   // svg visual with a size
   Visual::Base svgVisual2 = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions(200, 200) );
-  DALI_TEST_EQUALS( svgVisual2.GetSize(), Vector2( 200.f, 200.f ), TEST_LOCATION );
   svgVisual2.GetNaturalSize(naturalSize);
   DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION ); // Natural size should still be 100, 100
 
   svgVisual2.GetNaturalSize(naturalSize);
   DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION ); // Natural size should still be 100, 100
 
@@ -252,8 +261,7 @@ int UtcDaliVisualSize(void)
   propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
   propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
   Visual::Base batchImageVisual = factory.CreateVisual( propertyMap );
   propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
   propertyMap.Insert( ImageVisual::Property::BATCHING_ENABLED, true );
   Visual::Base batchImageVisual = factory.CreateVisual( propertyMap );
-  batchImageVisual.SetSize( visualSize );
-  DALI_TEST_EQUALS( batchImageVisual.GetSize(), visualSize, TEST_LOCATION );
+  batchImageVisual.SetTransformAndSize(DefaultTransform(), controlSize );
   batchImageVisual.GetNaturalSize( naturalSize );
   DALI_TEST_EQUALS( naturalSize, Vector2( 80.0f, 160.0f ), TEST_LOCATION );
 
   batchImageVisual.GetNaturalSize( naturalSize );
   DALI_TEST_EQUALS( naturalSize, Vector2( 80.0f, 160.0f ), TEST_LOCATION );
 
@@ -1677,3 +1685,47 @@ int UtcDaliVisualRendererRemovalAndReAddition(void)
 
   END_TEST;
 }
 
   END_TEST;
 }
+
+
+
+int UtcDaliVisualTextVisualRender(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "UtcDaliVisualTextVisualRender" );
+
+  VisualFactory factory = VisualFactory::Get();
+  Property::Map propertyMap;
+  propertyMap.Insert( Visual::Property::TYPE, Visual::TEXT );
+  propertyMap.Insert( "renderingBackend", static_cast<int>( Toolkit::Text::DEFAULT_RENDERING_BACKEND ) );
+  propertyMap.Insert( "text", "Hello world" );
+  propertyMap.Insert( "fontFamily", "TizenSans" );
+
+  Property::Map fontStyleMapSet;
+  fontStyleMapSet.Insert( "weight", "bold" );
+  propertyMap.Insert( "fontStyle", fontStyleMapSet );
+
+  propertyMap.Insert( "pointSize", 12.f );
+  propertyMap.Insert( "multiLine", true );
+  propertyMap.Insert( "horizontalAlignment", "CENTER" );
+  propertyMap.Insert( "verticalAlignment", "CENTER" );
+  propertyMap.Insert( "textColor", Color::RED );
+  propertyMap.Insert( "enableMarkup", false );
+  propertyMap.Insert( "enableAutoScroll", false );
+  propertyMap.Insert( "lineSpacing", 0.f );
+  propertyMap.Insert( "batchingEnabled", false );
+  Visual::Base textVisual = factory.CreateVisual( propertyMap );
+  textVisual.SetDepthIndex( 1.f );
+
+  DummyControl dummyControl = DummyControl::New(true);
+  DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummyControl.GetImplementation());
+  dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, textVisual );
+  DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 0, TEST_LOCATION );
+
+  dummyControl.SetSize(200.f, 200.f);
+
+  Stage::GetCurrent().Add( dummyControl );
+  application.SendNotification();
+  application.Render();
+
+  END_TEST;
+}
index 7d36ae6..ae8761f 100644 (file)
@@ -23,6 +23,8 @@
 #include <dali/public-api/rendering/texture-set.h>
 #include <dali/public-api/rendering/shader.h>
 #include <dali/devel-api/images/nine-patch-image.h>
 #include <dali/public-api/rendering/texture-set.h>
 #include <dali/public-api/rendering/shader.h>
 #include <dali/devel-api/images/nine-patch-image.h>
+#include <dali-toolkit/devel-api/align-enums.h>
+#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/dali-toolkit.h>
 #include "dummy-control.h"
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/dali-toolkit.h>
 #include "dummy-control.h"
@@ -47,6 +49,18 @@ static const char* gImage_34_RGBA = TEST_RESOURCE_DIR "/icon-edit.png";
 // resolution: 600*600, pixel format: RGB888
 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
 
 // resolution: 600*600, pixel format: RGB888
 static const char* gImage_600_RGB = TEST_RESOURCE_DIR "/test-image-600.jpg";
 
+Property::Map DefaultTransform()
+{
+  Property::Map transformMap;
+  transformMap
+    .Add( Toolkit::VisualProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
+    .Add( Toolkit::VisualProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
+    .Add( Toolkit::VisualProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
+    .Add( Toolkit::VisualProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
+    .Add( Toolkit::VisualProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
+  return transformMap;
+}
+
 Integration::Bitmap* CreateBitmap( unsigned int imageWidth, unsigned int imageHeight, unsigned int initialColor, Pixel::Format pixelFormat )
 {
   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
 Integration::Bitmap* CreateBitmap( unsigned int imageWidth, unsigned int imageHeight, unsigned int initialColor, Pixel::Format pixelFormat )
 {
   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
@@ -372,7 +386,7 @@ int UtcDaliVisualFactoryGetBorderVisual1(void)
   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
   actor.SetSize(200.f, 200.f);
   Stage::GetCurrent().Add( actor );
   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
   actor.SetSize(200.f, 200.f);
   Stage::GetCurrent().Add( actor );
-  visual.SetSize(Vector2(200.f, 200.f));
+  visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
 
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
   int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
 
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
   int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLEND_MODE );
@@ -420,7 +434,7 @@ int UtcDaliVisualFactoryGetBorderVisual2(void)
   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
   actor.SetSize(200.f, 200.f);
   Stage::GetCurrent().Add( actor );
   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
   actor.SetSize(200.f, 200.f);
   Stage::GetCurrent().Add( actor );
-  visual.SetSize(Vector2(200.f, 200.f));
+  visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f));
 
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
 
 
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
 
@@ -971,9 +985,8 @@ int UtcDaliVisualFactoryGetNPatchVisual3(void)
 
   ResourceImage image = ResourceImage::New(TEST_NPATCH_FILE_NAME);
   Visual::Base nPatchVisual = factory.CreateVisual( image );
 
   ResourceImage image = ResourceImage::New(TEST_NPATCH_FILE_NAME);
   Visual::Base nPatchVisual = factory.CreateVisual( image );
-  Vector2 visualSize( 20.f, 30.f ), naturalSize(0,0);
-  nPatchVisual.SetSize( visualSize );
-  DALI_TEST_EQUALS( nPatchVisual.GetSize(), visualSize, TEST_LOCATION );
+  Vector2 controlSize( 20.f, 30.f ), naturalSize(0,0);
+  nPatchVisual.SetTransformAndSize(DefaultTransform(), controlSize );
   nPatchVisual.GetNaturalSize( naturalSize );
   DALI_TEST_EQUALS( naturalSize, Vector2( ninePatchImageWidth-2, ninePatchImageHeight-2 ), TEST_LOCATION );
 
   nPatchVisual.GetNaturalSize( naturalSize );
   DALI_TEST_EQUALS( naturalSize, Vector2( ninePatchImageWidth-2, ninePatchImageHeight-2 ), TEST_LOCATION );
 
@@ -1124,7 +1137,7 @@ int UtcDaliVisualFactoryGetSvgVisual(void)
   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
   actor.SetSize( 200.f, 200.f );
   Stage::GetCurrent().Add( actor );
   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
   actor.SetSize( 200.f, 200.f );
   Stage::GetCurrent().Add( actor );
-  visual.SetSize( Vector2(200.f, 200.f) );
+  visual.SetTransformAndSize(DefaultTransform(), Vector2(200.f, 200.f) );
 
   application.SendNotification();
   application.Render();
 
   application.SendNotification();
   application.Render();
@@ -1132,11 +1145,7 @@ int UtcDaliVisualFactoryGetSvgVisual(void)
   // renderer is not added to actor until the rasterization is completed.
   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
 
   // renderer is not added to actor until the rasterization is completed.
   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
 
-  EventThreadCallback* eventTrigger = EventThreadCallback::Get();
-  CallbackBase* callback = eventTrigger->GetCallback();
-
-  eventTrigger->WaitingForTrigger( 1 );// waiting until the svg image is rasterized.
-  CallbackBase::Execute( *callback );
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
 
   // renderer is added to actor
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
 
   // renderer is added to actor
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
@@ -1163,8 +1172,9 @@ int UtcDaliVisualFactoryGetSvgVisualLarge(void)
   TraceCallStack& textureTrace = gl.GetTextureTrace();
   textureTrace.Enable(true);
 
   TraceCallStack& textureTrace = gl.GetTextureTrace();
   textureTrace.Enable(true);
 
-  DummyControl actor = DummyControl::New();
+  DummyControl actor = DummyControl::New(true);
   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+  actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); // Only rasterizes when it knows control size.
   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
   Stage::GetCurrent().Add( actor );
 
   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
   Stage::GetCurrent().Add( actor );
 
@@ -1174,11 +1184,7 @@ int UtcDaliVisualFactoryGetSvgVisualLarge(void)
   // renderer is not added to actor until the rasterization is completed.
   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
 
   // renderer is not added to actor until the rasterization is completed.
   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
 
-  EventThreadCallback* eventTrigger = EventThreadCallback::Get();
-  CallbackBase* callback = eventTrigger->GetCallback();
-
-  eventTrigger->WaitingForTrigger( 1 );// waiting until the svg image is rasterized.
-  CallbackBase::Execute( *callback );
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
 
   // renderer is added to actor
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
 
   // renderer is added to actor
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
@@ -1209,7 +1215,7 @@ void MeshVisualLoadsCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplic
   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
   actor.SetSize( 200.f, 200.f );
   Stage::GetCurrent().Add( actor );
   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
   actor.SetSize( 200.f, 200.f );
   Stage::GetCurrent().Add( actor );
-  visual.SetSize( Vector2( 200.f, 200.f ) );
+  visual.SetTransformAndSize(DefaultTransform(), Vector2( 200.f, 200.f ) );
 
   //Ensure set on stage.
   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
 
   //Ensure set on stage.
   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
@@ -1256,7 +1262,7 @@ void MeshVisualDoesNotLoadCorrectlyTest( Property::Map& propertyMap, ToolkitTest
   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
   actor.SetSize( 200.f, 200.f );
   Stage::GetCurrent().Add( actor );
   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
   actor.SetSize( 200.f, 200.f );
   Stage::GetCurrent().Add( actor );
-  visual.SetSize( Vector2( 200.f, 200.f ) );
+  visual.SetTransformAndSize(DefaultTransform(),  Vector2( 200.f, 200.f ) );
 
   //Ensure set on stage.
   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
 
   //Ensure set on stage.
   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
@@ -1538,7 +1544,7 @@ void TestPrimitiveVisualWithProperties( Property::Map& propertyMap, ToolkitTestA
 
   actor.SetSize( 200.f, 200.f );
   Stage::GetCurrent().Add( actor );
 
   actor.SetSize( 200.f, 200.f );
   Stage::GetCurrent().Add( actor );
-  visual.SetSize( Vector2( 200.f, 200.f ) );
+  visual.SetTransformAndSize(DefaultTransform(),  Vector2( 200.f, 200.f ) );
 
   //Ensure set on stage.
   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
 
   //Ensure set on stage.
   DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
@@ -1959,7 +1965,7 @@ int UtcDaliVisualFactoryGetBatchImageVisual1(void)
 
   actor.SetSize( 200.0f, 200.0f );
   Stage::GetCurrent().Add( actor );
 
   actor.SetSize( 200.0f, 200.0f );
   Stage::GetCurrent().Add( actor );
-  visual.SetSize( Vector2( 200.0f, 200.0f ) );
+  visual.SetTransformAndSize(DefaultTransform(),  Vector2( 200.0f, 200.0f ) );
 
   // Test SetOnStage().
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
 
   // Test SetOnStage().
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
@@ -2008,7 +2014,7 @@ int UtcDaliVisualFactoryGetBatchImageVisual2(void)
 
   actor.SetSize( 200.0f, 200.0f );
   Stage::GetCurrent().Add( actor );
 
   actor.SetSize( 200.0f, 200.0f );
   Stage::GetCurrent().Add( actor );
-  visual.SetSize( Vector2( 200.0f, 200.0f ) );
+  visual.SetTransformAndSize(DefaultTransform(),  Vector2( 200.0f, 200.0f ) );
 
   // Test SetOnStage().
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
 
   // Test SetOnStage().
   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
index c5b822d..790a3e7 100644 (file)
@@ -61,14 +61,9 @@ const std::string& Visual::Base::GetName()
   return GetImplementation( *this ).GetName();
 }
 
   return GetImplementation( *this ).GetName();
 }
 
-void Visual::Base::SetSize( const Vector2& size )
+void Visual::Base::SetTransformAndSize( const Property::Map& transform, Size controlSize )
 {
 {
-  GetImplementation( *this ).SetSize( size );
-}
-
-const Vector2& Visual::Base::GetSize() const
-{
-  return GetImplementation( *this ).GetSize();
+  GetImplementation( *this ).SetTransformAndSize( transform, controlSize );
 }
 
 float Visual::Base::GetHeightForWidth( float width ) const
 }
 
 float Visual::Base::GetHeightForWidth( float width ) const
index 7cfadbf..8b0f576 100644 (file)
@@ -128,18 +128,12 @@ public:
   const std::string& GetName();
 
   /**
   const std::string& GetName();
 
   /**
-   * @brief Set the size of the painting area.
+   * @brief Sets the transform and the control size
    *
    *
-   * @param[in] size The size of the painting area.
+   * @param[in] transform A property map describing the transform
+   * @param[in] controlSize The size of the parent control for visuals that need to scale internally.
    */
    */
-  void SetSize( const Vector2& size );
-
-  /**
-   * @brief Get the size of the painting area.
-   *
-   * @return The size of the visual's painting area.
-   */
-  const Vector2& GetSize() const;
+  void SetTransformAndSize( const Dali::Property::Map& transform, Size controlSize );
 
   /**
    * @brief Returns the height for a given width.
 
   /**
    * @brief Returns the height for a given width.
@@ -153,7 +147,11 @@ public:
   /**
    * @brief Return the natural size of the visual.
    *
   /**
    * @brief Return the natural size of the visual.
    *
-   * Deriving classes stipulate the natural size and by default a visual has a ZERO natural size.
+   * Deriving classes stipulate the natural size and by default a
+   * visual has a ZERO natural size.
+   *
+   * @note A visual may not actually have a natural size until it has
+   * been placed on stage and acquired all it's resources.
    *
    * @param[out] naturalSize The visual's natural size
    */
    *
    * @param[out] naturalSize The visual's natural size
    */
index 3c19992..f19f390 100644 (file)
@@ -15,6 +15,7 @@
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
+#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
 
 namespace Dali
 {
 
 namespace Dali
 {
@@ -42,6 +43,19 @@ DALI_PROPERTY_REGISTRATION( Toolkit, ImageView, "preMultipliedAlpha", BOOLEAN, P
 DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( Toolkit, ImageView, "pixelArea", Vector4(0.f, 0.f, 1.f, 1.f), PIXEL_AREA )
 DALI_TYPE_REGISTRATION_END()
 
 DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( Toolkit, ImageView, "pixelArea", Vector4(0.f, 0.f, 1.f, 1.f), PIXEL_AREA )
 DALI_TYPE_REGISTRATION_END()
 
+
+void SetDefaultTransformMap( Property::Map& transformMap )
+{
+  transformMap.Clear();
+  transformMap
+    .Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
+    .Add( Toolkit::Visual::DevelProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
+    .Add( Toolkit::Visual::DevelProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
+    .Add( Toolkit::Visual::DevelProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
+    .Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
+
+}
+
 } // anonymous namespace
 
 using namespace Dali;
 } // anonymous namespace
 
 using namespace Dali;
@@ -138,9 +152,13 @@ void ImageView::SetImage( const std::string& url, ImageDimensions size )
     }
 
     mVisual =  Toolkit::VisualFactory::Get().CreateVisual( url, size );
     }
 
     mVisual =  Toolkit::VisualFactory::Get().CreateVisual( url, size );
-    RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual  );
+    RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual );
 
 
-    mVisual.SetSize( mSizeSet );
+    // This transform fills the control
+    // Should provide a transform that handles aspect ratio according to image size
+    Property::Map transformMap;
+    SetDefaultTransformMap( transformMap );
+    mVisual.SetTransformAndSize( transformMap, mSizeSet );
 
     RelayoutRequest();
   }
 
     RelayoutRequest();
   }
@@ -239,7 +257,12 @@ void ImageView::OnSizeSet( const Vector3& targetSize )
   if( mVisual )
   {
     Vector2 size( targetSize );
   if( mVisual )
   {
     Vector2 size( targetSize );
-    mVisual.SetSize( size );
+
+    // This transform fills the control
+    // Should provide a transform that handles aspect ratio according to image size
+    Property::Map transformMap;
+    SetDefaultTransformMap( transformMap );
+    mVisual.SetTransformAndSize( transformMap, size );
   }
 }
 
   }
 }
 
index 82c6254..0d5ad54 100644 (file)
@@ -103,13 +103,6 @@ void ColorVisual::DoSetProperties( const Property::Map& propertyMap )
   }
 }
 
   }
 }
 
-void ColorVisual::SetSize( const Vector2& size )
-{
-  Visual::Base::SetSize( size );
-
-  // ToDo: renderer responds to the size change
-}
-
 void ColorVisual::DoSetOnStage( Actor& actor )
 {
   InitializeRenderer();
 void ColorVisual::DoSetOnStage( Actor& actor )
 {
   InitializeRenderer();
index d2f3ebe..a8214ea 100644 (file)
@@ -60,11 +60,6 @@ public:
 public:  // from Visual
 
   /**
 public:  // from Visual
 
   /**
-   * @copydoc Visual::Base::SetSize
-   */
-  virtual void SetSize( const Vector2& size );
-
-  /**
    * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
    * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
index bfc9130..bc354e5 100644 (file)
@@ -267,11 +267,6 @@ void GradientVisual::OnSetTransform()
   }
 }
 
   }
 }
 
-void GradientVisual::SetSize( const Vector2& size )
-{
-  Visual::Base::SetSize( size );
-}
-
 void GradientVisual::DoSetOnStage( Actor& actor )
 {
   InitializeRenderer();
 void GradientVisual::DoSetOnStage( Actor& actor )
 {
   InitializeRenderer();
index bc131ae..351e772 100644 (file)
@@ -95,11 +95,6 @@ public:
 public:  // from Visual
 
   /**
 public:  // from Visual
 
   /**
-   * @copydoc Visual::Base::SetSize
-   */
-  virtual void SetSize( const Vector2& size );
-
-  /**
    * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
    * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
index 90d2b53..b46048a 100644 (file)
@@ -127,11 +127,6 @@ void BatchImageVisual::DoSetProperties( const Property::Map& propertyMap )
   mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
 }
 
   mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
 }
 
-void BatchImageVisual::SetSize( const Vector2& size )
-{
-  Visual::Base::SetSize( size );
-}
-
 void BatchImageVisual::GetNaturalSize( Vector2& naturalSize )
 {
   if( mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0 )
 void BatchImageVisual::GetNaturalSize( Vector2& naturalSize )
 {
   if( mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0 )
@@ -275,6 +270,14 @@ void BatchImageVisual::CleanCache(const std::string& url)
   }
 }
 
   }
 }
 
+void BatchImageVisual::OnSetTransform()
+{
+  if( mImpl->mRenderer )
+  {
+    //Register transform properties
+    mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
+  }
+}
 
 } // namespace Internal
 
 
 } // namespace Internal
 
index 85ef5b4..60209d3 100644 (file)
@@ -50,11 +50,6 @@ public:
 public:  // from Visual
 
   /**
 public:  // from Visual
 
   /**
-   * @copydoc Visual::Base::SetSize
-   */
-  virtual void SetSize( const Vector2& size );
-
-  /**
    * @copydoc Visual::Base::GetNaturalSize
    */
   virtual void GetNaturalSize( Vector2& naturalSize );
    * @copydoc Visual::Base::GetNaturalSize
    */
   virtual void GetNaturalSize( Vector2& naturalSize );
@@ -103,6 +98,11 @@ protected:
    */
   virtual void DoSetOffStage( Actor& actor );
 
    */
   virtual void DoSetOffStage( Actor& actor );
 
+  /**
+   * @copydoc Visual::Base::OnSetTransform
+   */
+  virtual void OnSetTransform();
+
 private:
 
   /**
 private:
 
   /**
index 084491a..ab6d1b6 100644 (file)
@@ -122,7 +122,7 @@ const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
 
   void main()\n
   {\n
 
   void main()\n
   {\n
-    mediump vec4 vertexPosition = uMvpMatrix *ComputeVertexPosition();\n
+    mediump vec4 vertexPosition = uMvpMatrix * ComputeVertexPosition();\n
     vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n
     gl_Position = vertexPosition;\n
   }\n
     vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n
     gl_Position = vertexPosition;\n
   }\n
@@ -286,6 +286,8 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap )
     desiredHeightValue->Get( desiredHeight );
   }
 
     desiredHeightValue->Get( desiredHeight );
   }
 
+  mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
+
   Property::Value* pixelAreaValue = propertyMap.Find( Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME );
   if( pixelAreaValue )
   {
   Property::Value* pixelAreaValue = propertyMap.Find( Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME );
   if( pixelAreaValue )
   {
@@ -308,8 +310,6 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap )
     mWrapModeV = Dali::WrapMode::Type( value );
   }
 
     mWrapModeV = Dali::WrapMode::Type( value );
   }
 
-  mDesiredSize = ImageDimensions( desiredWidth, desiredHeight );
-
   Property::Value* syncLoading = propertyMap.Find( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, SYNCHRONOUS_LOADING );
   if( syncLoading )
   {
   Property::Value* syncLoading = propertyMap.Find( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, SYNCHRONOUS_LOADING );
   if( syncLoading )
   {
index 3384976..f0ba67b 100644 (file)
@@ -429,13 +429,6 @@ void MeshVisual::OnSetTransform()
   }
 }
 
   }
 }
 
-void MeshVisual::SetSize( const Vector2& size )
-{
-  Visual::Base::SetSize( size );
-
-  // ToDo: renderer responds to the size change
-}
-
 void MeshVisual::DoSetOnStage( Actor& actor )
 {
   InitializeRenderer();
 void MeshVisual::DoSetOnStage( Actor& actor )
 {
   InitializeRenderer();
index 2e3772c..75b4a86 100644 (file)
@@ -70,11 +70,6 @@ public:
 public:  // from Visual
 
   /**
 public:  // from Visual
 
   /**
-   * @copydoc Visual::Base::SetSize
-   */
-  virtual void SetSize( const Vector2& size );
-
-  /**
    * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
    * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
index 5fbde5a..f4a3fe5 100644 (file)
@@ -387,13 +387,6 @@ void PrimitiveVisual::DoSetProperties( const Property::Map& propertyMap )
   }
 }
 
   }
 }
 
-void PrimitiveVisual::SetSize( const Vector2& size )
-{
-  Visual::Base::SetSize( size );
-
-  // ToDo: renderer responds to the size change
-}
-
 void PrimitiveVisual::GetNaturalSize( Vector2& naturalSize )
 {
   naturalSize.x = mObjectDimensions.x;
 void PrimitiveVisual::GetNaturalSize( Vector2& naturalSize )
 {
   naturalSize.x = mObjectDimensions.x;
index 5239d3f..deda8d3 100644 (file)
@@ -112,11 +112,6 @@ public:
 public:  // from Visual
 
   /**
 public:  // from Visual
 
   /**
-   * @copydoc Visual::Base::SetSize
-   */
-  virtual void SetSize( const Vector2& size );
-
-  /**
    * @copydoc Visual::Base::GetNaturalSize
    */
   virtual void GetNaturalSize( Vector2& naturalSize );
    * @copydoc Visual::Base::GetNaturalSize
    */
   virtual void GetNaturalSize( Vector2& naturalSize );
index 8a390d4..df53192 100644 (file)
@@ -54,10 +54,10 @@ namespace Toolkit
 namespace Internal
 {
 
 namespace Internal
 {
 
-SvgVisualPtr SvgVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl, ImageDimensions size )
+SvgVisualPtr SvgVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl )
 {
   SvgVisual* svgVisual = new SvgVisual( factoryCache );
 {
   SvgVisual* svgVisual = new SvgVisual( factoryCache );
-  svgVisual->ParseFromUrl( imageUrl, size );
+  svgVisual->ParseFromUrl( imageUrl );
   return svgVisual;
 }
 
   return svgVisual;
 }
 
@@ -66,7 +66,8 @@ SvgVisual::SvgVisual( VisualFactoryCache& factoryCache )
   mAtlasRect( FULL_TEXTURE_RECT ),
   mImageUrl(),
   mParsedImage( NULL ),
   mAtlasRect( FULL_TEXTURE_RECT ),
   mImageUrl(),
   mParsedImage( NULL ),
-  mPlacementActor()
+  mPlacementActor(),
+  mVisualSize(Vector2::ZERO)
 {
   // the rasterized image is with pre-multiplied alpha format
   mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
 {
   // the rasterized image is with pre-multiplied alpha format
   mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
@@ -101,10 +102,7 @@ void SvgVisual::DoSetOnStage( Actor& actor )
   // Register transform properties
   mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
 
   // Register transform properties
   mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
 
-  if( mImpl->mSize != Vector2::ZERO && mParsedImage )
-  {
-    AddRasterizationTask( mImpl->mSize );
-  }
+  // Defer the rasterisation task until we get given a size (by Size Negotiation algorithm)
 
   // Hold the weak handle of the placement actor and delay the adding of renderer until the svg rasterization is finished.
   mPlacementActor = actor;
 
   // Hold the weak handle of the placement actor and delay the adding of renderer until the svg rasterization is finished.
   mPlacementActor = actor;
@@ -132,15 +130,6 @@ void SvgVisual::GetNaturalSize( Vector2& naturalSize )
   }
 }
 
   }
 }
 
-void SvgVisual::SetSize( const Vector2& size )
-{
-  if(mImpl->mSize != size && mParsedImage && IsOnStage() )
-  {
-    AddRasterizationTask( size );
-  }
-  mImpl->mSize = size;
-}
-
 void SvgVisual::DoCreatePropertyMap( Property::Map& map ) const
 {
   map.Clear();
 void SvgVisual::DoCreatePropertyMap( Property::Map& map ) const
 {
   map.Clear();
@@ -162,19 +151,13 @@ Dali::Property::Value SvgVisual::DoGetProperty( Dali::Property::Index index )
   return Dali::Property::Value();
 }
 
   return Dali::Property::Value();
 }
 
-void SvgVisual::ParseFromUrl( const std::string& imageUrl, ImageDimensions size )
+void SvgVisual::ParseFromUrl( const std::string& imageUrl )
 {
   mImageUrl = imageUrl;
 
   Vector2 dpi = Stage::GetCurrent().GetDpi();
   float meanDpi = (dpi.height + dpi.width) * 0.5f;
   mParsedImage = nsvgParseFromFile( imageUrl.c_str(), UNITS, meanDpi );
 {
   mImageUrl = imageUrl;
 
   Vector2 dpi = Stage::GetCurrent().GetDpi();
   float meanDpi = (dpi.height + dpi.width) * 0.5f;
   mParsedImage = nsvgParseFromFile( imageUrl.c_str(), UNITS, meanDpi );
-
-  if( size.GetWidth() != 0u && size.GetHeight() != 0u)
-  {
-    mImpl->mSize.x = size.GetWidth();
-    mImpl->mSize.y = size.GetHeight();
-  }
 }
 
 void SvgVisual::AddRasterizationTask( const Vector2& size )
 }
 
 void SvgVisual::AddRasterizationTask( const Vector2& size )
@@ -248,6 +231,19 @@ void SvgVisual::ApplyRasterizedImage( PixelData rasterizedPixelData )
   }
 }
 
   }
 }
 
+void SvgVisual::OnSetTransform()
+{
+  Vector2 visualSize = mImpl->mTransform.GetVisualSize( mImpl->mControlSize );
+
+  if( mParsedImage && IsOnStage() )
+  {
+    if( visualSize != mVisualSize )
+    {
+      AddRasterizationTask( visualSize );
+      mVisualSize = visualSize;
+    }
+  }
+}
 
 } // namespace Internal
 
 
 } // namespace Internal
 
index e5a2f8e..43ac1f4 100644 (file)
@@ -61,9 +61,8 @@ public:
    *
    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
    * @param[in] imageUrl The URL to svg resource to use
    *
    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
    * @param[in] imageUrl The URL to svg resource to use
-   * @param[in] size The required size for the SVG
    */
    */
-  static SvgVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
+  static SvgVisualPtr New( VisualFactoryCache& factoryCache, const std::string& imageUrl );
 
 public:  // from Visual
 
 
 public:  // from Visual
 
@@ -73,11 +72,6 @@ public:  // from Visual
   virtual void GetNaturalSize( Vector2& naturalSize );
 
   /**
   virtual void GetNaturalSize( Vector2& naturalSize );
 
   /**
-   * @copydoc Visual::Base::SetSize
-   */
-  virtual void SetSize( const Vector2& size );
-
-  /**
    * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
    * @copydoc Visual::Base::CreatePropertyMap
    */
   virtual void DoCreatePropertyMap( Property::Map& map ) const;
@@ -121,6 +115,11 @@ protected:
    */
   virtual void DoSetOffStage( Actor& actor );
 
    */
   virtual void DoSetOffStage( Actor& actor );
 
+  /**
+   * @copydoc Visual::Base::OnSetTransform
+   */
+  virtual void OnSetTransform();
+
 public:
 
   /**
 public:
 
   /**
@@ -136,9 +135,8 @@ private:
    * @brief Parses the SVG Image from the set URL.
    *
    * @param[in] imageUrl The URL of the image to parse the SVG from.
    * @brief Parses the SVG Image from the set URL.
    *
    * @param[in] imageUrl The URL of the image to parse the SVG from.
-   * @param[in] size The required size of the SVG
    */
    */
-  void ParseFromUrl( const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
+  void ParseFromUrl( const std::string& imageUrl );
 
   /**
    * @bried Rasterize the svg with the given size, and add it to the visual.
 
   /**
    * @bried Rasterize the svg with the given size, and add it to the visual.
@@ -159,7 +157,7 @@ private:
   std::string          mImageUrl;
   NSVGimage*           mParsedImage;
   WeakHandle<Actor>    mPlacementActor;
   std::string          mImageUrl;
   NSVGimage*           mParsedImage;
   WeakHandle<Actor>    mPlacementActor;
-
+  Vector2              mVisualSize;
 };
 
 } // namespace Internal
 };
 
 } // namespace Internal
index baba744..4228ecf 100644 (file)
@@ -162,22 +162,6 @@ TextVisualPtr TextVisual::New( VisualFactoryCache& factoryCache )
   return new TextVisual( factoryCache );
 }
 
   return new TextVisual( factoryCache );
 }
 
-void TextVisual::SetSize( const Vector2& size )
-{
-  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( size );
-
-  if( ( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) ) ||
-      !mRenderer )
-  {
-    if( !mRenderer )
-    {
-      mRenderer = Text::Backend::Get().NewRenderer( mRenderingBackend );
-    }
-
-    RenderText();
-  }
-}
-
 float TextVisual::GetHeightForWidth( float width ) const
 {
   return mController->GetHeightForWidth( width );
 float TextVisual::GetHeightForWidth( float width ) const
 {
   return mController->GetHeightForWidth( width );
@@ -768,6 +752,26 @@ Dali::Property::Value TextVisual::DoGetProperty( Dali::Property::Index index )
   return value;
 }
 
   return value;
 }
 
+void TextVisual::OnSetTransform()
+{
+  Vector2 visualSize = mImpl->mTransform.GetVisualSize( mImpl->mControlSize );
+
+  // Note, the direction should come from the layout of the parent control
+  mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
+
+  const Text::Controller::UpdateTextType updateTextType = mController->Relayout( visualSize );
+
+  if( ( Text::Controller::NONE_UPDATED != ( Text::Controller::MODEL_UPDATED & updateTextType ) ) ||
+      !mRenderer )
+  {
+    if( !mRenderer )
+    {
+      mRenderer = Text::Backend::Get().NewRenderer( mRenderingBackend );
+    }
+    RenderText();
+  }
+}
+
 void TextVisual::RenderText()
 {
   Actor self = mSelf.GetHandle();
 void TextVisual::RenderText()
 {
   Actor self = mSelf.GetHandle();
index dd1abf6..b345c76 100644 (file)
@@ -84,12 +84,7 @@ public: // from Visual::Base
   /**
    * @copydoc Visual::Base::GetHeightForWidth()
    */
   /**
    * @copydoc Visual::Base::GetHeightForWidth()
    */
-  float GetHeightForWidth( float width ) const;
-
-  /**
-   * @copydoc Visual::Base::GetNaturalSize()
-   */
-  virtual void SetSize( const Vector2& size );
+  virtual float GetHeightForWidth( float width ) const;
 
   /**
    * @copydoc Visual::Base::GetNaturalSize()
 
   /**
    * @copydoc Visual::Base::GetNaturalSize()
@@ -142,6 +137,11 @@ protected:
    */
   virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
 
    */
   virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
 
+  /**
+   * @copydoc Visual::Base::OnSetTransform
+   */
+  virtual void OnSetTransform();
+
 private:
 
   /**
 private:
 
   /**
index 1826196..158c432 100644 (file)
@@ -82,8 +82,9 @@ Dali::Vector2 PointToVector2( Toolkit::Align::Type point, Toolkit::Direction::Ty
 } // unnamed namespace
 
 Internal::Visual::Base::Impl::Impl()
 } // unnamed namespace
 
 Internal::Visual::Base::Impl::Impl()
-: mCustomShader(NULL),
+: mCustomShader( NULL ),
   mTransform(),
   mTransform(),
+  mControlSize( Vector2::ZERO ),
   mDepthIndex( 0.0f ),
   mFlags( 0 )
 {
   mDepthIndex( 0.0f ),
   mFlags( 0 )
 {
@@ -267,6 +268,13 @@ void Internal::Visual::Base::Impl::Transform::RegisterUniforms( Dali::Renderer r
   renderer.RegisterProperty( ANCHOR_POINT, Vector2(0.5,0.5) - PointToVector2( mAnchorPoint, direction ) );
 }
 
   renderer.RegisterProperty( ANCHOR_POINT, Vector2(0.5,0.5) - PointToVector2( mAnchorPoint, direction ) );
 }
 
+Vector2 Internal::Visual::Base::Impl::Transform::GetVisualSize( const Vector2& controlSize )
+{
+  return Vector2( Lerp( mOffsetSizeMode.x, mSize.x * controlSize.x, mSize.x ),
+                  Lerp( mOffsetSizeMode.y, mSize.y * controlSize.y, mSize.y ) );
+}
+
+
 } // namespace Internal
 
 } // namespace Toolkit
 } // namespace Internal
 
 } // namespace Toolkit
index f8ceabf..e631f43 100644 (file)
@@ -73,13 +73,14 @@ struct Base::Impl
     void SetPropertyMap( const Property::Map& map );
     void GetPropertyMap( Property::Map& map ) const;
     void RegisterUniforms( Renderer renderer, Toolkit::Direction::Type direction );
     void SetPropertyMap( const Property::Map& map );
     void GetPropertyMap( Property::Map& map ) const;
     void RegisterUniforms( Renderer renderer, Toolkit::Direction::Type direction );
+    Vector2 GetVisualSize( const Vector2& controlSize );
   };
 
   Renderer      mRenderer;
   CustomShader* mCustomShader;
   std::string   mName;
   Transform     mTransform;
   };
 
   Renderer      mRenderer;
   CustomShader* mCustomShader;
   std::string   mName;
   Transform     mTransform;
-  Vector2       mSize;
+  Size          mControlSize;
   float         mDepthIndex;
   int           mFlags;
 
   float         mDepthIndex;
   int           mFlags;
 
index e8ed4a3..12b6b35 100644 (file)
@@ -84,6 +84,13 @@ void Visual::Base::SetProperties( const Property::Map& propertyMap )
   DoSetProperties( propertyMap );
 }
 
   DoSetProperties( propertyMap );
 }
 
+void Visual::Base::SetTransformAndSize( const Property::Map& transform, Size controlSize )
+{
+  mImpl->mControlSize = controlSize;
+  mImpl->mTransform.SetPropertyMap( transform );
+  OnSetTransform();
+}
+
 void Visual::Base::SetName( const std::string& name )
 {
   mImpl->mName = name;
 void Visual::Base::SetName( const std::string& name )
 {
   mImpl->mName = name;
@@ -94,16 +101,6 @@ const std::string& Visual::Base::GetName()
   return mImpl->mName;
 }
 
   return mImpl->mName;
 }
 
-void Visual::Base::SetSize( const Vector2& size )
-{
-  mImpl->mSize = size;
-}
-
-const Vector2& Visual::Base::GetSize() const
-{
-  return mImpl->mSize;
-}
-
 float Visual::Base::GetHeightForWidth( float width ) const
 {
   return 0.f;
 float Visual::Base::GetHeightForWidth( float width ) const
 {
   return 0.f;
@@ -217,11 +214,10 @@ void Visual::Base::SetProperty( Dali::Property::Index index, const Dali::Propert
   {
     if( index == Dali::Toolkit::Visual::DevelProperty::TRANSFORM )
     {
   {
     if( index == Dali::Toolkit::Visual::DevelProperty::TRANSFORM )
     {
-      Property::Map* map = propertyValue.GetMap();
-      if( map )
+      Property::Map* transformMap = propertyValue.GetMap();
+      if( transformMap )
       {
       {
-        mImpl->mTransform.SetPropertyMap( *map );
-        OnSetTransform();
+        SetTransformAndSize( *transformMap, mImpl->mControlSize );
       }
     }
 
       }
     }
 
index 4028ca4..cb0c7be 100644 (file)
@@ -84,12 +84,7 @@ public:
   /**
    * @copydoc Toolkit::Visual::Base::SetSize
    */
   /**
    * @copydoc Toolkit::Visual::Base::SetSize
    */
-  virtual void SetSize( const Vector2& size );
-
-  /**
-   * @copydoc Toolkit::Visual::Base::GetSize
-   */
-  const Vector2& GetSize() const;
+  void SetTransformAndSize( const Property::Map& transform, Size controlSize );
 
   /**
    * @copydoc Toolkit::Visual::Base::GetHeightForWidth
 
   /**
    * @copydoc Toolkit::Visual::Base::GetHeightForWidth
@@ -187,9 +182,10 @@ protected:
   virtual void DoSetProperties( const Property::Map& propertyMap ) = 0;
 
   /**
   virtual void DoSetProperties( const Property::Map& propertyMap ) = 0;
 
   /**
-   * @brief Called when transform property changes
+   * @brief Called when transform or control size changes
+   * ( Of use to SVG and Text visuals )
    */
    */
-  virtual void OnSetTransform(){}
+  virtual void OnSetTransform() = 0;
 
 protected:
 
 
 protected:
 
index 9b77e63..301fab7 100644 (file)
@@ -258,7 +258,7 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const std::string& url, Image
   }
   else if( UrlType::SVG == type )
   {
   }
   else if( UrlType::SVG == type )
   {
-    visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), url, size );
+    visualPtr = SvgVisual::New( *( mFactoryCache.Get() ), url );
   }
   else // Regular image
   {
   }
   else // Regular image
   {
index 2e1e4a3..493988e 100644 (file)
@@ -150,6 +150,15 @@ Geometry WireframeVisual::CreateQuadWireframeGeometry()
   return geometry;
 }
 
   return geometry;
 }
 
+void WireframeVisual::OnSetTransform()
+{
+  if( mImpl->mRenderer )
+  {
+    //Register transform properties
+    mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
+  }
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
 } // namespace Internal
 
 } // namespace Toolkit
index 3756e00..19cbc46 100644 (file)
@@ -90,6 +90,11 @@ protected:
    */
   virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
 
    */
   virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
 
+  /**
+   * @copydoc Visual::Base::OnSetTransform
+   */
+  virtual void OnSetTransform();
+
 private:
   /**
    * Create the geometry which presents the quad wireframe.
 private:
   /**
    * Create the geometry which presents the quad wireframe.
index 90b3bb6..d3f4362 100644 (file)
@@ -44,6 +44,7 @@
 #include <dali-toolkit/internal/styling/style-manager-impl.h>
 #include <dali-toolkit/internal/visuals/color/color-visual.h>
 #include <dali-toolkit/internal/visuals/transition-data-impl.h>
 #include <dali-toolkit/internal/styling/style-manager-impl.h>
 #include <dali-toolkit/internal/visuals/color/color-visual.h>
 #include <dali-toolkit/internal/visuals/transition-data-impl.h>
+#include <dali-toolkit/devel-api/align-enums.h>
 
 namespace Dali
 {
 
 namespace Dali
 {
@@ -165,6 +166,16 @@ HandleIndex GetVisualProperty(
   return HandleIndex( handle, Property::INVALID_INDEX );
 }
 
   return HandleIndex( handle, Property::INVALID_INDEX );
 }
 
+void SetDefaultTransform( Property::Map& propertyMap )
+{
+  propertyMap.Clear();
+  propertyMap
+    .Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) )
+    .Add( Toolkit::Visual::DevelProperty::Transform::Property::SIZE, Vector2(1.0f, 1.0f) )
+    .Add( Toolkit::Visual::DevelProperty::Transform::Property::ORIGIN, Toolkit::Align::CENTER )
+    .Add( Toolkit::Visual::DevelProperty::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER )
+    .Add( Toolkit::Visual::DevelProperty::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO );
+}
 
 /**
  * Creates control through type registry
 
 /**
  * Creates control through type registry
@@ -747,22 +758,22 @@ void Control::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visu
   bool visualReplaced ( false );
   Actor self = Self();
 
   bool visualReplaced ( false );
   Actor self = Self();
 
-  if ( !mImpl->mVisuals.Empty() )
+  if( !mImpl->mVisuals.Empty() )
   {
   {
-      RegisteredVisualContainer::Iterator iter;
-      // Check if visual (index) is already registered.  Replace if so.
-      if ( FindVisual( index, mImpl->mVisuals, iter ) )
+    RegisteredVisualContainer::Iterator iter;
+    // Check if visual (index) is already registered.  Replace if so.
+    if ( FindVisual( index, mImpl->mVisuals, iter ) )
+    {
+      if( (*iter)->visual && self.OnStage() )
       {
       {
-        if( (*iter)->visual && self.OnStage() )
-        {
-          Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
-        }
-        (*iter)->visual = visual;
-        visualReplaced = true;
+        Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
       }
       }
+      (*iter)->visual = visual;
+      visualReplaced = true;
+    }
   }
 
   }
 
-  if ( !visualReplaced ) // New registration entry
+  if( !visualReplaced ) // New registration entry
   {
     mImpl->mVisuals.PushBack( new RegisteredVisual( index, visual, enabled ) );
   }
   {
     mImpl->mVisuals.PushBack( new RegisteredVisual( index, visual, enabled ) );
   }
@@ -1142,7 +1153,9 @@ void Control::OnSizeSet(const Vector3& targetSize)
   if( visual )
   {
     Vector2 size( targetSize );
   if( visual )
   {
     Vector2 size( targetSize );
-    visual.SetSize( size );
+    Property::Map transformMap;
+    SetDefaultTransform( transformMap );
+    visual.SetTransformAndSize( transformMap, size );
   }
 }
 
   }
 }
 
@@ -1177,6 +1190,15 @@ void Control::OnRelayout( const Vector2& size, RelayoutContainer& container )
   {
     container.Add( Self().GetChildAt( i ), size );
   }
   {
     container.Add( Self().GetChildAt( i ), size );
   }
+
+  Toolkit::Visual::Base visual = GetVisual( Toolkit::Control::Property::BACKGROUND );
+  if( visual )
+  {
+    Vector2 controlSize( size );
+    Property::Map transformMap;
+    SetDefaultTransform( transformMap );
+    visual.SetTransformAndSize( transformMap, controlSize );
+  }
 }
 
 void Control::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
 }
 
 void Control::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )