Wrap mode support for AnimatedImageVisual 84/105484/6
authorXiangyin Ma <x1.ma@samsung.com>
Fri, 16 Dec 2016 16:15:21 +0000 (16:15 +0000)
committerXiangyin Ma <x1.ma@samsung.com>
Mon, 16 Jan 2017 16:49:29 +0000 (08:49 -0800)
Change-Id: If7fdddf3d833a13888a810a218cc5da2d89fd771

automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp
automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp
dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp
dali-toolkit/internal/visuals/animated-image/animated-image-visual.h
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/image/image-visual.h
dali-toolkit/internal/visuals/text/text-visual.cpp
dali-toolkit/internal/visuals/visual-string-constants.cpp
dali-toolkit/internal/visuals/visual-string-constants.h
docs/content/shared-javascript-and-cpp-documentation/visuals.md

index 40f9c7c..3921404 100644 (file)
@@ -80,6 +80,9 @@ 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";
 
+// resolution: 50*50, frame count: 4, frame delay: 0.2 second for each frame
+const char* TEST_GIF_FILE_NAME = TEST_RESOURCE_DIR "/anim.gif";
+
 void TestImage( ImageView imageView, BufferImage image )
 {
   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
 void TestImage( ImageView imageView, BufferImage image )
 {
   Property::Value value = imageView.GetProperty( imageView.GetPropertyIndex( "image" ) );
@@ -363,6 +366,62 @@ int UtcDaliImageViewSetGetProperty03(void)
   END_TEST;
 }
 
   END_TEST;
 }
 
+int UtcDaliImageViewPixelArea(void)
+{
+  // Test pixel area property
+  ToolkitTestApplication application;
+
+  // Gif image, use AnimatedImageVisual internally
+  // Atlasing is applied to pack multiple frames, use custom wrap mode
+  ImageView gifView = ImageView::New();
+  const Vector4 pixelAreaVisual( 0.f, 0.f, 2.f, 2.f );
+  gifView.SetProperty( ImageView::Property::IMAGE,
+                       Property::Map().Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME )
+                                      .Add( ImageVisual::Property::PIXEL_AREA, pixelAreaVisual ) );
+
+  // Add to stage
+  Stage stage = Stage::GetCurrent();
+  stage.Add( gifView );
+
+  // loading started
+  application.SendNotification();
+  application.Render(16);
+  DALI_TEST_CHECK( gifView.GetRendererCount() == 1u );
+
+  const Vector4 fullTextureRect( 0.f, 0.f, 1.f, 1.f );
+  // test that the pixel area value defined in the visual property map is registered on renderer
+  Renderer renderer = gifView.GetRendererAt(0);
+  Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
+  DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaVisual, TEST_LOCATION );
+
+  // test that the shader has the default pixel area value registered.
+  Shader shader = renderer.GetShader();
+  pixelAreaValue = shader.GetProperty( shader.GetPropertyIndex( "pixelArea" ) );
+  DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), fullTextureRect, TEST_LOCATION );
+
+  // test that the uniform uses the pixelArea property on the renderer.
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+  Vector4 pixelAreaUniform;
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
+  DALI_TEST_EQUALS( pixelAreaVisual, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+  // set the pixelArea property on the control
+  const Vector4 pixelAreaControl( -1.f, -1.f, 3.f, 3.f );
+  gifView.SetProperty( ImageView::Property::PIXEL_AREA, pixelAreaControl );
+  application.SendNotification();
+  application.Render(16);
+
+  // check the pixelArea property on the control
+  pixelAreaValue = gifView.GetProperty( gifView.GetPropertyIndex( "pixelArea" ) );
+  DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelAreaControl, TEST_LOCATION );
+  // test that the uniform uses the pixelArea property on the control.
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
+  DALI_TEST_EQUALS( pixelAreaControl, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+
+  END_TEST;
+}
+
 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
 {
   ToolkitTestApplication application;
 int UtcDaliImageViewAsyncLoadingWithoutAltasing(void)
 {
   ToolkitTestApplication application;
index 0b1be30..48de1ca 100644 (file)
@@ -2112,10 +2112,10 @@ int UtcDaliVisualFactoryGetBatchImageVisual4N(void)
   END_TEST;
 }
 
   END_TEST;
 }
 
-int UtcDaliVisualFactoryGetAnimatedImageVisual(void)
+int UtcDaliVisualFactoryGetAnimatedImageVisual1(void)
 {
   ToolkitTestApplication application;
 {
   ToolkitTestApplication application;
-  tet_infoline( "UtcDaliVisualFactoryGetAnimatedImageVisual: Request animated image visual with a gif url" );
+  tet_infoline( "UtcDaliVisualFactoryGetAnimatedImageVisual1: Request animated image visual with a gif url" );
 
   VisualFactory factory = VisualFactory::Get();
   Visual::Base visual = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() );
 
   VisualFactory factory = VisualFactory::Get();
   Visual::Base visual = factory.CreateVisual( TEST_GIF_FILE_NAME, ImageDimensions() );
@@ -2128,6 +2128,7 @@ int UtcDaliVisualFactoryGetAnimatedImageVisual(void)
   DummyControl actor = DummyControl::New();
   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
   DummyControl actor = DummyControl::New();
   DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
   dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
+  actor.SetSize( 200.0f, 200.0f );
   Stage::GetCurrent().Add( actor );
 
   application.SendNotification();
   Stage::GetCurrent().Add( actor );
 
   application.SendNotification();
@@ -2190,3 +2191,69 @@ int UtcDaliVisualFactoryGetAnimatedImageVisual(void)
 
   END_TEST;
 }
 
   END_TEST;
 }
+
+int UtcDaliVisualFactoryGetAnimatedImageVisual2(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline( "UtcDaliVisualFactoryGetAnimatedImageVisual2: Request animated image visual with a Property::Map, test custom wrap mode and pixel area" );
+
+  const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
+  Property::Map propertyMap;
+  propertyMap.Add( Visual::Property::TYPE,  Visual::IMAGE  )
+             .Add( ImageVisual::Property::URL, TEST_GIF_FILE_NAME  )
+             .Add( ImageVisual::Property::PIXEL_AREA, pixelArea )
+             .Add( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT )
+             .Add( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
+
+  Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
+  DALI_TEST_CHECK( visual );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+  TraceCallStack& textureTrace = gl.GetTextureTrace();
+  textureTrace.Enable(true);
+  TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
+  texParameterTrace.Enable( true );
+
+  DummyControl actor = DummyControl::New();
+  DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+  dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
+  actor.SetSize( 200.0f, 200.0f );
+  Stage::GetCurrent().Add( actor );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+  DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+
+  // For animated image visual, the wrapping is handled manually in shader, so the following gl function should not be called
+  std::stringstream out;
+  out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
+  DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
+  out.str("");
+  out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
+  DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
+
+  // test the uniforms which used to handle the wrap mode
+  Renderer renderer = actor.GetRendererAt( 0u );
+  DALI_TEST_CHECK( renderer );
+
+  Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
+  DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
+  Vector4 pixelAreaUniform;
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
+  DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+  Property::Value wrapModeValue = renderer.GetProperty( renderer.GetPropertyIndex( "wrapMode" ) );
+  Vector2 wrapMode( WrapMode::MIRRORED_REPEAT-1, WrapMode::REPEAT-1 );
+  DALI_TEST_EQUALS( wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION );
+  Vector2 wrapModeUniform;
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector2>( "wrapMode", wrapModeUniform ) );
+  DALI_TEST_EQUALS( wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
+
+  actor.Unparent( );
+  DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+  END_TEST;
+}
index 9a2ba3c..2b58ce9 100644 (file)
@@ -40,6 +40,20 @@ namespace Toolkit
 namespace Internal
 {
 
 namespace Internal
 {
 
+namespace
+{
+// wrap modes
+DALI_ENUM_TO_STRING_TABLE_BEGIN( WRAP_MODE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::WrapMode, DEFAULT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::WrapMode, CLAMP_TO_EDGE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::WrapMode, REPEAT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::WrapMode, MIRRORED_REPEAT )
+DALI_ENUM_TO_STRING_TABLE_END( WRAP_MODE )
+
+const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
+
+}
+
 AnimatedImageVisualPtr AnimatedImageVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl, const Property::Map& properties )
 {
   AnimatedImageVisual* visual = new AnimatedImageVisual( factoryCache );
 AnimatedImageVisualPtr AnimatedImageVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl, const Property::Map& properties )
 {
   AnimatedImageVisual* visual = new AnimatedImageVisual( factoryCache );
@@ -60,9 +74,12 @@ AnimatedImageVisualPtr AnimatedImageVisual::New( VisualFactoryCache& factoryCach
 AnimatedImageVisual::AnimatedImageVisual( VisualFactoryCache& factoryCache )
 : Visual::Base( factoryCache ),
   mFrameDelayTimer(),
 AnimatedImageVisual::AnimatedImageVisual( VisualFactoryCache& factoryCache )
 : Visual::Base( factoryCache ),
   mFrameDelayTimer(),
+  mPixelArea( FULL_TEXTURE_RECT ),
   mImageUrl(),
   mImageSize(),
   mImageUrl(),
   mImageSize(),
-  mCurrentFrameIndex( 0 )
+  mCurrentFrameIndex( 0 ),
+  mWrapModeU( WrapMode::DEFAULT ),
+  mWrapModeV( WrapMode::DEFAULT )
 {}
 
 AnimatedImageVisual::~AnimatedImageVisual()
 {}
 
 AnimatedImageVisual::~AnimatedImageVisual()
@@ -83,17 +100,44 @@ void AnimatedImageVisual::GetNaturalSize( Vector2& naturalSize )
 void AnimatedImageVisual::DoCreatePropertyMap( Property::Map& map ) const
 {
   map.Clear();
 void AnimatedImageVisual::DoCreatePropertyMap( Property::Map& map ) const
 {
   map.Clear();
+
   map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::IMAGE );
 
   if( !mImageUrl.empty() )
   {
     map.Insert( Toolkit::ImageVisual::Property::URL, mImageUrl );
   }
   map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::IMAGE );
 
   if( !mImageUrl.empty() )
   {
     map.Insert( Toolkit::ImageVisual::Property::URL, mImageUrl );
   }
+
+  map.Insert( Toolkit::ImageVisual::Property::PIXEL_AREA, mPixelArea );
+  map.Insert( Toolkit::ImageVisual::Property::WRAP_MODE_U, mWrapModeU );
+  map.Insert( Toolkit::ImageVisual::Property::WRAP_MODE_V, mWrapModeV );
 }
 
 void AnimatedImageVisual::DoSetProperties( const Property::Map& propertyMap )
 {
   // url already passed in from constructor
 }
 
 void AnimatedImageVisual::DoSetProperties( const Property::Map& propertyMap )
 {
   // url already passed in from constructor
+
+  Property::Value* pixelAreaValue = propertyMap.Find( Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME );
+  if( pixelAreaValue )
+  {
+    pixelAreaValue->Get( mPixelArea );
+  }
+
+  Property::Value* wrapModeValueU = propertyMap.Find( Toolkit::ImageVisual::Property::WRAP_MODE_U, IMAGE_WRAP_MODE_U );
+  if( wrapModeValueU )
+  {
+    int value;
+    Scripting::GetEnumerationProperty( *wrapModeValueU, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, value );
+    mWrapModeU = Dali::WrapMode::Type( value );
+  }
+
+  Property::Value* wrapModeValueV = propertyMap.Find( Toolkit::ImageVisual::Property::WRAP_MODE_V, IMAGE_WRAP_MODE_V );
+  if( wrapModeValueV )
+  {
+    int value;
+    Scripting::GetEnumerationProperty( *wrapModeValueV, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, value );
+    mWrapModeV = Dali::WrapMode::Type( value );
+  }
 }
 
 void AnimatedImageVisual::DoSetOnStage( Actor& actor )
 }
 
 void AnimatedImageVisual::DoSetOnStage( Actor& actor )
@@ -101,18 +145,34 @@ void AnimatedImageVisual::DoSetOnStage( Actor& actor )
   Texture texture = PrepareAnimatedImage();
   if( texture ) // if the image loading is successful
   {
   Texture texture = PrepareAnimatedImage();
   if( texture ) // if the image loading is successful
   {
-    Shader shader = ImageVisual::GetImageShader( mFactoryCache, true, true );
+    bool defaultWrapMode = mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE;
+    Shader shader = ImageVisual::GetImageShader( mFactoryCache, true, defaultWrapMode );
+
     Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
     Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
+
     TextureSet textureSet = TextureSet::New();
     TextureSet textureSet = TextureSet::New();
+    textureSet.SetTexture( 0u, texture );
+
     mImpl->mRenderer = Renderer::New( geometry, shader );
     mImpl->mRenderer.SetTextures( textureSet );
     mImpl->mRenderer = Renderer::New( geometry, shader );
     mImpl->mRenderer.SetTextures( textureSet );
-    textureSet.SetTexture( 0u, PrepareAnimatedImage() );
-    mImpl->mRenderer.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, mTextureRectContainer[0] );
 
     // 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( !defaultWrapMode ) // custom wrap mode
+    {
+      Vector2 wrapMode(mWrapModeU-WrapMode::CLAMP_TO_EDGE, mWrapModeV-WrapMode::CLAMP_TO_EDGE);
+      wrapMode.Clamp( Vector2::ZERO, Vector2( 2.f, 2.f ) );
+      mImpl->mRenderer.RegisterProperty( WRAP_MODE_UNIFORM_NAME, wrapMode );
+    }
+
+    if( mPixelArea != FULL_TEXTURE_RECT )
+    {
+      mImpl->mRenderer.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, mPixelArea );
+    }
+
     mCurrentFrameIndex = 0;
     mCurrentFrameIndex = 0;
+    mImpl->mRenderer.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, mTextureRectContainer[mCurrentFrameIndex] );
     if( mFrameDelayContainer.Count() > 1 )
     {
       mFrameDelayTimer = Timer::New( mFrameDelayContainer[0] );
     if( mFrameDelayContainer.Count() > 1 )
     {
       mFrameDelayTimer = Timer::New( mFrameDelayContainer[0] );
index 15dff43..d19fd09 100644 (file)
@@ -44,10 +44,24 @@ typedef IntrusivePtr< AnimatedImageVisual > AnimatedImageVisualPtr;
  *
  * The following property is essential
  *
  *
  * The following property is essential
  *
- * | %Property Name           | Type             |
- * |--------------------------|------------------|
- * | url                      | STRING           |
+ * | %Property Name     | Type              |
+ * |------------------- |-------------------|
+ * | url                | STRING            |
+ * | pixelArea          | VECTOR4           |
+ * | wrapModeU          | INTEGER OR STRING |
+ * | wrapModeV          | INTEGER OR STRING |
  *
  *
+ * where pixelArea is a rectangular area.
+ * In its Vector4 value, the first two elements indicate the top-left position of the area,
+ * and the last two elements are the area width and height respectively.
+ * If not specified, the default value is [0.0, 0.0, 1.0, 1.0], i.e. the entire area of the image.
+ *
+ * where wrapModeU and wrapModeV separately decide how the texture should be sampled when the u and v coordinate exceeds the range of 0.0 to 1.0.
+ * Its value should be one of the following wrap mode:
+ *   "DEFAULT"
+ *   "CLAMP_TO_EDGE"
+ *   "REPEAT"
+ *   "MIRRORED_REPEAT"
  */
 
 class AnimatedImageVisual : public Visual::Base, public ConnectionTracker
  */
 
 class AnimatedImageVisual : public Visual::Base, public ConnectionTracker
@@ -143,9 +157,13 @@ private:
   Timer mFrameDelayTimer;
   Dali::Vector<Vector4> mTextureRectContainer;
   Dali::Vector<uint32_t> mFrameDelayContainer;
   Timer mFrameDelayTimer;
   Dali::Vector<Vector4> mTextureRectContainer;
   Dali::Vector<uint32_t> mFrameDelayContainer;
+  Vector4 mPixelArea;
   std::string  mImageUrl;
   std::string  mImageUrl;
+
   ImageDimensions mImageSize;
   uint32_t mCurrentFrameIndex;
   ImageDimensions mImageSize;
   uint32_t mCurrentFrameIndex;
+  Dali::WrapMode::Type mWrapModeU:3;
+  Dali::WrapMode::Type mWrapModeV:3;
 };
 
 } // namespace Internal
 };
 
 } // namespace Internal
index 6493659..9ce3a92 100644 (file)
@@ -58,8 +58,6 @@ const char * const IMAGE_FITTING_MODE( "fittingMode" );
 const char * const IMAGE_SAMPLING_MODE( "samplingMode" );
 const char * const IMAGE_DESIRED_WIDTH( "desiredWidth" );
 const char * const IMAGE_DESIRED_HEIGHT( "desiredHeight" );
 const char * const IMAGE_SAMPLING_MODE( "samplingMode" );
 const char * const IMAGE_DESIRED_WIDTH( "desiredWidth" );
 const char * const IMAGE_DESIRED_HEIGHT( "desiredHeight" );
-const char * const IMAGE_WRAP_MODE_U("wrapModeU");
-const char * const IMAGE_WRAP_MODE_V("wrapModeV");
 const char * const SYNCHRONOUS_LOADING( "synchronousLoading" );
 const char * const BATCHING_ENABLED( "batchingEnabled" );
 
 const char * const SYNCHRONOUS_LOADING( "synchronousLoading" );
 const char * const BATCHING_ENABLED( "batchingEnabled" );
 
@@ -91,9 +89,6 @@ DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::WrapMode, REPEAT )
 DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::WrapMode, MIRRORED_REPEAT )
 DALI_ENUM_TO_STRING_TABLE_END( WRAP_MODE )
 
 DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::WrapMode, MIRRORED_REPEAT )
 DALI_ENUM_TO_STRING_TABLE_END( WRAP_MODE )
 
-const std::string PIXEL_AREA_UNIFORM_NAME = "pixelArea";
-const std::string WRAP_MODE_UNIFORM_NAME = "wrapMode";
-
 const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
 
 const char* DEFAULT_SAMPLER_TYPENAME = "sampler2D";
 const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
 
 const char* DEFAULT_SAMPLER_TYPENAME = "sampler2D";
index c2ea067..52312ea 100644 (file)
@@ -48,14 +48,29 @@ typedef IntrusivePtr< ImageVisual > ImageVisualPtr;
  *
  * The following properties are optional
  *
  *
  * The following properties are optional
  *
- * | %Property Name     | Type             |
- * |--------------------|------------------|
- * | url                | STRING           |
- * | fittingMode        | STRING           |
- * | samplingMode       | STRING           |
- * | desiredWidth       | INT              |
- * | desiredHeight      | INT              |
- * | synchronousLoading | BOOLEAN          |
+ * | %Property Name     | Type              |
+ * |--------------------|-------------------|
+ * | url                | STRING            |
+ * | fittingMode        | INTEGER OR STRING |
+ * | samplingMode       | INTEGER OR STRING |
+ * | desiredWidth       | INTEGER           |
+ * | desiredHeight      | INTEGER           |
+ * | synchronousLoading | BOOLEAN           |
+ * | pixelArea          | VECTOR4           |
+ * | wrapModeU          | INTEGER OR STRING |
+ * | wrapModeV          | INTEGER OR STRING |
+ *
+ * where pixelArea is a rectangular area.
+ * In its Vector4 value, the first two elements indicate the top-left position of the area,
+ * and the last two elements are the area width and height respectively.
+ * If not specified, the default value is [0.0, 0.0, 1.0, 1.0], i.e. the entire area of the image.
+ *
+ * where wrapModeU and wrapModeV separately decide how the texture should be sampled when the u and v coordinate exceeds the range of 0.0 to 1.0.
+ * Its value should be one of the following wrap mode:
+ *   "DEFAULT"
+ *   "CLAMP_TO_EDGE"
+ *   "REPEAT"
+ *   "MIRRORED_REPEAT"
  *
  * where imageFittingMode should be one of the following fitting modes:
  *   "SHRINK_TO_FIT"
  *
  * where imageFittingMode should be one of the following fitting modes:
  *   "SHRINK_TO_FIT"
index abca281..5f15294 100644 (file)
@@ -50,8 +50,6 @@ const char * const VERTICAL_ALIGNMENT_PROPERTY( "verticalAlignment" );
 const char * const TEXT_COLOR_PROPERTY( "textColor" );
 const char * const ENABLE_MARKUP_PROPERTY( "enableMarkup" );
 
 const char * const TEXT_COLOR_PROPERTY( "textColor" );
 const char * const ENABLE_MARKUP_PROPERTY( "enableMarkup" );
 
-const std::string PIXEL_AREA_UNIFORM_NAME = "pixelArea";
-
 const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
 {
   { "BEGIN",  Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN  },
 const Scripting::StringEnum HORIZONTAL_ALIGNMENT_STRING_TABLE[] =
 {
   { "BEGIN",  Toolkit::Text::Layout::HORIZONTAL_ALIGN_BEGIN  },
index 6f1875a..864227e 100644 (file)
@@ -69,7 +69,11 @@ const char * const MIX_COLOR( "mixColor" );
 
 // Image visual
 const char * const IMAGE_URL_NAME( "url" );
 
 // Image visual
 const char * const IMAGE_URL_NAME( "url" );
-const char * const ATLAS_RECT_UNIFORM_NAME ( "uAtlasRect" );
+const char * const ATLAS_RECT_UNIFORM_NAME( "uAtlasRect" );
+const char * const PIXEL_AREA_UNIFORM_NAME( "pixelArea" );
+const char * const WRAP_MODE_UNIFORM_NAME( "wrapMode" );
+const char * const IMAGE_WRAP_MODE_U("wrapModeU");
+const char * const IMAGE_WRAP_MODE_V("wrapModeV");
 
 // Text visual
 const char * const TEXT_PROPERTY( "text" );
 
 // Text visual
 const char * const TEXT_PROPERTY( "text" );
index d00feed..8079d34 100644 (file)
@@ -60,6 +60,10 @@ extern const char * const MIX_COLOR;
 // Image visual
 extern const char * const IMAGE_URL_NAME;
 extern const char * const ATLAS_RECT_UNIFORM_NAME;
 // Image visual
 extern const char * const IMAGE_URL_NAME;
 extern const char * const ATLAS_RECT_UNIFORM_NAME;
+extern const char * const PIXEL_AREA_UNIFORM_NAME;
+extern const char * const WRAP_MODE_UNIFORM_NAME;
+extern const char * const IMAGE_WRAP_MODE_U;
+extern const char * const IMAGE_WRAP_MODE_V;
 
 // Text visual
 extern const char * const TEXT_PROPERTY;
 
 // Text visual
 extern const char * const TEXT_PROPERTY;
index eaaaed5..53acaa1 100644 (file)
@@ -304,6 +304,9 @@ Renders a raster image ( jpg, png etc.) into the visual's quad geometry.
 | Dali::Toolkit::ImageVisual::Property::SAMPLING_MODE  | samplingMode  | INTEGER or STRING | No       | Filtering options, used when resizing images to sample original pixels. [More info](@ref resourceimagescaling-scaling)   |
 | Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH  | desiredWidth  | INT               | No       | The desired image width. Will use actual image width if not specified.                                                   |
 | Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT | desiredHeight | INT               | No       | The desired image height. Will use actual image height if not specified.                                                 |
 | Dali::Toolkit::ImageVisual::Property::SAMPLING_MODE  | samplingMode  | INTEGER or STRING | No       | Filtering options, used when resizing images to sample original pixels. [More info](@ref resourceimagescaling-scaling)   |
 | Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH  | desiredWidth  | INT               | No       | The desired image width. Will use actual image width if not specified.                                                   |
 | Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT | desiredHeight | INT               | No       | The desired image height. Will use actual image height if not specified.                                                 |
+| Dali::Toolkit::ImageVisual::Property::PIXEL_AREA     | pixelArea     | VECTOR4           | No       | The image area to be displayed, default value is [0.0, 0.0, 1.0, 1.0]                                                    |
+| Dali::Toolkit::ImageVisual::Property::WRAP_MODE_U    | wrapModeU     | INTEGER or STRING | No       | Wrap mode for u coordinate, valid values are CLAMP_TO_EDGE(default), REPEAT, MIRRORED_REPEAT                               |
+| Dali::Toolkit::ImageVisual::Property::WRAP_MODE_V    | wrapModeV     | INTEGER or STRING | No       | Wrap mode for v coordinate, valid values are CLAMP_TO_EDGE(default), REPEAT, MIRRORED_REPEAT                               |
 
 #### Usage
 
 
 #### Usage
 
@@ -455,9 +458,12 @@ Renders an animated image into the visual's quad geometry. Currently, only the G
 
 **VisualType:** Dali::Toolkit::Visual::IMAGE, "IMAGE"
 
 
 **VisualType:** Dali::Toolkit::Visual::IMAGE, "IMAGE"
 
-| Property                                  | String | Type    | Required | Description                      |
-|-------------------------------------------|--------|:-------:|:--------:|----------------------------------|
-| Dali::Toolkit::ImageVisual::Property::URL | url    | STRING  | Yes      | The URL of the animated image.    |
+| Property                                          | String     | Type              | Required | Description                                                                                  |
+|---------------------------------------------------|------------|:-----------------:|:--------:|----------------------------------------------------------------------------------------------|
+| Dali::Toolkit::ImageVisual::Property::URL         | url        | STRING            | Yes      | The URL of the animated image.                                                               |
+| Dali::Toolkit::ImageVisual::Property::PIXEL_AREA  | pixelArea  | VECTOR4           | No       | The image area to be displayed, default value is [0.0, 0.0, 1.0, 1.0]                        |
+| Dali::Toolkit::ImageVisual::Property::WRAP_MODE_U | wrapModeU  | INTEGER or STRING | No       | Wrap mode for u coordinate, valid values are CLAMP_TO_EDGE(default), REPEAT, MIRRORED_REPEAT |
+| Dali::Toolkit::ImageVisual::Property::WRAP_MODE_V | wrapModeV  | INTEGER or STRING | No       | Wrap mode for v coordinate, valid values are CLAMP_TO_EDGE(default), REPEAT, MIRRORED_REPEAT |
 
 #### Usage
 
 
 #### Usage