From: Agnelo Vaz Date: Thu, 23 Mar 2017 16:19:34 +0000 (+0000) Subject: Disabled Atlasing for ImageVisuals to prevent bluring X-Git-Tag: dali_1.2.33~10^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F75%2F120675%2F5;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Disabled Atlasing for ImageVisuals to prevent bluring Change-Id: I1e1a8303354f0f0a06cd299afd1e50e2d7ca1687 --- diff --git a/automated-tests/src/dali-toolkit-styling/default-theme.json b/automated-tests/src/dali-toolkit-styling/default-theme.json index 4f9fb77..c9e87f8 100644 --- a/automated-tests/src/dali-toolkit-styling/default-theme.json +++ b/automated-tests/src/dali-toolkit-styling/default-theme.json @@ -132,7 +132,8 @@ "testVisual": { "visualType":"IMAGE", - "url":"0001.png" + "url":"0001.png", + "atlasing":true }, "testVisual2": { @@ -146,7 +147,8 @@ "foregroundVisual": { "visualType":"IMAGE", - "url":"theSameImage.png" + "url":"theSameImage.png", + "atlasing":true }, "labelVisual": { @@ -163,7 +165,8 @@ "testVisual": { "visualType":"IMAGE", - "url":"0002.png" + "url":"0002.png", + "atlasing":true }, "testVisual2": { @@ -173,7 +176,8 @@ "foregroundVisual": { "visualType":"IMAGE", - "url":"theSameImage.png" + "url":"theSameImage.png", + "atlasing":true }, "labelVisual": { @@ -258,7 +262,8 @@ "testVisual": { "visualType":"IMAGE", - "url":"0001.png" + "url":"0001.png", + "atlasing":true }, "testVisual2": { @@ -340,7 +345,8 @@ "focusVisual": { "visualType":"IMAGE", - "url": "focus.png" + "url": "focus.png", + "atlasing":true } }, "entryTransition": diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp index 17b4432..f6164fb 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp @@ -21,7 +21,10 @@ #include #include #include +#include + #include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -390,8 +393,25 @@ int UtcDaliImageAtlasImageView(void) 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 ); @@ -434,7 +454,16 @@ int UtcDaliImageAtlasImageView(void) 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 ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp index 721bfec..596d09a 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -452,7 +453,15 @@ int UtcDaliImageViewAsyncLoadingWithAtlasing(void) 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 @@ -493,6 +502,7 @@ int UtcDaliImageViewAsyncLoadingWithAtlasing02(void) asyncLoadingMap[ "desiredHeight" ] = 34; asyncLoadingMap[ "desiredWidth" ] = 34; asyncLoadingMap[ "synchronousLoading" ] = false; + asyncLoadingMap[ "atlasing" ] = true; 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; + syncLoadingMap[ DevelImageVisual::Property::ATLASING ] = true; // 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 ); + // 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[ "atlasing" ] = true; imageView.SetProperty( ImageView::Property::IMAGE, syncLoadingMap ); // loading is started even if the actor is offStage diff --git a/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp b/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp index 29c4cc7..4966804 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-VisualFactory.cpp @@ -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( DevelImageVisual::Property::ATLASING, true ); Visual::Base visual = factory.CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); diff --git a/dali-toolkit/devel-api/visuals/image-visual-properties-devel.h b/dali-toolkit/devel-api/visuals/image-visual-properties-devel.h index eb2ac49..d2622da 100644 --- a/dali-toolkit/devel-api/visuals/image-visual-properties-devel.h +++ b/dali-toolkit/devel-api/visuals/image-visual-properties-devel.h @@ -55,6 +55,15 @@ enum Type * @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 diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index 49e2c00..16b6eb2 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -31,6 +31,7 @@ // INTERNAL HEADERS #include +#include #include #include #include @@ -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_ATLASING("atlasing"); // 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 ), - 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 ), - 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 ); } + 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 @@ -423,6 +431,12 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v 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 - 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 @@ -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::DevelImageVisual::Property::ATLASING, mAttemptAtlasing ); } void ImageVisual::DoCreateInstancePropertyMap( Property::Map& map ) const diff --git a/dali-toolkit/internal/visuals/image/image-visual.h b/dali-toolkit/internal/visuals/image/image-visual.h index 83fd71c..f2d7023 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.h +++ b/dali-toolkit/internal/visuals/image/image-visual.h @@ -320,6 +320,8 @@ private: Dali::WrapMode::Type mWrapModeU:3; Dali::WrapMode::Type mWrapModeV:3; + bool mAttemptAtlasing:1; // If true will attempt atlasing, otherwise create unique texture + }; } // namespace Internal