X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbloom-view%2Fbloom-view-impl.cpp;h=cc84448b4339ae1af7222afcefe6bbfa959855df;hb=fc2392c09ab526295f52c430ead7879e1e91a096;hp=82516233940af95b3ff473c39898ff0cdd16034c;hpb=e2eda444afbe82e9591fe198eef339227f90a616;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 8251623..cc84448 100644 --- a/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp +++ b/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp @@ -1,30 +1,38 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * Copyright (c) 2014 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ // CLASS HEADER #include "bloom-view-impl.h" -#include "../gaussian-blur-view/gaussian-blur-view-impl.h" // EXTERNAL INCLUDES #include #include +#include +#include +#include +#include +#include +#include +#include // INTERNAL INCLUDES #include #include +#include "../gaussian-blur-view/gaussian-blur-view-impl.h" namespace Dali { @@ -45,7 +53,8 @@ BaseHandle Create() return Toolkit::BloomView::New(); } -TypeRegistration mType( typeid(Toolkit::BloomView), typeid(Toolkit::Control), Create ); +DALI_TYPE_REGISTRATION_BEGIN( Toolkit::BloomView, Toolkit::Control, Create ) +DALI_TYPE_REGISTRATION_END() // default parameters const float BLOOM_THRESHOLD_DEFAULT = 0.25f; @@ -65,14 +74,13 @@ const float BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE = 0.5f; const float ARBITRARY_FIELD_OF_VIEW = Math::PI / 4.0f; -const std::string BLOOM_BLUR_STRENGTH_PROPERTY_NAME( "BlurStrengthProperty" ); - -const std::string BLOOM_THRESHOLD_PROPERTY_NAME( "uBloomThreshold" ); -const std::string RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME( "uRecipOneMinusBloomThreshold" ); -const std::string BLOOM_INTENSITY_PROPERTY_NAME( "uBloomIntensity" ); -const std::string BLOOM_SATURATION_PROPERTY_NAME( "uBloomSaturation" ); -const std::string IMAGE_INTENSITY_PROPERTY_NAME( "uImageIntensity" ); -const std::string IMAGE_SATURATION_PROPERTY_NAME( "uImageSaturation" ); +const char* const BLOOM_BLUR_STRENGTH_PROPERTY_NAME = "BlurStrengthProperty"; +const char* const BLOOM_THRESHOLD_PROPERTY_NAME = "uBloomThreshold"; +const char* const RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME = "uRecipOneMinusBloomThreshold"; +const char* const BLOOM_INTENSITY_PROPERTY_NAME = "uBloomIntensity"; +const char* const BLOOM_SATURATION_PROPERTY_NAME = "uBloomSaturation"; +const char* const IMAGE_INTENSITY_PROPERTY_NAME = "uImageIntensity"; +const char* const IMAGE_SATURATION_PROPERTY_NAME = "uImageSaturation"; /////////////////////////////////////////////////////// // @@ -119,7 +127,7 @@ const char* const COMPOSITE_FRAGMENT_SOURCE = BloomView::BloomView() - : ControlImpl( false ) // doesn't require touch events + : Control( CONTROL_BEHAVIOUR_NONE ) , mBlurNumSamples(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES) , mBlurBellCurveWidth(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_BELL_CURVE_WIDTH) , mPixelFormat(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT) @@ -141,7 +149,7 @@ BloomView::BloomView() BloomView::BloomView( const unsigned int blurNumSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat, const float downsampleWidthScale, const float downsampleHeightScale) - : ControlImpl( false ) // doesn't require touch events + : Control( CONTROL_BEHAVIOUR_NONE ) , mBlurNumSamples(blurNumSamples) , mBlurBellCurveWidth(blurBellCurveWidth) , mPixelFormat(renderTargetPixelFormat) @@ -219,8 +227,6 @@ void BloomView::OnInitialize() { // root actor to parent all user added actors, needed to allow us to set that subtree as exclusive for our child render task mChildrenRoot.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - mChildrenRoot.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); // same size as BloomView object - ////////////////////////////////////////////////////// // Create shaders @@ -244,14 +250,12 @@ void BloomView::OnInitialize() // Create an ImageActor for compositing the result (scene and bloom textures) to output mCompositeImageActor = ImageActor::New(); mCompositeImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - mCompositeImageActor.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); // same size as BloomView object mCompositeImageActor.SetShaderEffect( mCompositeShader ); mCompositeImageActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME // Create an ImageActor for holding final result, i.e. the blurred image. This will get rendered to screen later, via default / user render task mTargetImageActor = ImageActor::New(); mTargetImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - mTargetImageActor.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); // same size as BloomView object mTargetImageActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME @@ -286,35 +290,22 @@ void BloomView::OnInitialize() SetupProperties(); } -/** - * ZrelativeToYconstraint - * - * f(current, property, scale) = Vector3(current.x, current.y, property.y * scale) - */ -struct ZrelativeToYconstraint -{ - ZrelativeToYconstraint( float scale ) - : mScale( scale ) - {} - - Vector3 operator()(const Vector3& current, - const PropertyInput& property) - { - Vector3 v; - - v.x = current.x; - v.y = current.y; - v.z = property.GetVector3().y * mScale; - - return v; - } - - float mScale; -}; - void BloomView::OnControlSizeSet(const Vector3& targetSize) { mTargetSize = Vector2(targetSize); + mChildrenRoot.SetSize(targetSize); + mCompositeImageActor.SetSize(targetSize); + mTargetImageActor.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 accordingly so they still exactly + // fill the render target. Note that this means the effective resolution of + // the child render changes as the GaussianBlurView object changes size, + // this is the trade off for not being able to modify render target size + // Change camera z position based on GaussianBlurView actor height + float cameraPosConstraintScale = 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f); + mRenderFullSizeCamera.SetZ( mTargetSize.height * cameraPosConstraintScale); // if we are already on stage, need to update render target sizes now to reflect the new size of this actor if(Self().OnStage()) @@ -359,19 +350,6 @@ void BloomView::AllocateResources() float cameraPosConstraintScale = 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f); mRenderFullSizeCamera.SetPosition(0.0f, 0.0f, mTargetSize.height * cameraPosConstraintScale); - - // 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 accordingly so they still exactly - // fill the render target. Note that this means the effective resolution of - // the child render changes as the GaussianBlurView object changes size, - // this is the trade off for not being able to modify render target size - // Change camera z position based on GaussianBlurView actor height - - mRenderFullSizeCamera.RemoveConstraints(); - mRenderFullSizeCamera.ApplyConstraint( Constraint::New( Actor::POSITION, ParentSource( Actor::SIZE ), ZrelativeToYconstraint(cameraPosConstraintScale) ) ); - - ////////////////////////////////////////////////////// // Pass size change onto GaussianBlurView, so it matches mGaussianBlurView.SetSize(mTargetSize); @@ -382,9 +360,9 @@ void BloomView::AllocateResources() // Create render targets // create off screen buffer of new size to render our child actors to - mRenderTargetForRenderingChildren = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::Unused ); - mBloomExtractTarget = FrameBufferImage::New( mDownsampledWidth, mDownsampledHeight, mPixelFormat, Dali::Image::Unused ); - mOutputRenderTarget = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::Unused ); + mRenderTargetForRenderingChildren = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::UNUSED ); + mBloomExtractTarget = FrameBufferImage::New( mDownsampledWidth, mDownsampledHeight, mPixelFormat, Dali::Image::UNUSED ); + mOutputRenderTarget = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Dali::Image::UNUSED); //////////////////////////////////////////////////////