Visuals - Avoid having 2 devel headers for visual-properties.h
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / gaussian-blur-view / gaussian-blur-view-impl.cpp
index e7e14eb..a202236 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <dali/public-api/animation/constraint.h>
 #include <dali/public-api/animation/constraints.h>
 #include <dali/public-api/common/stage.h>
-#include <dali/public-api/object/property-map.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali/public-api/render-tasks/render-task-list.h>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/gaussian-blur-view/gaussian-blur-view.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 
 // TODO:
 // pixel format / size - set from JSON
@@ -118,47 +117,50 @@ const char* const GAUSSIAN_BLUR_FRAGMENT_SOURCE =
 
 
 GaussianBlurView::GaussianBlurView()
-  : Control( ControlBehaviour( DISABLE_SIZE_NEGOTIATION ) )
-  , mNumSamples(GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES)
-  , mBlurBellCurveWidth( 0.001f )
-  , mPixelFormat(GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT)
-  , mDownsampleWidthScale(GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_WIDTH_SCALE)
-  , mDownsampleHeightScale(GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE)
-  , mDownsampledWidth( 0.0f )
-  , mDownsampledHeight( 0.0f )
-  , mBlurUserImage( false )
-  , mRenderOnce( false )
-  , mBackgroundColor( Color::BLACK )
-  , mTargetSize(Vector2::ZERO)
-  , mLastSize(Vector2::ZERO)
-  , mChildrenRoot(Actor::New())
-  , mInternalRoot(Actor::New())
-  , mBlurStrengthPropertyIndex(Property::INVALID_INDEX)
-  mActivated( false )
+: Control( ControlBehaviour( DISABLE_SIZE_NEGOTIATION | DISABLE_STYLE_CHANGE_SIGNALS ) ),
+  mNumSamples(GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES),
+  mBlurBellCurveWidth( 0.001f ),
+  mPixelFormat(GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT),
+  mDownsampleWidthScale(GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_WIDTH_SCALE),
+  mDownsampleHeightScale(GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE),
+  mDownsampledWidth( 0.0f ),
+  mDownsampledHeight( 0.0f ),
+  mBlurUserImage( false ),
+  mRenderOnce( false ),
+  mBackgroundColor( Color::BLACK ),
+  mTargetSize(Vector2::ZERO),
+  mLastSize(Vector2::ZERO),
+  mChildrenRoot(Actor::New()),
+  mInternalRoot(Actor::New()),
+  mBlurStrengthPropertyIndex(Property::INVALID_INDEX),
+  mActivated( false )
 {
   SetBlurBellCurveWidth(GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_BELL_CURVE_WIDTH);
 }
 
-GaussianBlurView::GaussianBlurView( const unsigned int numSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat,
-                                    const float downsampleWidthScale, const float downsampleHeightScale,
+GaussianBlurView::GaussianBlurView( const unsigned int numSamples,
+                                    const float blurBellCurveWidth,
+                                    const Pixel::Format renderTargetPixelFormat,
+                                    const float downsampleWidthScale,
+                                    const float downsampleHeightScale,
                                     bool blurUserImage)
-  : Control( ControlBehaviour( DISABLE_SIZE_NEGOTIATION ) )
-  , mNumSamples(numSamples)
-  , mBlurBellCurveWidth( 0.001f )
-  , mPixelFormat(renderTargetPixelFormat)
-  , mDownsampleWidthScale(downsampleWidthScale)
-  , mDownsampleHeightScale(downsampleHeightScale)
-  , mDownsampledWidth( 0.0f )
-  , mDownsampledHeight( 0.0f )
-  , mBlurUserImage( blurUserImage )
-  , mRenderOnce( false )
-  , mBackgroundColor( Color::BLACK )
-  , mTargetSize(Vector2::ZERO)
-  , mLastSize(Vector2::ZERO)
-  , mChildrenRoot(Actor::New())
-  , mInternalRoot(Actor::New())
-  , mBlurStrengthPropertyIndex(Property::INVALID_INDEX)
-  mActivated( false )
+: Control( ControlBehaviour( DISABLE_SIZE_NEGOTIATION | DISABLE_STYLE_CHANGE_SIGNALS ) ),
+  mNumSamples(numSamples),
+  mBlurBellCurveWidth( 0.001f ),
+  mPixelFormat(renderTargetPixelFormat),
+  mDownsampleWidthScale(downsampleWidthScale),
+  mDownsampleHeightScale(downsampleHeightScale),
+  mDownsampledWidth( 0.0f ),
+  mDownsampledHeight( 0.0f ),
+  mBlurUserImage( blurUserImage ),
+  mRenderOnce( false ),
+  mBackgroundColor( Color::BLACK ),
+  mTargetSize(Vector2::ZERO),
+  mLastSize(Vector2::ZERO),
+  mChildrenRoot(Actor::New()),
+  mInternalRoot(Actor::New()),
+  mBlurStrengthPropertyIndex(Property::INVALID_INDEX),
+  mActivated( false )
 {
   SetBlurBellCurveWidth(blurBellCurveWidth);
 }
@@ -218,6 +220,7 @@ void GaussianBlurView::SetUserImageAndOutputRenderTarget(Image inputImage, Frame
 
   mUserInputImage = inputImage;
   mImageViewHorizBlur.SetImage( mUserInputImage );
+  mImageViewHorizBlur.SetProperty( Toolkit::ImageView::Property::IMAGE, mCustomShader );
 
   mUserOutputRenderTarget = outputRenderTarget;
 }
@@ -259,11 +262,9 @@ void GaussianBlurView::OnInitialize()
   std::ostringstream horizFragmentShaderStringStream;
   horizFragmentShaderStringStream << "#define NUM_SAMPLES " << mNumSamples << "\n";
   horizFragmentShaderStringStream << GAUSSIAN_BLUR_FRAGMENT_SOURCE;
-  Property::Map customShader;
-  customShader[ "fragmentShader" ] = horizFragmentShaderStringStream.str();
-  Property::Map rendererMap;
-  rendererMap.Insert( "rendererType", "image" );
-  rendererMap.Insert( "shader", customShader );
+  Property::Map source;
+  source[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = horizFragmentShaderStringStream.str();
+  mCustomShader[ Toolkit::DevelVisual::Property::SHADER ] = source;
 
   //////////////////////////////////////////////////////
   // Create actors
@@ -271,12 +272,10 @@ void GaussianBlurView::OnInitialize()
   // Create an image view for performing a horizontal blur on the texture
   mImageViewHorizBlur = Toolkit::ImageView::New();
   mImageViewHorizBlur.SetParentOrigin(ParentOrigin::CENTER);
-  mImageViewHorizBlur.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
 
   // Create an image view for performing a vertical blur on the texture
   mImageViewVertBlur = Toolkit::ImageView::New();
   mImageViewVertBlur.SetParentOrigin(ParentOrigin::CENTER);
-  mImageViewVertBlur.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap );
 
   // Register a property that the user can control to fade the blur in / out via the GaussianBlurView object
   Actor self = Self();
@@ -414,6 +413,7 @@ void GaussianBlurView::AllocateResources()
 
       // Set image view for performing a horizontal blur on the texture
       mImageViewHorizBlur.SetImage( mRenderTargetForRenderingChildren );
+      mImageViewHorizBlur.SetProperty( Toolkit::ImageView::Property::IMAGE, mCustomShader );
 
       // Create offscreen buffer for vert blur pass
       mRenderTarget1 = FrameBufferImage::New( mDownsampledWidth, mDownsampledHeight, mPixelFormat );
@@ -433,6 +433,7 @@ void GaussianBlurView::AllocateResources()
 
     // size needs to match render target
     mImageViewVertBlur.SetImage( mRenderTarget2 );
+    mImageViewVertBlur.SetProperty( Toolkit::ImageView::Property::IMAGE, mCustomShader );
     mImageViewVertBlur.SetSize(mDownsampledWidth, mDownsampledHeight);
 
     // set gaussian blur up for new sized render targets