From aa273253ab5bb8febb5e4afa7cd511cd945f40d7 Mon Sep 17 00:00:00 2001
From: Paul Wisbey
Date: Tue, 18 Jun 2019 16:10:31 +0100
Subject: [PATCH] Remove deprecated APIs from GaussianBlurView
Change-Id: I1bb84da3681b77b901a47e3a6c7c215e469dc269
---
.../src/dali-toolkit/utc-Dali-GaussianBlurView.cpp | 12 +-
.../src/dali-toolkit/utc-Dali-SuperBlurView.cpp | 139 +++++------
.../gaussian-blur-view/gaussian-blur-view.cpp | 4 +-
.../gaussian-blur-view/gaussian-blur-view.h | 7 +-
.../controls/super-blur-view/super-blur-view.cpp | 8 +-
.../controls/super-blur-view/super-blur-view.h | 26 +--
.../controls/bloom-view/bloom-view-impl.cpp | 18 +-
.../internal/controls/bloom-view/bloom-view-impl.h | 3 +-
.../gaussian-blur-view/gaussian-blur-view-impl.cpp | 255 +++++++++++++++------
.../gaussian-blur-view/gaussian-blur-view-impl.h | 24 +-
.../super-blur-view/super-blur-view-impl.cpp | 238 ++++++++++++++-----
.../super-blur-view/super-blur-view-impl.h | 44 ++--
12 files changed, 488 insertions(+), 290 deletions(-)
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-GaussianBlurView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-GaussianBlurView.cpp
index d0f90ce..4a19b78 100644
--- a/automated-tests/src/dali-toolkit/utc-Dali-GaussianBlurView.cpp
+++ b/automated-tests/src/dali-toolkit/utc-Dali-GaussianBlurView.cpp
@@ -26,7 +26,7 @@ using namespace Dali::Toolkit;
namespace
{
-const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
+const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
} // namespace
void utc_gaussian_blur_view_startup(void)
@@ -216,8 +216,12 @@ int UtcDaliGaussianBlurViewSetGetRenderTarget(void)
Stage::GetCurrent().Add(view);
view.Activate();
- FrameBufferImage renderTarget = FrameBufferImage::New( 480.0f, 800.0f, Pixel::RGB888 );
- view.SetUserImageAndOutputRenderTarget(ResourceImage::New(TEST_IMAGE_FILE_NAME), renderTarget);
+ PixelData pixels = Toolkit::SyncImageLoader::Load( TEST_IMAGE_FILE_NAME );
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, pixels.GetPixelFormat(), pixels.GetWidth(), pixels.GetHeight() );
+ texture.Upload( pixels, 0, 0, 0, 0, pixels.GetWidth(), pixels.GetHeight() );
+
+ FrameBuffer renderTarget = FrameBuffer::New( 480, 800, FrameBuffer::Attachment::NONE );
+ view.SetUserImageAndOutputRenderTarget(texture, renderTarget);
DALI_TEST_CHECK( view.GetBlurredRenderTarget() == renderTarget );
END_TEST;
}
@@ -249,7 +253,7 @@ int UtcDaliGaussianBlurViewActivateOnce(void)
int UtcDaliGaussianBlurViewFinishedSignalN(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliGaussianBlurViewSetGetRenderTarget");
+ tet_infoline("UtcDaliGaussianBlurViewFinishedSignalN");
Toolkit::GaussianBlurView view = Toolkit::GaussianBlurView::New(5, 1.5f, Pixel::RGB888, 0.5f, 0.5f, true);
DALI_TEST_CHECK( view );
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp
index 2967639..664c2a8 100644
--- a/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp
+++ b/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp
@@ -44,7 +44,7 @@ namespace
{
const int BLUR_LEVELS = 3;
const int RENDER_FRAME_INTERVAL = 16;
-const char* TEST_IMAGE_FILE_NAME("image.png");
+static const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
static bool gObjectCreatedCallBackCalled;
static void TestCallback(BaseHandle handle)
{
@@ -74,37 +74,25 @@ int Wait(ToolkitTestApplication& application, int duration = 0)
return time;
}
-Image CreateSolidColorImage( ToolkitTestApplication& application, const Vector4& color, unsigned int width, unsigned int height )
+Texture CreateSolidColorTexture( ToolkitTestApplication& application, const Vector4& color, unsigned int width, unsigned int height )
{
- BufferImage imageData = BufferImage::New( width, height, Pixel::RGBA8888 );
-
- // Create the image
- PixelBuffer* pixbuf = imageData.GetBuffer();
unsigned int size = width * height;
+ uint8_t* pixbuf = new uint8_t[size*4];
for( size_t i = 0; i < size; i++ )
- {
- pixbuf[i*4+0] = 0xFF * color.r;
- pixbuf[i*4+1] = 0xFF * color.g;
- pixbuf[i*4+2] = 0xFF * color.b;
- pixbuf[i*4+3] = 0xFF * color.a;
- }
- imageData.Update();
+ {
+ pixbuf[i*4+0] = 0xFF * color.r;
+ pixbuf[i*4+1] = 0xFF * color.g;
+ pixbuf[i*4+2] = 0xFF * color.b;
+ pixbuf[i*4+3] = 0xFF * color.a;
+ }
- application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE );
- application.SendNotification();
- application.Render(RENDER_FRAME_INTERVAL);
- application.Render(RENDER_FRAME_INTERVAL);
- application.SendNotification();
+ PixelData pixels = PixelData::New( pixbuf, size, width, height, Pixel::RGBA8888, PixelData::ReleaseFunction::DELETE_ARRAY );
- return imageData;
-}
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, pixels.GetPixelFormat(), pixels.GetWidth(), pixels.GetHeight() );
+ texture.Upload( pixels, 0, 0, 0, 0, pixels.GetWidth(), pixels.GetHeight() );
-void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
-{
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
- Integration::ResourcePointer resource(bitmap);
- bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
+ return texture;
}
class SignalHandler : public Dali::ConnectionTracker
@@ -197,22 +185,22 @@ int UtcDaliSuperBlurViewCreate(void)
}
-int UtcDaliSuperBlurViewSetImage(void)
+int UtcDaliSuperBlurViewSetTexture(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliSuperBlurViewSetImage ");
+ tet_infoline(" UtcDaliSuperBlurViewSetTexture ");
SuperBlurView blurView = SuperBlurView::New( BLUR_LEVELS );
blurView.SetSize( 100.f, 100.f );
- Image inputImage = CreateSolidColorImage( application, Color::GREEN, 50, 50 );
- blurView.SetImage( inputImage );
+ Texture inputTexture = CreateSolidColorTexture( application, Color::GREEN, 50, 50 );
+ blurView.SetTexture( inputTexture );
// start multiple guassian blur call, each guassian blur creates two render tasks
DALI_TEST_CHECK( Stage::GetCurrent().GetRenderTaskList().GetTaskCount() == 1+BLUR_LEVELS*2);
{
- // create image renderers for the original image and each blurred image
+ // create renderers for the original image and each blurred image
Stage::GetCurrent().Add( blurView );
Wait(application);
DALI_TEST_EQUALS(blurView.GetRendererCount(), BLUR_LEVELS+1, TEST_LOCATION );
@@ -224,24 +212,24 @@ int UtcDaliSuperBlurViewSetImage(void)
END_TEST;
}
-int UtcDaliSuperBlurViewSetImage2(void)
+int UtcDaliSuperBlurViewSetTexture2(void)
{
ToolkitTestApplication application;
Stage stage = Stage::GetCurrent();
- tet_infoline(" UtcDaliSuperBlurViewSetImage2 - test setting a second image ");
+ tet_infoline(" UtcDaliSuperBlurViewSetTexture2 - test setting a second texture ");
SuperBlurView blurView = SuperBlurView::New( BLUR_LEVELS );
blurView.SetSize( 100.f, 100.f );
- tet_infoline("Call SetImage and add blurview to stage");
- Image inputImage = CreateSolidColorImage( application, Color::GREEN, 50, 50 );
- blurView.SetImage( inputImage );
+ tet_infoline("Call SetTexture and add blurview to stage");
+ Texture inputTexture = CreateSolidColorTexture( application, Color::GREEN, 50, 50 );
+ blurView.SetTexture( inputTexture );
// start multiple guassian blur call, each guassian blur creates two render tasks
DALI_TEST_CHECK( Stage::GetCurrent().GetRenderTaskList().GetTaskCount() == 1+BLUR_LEVELS*2);
{
- // create image renderers for the original image and each blurred image
+ // create renderers for the original image and each blurred image
stage.Add( blurView );
Wait(application);
DALI_TEST_EQUALS(blurView.GetRendererCount(), BLUR_LEVELS+1, TEST_LOCATION );
@@ -256,14 +244,14 @@ int UtcDaliSuperBlurViewSetImage2(void)
tet_infoline("Test that there are no render tasks remaining");
DALI_TEST_EQUALS(blurView.GetRendererCount(), 0, TEST_LOCATION );
- tet_infoline("Call SetImage a second time and add blurview back to stage");
- Image inputImage2 = CreateSolidColorImage( application, Color::CYAN, 50, 50 );
- blurView.SetImage( inputImage2 );
+ tet_infoline("Call SetTexture a second time and add blurview back to stage");
+ Texture inputTexture2 = CreateSolidColorTexture( application, Color::CYAN, 50, 50 );
+ blurView.SetTexture( inputTexture2 );
// start multiple guassian blur call, each guassian blur creates two render tasks
DALI_TEST_CHECK( Stage::GetCurrent().GetRenderTaskList().GetTaskCount() == 1+BLUR_LEVELS*2);
{
- // create image renderers for the original image and each blurred image
+ // create renderers for the original image and each blurred image
Stage::GetCurrent().Add( blurView );
Wait(application);
DALI_TEST_EQUALS(blurView.GetRendererCount(), BLUR_LEVELS+1, TEST_LOCATION );
@@ -289,26 +277,18 @@ int UtcDaliSuperBlurViewSetProperty(void)
tet_infoline(" UtcDaliSuperBlurViewSetProperty ");
SuperBlurView blurView = SuperBlurView::New( BLUR_LEVELS );
- // create image renderers for the original image and each blurred image
+ // create renderers for the original image and each blurred image
Stage::GetCurrent().Add( blurView );
blurView.SetSize( 100.f, 100.f );
- tet_infoline(" Set property map. Set height and width large enough to avoid atlassing");
- int width(512);
- int height(513);
- LoadBitmapResource( application.GetPlatform(), width, height );
-
- Property::Map propertyMap;
- propertyMap["filename"] = TEST_IMAGE_FILE_NAME ;
- propertyMap["width"] = width;
- propertyMap["height"] = height;
-
// Will create ResourceImage
- blurView.SetProperty(SuperBlurView::Property::IMAGE, propertyMap);
+ blurView.SetProperty(SuperBlurView::Property::IMAGE_URL, TEST_IMAGE_FILE_NAME);
Wait(application);
// start multiple guassian blur call, each guassian blur creates two render tasks
- DALI_TEST_CHECK( Stage::GetCurrent().GetRenderTaskList().GetTaskCount() == 1+BLUR_LEVELS*2);
+
+ unsigned int count = Stage::GetCurrent().GetRenderTaskList().GetTaskCount();
+ DALI_TEST_CHECK( count == 1+BLUR_LEVELS*2 );
Wait(application);
@@ -325,31 +305,14 @@ int UtcDaliSuperBlurViewGetProperty(void)
SuperBlurView blurView = SuperBlurView::New( BLUR_LEVELS );
blurView.SetSize( 100.f, 100.f );
- tet_infoline(" Set property map.");
- int width(512);
- int height(513); // Value large enough to avoid future atlassing
- LoadBitmapResource( application.GetPlatform(), width, height );
-
- Property::Map propertyMap;
- propertyMap["filename"] = TEST_IMAGE_FILE_NAME ;
- propertyMap["width"] = width;
- propertyMap["height"] = height;
-
- // Will create ResourceImage
- blurView.SetProperty(SuperBlurView::Property::IMAGE, propertyMap);
+ blurView.SetProperty(SuperBlurView::Property::IMAGE_URL, TEST_IMAGE_FILE_NAME);
Wait(application);
- // create image renderers for the original image and each blurred image
+ // create renderers for the original image and each blurred image
Stage::GetCurrent().Add( blurView );
- Property::Value imageProperty = blurView.GetProperty(SuperBlurView::Property::IMAGE);
- Property::Map* map = imageProperty.GetMap();
- DALI_TEST_CHECK( map != NULL );
- if( map )
- {
- Property::Map& mapRef = *map;
- DALI_TEST_EQUALS( mapRef["filename"], TEST_IMAGE_FILE_NAME, TEST_LOCATION );
- }
+ std::string imageUrl = blurView.GetProperty( SuperBlurView::Property::IMAGE_URL );
+ DALI_TEST_EQUALS( imageUrl, TEST_IMAGE_FILE_NAME, TEST_LOCATION );
END_TEST;
}
@@ -390,28 +353,28 @@ int UtcDaliSuperBlurViewGetBlurStrengthPropertyIndex(void)
END_TEST;
}
-int UtcDaliSuperBlurViewGetBlurredImage(void)
+int UtcDaliSuperBlurViewGetBlurredTexture(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliSuperBlurViewGetBlurredImage" );
+ tet_infoline( "UtcDaliSuperBlurViewGetBlurredTexture" );
SuperBlurView blurView = SuperBlurView::New( BLUR_LEVELS );
blurView.SetSize( 100.f,100.f );
- Image inputImage = CreateSolidColorImage( application, Color::GREEN, 100, 100 );
- blurView.SetImage( inputImage );
+ Texture inputTexture = CreateSolidColorTexture( application, Color::GREEN, 100, 100 );
+ blurView.SetTexture( inputTexture );
Wait(application, 200); // Make sure all the gaussian blur finished
- Image image1 = blurView.GetBlurredImage( 1 );
- DALI_TEST_CHECK( image1 );
+ Texture texture1 = blurView.GetBlurredTexture( 1 );
+ DALI_TEST_CHECK( texture1 );
- Image image2 = blurView.GetBlurredImage( 2 );
- DALI_TEST_EQUALS( image2.GetWidth(), 25u, TEST_LOCATION );
- DALI_TEST_EQUALS( image2.GetHeight(), 25u, TEST_LOCATION );
+ Texture texture2 = blurView.GetBlurredTexture( 2 );
+ DALI_TEST_EQUALS( texture2.GetWidth(), 25u, TEST_LOCATION );
+ DALI_TEST_EQUALS( texture2.GetHeight(), 25u, TEST_LOCATION );
- Image image3 = blurView.GetBlurredImage( 3 );
- DALI_TEST_CHECK( FrameBufferImage::DownCast( image3 ) );
+ Texture texture3 = blurView.GetBlurredTexture( 3 );
+ DALI_TEST_CHECK( texture3 );
END_TEST;
}
@@ -425,15 +388,15 @@ int UtcDaliSuperBlurViewBlurSignal(void)
SuperBlurView blurView = SuperBlurView::New( BLUR_LEVELS );
blurView.SetSize( 100.f, 100.f );
- Image inputImage = CreateSolidColorImage( application, Color::GREEN, 50, 50 );
- blurView.SetImage( inputImage );
+ Texture inputTexture = CreateSolidColorTexture( application, Color::GREEN, 50, 50 );
+ blurView.SetTexture( inputTexture );
// start multiple guassian blur call, each guassian blur creates two render tasks
DALI_TEST_CHECK( Stage::GetCurrent().GetRenderTaskList().GetTaskCount() == 1+BLUR_LEVELS*2);
SignalHandler signalHandler;
blurView.BlurFinishedSignal().Connect(&signalHandler, &SignalHandler::Callback);
- // create image renderers for the original image and each blurred image
+ // create renderers for the original image and each blurred image
Stage::GetCurrent().Add( blurView );
Wait(application, 1000);
diff --git a/dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.cpp b/dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.cpp
index 2001939..3d71e4b 100644
--- a/dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.cpp
+++ b/dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.cpp
@@ -106,7 +106,7 @@ void GaussianBlurView::Deactivate()
GetImpl(*this).Deactivate();
}
-void GaussianBlurView::SetUserImageAndOutputRenderTarget(Image inputImage, FrameBufferImage outputRenderTarget)
+void GaussianBlurView::SetUserImageAndOutputRenderTarget(Texture inputImage, FrameBuffer outputRenderTarget)
{
GetImpl(*this).SetUserImageAndOutputRenderTarget(inputImage, outputRenderTarget);
}
@@ -116,7 +116,7 @@ Property::Index GaussianBlurView::GetBlurStrengthPropertyIndex() const
return GetImpl(*this).GetBlurStrengthPropertyIndex();
}
-FrameBufferImage GaussianBlurView::GetBlurredRenderTarget() const
+FrameBuffer GaussianBlurView::GetBlurredRenderTarget() const
{
return GetImpl(*this).GetBlurredRenderTarget();
}
diff --git a/dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.h b/dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.h
index d93e880..9b7824c 100644
--- a/dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.h
+++ b/dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.h
@@ -21,7 +21,8 @@
// EXTERNAL INCLUDES
#include
#include
-#include
+#include
+#include
#include
// INTERNAL INCLUDES
@@ -249,7 +250,7 @@ public:
* @param outputRenderTarget A render target to receive the blurred result. Passing NULL is allowed. See also GetBlurredRenderTarget().
* @pre This object was created with a New( ... ) call where the blurUserImage argument was set to true. If this was not the case an exception will be thrown.
*/
- void SetUserImageAndOutputRenderTarget(Image inputImage, FrameBufferImage outputRenderTarget);
+ void SetUserImageAndOutputRenderTarget(Dali::Texture inputImage, Dali::FrameBuffer outputRenderTarget);
/**
* @brief Get the index of the property that can be used to fade the blur in / out.
@@ -271,7 +272,7 @@ public:
* @return A handle on the blurred image, contained in a render target.
* @pre The user must call Activate() before the render target will be returned.
*/
- FrameBufferImage GetBlurredRenderTarget() const;
+ Dali::FrameBuffer GetBlurredRenderTarget() const;
/**
* @brief Set background color for the view. The background will be filled with this color.
diff --git a/dali-toolkit/devel-api/controls/super-blur-view/super-blur-view.cpp b/dali-toolkit/devel-api/controls/super-blur-view/super-blur-view.cpp
index fda059b..db77511 100644
--- a/dali-toolkit/devel-api/controls/super-blur-view/super-blur-view.cpp
+++ b/dali-toolkit/devel-api/controls/super-blur-view/super-blur-view.cpp
@@ -70,9 +70,9 @@ SuperBlurView::SuperBlurView(Dali::Internal::CustomActor* internal)
VerifyCustomActorPointer( internal );
}
-void SuperBlurView::SetImage(Image inputImage)
+void SuperBlurView::SetTexture( Texture texture )
{
- GetImpl(*this).SetImage( inputImage );
+ GetImpl(*this).SetTexture( texture );
}
Property::Index SuperBlurView::GetBlurStrengthPropertyIndex() const
@@ -95,9 +95,9 @@ SuperBlurView::SuperBlurViewSignal& SuperBlurView::BlurFinishedSignal()
return GetImpl(*this).BlurFinishedSignal();
}
-Image SuperBlurView::GetBlurredImage( unsigned int level )
+Texture SuperBlurView::GetBlurredTexture( unsigned int level )
{
- return GetImpl(*this).GetBlurredImage( level );
+ return GetImpl(*this).GetBlurredTexture( level );
}
} // namespace Toolkit
diff --git a/dali-toolkit/devel-api/controls/super-blur-view/super-blur-view.h b/dali-toolkit/devel-api/controls/super-blur-view/super-blur-view.h
index 6bc0db2..fbbbf9f 100644
--- a/dali-toolkit/devel-api/controls/super-blur-view/super-blur-view.h
+++ b/dali-toolkit/devel-api/controls/super-blur-view/super-blur-view.h
@@ -19,6 +19,7 @@
*/
// EXTERNAL INCLUDES
+#include
// INTERNAL INCLUDES
#include
@@ -44,8 +45,7 @@ class SuperBlurView;
* Stage::GetCurrent().Add(blurView);\n
*
* // Set the input image
- * ResourceImage image = ResourceImage::New(...);\n
- * blurView.SetImage(image);\n
+ * blurView.SetProperty( SuperBlurView::Property::IMAGE_URL, url );\n
*
* // animate the strength of the blur - this can fade between no blur and full blur. .\n
* Animation blurAnimation = Animation::New( ... );\n
@@ -72,7 +72,7 @@ public:
{
enum
{
- IMAGE = PROPERTY_START_INDEX, ///< name "image", @see SetImage, type Map
+ IMAGE_URL = PROPERTY_START_INDEX, ///< name "imageUrl", @see SetTexture, type String
};
};
@@ -89,7 +89,7 @@ public:
/**
* @brief Create an initialized SuperBlurView.
*
- * @param[in] blurLevels The final blur strength level. It decides how many filtering passes are used to create the group of blurred images.
+ * @param[in] blurLevels The final blur strength level. It decides how many filtering passes are used to create the group of blurred textures.
* @return A handle to a newly allocated Dali resource
*/
static SuperBlurView New( unsigned int blurLevels );
@@ -129,11 +129,11 @@ public:
static SuperBlurView DownCast( BaseHandle handle );
/**
- * @brief Sets a custom image to be blurred.
+ * @brief Sets a custom texture to be blurred.
*
- * @param[in] inputImage The image that the user wishes to blur
+ * @param[in] texture The texture that the user wishes to blur
*/
- void SetImage(Image inputImage);
+ void SetTexture( Texture texture );
/**
* @brief Get the index of the property that can be used to fade the blur in / out.
@@ -145,9 +145,9 @@ public:
Dali::Property::Index GetBlurStrengthPropertyIndex() const;
/**
- * @brief Set the blur strength to display the image.
+ * @brief Set the blur strength to display the texture.
*
- * @param[in] blurStrength The blur strength used to display the image.
+ * @param[in] blurStrength The blur strength used to display the texture.
*/
void SetBlurStrength( float blurStrength );
@@ -166,13 +166,13 @@ public:
SuperBlurViewSignal& BlurFinishedSignal();
/**
- * @brief Get the blurred image.
+ * @brief Get the blurred texture.
*
* Should wait for the BlurFinishedSignal before calling this method.
- * @param[in] level Indicate which blurred image to get, must be a value between 1 and blurLevels
- * @return The level-th blurred image
+ * @param[in] level Indicate which blurred texture to get, must be a value between 1 and blurLevels
+ * @return The level-th blurred texture
*/
- Image GetBlurredImage( unsigned int level );
+ Texture GetBlurredTexture( unsigned int level );
public: // Not intended for application developers
diff --git a/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp b/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp
index c05e954..8d99d68 100644
--- a/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp
+++ b/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp
@@ -365,10 +365,16 @@ void BloomView::AllocateResources()
// create off screen buffer of new size to render our child actors to
mRenderTargetForRenderingChildren = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat );
- mBloomExtractTarget = FrameBufferImage::New( mDownsampledWidth, mDownsampledHeight, mPixelFormat );
- FrameBufferImage mBlurExtractTarget = FrameBufferImage::New( mDownsampledWidth, mDownsampledHeight, mPixelFormat );
- mOutputRenderTarget = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat );
+ mBloomExtractTarget = FrameBuffer::New( mDownsampledWidth, mDownsampledHeight, FrameBuffer::Attachment::NONE );
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, mPixelFormat, unsigned(mDownsampledWidth), unsigned(mDownsampledHeight) );
+ mBloomExtractTarget.AttachColorTexture( texture );
+
+ FrameBuffer blurExtractTarget = FrameBuffer::New( mDownsampledWidth, mDownsampledHeight, FrameBuffer::Attachment::NONE );
+ texture = Texture::New( TextureType::TEXTURE_2D, mPixelFormat, unsigned(mDownsampledWidth), unsigned(mDownsampledHeight) );
+ blurExtractTarget.AttachColorTexture( texture );
+
+ mOutputRenderTarget = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat );
//////////////////////////////////////////////////////
// Point actors and render tasks at new render targets
@@ -383,7 +389,7 @@ void BloomView::AllocateResources()
mBloomExtractImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
// set GaussianBlurView to blur our extracted bloom
- mGaussianBlurView.SetUserImageAndOutputRenderTarget(mBloomExtractTarget, mBlurExtractTarget);
+ mGaussianBlurView.SetUserImageAndOutputRenderTarget( mBloomExtractTarget.GetColorTexture(), blurExtractTarget );
// use the completed blur in the first buffer and composite with the original child actors render
mCompositeImageView.SetImage( mRenderTargetForRenderingChildren );
@@ -392,7 +398,7 @@ void BloomView::AllocateResources()
visualMap[ Toolkit::Visual::Property::SHADER ] = customShader;
mCompositeImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap );
TextureSet textureSet = mCompositeImageView.GetRendererAt(0).GetTextures();
- TextureSetImage( textureSet, 1u, mBlurExtractTarget );
+ textureSet.SetTexture( 1u, blurExtractTarget.GetColorTexture() );
// set up target actor for rendering result, i.e. the blurred image
mTargetImageView.SetImage(mOutputRenderTarget);
@@ -419,7 +425,7 @@ void BloomView::CreateRenderTasks()
mBloomExtractTask.SetInputEnabled( false );
mBloomExtractTask.SetClearEnabled( true );
mBloomExtractTask.SetCameraActor(mRenderDownsampledCamera);
- mBloomExtractTask.SetTargetFrameBuffer( mBloomExtractTarget );
+ mBloomExtractTask.SetFrameBuffer( mBloomExtractTarget );
// GaussianBlurView tasks must be created here, so they are executed in the correct order with respect to BloomView tasks
GetImpl(mGaussianBlurView).CreateRenderTasks();
diff --git a/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.h b/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.h
index 9f6e64b..71ed4c7 100644
--- a/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.h
+++ b/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.h
@@ -23,6 +23,7 @@
#include
#include
#include
+#include
// INTERNAL INCLUDES
#include
@@ -137,7 +138,7 @@ private:
/////////////////////////////////////////////////////////////
// for extracting bright parts of image to an offscreen target
- FrameBufferImage mBloomExtractTarget; // for rendering bright parts of image into separate texture, also used as target for gaussian blur
+ FrameBuffer mBloomExtractTarget; // for rendering bright parts of image into separate texture, also used as target for gaussian blur
RenderTask mBloomExtractTask;
Toolkit::ImageView mBloomExtractImageView;
diff --git a/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp b/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp
index e3e5436..987acbe 100644
--- a/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp
+++ b/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.cpp
@@ -26,6 +26,10 @@
#include
#include
#include
+#include
+#include
+#include
+#include
#include
#include
@@ -54,13 +58,13 @@
// 2 modes:
// 1st mode, this control has a tree of actors (use Add() to add children) that are rendered and blurred.
// mRenderChildrenTask renders children to FB mRenderTargetForRenderingChildren
-// mHorizBlurTask renders mImageViewHorizBlur Actor showing FB mRenderTargetForRenderingChildren into FB mRenderTarget2
-// mVertBlurTask renders mImageViewVertBlur Actor showing FB mRenderTarget2 into FB mRenderTarget1
-// mCompositeTask renders mImageViewComposite Actor showing FB mRenderTarget1 into FB mRenderTargetForRenderingChildren
+// mHorizBlurTask renders mHorizBlurActor Actor showing FB mRenderTargetForRenderingChildren into FB mRenderTarget2
+// mVertBlurTask renders mVertBlurActor Actor showing FB mRenderTarget2 into FB mRenderTarget1
+// mCompositeTask renders mCompositingActor Actor showing FB mRenderTarget1 into FB mRenderTargetForRenderingChildren
//
// 2nd mode, an image is blurred and rendered to a supplied target framebuffer
-// mHorizBlurTask renders mImageViewHorizBlur Actor showing mUserInputImage into FB mRenderTarget2
-// mVertBlurTask renders mImageViewVertBlur Actor showing mRenderTarget2 into FB mUserOutputRenderTarget
+// mHorizBlurTask renders mHorizBlurActor Actor showing mUserInputImage into FB mRenderTarget2
+// mVertBlurTask renders mVertBlurActor Actor showing mRenderTarget2 into FB mUserOutputRenderTarget
//
// Only this 2nd mode handles ActivateOnce
@@ -96,22 +100,120 @@ const float GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE = 0.5f;
const float ARBITRARY_FIELD_OF_VIEW = Math::PI / 4.0f;
-const char* const GAUSSIAN_BLUR_FRAGMENT_SOURCE =
- "varying mediump vec2 vTexCoord;\n"
- "uniform sampler2D sTexture;\n"
- "uniform lowp vec4 uColor;\n"
- "uniform mediump vec2 uSampleOffsets[NUM_SAMPLES];\n"
- "uniform mediump float uSampleWeights[NUM_SAMPLES];\n"
-
- "void main()\n"
- "{\n"
- " mediump vec4 col = texture2D(sTexture, vTexCoord + uSampleOffsets[0]) * uSampleWeights[0];\n"
- " for (int i=1; i( mImageViewComposite, Actor::Property::COLOR_ALPHA, EqualToConstraint());
+ Constraint blurStrengthConstraint = Constraint::New( mCompositingActor, Actor::Property::COLOR_ALPHA, EqualToConstraint());
blurStrengthConstraint.AddSource( Source( self, mBlurStrengthPropertyIndex) );
blurStrengthConstraint.Apply();
// Create an image view for holding final result, i.e. the blurred image. This will get rendered to screen later, via default / user render task
- mTargetActor = Toolkit::ImageView::New();
+ mTargetActor = Actor::New();
mTargetActor.SetParentOrigin(ParentOrigin::CENTER);
+ renderer = CreateRenderer( BASIC_VERTEX_SOURCE, BASIC_FRAGMENT_SOURCE );
+ mTargetActor.AddRenderer( renderer );
//////////////////////////////////////////////////////
// Create cameras for the renders corresponding to the view size
@@ -302,28 +410,25 @@ void GaussianBlurView::OnInitialize()
mRenderFullSizeCamera.SetInvertYAxis( true );
mRenderFullSizeCamera.SetParentOrigin(ParentOrigin::CENTER);
-
//////////////////////////////////////////////////////
// Connect to actor tree
- mInternalRoot.Add( mImageViewComposite );
+ mInternalRoot.Add( mCompositingActor );
mInternalRoot.Add( mTargetActor );
mInternalRoot.Add( mRenderFullSizeCamera );
}
-
//////////////////////////////////////////////////////
// Create camera for the renders corresponding to the (potentially downsampled) render targets' size
mRenderDownsampledCamera = CameraActor::New();
mRenderDownsampledCamera.SetInvertYAxis( true );
mRenderDownsampledCamera.SetParentOrigin(ParentOrigin::CENTER);
-
//////////////////////////////////////////////////////
// Connect to actor tree
Self().Add( mChildrenRoot );
Self().Add( mInternalRoot );
- mInternalRoot.Add( mImageViewHorizBlur );
- mInternalRoot.Add( mImageViewVertBlur );
+ mInternalRoot.Add( mHorizBlurActor );
+ mInternalRoot.Add( mVertBlurActor );
mInternalRoot.Add( mRenderDownsampledCamera );
}
@@ -336,7 +441,7 @@ void GaussianBlurView::OnSizeSet(const Vector3& targetSize)
if( !mBlurUserImage )
{
- mImageViewComposite.SetSize(targetSize);
+ mCompositingActor.SetSize(targetSize);
mTargetActor.SetSize(targetSize);
// Children render camera must move when GaussianBlurView object is resized. This is since we cannot change render target size - so we need to remap the child actors' rendering
@@ -409,32 +514,36 @@ void GaussianBlurView::AllocateResources()
mRenderFullSizeCamera.SetPosition(0.0f, 0.0f, mTargetSize.height * cameraPosConstraintScale);
// create offscreen buffer of new size to render our child actors to
- mRenderTargetForRenderingChildren = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat );
+ mRenderTargetForRenderingChildren = FrameBuffer::New( mTargetSize.width, mTargetSize.height, FrameBuffer::Attachment::NONE );
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, mPixelFormat, unsigned(mTargetSize.width), unsigned(mTargetSize.height) );
+ mRenderTargetForRenderingChildren.AttachColorTexture( texture );
- // Set image view for performing a horizontal blur on the texture
- mImageViewHorizBlur.SetImage( mRenderTargetForRenderingChildren );
- mImageViewHorizBlur.SetProperty( Toolkit::ImageView::Property::IMAGE, mCustomShader );
+ // Set actor for performing a horizontal blur
+ SetTexture( mHorizBlurActor, mRenderTargetForRenderingChildren );
// Create offscreen buffer for vert blur pass
- mRenderTarget1 = FrameBufferImage::New( mDownsampledWidth, mDownsampledHeight, mPixelFormat );
+ mRenderTarget1 = FrameBuffer::New( mDownsampledWidth, mDownsampledHeight, FrameBuffer::Attachment::NONE );
+ texture = Texture::New(TextureType::TEXTURE_2D, mPixelFormat, unsigned(mDownsampledWidth), unsigned(mDownsampledHeight));
+ mRenderTarget1.AttachColorTexture( texture );
// use the completed blur in the first buffer and composite with the original child actors render
- mImageViewComposite.SetImage( mRenderTarget1 );
+ SetTexture( mCompositingActor, mRenderTarget1 );
// set up target actor for rendering result, i.e. the blurred image
- mTargetActor.SetImage(mRenderTargetForRenderingChildren);
+ SetTexture( mTargetActor, mRenderTargetForRenderingChildren );
}
// Create offscreen buffer for horiz blur pass
- mRenderTarget2 = FrameBufferImage::New( mDownsampledWidth, mDownsampledHeight, mPixelFormat );
+ mRenderTarget2 = FrameBuffer::New( mDownsampledWidth, mDownsampledHeight, FrameBuffer::Attachment::NONE );
+ Texture texture = Texture::New(TextureType::TEXTURE_2D, mPixelFormat, unsigned(mDownsampledWidth), unsigned(mDownsampledHeight));
+ mRenderTarget2.AttachColorTexture( texture );
// size needs to match render target
- mImageViewHorizBlur.SetSize(mDownsampledWidth, mDownsampledHeight);
+ mHorizBlurActor.SetSize(mDownsampledWidth, mDownsampledHeight);
// size needs to match render target
- mImageViewVertBlur.SetImage( mRenderTarget2 );
- mImageViewVertBlur.SetProperty( Toolkit::ImageView::Property::IMAGE, mCustomShader );
- mImageViewVertBlur.SetSize(mDownsampledWidth, mDownsampledHeight);
+ mVertBlurActor.SetSize(mDownsampledWidth, mDownsampledHeight);
+ SetTexture( mVertBlurActor, mRenderTarget2 );
// set gaussian blur up for new sized render targets
SetShaderConstants();
@@ -456,18 +565,18 @@ void GaussianBlurView::CreateRenderTasks()
mRenderChildrenTask.SetClearColor( mBackgroundColor );
mRenderChildrenTask.SetCameraActor(mRenderFullSizeCamera);
- mRenderChildrenTask.SetTargetFrameBuffer( mRenderTargetForRenderingChildren );
+ mRenderChildrenTask.SetFrameBuffer( mRenderTargetForRenderingChildren );
}
// perform a horizontal blur targeting the second buffer
mHorizBlurTask = taskList.CreateTask();
- mHorizBlurTask.SetSourceActor( mImageViewHorizBlur );
+ mHorizBlurTask.SetSourceActor( mHorizBlurActor );
mHorizBlurTask.SetExclusive(true);
mHorizBlurTask.SetInputEnabled( false );
mHorizBlurTask.SetClearEnabled( true );
mHorizBlurTask.SetClearColor( mBackgroundColor );
mHorizBlurTask.SetCameraActor(mRenderDownsampledCamera);
- mHorizBlurTask.SetTargetFrameBuffer( mRenderTarget2 );
+ mHorizBlurTask.SetFrameBuffer( mRenderTarget2 );
if( mRenderOnce && mBlurUserImage )
{
mHorizBlurTask.SetRefreshRate(RenderTask::REFRESH_ONCE);
@@ -475,7 +584,7 @@ void GaussianBlurView::CreateRenderTasks()
// use the second buffer and perform a horizontal blur targeting the first buffer
mVertBlurTask = taskList.CreateTask();
- mVertBlurTask.SetSourceActor( mImageViewVertBlur );
+ mVertBlurTask.SetSourceActor( mVertBlurActor );
mVertBlurTask.SetExclusive(true);
mVertBlurTask.SetInputEnabled( false );
mVertBlurTask.SetClearEnabled( true );
@@ -483,11 +592,11 @@ void GaussianBlurView::CreateRenderTasks()
mVertBlurTask.SetCameraActor(mRenderDownsampledCamera);
if(mUserOutputRenderTarget)
{
- mVertBlurTask.SetTargetFrameBuffer( mUserOutputRenderTarget );
+ mVertBlurTask.SetFrameBuffer( mUserOutputRenderTarget );
}
else
{
- mVertBlurTask.SetTargetFrameBuffer( mRenderTarget1 );
+ mVertBlurTask.SetFrameBuffer( mRenderTarget1 );
}
if( mRenderOnce && mBlurUserImage )
{
@@ -499,12 +608,12 @@ void GaussianBlurView::CreateRenderTasks()
if(!mBlurUserImage)
{
mCompositeTask = taskList.CreateTask();
- mCompositeTask.SetSourceActor( mImageViewComposite );
+ mCompositeTask.SetSourceActor( mCompositingActor );
mCompositeTask.SetExclusive(true);
mCompositeTask.SetInputEnabled( false );
mCompositeTask.SetCameraActor(mRenderFullSizeCamera);
- mCompositeTask.SetTargetFrameBuffer( mRenderTargetForRenderingChildren );
+ mCompositeTask.SetFrameBuffer( mRenderTargetForRenderingChildren );
}
}
@@ -601,11 +710,11 @@ void GaussianBlurView::SetShaderConstants()
Vector2 yAxis(0.0f, 1.0f);
for (i = 0; i < mNumSamples; ++i )
{
- mImageViewHorizBlur.RegisterProperty( GetSampleOffsetsPropertyName( i ), uvOffsets[ i ] * xAxis );
- mImageViewHorizBlur.RegisterProperty( GetSampleWeightsPropertyName( i ), weights[ i ] );
+ mHorizBlurActor.RegisterProperty( GetSampleOffsetsPropertyName( i ), uvOffsets[ i ] * xAxis );
+ mHorizBlurActor.RegisterProperty( GetSampleWeightsPropertyName( i ), weights[ i ] );
- mImageViewVertBlur.RegisterProperty( GetSampleOffsetsPropertyName( i ), uvOffsets[ i ] * yAxis );
- mImageViewVertBlur.RegisterProperty( GetSampleWeightsPropertyName( i ), weights[ i ] );
+ mVertBlurActor.RegisterProperty( GetSampleOffsetsPropertyName( i ), uvOffsets[ i ] * yAxis );
+ mVertBlurActor.RegisterProperty( GetSampleWeightsPropertyName( i ), weights[ i ] );
}
delete[] uvOffsets;
diff --git a/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.h b/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.h
index 792c1b1..7ecf96b 100644
--- a/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.h
+++ b/dali-toolkit/internal/controls/gaussian-blur-view/gaussian-blur-view-impl.h
@@ -78,10 +78,10 @@ public:
void ActivateOnce();
void Deactivate();
- void SetUserImageAndOutputRenderTarget(Image inputImage, FrameBufferImage outputRenderTarget);
+ void SetUserImageAndOutputRenderTarget(Texture inputImage, FrameBuffer outputRenderTarget);
Property::Index GetBlurStrengthPropertyIndex() const {return mBlurStrengthPropertyIndex;}
- FrameBufferImage GetBlurredRenderTarget() const;
+ FrameBuffer GetBlurredRenderTarget() const;
/// @copydoc Dali::Toolkit::GaussianBlurView::SetBackgroundColor(const Vector4&)
void SetBackgroundColor( const Vector4& color );
@@ -159,30 +159,28 @@ private:
/////////////////////////////////////////////////////////////
// for rendering all user added children to offscreen target
- FrameBufferImage mRenderTargetForRenderingChildren;
+ FrameBuffer mRenderTargetForRenderingChildren;
RenderTask mRenderChildrenTask;
/////////////////////////////////////////////////////////////
// for rendering separated blur passes to offscreen targets
- FrameBufferImage mRenderTarget1;
- FrameBufferImage mRenderTarget2;
+ FrameBuffer mRenderTarget1;
+ FrameBuffer mRenderTarget2;
- Toolkit::ImageView mImageViewHorizBlur;
- Toolkit::ImageView mImageViewVertBlur;
-
- Property::Map mCustomShader;
+ Actor mHorizBlurActor;
+ Actor mVertBlurActor;
RenderTask mHorizBlurTask;
RenderTask mVertBlurTask;
/////////////////////////////////////////////////////////////
// for compositing blur and children renders to offscreen target
- Toolkit::ImageView mImageViewComposite;
+ Actor mCompositingActor;
RenderTask mCompositeTask;
/////////////////////////////////////////////////////////////
// for holding blurred result
- Toolkit::ImageView mTargetActor;
+ Actor mTargetActor;
/////////////////////////////////////////////////////////////
// for animating fade in / out of blur, hiding internal implementation but allowing user to set via GaussianBlurView interface
@@ -190,8 +188,8 @@ private:
/////////////////////////////////////////////////////////////
// User can specify image to blur and output target, so we can use GaussianBlurView for arbitrary blur processes
- Image mUserInputImage;
- FrameBufferImage mUserOutputRenderTarget;
+ Texture mUserInputImage;
+ FrameBuffer mUserOutputRenderTarget;
Dali::Toolkit::GaussianBlurView::GaussianBlurViewSignal mFinishedSignal; ///< Signal emitted when blur has completed.
diff --git a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp
index 9721dcf..78f354b 100644
--- a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp
+++ b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp
@@ -30,6 +30,7 @@
#include
// INTERNAL_INCLUDES
+#include
#include
#include
#include
@@ -94,6 +95,104 @@ struct ActorOpacityConstraint
Vector2 mRange;
};
+#define DALI_COMPOSE_SHADER(STR) #STR
+
+const char * const BASIC_VERTEX_SOURCE = DALI_COMPOSE_SHADER(
+ precision mediump float;\n
+ attribute mediump vec2 aPosition;\n
+ attribute mediump vec2 aTexture;\n
+ varying mediump vec2 vTexCoord;\n
+ uniform mediump mat4 uMvpMatrix;\n
+ uniform mediump vec3 uSize;\n
+ \n
+ void main()\n
+ {\n
+ mediump vec4 vertexPosition = vec4(aPosition * uSize.xy, 0.0, 1.0);\n
+ vTexCoord = aTexture;\n
+ gl_Position = uMvpMatrix * vertexPosition;\n
+ }\n
+);
+
+const char * const BASIC_FRAGMENT_SOURCE = DALI_COMPOSE_SHADER(
+ precision mediump float;\n
+ varying mediump vec2 vTexCoord;\n
+ uniform sampler2D sTexture;\n
+ uniform vec4 uColor;\n
+ \n
+ void main()\n
+ {\n
+ gl_FragColor = texture2D(sTexture, vTexCoord);\n
+ gl_FragColor *= uColor;
+ }\n
+);
+
+Renderer CreateRenderer( const char* vertexSrc, const char* fragmentSrc )
+{
+ Shader shader = Shader::New( vertexSrc, fragmentSrc );
+
+ Geometry texturedQuadGeometry = Geometry::New();
+
+ struct VertexPosition { Vector2 position; };
+ struct VertexTexture { Vector2 texture; };
+
+ VertexPosition positionArray[] =
+ {
+ { Vector2( -0.5f, -0.5f ) },
+ { Vector2( 0.5f, -0.5f ) },
+ { Vector2( -0.5f, 0.5f ) },
+ { Vector2( 0.5f, 0.5f ) }
+ };
+ uint32_t numberOfVertices = sizeof(positionArray)/sizeof(VertexPosition);
+
+ VertexTexture uvArray[] =
+ {
+ { Vector2( 0.0f, 0.0f ) },
+ { Vector2( 1.0f, 0.0f ) },
+ { Vector2( 0.0f, 1.0f ) },
+ { Vector2( 1.0f, 1.0f ) }
+ };
+
+ Property::Map positionVertexFormat;
+ positionVertexFormat["aPosition"] = Property::VECTOR2;
+ PropertyBuffer positionVertices = PropertyBuffer::New( positionVertexFormat );
+ positionVertices.SetData( positionArray, numberOfVertices );
+ texturedQuadGeometry.AddVertexBuffer( positionVertices );
+
+ Property::Map textureVertexFormat;
+ textureVertexFormat["aTexture"] = Property::VECTOR2;
+ PropertyBuffer textureVertices = PropertyBuffer::New( textureVertexFormat );
+ textureVertices.SetData( uvArray, numberOfVertices );
+ texturedQuadGeometry.AddVertexBuffer( textureVertices );
+
+ const uint16_t indices[] = { 0, 3, 1, 0, 2, 3 };
+ texturedQuadGeometry.SetIndexBuffer ( &indices[0], sizeof( indices )/ sizeof( indices[0] ) );
+
+ Renderer renderer = Renderer::New( texturedQuadGeometry, shader );
+
+ TextureSet textureSet = TextureSet::New();
+ renderer.SetTextures( textureSet );
+
+ return renderer;
+}
+
+void SetRendererTexture( Renderer& renderer, Texture& texture )
+{
+ if( renderer )
+ {
+ TextureSet textureSet = renderer.GetTextures();
+ textureSet.SetTexture( 0u, texture );
+ }
+}
+
+void SetRendererTexture( Renderer& renderer, FrameBuffer& frameBuffer )
+{
+ if( frameBuffer )
+ {
+ Texture texture = frameBuffer.GetColorTexture();
+ SetRendererTexture( renderer, texture );
+ }
+}
+
} // namespace
namespace Dali
@@ -118,7 +217,7 @@ BaseHandle Create()
// Setup properties, signals and actions using the type-registry.
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::SuperBlurView, Toolkit::Control, Create )
-DALI_PROPERTY_REGISTRATION( Toolkit, SuperBlurView, "image", MAP, IMAGE )
+DALI_PROPERTY_REGISTRATION( Toolkit, SuperBlurView, "imageUrl", STRING, IMAGE_URL )
DALI_TYPE_REGISTRATION_END()
@@ -133,8 +232,8 @@ SuperBlurView::SuperBlurView( unsigned int blurLevels )
{
DALI_ASSERT_ALWAYS( mBlurLevels > 0 && " Minimal blur level is one, otherwise no blur is needed" );
mGaussianBlurView.assign( blurLevels, Toolkit::GaussianBlurView() );
- mBlurredImage.assign( blurLevels, FrameBufferImage() );
- mVisuals.assign( blurLevels+1, Toolkit::Visual::Base() );
+ mBlurredImage.assign( blurLevels, FrameBuffer() );
+ mRenderers.assign( blurLevels+1, Dali::Renderer() );
}
SuperBlurView::~SuperBlurView()
@@ -158,12 +257,15 @@ Toolkit::SuperBlurView SuperBlurView::New( unsigned int blurLevels )
void SuperBlurView::OnInitialize()
{
- mBlurStrengthPropertyIndex = Self().RegisterProperty( "blurStrength", 0.f );
+ Actor self( Self() );
+
+ mBlurStrengthPropertyIndex = self.RegisterProperty( "blurStrength", 0.f );
}
-void SuperBlurView::SetImage(Image inputImage)
+void SuperBlurView::SetTexture( Texture texture )
{
- mInputImage = inputImage;
+ mInputTexture = texture;
+
if( mTargetSize == Vector2::ZERO )
{
return;
@@ -173,22 +275,19 @@ void SuperBlurView::SetImage(Image inputImage)
Actor self( Self() );
- mVisuals[0] = Toolkit::VisualFactory::Get().CreateVisual( mInputImage );
- DevelControl::RegisterVisual( *this, 0, mVisuals[0], 0 ); // Will clean up previously registered visuals for this index.
- // custom shader is not applied on the original image.
+ BlurTexture( 0, mInputTexture );
+ SetRendererTexture( mRenderers[0], texture );
- BlurImage( 0, inputImage);
- for(unsigned int i=1; i0 && level<=mBlurLevels );
- return mBlurredImage[level-1];
+
+ FrameBuffer frameBuffer = mBlurredImage[level-1];
+
+ return frameBuffer.GetColorTexture();
}
-void SuperBlurView::BlurImage( unsigned int idx, Image image )
+void SuperBlurView::BlurTexture( unsigned int idx, Texture texture )
{
DALI_ASSERT_ALWAYS( mGaussianBlurView.size()>idx );
mGaussianBlurView[idx] = Toolkit::GaussianBlurView::New( GAUSSIAN_BLUR_DEFAULT_NUM_SAMPLES+GAUSSIAN_BLUR_NUM_SAMPLES_INCREMENTATION*idx,
@@ -230,7 +332,9 @@ void SuperBlurView::BlurImage( unsigned int idx, Image image )
mGaussianBlurView[idx].SetParentOrigin(ParentOrigin::CENTER);
mGaussianBlurView[idx].SetSize(mTargetSize);
Stage::GetCurrent().Add( mGaussianBlurView[idx] );
- mGaussianBlurView[idx].SetUserImageAndOutputRenderTarget( image, mBlurredImage[idx] );
+
+ mGaussianBlurView[idx].SetUserImageAndOutputRenderTarget( texture, mBlurredImage[idx] );
+
mGaussianBlurView[idx].ActivateOnce();
if( idx == mBlurLevels-1 )
{
@@ -258,15 +362,6 @@ void SuperBlurView::ClearBlurResource()
mResourcesCleared = true;
}
}
-void SuperBlurView::SetShaderEffect( Toolkit::Visual::Base& visual )
-{
- Property::Map shaderMap;
- std::stringstream verterShaderString;
- shaderMap[ "fragmentShader" ] = FRAGMENT_SHADER;
-
- Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
- visualImpl.SetCustomShader( shaderMap );
-}
void SuperBlurView::OnSizeSet( const Vector3& targetSize )
{
@@ -278,17 +373,18 @@ void SuperBlurView::OnSizeSet( const Vector3& targetSize )
for( unsigned int i = 1; i <= mBlurLevels; i++ )
{
float exponent = static_cast(i);
- mBlurredImage[i-1] = FrameBufferImage::New( mTargetSize.width/std::pow(2.f,exponent) , mTargetSize.height/std::pow(2.f,exponent),
- GAUSSIAN_BLUR_RENDER_TARGET_PIXEL_FORMAT );
- mVisuals[i] = Toolkit::VisualFactory::Get().CreateVisual( mBlurredImage[i - 1] );
- DevelControl::RegisterVisual( *this, i, mVisuals[i], int( i ) ); // Will clean up existing visual with same index.
- SetShaderEffect( mVisuals[i] );
+ unsigned int width = mTargetSize.width/std::pow(2.f,exponent);
+ unsigned int height = mTargetSize.height/std::pow(2.f,exponent);
+
+ mBlurredImage[i-1] = FrameBuffer::New( width, height, FrameBuffer::Attachment::NONE );
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, GAUSSIAN_BLUR_RENDER_TARGET_PIXEL_FORMAT, unsigned(width), unsigned(height) );
+ mBlurredImage[i-1].AttachColorTexture( texture );
}
- if( mInputImage )
+ if( mInputTexture )
{
- SetImage( mInputImage );
+ SetTexture( mInputTexture );
}
}
@@ -306,29 +402,51 @@ void SuperBlurView::OnStageConnection( int depth )
Control::OnStageConnection( depth );
Actor self = Self();
- for(unsigned int i=0; i<=mBlurLevels;i++)
+
+ for(unsigned int i=0; i(Renderer::Property::DEPTH_INDEX);
- if( depthIndex > 0 )
+ mRenderers[i] = CreateRenderer( BASIC_VERTEX_SOURCE, FRAGMENT_SHADER );
+ mRenderers[i].SetProperty( Dali::Renderer::Property::DEPTH_INDEX, (int)i );
+ self.AddRenderer( mRenderers[i] );
+
+ if( i > 0 )
{
+ Renderer renderer = mRenderers[i];
Property::Index index = renderer.RegisterProperty( ALPHA_UNIFORM_NAME, 0.f );
- Constraint constraint = Constraint::New( renderer, index, ActorOpacityConstraint(mBlurLevels, depthIndex-1) );
+ Constraint constraint = Constraint::New( renderer, index, ActorOpacityConstraint(mBlurLevels, i-1) );
constraint.AddSource( Source( self, mBlurStrengthPropertyIndex ) );
constraint.Apply();
}
}
+
+ if( mInputTexture )
+ {
+ SetRendererTexture( mRenderers[0], mInputTexture );
+ unsigned int i = 1;
+ for(; i
+#include
+
// INTERNAL INCLUDES
#include
#include
@@ -51,13 +55,7 @@ public:
/**
* @copydoc Dali::Toolkit::SuperBlurView::SetImage
*/
- void SetImage(Image inputImage);
-
- /**
- * Get the image for blurring.
- * @return The image for blurring.
- */
- Image GetImage();
+ void SetTexture( Texture texture );
/**
* @copydoc Dali::Toolkit::SuperBlurView::GetBlurStrengthPropertyIndex
@@ -80,9 +78,9 @@ public:
Dali::Toolkit::SuperBlurView::SuperBlurViewSignal& BlurFinishedSignal();
/**
- * @copydoc Dali::Toolkit::SuperBlurView::GetBlurredImage
+ * @copydoc Dali::Toolkit::SuperBlurView::GetBlurredTexture
*/
- Image GetBlurredImage( unsigned int level );
+ Texture GetBlurredTexture( unsigned int level );
// Properties
@@ -132,6 +130,11 @@ private: // from Control
virtual void OnStageConnection( int depth );
/**
+ * @copydoc CustomActorImpl::OnStageDisconnection()
+ */
+ virtual void OnStageDisconnection();
+
+ /**
* @copydoc CustomActorImpl::GetNaturalSize()
*/
virtual Vector3 GetNaturalSize();
@@ -141,9 +144,9 @@ private:
/**
* Carry out the idx-th pass of blurring
* @param[in] idx The blur pass index
- * @param[in] image The input image for the current blurring, it is either the original image or the blurred image from the previous pass
+ * @param[in] texture The input texture for the current blurring, it is either the original image or the blurred texture from the previous pass
*/
- void BlurImage( unsigned int idx, Image image );
+ void BlurTexture( unsigned int idx, Texture texture );
/**
* Signal handler to tell when the last blur view completes
@@ -156,27 +159,22 @@ private:
*/
void ClearBlurResource();
- /**
- * Sets shader effect on the control renderer
- * @param[in,out] Sets custom shader effect on the given visual
- */
- void SetShaderEffect( Toolkit::Visual::Base& visual );
-
private:
std::vector mGaussianBlurView;
- std::vector mBlurredImage;
- std::vector mVisuals;
- Image mInputImage;
+ std::vector mBlurredImage;
+ std::vector mRenderers;
+ Texture mInputTexture;
Vector2 mTargetSize;
Toolkit::SuperBlurView::SuperBlurViewSignal mBlurFinishedSignal; ///< Signal emitted when blur has completed.
+ std::string mUrl;
Property::Index mBlurStrengthPropertyIndex;
unsigned int mBlurLevels;
bool mResourcesCleared;
};
-} // namespace Internal
+}
// Helpers for public-api forwarding methods
inline Toolkit::Internal::SuperBlurView& GetImpl( Toolkit::SuperBlurView& obj )
@@ -193,8 +191,8 @@ inline const Toolkit::Internal::SuperBlurView& GetImpl( const Toolkit::SuperBlur
return static_cast(handle);
}
-} // namespace Toolkit
+}
-} // namespace Dali
+}
#endif // DALI_TOOLKIT_INTERNAL_SUPER_BLUR_VIEW_H
--
2.7.4