Disabled Atlasing for ImageVisuals to prevent bluring 75/120675/5
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Thu, 23 Mar 2017 16:19:34 +0000 (16:19 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 24 Mar 2017 17:32:25 +0000 (10:32 -0700)
Change-Id: I1e1a8303354f0f0a06cd299afd1e50e2d7ca1687

automated-tests/src/dali-toolkit-styling/default-theme.json
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-VisualFactory.cpp
dali-toolkit/devel-api/visuals/image-visual-properties-devel.h
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/image/image-visual.h

index 4f9fb77..c9e87f8 100644 (file)
                 "testVisual":
                 {
                   "visualType":"IMAGE",
                 "testVisual":
                 {
                   "visualType":"IMAGE",
-                  "url":"0001.png"
+                  "url":"0001.png",
+                  "atlasing":true
                 },
                 "testVisual2":
                 {
                 },
                 "testVisual2":
                 {
                 "foregroundVisual":
                 {
                   "visualType":"IMAGE",
                 "foregroundVisual":
                 {
                   "visualType":"IMAGE",
-                  "url":"theSameImage.png"
+                  "url":"theSameImage.png",
+                  "atlasing":true
                 },
                 "labelVisual":
                 {
                 },
                 "labelVisual":
                 {
                 "testVisual":
                 {
                   "visualType":"IMAGE",
                 "testVisual":
                 {
                   "visualType":"IMAGE",
-                  "url":"0002.png"
+                  "url":"0002.png",
+                  "atlasing":true
                 },
                 "testVisual2":
                 {
                 },
                 "testVisual2":
                 {
                 "foregroundVisual":
                 {
                   "visualType":"IMAGE",
                 "foregroundVisual":
                 {
                   "visualType":"IMAGE",
-                  "url":"theSameImage.png"
+                  "url":"theSameImage.png",
+                  "atlasing":true
                 },
                 "labelVisual":
                 {
                 },
                 "labelVisual":
                 {
                 "testVisual":
                 {
                   "visualType":"IMAGE",
                 "testVisual":
                 {
                   "visualType":"IMAGE",
-                  "url":"0001.png"
+                  "url":"0001.png",
+                  "atlasing":true
                 },
                 "testVisual2":
                 {
                 },
                 "testVisual2":
                 {
             "focusVisual":
             {
               "visualType":"IMAGE",
             "focusVisual":
             {
               "visualType":"IMAGE",
-              "url": "focus.png"
+              "url": "focus.png",
+              "atlasing":true
             }
           },
           "entryTransition":
             }
           },
           "entryTransition":
index 17b4432..f6164fb 100644 (file)
 #include <dali-toolkit-test-suite-utils.h>
 #include <toolkit-event-thread-callback.h>
 #include <dali-toolkit/devel-api/image-loader/image-atlas.h>
 #include <dali-toolkit-test-suite-utils.h>
 #include <toolkit-event-thread-callback.h>
 #include <dali-toolkit/devel-api/image-loader/image-atlas.h>
+#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+
 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
+#include <dali-toolkit/dali-toolkit.h>
 
 using namespace Dali;
 using namespace Dali::Toolkit;
 
 using namespace Dali;
 using namespace Dali::Toolkit;
@@ -390,8 +393,25 @@ int UtcDaliImageAtlasImageView(void)
   callStack.Reset();
   callStack.Enable(true);
 
   callStack.Reset();
   callStack.Enable(true);
 
-  ImageView imageView1 = ImageView::New( gImage_34_RGBA, ImageDimensions(34, 34) );
-  ImageView imageView2 = ImageView::New( gImage_50_RGBA, ImageDimensions(50, 50) );
+  Property::Map imageMap1;
+
+  imageMap1[ ImageVisual::Property::URL ] = gImage_34_RGBA;
+  imageMap1[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
+  imageMap1[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
+  imageMap1[ DevelImageVisual::Property::ATLASING] = true;
+
+  Property::Map imageMap2;
+
+  imageMap2[ ImageVisual::Property::URL ] = gImage_50_RGBA;
+  imageMap2[ ImageVisual::Property::DESIRED_HEIGHT ] = 50;
+  imageMap2[ ImageVisual::Property::DESIRED_WIDTH ] = 50;
+  imageMap2[ DevelImageVisual::Property::ATLASING ] = true;
+
+  ImageView imageView1 = ImageView::New();
+  imageView1.SetProperty( ImageView::Property::IMAGE, imageMap1 );
+
+  ImageView imageView2 = ImageView::New();
+  imageView2.SetProperty( ImageView::Property::IMAGE, imageMap2 );
 
   // ImageView doesn't do size negotiation properly: it only listens to OnSizeSet:
   imageView1.SetSize( 100, 100 );
 
   // ImageView doesn't do size negotiation properly: it only listens to OnSizeSet:
   imageView1.SetSize( 100, 100 );
@@ -434,7 +454,16 @@ int UtcDaliImageAtlasImageView(void)
   Stage::GetCurrent().Remove( imageView2 );
   application.SendNotification();
   application.Render(RENDER_FRAME_INTERVAL);
   Stage::GetCurrent().Remove( imageView2 );
   application.SendNotification();
   application.Render(RENDER_FRAME_INTERVAL);
-  ImageView imageView3 = ImageView::New( gImage_128_RGB, ImageDimensions(100, 100) );
+
+  Property::Map imageMap3;
+  imageMap3[ ImageVisual::Property::URL ] = gImage_128_RGB;
+  imageMap3[ ImageVisual::Property::DESIRED_HEIGHT ] = 100;
+  imageMap3[ ImageVisual::Property::DESIRED_WIDTH ] = 100;
+  imageMap3[ DevelImageVisual::Property::ATLASING ] = true;
+
+  ImageView imageView3 = ImageView::New();
+  imageView3.SetProperty( ImageView::Property::IMAGE, imageMap3 );
+
   application.GetPlatform().SetClosestImageSize(  Vector2(100, 100) );
   Stage::GetCurrent().Add( imageView3 );
 
   application.GetPlatform().SetClosestImageSize(  Vector2(100, 100) );
   Stage::GetCurrent().Add( imageView3 );
 
index 721bfec..596d09a 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali/devel-api/scripting/scripting.h>
 
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali/devel-api/scripting/scripting.h>
+#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
 #include <dali/public-api/rendering/renderer.h>
 
 #include <test-native-image.h>
 #include <dali/public-api/rendering/renderer.h>
 
 #include <test-native-image.h>
@@ -452,7 +453,15 @@ int UtcDaliImageViewAsyncLoadingWithAtlasing(void)
   callStack.Reset();
   callStack.Enable(true);
 
   callStack.Reset();
   callStack.Enable(true);
 
-  ImageView imageView = ImageView::New( gImage_34_RGBA, ImageDimensions( 34, 34 ) );
+  Property::Map imageMap;
+
+  imageMap[ ImageVisual::Property::URL ] = gImage_34_RGBA;
+  imageMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 34;
+  imageMap[ ImageVisual::Property::DESIRED_WIDTH ] = 34;
+  imageMap[ DevelImageVisual::Property::ATLASING] = true;
+
+  ImageView imageView = ImageView::New();
+  imageView.SetProperty( ImageView::Property::IMAGE, imageMap );
 
   // By default, Aysnc loading is used
   // loading is not started if the actor is offStage
 
   // By default, Aysnc loading is used
   // loading is not started if the actor is offStage
@@ -493,6 +502,7 @@ int UtcDaliImageViewAsyncLoadingWithAtlasing02(void)
   asyncLoadingMap[ "desiredHeight" ] = 34;
   asyncLoadingMap[ "desiredWidth" ] = 34;
   asyncLoadingMap[ "synchronousLoading" ] = false;
   asyncLoadingMap[ "desiredHeight" ] = 34;
   asyncLoadingMap[ "desiredWidth" ] = 34;
   asyncLoadingMap[ "synchronousLoading" ] = false;
+  asyncLoadingMap[ "atlasing" ] = true;
 
   ImageView imageView = ImageView::New();
   imageView.SetProperty( ImageView::Property::IMAGE, asyncLoadingMap );
 
   ImageView imageView = ImageView::New();
   imageView.SetProperty( ImageView::Property::IMAGE, asyncLoadingMap );
@@ -527,6 +537,7 @@ int UtcDaliImageViewSyncLoading(void)
 
   Property::Map syncLoadingMap;
   syncLoadingMap[ ImageVisual::Property::SYNCHRONOUS_LOADING ] = true;
 
   Property::Map syncLoadingMap;
   syncLoadingMap[ ImageVisual::Property::SYNCHRONOUS_LOADING ] = true;
+  syncLoadingMap[ DevelImageVisual::Property::ATLASING ] = true;
 
   // Sync loading, no atlasing for big size image
   {
 
   // Sync loading, no atlasing for big size image
   {
@@ -536,6 +547,7 @@ int UtcDaliImageViewSyncLoading(void)
     syncLoadingMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
     imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
 
     syncLoadingMap[ ImageVisual::Property::URL ] = gImage_600_RGB;
     imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
 
+
     // BitmapLoader is used, and the loading is started immediately even the actor is not on stage.
     BitmapLoader loader = BitmapLoader::GetLatestCreated();
     DALI_TEST_CHECK( loader );
     // BitmapLoader is used, and the loading is started immediately even the actor is not on stage.
     BitmapLoader loader = BitmapLoader::GetLatestCreated();
     DALI_TEST_CHECK( loader );
@@ -598,6 +610,7 @@ int UtcDaliImageViewSyncLoading02(void)
     syncLoadingMap[ "desiredHeight" ] = 34;
     syncLoadingMap[ "desiredWidth" ] = 34;
     syncLoadingMap[ "synchronousLoading" ] = true;
     syncLoadingMap[ "desiredHeight" ] = 34;
     syncLoadingMap[ "desiredWidth" ] = 34;
     syncLoadingMap[ "synchronousLoading" ] = true;
+    syncLoadingMap[ "atlasing" ] = true;
     imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
 
     // loading is started even if the actor is offStage
     imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap );
 
     // loading is started even if the actor is offStage
index 29c4cc7..4966804 100644 (file)
@@ -687,6 +687,7 @@ int UtcDaliVisualFactoryGetImageVisual3(void)
   propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
   propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
   propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
   propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
   propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
   propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
+  propertyMap.Insert( DevelImageVisual::Property::ATLASING, true );
 
   Visual::Base visual = factory.CreateVisual( propertyMap );
   DALI_TEST_CHECK( visual );
 
   Visual::Base visual = factory.CreateVisual( propertyMap );
   DALI_TEST_CHECK( visual );
index eb2ac49..d2622da 100644 (file)
@@ -55,6 +55,15 @@ enum Type
    * @note For N-Patch images only.
    */
   BORDER = WRAP_MODE_V + 1,
    * @note For N-Patch images only.
    */
   BORDER = WRAP_MODE_V + 1,
+
+  /**
+   * @brief Whether to use the texture atlas
+   * @details Name "atlasing", type Property::BOOLEAN, true to enable texture atlas
+   *
+   * @note Optional. By default atlasing is off.
+   */
+
+  ATLASING = WRAP_MODE_V + 2,
 };
 
 } //namespace Property
 };
 
 } //namespace Property
index 49e2c00..16b6eb2 100644 (file)
@@ -31,6 +31,7 @@
 
 // INTERNAL HEADERS
 #include <dali-toolkit/public-api/visuals/image-visual-properties.h>
 
 // INTERNAL HEADERS
 #include <dali-toolkit/public-api/visuals/image-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
@@ -58,6 +59,7 @@ const char * const IMAGE_SAMPLING_MODE( "samplingMode" );
 const char * const IMAGE_DESIRED_WIDTH( "desiredWidth" );
 const char * const IMAGE_DESIRED_HEIGHT( "desiredHeight" );
 const char * const SYNCHRONOUS_LOADING( "synchronousLoading" );
 const char * const IMAGE_DESIRED_WIDTH( "desiredWidth" );
 const char * const IMAGE_DESIRED_HEIGHT( "desiredHeight" );
 const char * const SYNCHRONOUS_LOADING( "synchronousLoading" );
+const char * const IMAGE_ATLASING("atlasing");
 
 // fitting modes
 DALI_ENUM_TO_STRING_TABLE_BEGIN( FITTING_MODE )
 
 // fitting modes
 DALI_ENUM_TO_STRING_TABLE_BEGIN( FITTING_MODE )
@@ -253,7 +255,8 @@ ImageVisual::ImageVisual( VisualFactoryCache& factoryCache,
   mFittingMode( fittingMode ),
   mSamplingMode( samplingMode ),
   mWrapModeU( WrapMode::DEFAULT ),
   mFittingMode( fittingMode ),
   mSamplingMode( samplingMode ),
   mWrapModeU( WrapMode::DEFAULT ),
-  mWrapModeV( WrapMode::DEFAULT )
+  mWrapModeV( WrapMode::DEFAULT ),
+  mAttemptAtlasing( false )
 {
 }
 
 {
 }
 
@@ -268,7 +271,8 @@ ImageVisual::ImageVisual( VisualFactoryCache& factoryCache, const Image& image )
   mFittingMode( FittingMode::DEFAULT ),
   mSamplingMode( SamplingMode::DEFAULT ),
   mWrapModeU( WrapMode::DEFAULT ),
   mFittingMode( FittingMode::DEFAULT ),
   mSamplingMode( SamplingMode::DEFAULT ),
   mWrapModeU( WrapMode::DEFAULT ),
-  mWrapModeV( WrapMode::DEFAULT )
+  mWrapModeV( WrapMode::DEFAULT ),
+  mAttemptAtlasing( false )
 {
 }
 
 {
 }
 
@@ -320,10 +324,14 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap )
       {
         DoSetProperty( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, keyValue.second );
       }
       {
         DoSetProperty( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, keyValue.second );
       }
+      else if ( keyValue.first == IMAGE_ATLASING )
+      {
+        DoSetProperty( Toolkit::DevelImageVisual::Property::ATLASING, keyValue.second );
+      }
     }
   }
 
     }
   }
 
-  if( mImpl->mFlags & Impl::IS_SYNCHRONOUS_RESOURCE_LOADING && mImageUrl.IsValid() )
+  if( ( mImpl->mFlags & Impl::IS_SYNCHRONOUS_RESOURCE_LOADING ) && mImageUrl.IsValid() )
   {
     // if sync loading is required, the loading should start
     // immediately when new image url is set or the actor is off stage
   {
     // if sync loading is required, the loading should start
     // immediately when new image url is set or the actor is off stage
@@ -423,6 +431,12 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v
       mWrapModeV = Dali::WrapMode::Type( wrapMode );
       break;
     }
       mWrapModeV = Dali::WrapMode::Type( wrapMode );
       break;
     }
+
+    case Toolkit::DevelImageVisual::Property::ATLASING:
+    {
+      bool atlasing = false;
+      mAttemptAtlasing = value.Get( atlasing );
+    }
   }
 }
 
   }
 }
 
@@ -628,7 +642,7 @@ void ImageVisual::InitializeRenderer()
     Vector4 atlasRect;
     // texture set has to be created first as we need to know if atlasing succeeded or not
     // when selecting the shader
     Vector4 atlasRect;
     // texture set has to be created first as we need to know if atlasing succeeded or not
     // when selecting the shader
-    TextureSet textures = CreateTextureSet( atlasRect, IsSynchronousResourceLoading(), true );
+    TextureSet textures = CreateTextureSet( atlasRect, IsSynchronousResourceLoading(), mAttemptAtlasing );
     CreateRenderer( textures );
 
     if( mImpl->mFlags & Impl::IS_ATLASING_APPLIED ) // the texture is packed inside atlas
     CreateRenderer( textures );
 
     if( mImpl->mFlags & Impl::IS_ATLASING_APPLIED ) // the texture is packed inside atlas
@@ -761,6 +775,8 @@ void ImageVisual::DoCreatePropertyMap( Property::Map& map ) const
   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 );
   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 );
+
+  map.Insert( Toolkit::DevelImageVisual::Property::ATLASING, mAttemptAtlasing );
 }
 
 void ImageVisual::DoCreateInstancePropertyMap( Property::Map& map ) const
 }
 
 void ImageVisual::DoCreateInstancePropertyMap( Property::Map& map ) const
index 83fd71c..f2d7023 100644 (file)
@@ -320,6 +320,8 @@ private:
   Dali::WrapMode::Type mWrapModeU:3;
   Dali::WrapMode::Type mWrapModeV:3;
 
   Dali::WrapMode::Type mWrapModeU:3;
   Dali::WrapMode::Type mWrapModeV:3;
 
+  bool mAttemptAtlasing:1; // If true will attempt atlasing, otherwise create unique texture
+
 };
 
 } // namespace Internal
 };
 
 } // namespace Internal