X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fgaussian-blur-view%2Fgaussian-blur-view-impl.cpp;h=5da61104823948f86bbbc935ceda8d9aabb23cb6;hb=2af79c9045fb0df64012413c08e7a17efbf16d4b;hp=ef1c7ddcd70a32d7748f64a9d7f6da748e2a2e4d;hpb=843352ddfe65e9a2f6fa1fb73197b46960efb40c;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 ef1c7dd..5da6110 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 @@ -21,11 +21,11 @@ // EXTERNAL INCLUDES #include #include -#include #include #include #include #include +#include #include #include @@ -40,7 +40,6 @@ // Manager object - re-use render targets if there are multiple GaussianBlurViews created - ///////////////////////////////////////////////////////// // IMPLEMENTATION NOTES @@ -85,14 +84,14 @@ BaseHandle Create() return Toolkit::GaussianBlurView::New(); } -TypeRegistration mType( typeid(Toolkit::GaussianBlurView), typeid(Toolkit::Control), Create ); - +DALI_TYPE_REGISTRATION_BEGIN( Toolkit::GaussianBlurView, Toolkit::Control, Create ) +DALI_TYPE_REGISTRATION_END() const unsigned int GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES = 5; const float GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_BELL_CURVE_WIDTH = 1.5f; const Pixel::Format GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT = Pixel::RGBA8888; const float GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_STRENGTH = 1.0f; // default, fully blurred -const std::string GAUSSIAN_BLUR_VIEW_STRENGTH_PROPERTY_NAME("GaussianBlurStrengthPropertyName"); +const char* const GAUSSIAN_BLUR_VIEW_STRENGTH_PROPERTY_NAME = "GaussianBlurStrengthPropertyName"; const float GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_WIDTH_SCALE = 0.5f; const float GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE = 0.5f; @@ -117,7 +116,7 @@ const char* const GAUSSIAN_BLUR_FRAGMENT_SOURCE = GaussianBlurView::GaussianBlurView() - : Control( CONTROL_BEHAVIOUR_NONE ) + : Control( ControlBehaviour( DISABLE_SIZE_NEGOTIATION ) ) , mNumSamples(GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES) , mBlurBellCurveWidth( 0.001f ) , mPixelFormat(GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT) @@ -139,7 +138,7 @@ GaussianBlurView::GaussianBlurView() GaussianBlurView::GaussianBlurView( const unsigned int numSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat, const float downsampleWidthScale, const float downsampleHeightScale, bool blurUserImage) - : Control( CONTROL_BEHAVIOUR_NONE ) + : Control( ControlBehaviour( DISABLE_SIZE_NEGOTIATION ) ) , mNumSamples(numSamples) , mBlurBellCurveWidth( 0.001f ) , mPixelFormat(renderTargetPixelFormat) @@ -242,18 +241,6 @@ Vector4 GaussianBlurView::GetBackgroundColor() const // Private methods // -/** - * EqualToConstraintFloat - * - * f(current, property) = property - */ -struct EqualToConstraintFloat -{ - EqualToConstraintFloat(){} - - float operator()(const float current, const PropertyInput& property) {return property.GetFloat();} -}; - void GaussianBlurView::OnInitialize() { // root actor to parent all user added actors, needed to allow us to set that subtree as exclusive for our child render task @@ -300,8 +287,9 @@ void GaussianBlurView::OnInitialize() mImageActorComposite.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME mImageActorComposite.SetOpacity(GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_STRENGTH); // ensure alpha is enabled for this object and set default value - Constraint blurStrengthConstraint = Constraint::New( Actor::COLOR_ALPHA, ParentSource(mBlurStrengthPropertyIndex), EqualToConstraintFloat()); - mImageActorComposite.ApplyConstraint(blurStrengthConstraint); + Constraint blurStrengthConstraint = Constraint::New( mImageActorComposite, Actor::Property::COLOR_ALPHA, EqualToConstraint()); + blurStrengthConstraint.AddSource( ParentSource(mBlurStrengthPropertyIndex) ); + blurStrengthConstraint.Apply(); // Create an ImageActor for holding final result, i.e. the blurred image. This will get rendered to screen later, via default / user render task mTargetActor = ImageActor::New(); @@ -364,7 +352,7 @@ struct ZrelativeToYconstraint float mScale; }; -void GaussianBlurView::OnControlSizeSet(const Vector3& targetSize) +void GaussianBlurView::OnSizeSet(const Vector3& targetSize) { mTargetSize = Vector2(targetSize); @@ -408,8 +396,6 @@ void GaussianBlurView::AllocateResources() mRenderDownsampledCamera.SetNearClippingPlane(1.0f); mRenderDownsampledCamera.SetAspectRatio(mDownsampledWidth / mDownsampledHeight); mRenderDownsampledCamera.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor - // Point the camera back into the scene - mRenderDownsampledCamera.SetRotation(Quaternion(M_PI, Vector3::YAXIS)); mRenderDownsampledCamera.SetPosition(0.0f, 0.0f, ((mDownsampledHeight * 0.5f) / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f))); @@ -422,8 +408,6 @@ void GaussianBlurView::AllocateResources() mRenderFullSizeCamera.SetNearClippingPlane(1.0f); mRenderFullSizeCamera.SetAspectRatio(mTargetSize.width / mTargetSize.height); mRenderFullSizeCamera.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor - // Point the camera back into the scene - mRenderFullSizeCamera.SetRotation(Quaternion(M_PI, Vector3::YAXIS)); float cameraPosConstraintScale = 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f); mRenderFullSizeCamera.SetPosition(0.0f, 0.0f, mTargetSize.height * cameraPosConstraintScale); @@ -538,20 +522,6 @@ void GaussianBlurView::RemoveRenderTasks() taskList.RemoveTask(mCompositeTask); } -void GaussianBlurView::OnStageDisconnection() -{ - // TODO: can't call this here, since SetImage() calls fails similarly to above - // Need to fix the stage connection so this callback can be used arbitrarily. At that point we can simplify the API by removing the need for Activate() / Deactivate() - //Deactivate(); -} - -void GaussianBlurView::OnControlStageConnection() -{ - // TODO: can't call this here, since SetImage() calls fail to connect images to stage, since parent chain not fully on stage yet - // Need to fix the stage connection so this callback can be used arbitrarily. At that point we can simplify the API by removing the need for Activate() / Deactivate() - //Activate(); -} - void GaussianBlurView::Activate() { // make sure resources are allocated and start the render tasks processing