X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbloom-view%2Fbloom-view-impl.cpp;h=eab906ca6b676d18aae8604daaea2c1926e10825;hp=dfbebc4382588ea204aefee18bc4c8a4662b40f5;hb=385a58a746d2481d4725b3018e6ebf5949aab6ee;hpb=843352ddfe65e9a2f6fa1fb73197b46960efb40c 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 dfbebc4..eab906c 100644 --- a/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp +++ b/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp @@ -21,16 +21,16 @@ // EXTERNAL INCLUDES #include #include -#include #include #include #include #include +#include #include // INTERNAL INCLUDES #include -#include +#include #include "../gaussian-blur-view/gaussian-blur-view-impl.h" namespace Dali @@ -52,7 +52,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; @@ -72,14 +73,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"; /////////////////////////////////////////////////////// // @@ -126,7 +126,7 @@ const char* const COMPOSITE_FRAGMENT_SOURCE = BloomView::BloomView() - : Control( CONTROL_BEHAVIOUR_NONE ) + : Control( ControlBehaviour( ACTOR_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) @@ -148,7 +148,7 @@ BloomView::BloomView() BloomView::BloomView( const unsigned int blurNumSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat, const float downsampleWidthScale, const float downsampleHeightScale) - : Control( CONTROL_BEHAVIOUR_NONE ) + : Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ) , mBlurNumSamples(blurNumSamples) , mBlurBellCurveWidth(blurBellCurveWidth) , mPixelFormat(renderTargetPixelFormat) @@ -289,7 +289,7 @@ void BloomView::OnInitialize() SetupProperties(); } -void BloomView::OnControlSizeSet(const Vector3& targetSize) +void BloomView::OnSizeSet(const Vector3& targetSize) { mTargetSize = Vector2(targetSize); mChildrenRoot.SetSize(targetSize); @@ -334,7 +334,6 @@ void BloomView::AllocateResources() mRenderDownsampledCamera.SetNearClippingPlane(1.0f); mRenderDownsampledCamera.SetAspectRatio(mDownsampledWidth / mDownsampledHeight); mRenderDownsampledCamera.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor - mRenderDownsampledCamera.SetRotation(Quaternion(M_PI, Vector3::YAXIS)); // Rotate to look at origin mRenderDownsampledCamera.SetPosition(0.0f, 0.0f, ((mDownsampledHeight * 0.5f) / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f))); @@ -344,7 +343,6 @@ void BloomView::AllocateResources() mRenderFullSizeCamera.SetNearClippingPlane(1.0f); mRenderFullSizeCamera.SetAspectRatio(mTargetSize.width / mTargetSize.height); mRenderFullSizeCamera.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor - mRenderFullSizeCamera.SetRotation(Quaternion(M_PI, Vector3::YAXIS)); // Rotate to look at origin float cameraPosConstraintScale = 0.5f / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f); mRenderFullSizeCamera.SetPosition(0.0f, 0.0f, mTargetSize.height * cameraPosConstraintScale); @@ -431,20 +429,6 @@ void BloomView::RemoveRenderTasks() taskList.RemoveTask(mCompositeTask); } -void BloomView::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 BloomView::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 BloomView::Activate() { // make sure resources are allocated and start the render tasks processing @@ -460,18 +444,6 @@ void BloomView::Deactivate() } /** - * EqualToConstraintFloat - * - * f(current, property) = property - */ -struct EqualToConstraintFloat -{ - EqualToConstraintFloat(){} - - float operator()(const float current, const PropertyInput& property) {return property.GetFloat();} -}; - -/** * RecipOneMinusConstraint * * f(current, property) = property @@ -480,9 +452,9 @@ struct RecipOneMinusConstraint { RecipOneMinusConstraint(){} - float operator()(const float current, const PropertyInput& property) + void operator()( float& current, const PropertyInputContainer& inputs ) { - return 1.0f / (1.0f - property.GetFloat()); + current = 1.0f / ( 1.0f - inputs[0]->GetFloat() ); } }; @@ -503,13 +475,15 @@ void BloomView::SetupProperties() // Register a property that the user can control to change the bloom threshold mBloomThresholdPropertyIndex = self.RegisterProperty(BLOOM_THRESHOLD_PROPERTY_NAME, BLOOM_THRESHOLD_DEFAULT); Property::Index shaderBloomThresholdPropertyIndex = mBloomExtractShader.GetPropertyIndex(BLOOM_THRESHOLD_PROPERTY_NAME); - Constraint bloomThresholdConstraint = Constraint::New(shaderBloomThresholdPropertyIndex, Source(self, mBloomThresholdPropertyIndex), EqualToConstraintFloat()); - mBloomExtractShader.ApplyConstraint(bloomThresholdConstraint); + Constraint bloomThresholdConstraint = Constraint::New( mBloomExtractShader, shaderBloomThresholdPropertyIndex, EqualToConstraint()); + bloomThresholdConstraint.AddSource( Source(self, mBloomThresholdPropertyIndex) ); + bloomThresholdConstraint.Apply(); // precalc 1.0 / (1.0 - threshold) on CPU to save shader insns, using constraint to tie to the normal threshold property Property::Index shaderRecipOneMinusBloomThresholdPropertyIndex = mBloomExtractShader.GetPropertyIndex(RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME); - Constraint thresholdConstraint = Constraint::New( shaderRecipOneMinusBloomThresholdPropertyIndex, LocalSource(shaderBloomThresholdPropertyIndex), RecipOneMinusConstraint()); - mBloomExtractShader.ApplyConstraint(thresholdConstraint); + Constraint thresholdConstraint = Constraint::New( mBloomExtractShader, shaderRecipOneMinusBloomThresholdPropertyIndex, RecipOneMinusConstraint()); + thresholdConstraint.AddSource( LocalSource(shaderBloomThresholdPropertyIndex) ); + thresholdConstraint.Apply(); //////////////////////////////////////////// @@ -517,8 +491,9 @@ void BloomView::SetupProperties() // Register a property that the user can control to fade the blur in / out via internal GaussianBlurView object mBlurStrengthPropertyIndex = self.RegisterProperty(BLOOM_BLUR_STRENGTH_PROPERTY_NAME, BLOOM_BLUR_STRENGTH_DEFAULT); - Constraint blurStrengthConstraint = Constraint::New( mGaussianBlurView.GetBlurStrengthPropertyIndex(), Source(self, mBlurStrengthPropertyIndex), EqualToConstraintFloat()); - mGaussianBlurView.ApplyConstraint(blurStrengthConstraint); + Constraint blurStrengthConstraint = Constraint::New( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex(), EqualToConstraint()); + blurStrengthConstraint.AddSource( Source(self, mBlurStrengthPropertyIndex) ); + blurStrengthConstraint.Apply(); //////////////////////////////////////////// @@ -528,8 +503,9 @@ void BloomView::SetupProperties() mBloomIntensityPropertyIndex = self.RegisterProperty(BLOOM_INTENSITY_PROPERTY_NAME, BLOOM_INTENSITY_DEFAULT); mCompositeShader.SetUniform( BLOOM_INTENSITY_PROPERTY_NAME, BLOOM_INTENSITY_DEFAULT ); Property::Index shaderBloomIntensityPropertyIndex = mCompositeShader.GetPropertyIndex(BLOOM_INTENSITY_PROPERTY_NAME); - Constraint bloomIntensityConstraint = Constraint::New( shaderBloomIntensityPropertyIndex, Source(self, mBloomIntensityPropertyIndex), EqualToConstraintFloat()); - mCompositeShader.ApplyConstraint(bloomIntensityConstraint); + Constraint bloomIntensityConstraint = Constraint::New( mCompositeShader, shaderBloomIntensityPropertyIndex, EqualToConstraint()); + bloomIntensityConstraint.AddSource( Source(self, mBloomIntensityPropertyIndex) ); + bloomIntensityConstraint.Apply(); //////////////////////////////////////////// @@ -539,8 +515,9 @@ void BloomView::SetupProperties() mBloomSaturationPropertyIndex = self.RegisterProperty(BLOOM_SATURATION_PROPERTY_NAME, BLOOM_SATURATION_DEFAULT); mCompositeShader.SetUniform( BLOOM_SATURATION_PROPERTY_NAME, BLOOM_SATURATION_DEFAULT ); Property::Index shaderBloomSaturationPropertyIndex = mCompositeShader.GetPropertyIndex(BLOOM_SATURATION_PROPERTY_NAME); - Constraint bloomSaturationConstraint = Constraint::New( shaderBloomSaturationPropertyIndex, Source(self, mBloomSaturationPropertyIndex), EqualToConstraintFloat()); - mCompositeShader.ApplyConstraint(bloomSaturationConstraint); + Constraint bloomSaturationConstraint = Constraint::New( mCompositeShader, shaderBloomSaturationPropertyIndex, EqualToConstraint()); + bloomSaturationConstraint.AddSource( Source(self, mBloomSaturationPropertyIndex) ); + bloomSaturationConstraint.Apply(); //////////////////////////////////////////// @@ -550,8 +527,9 @@ void BloomView::SetupProperties() mImageIntensityPropertyIndex = self.RegisterProperty(IMAGE_INTENSITY_PROPERTY_NAME, IMAGE_INTENSITY_DEFAULT); mCompositeShader.SetUniform( IMAGE_INTENSITY_PROPERTY_NAME, IMAGE_INTENSITY_DEFAULT ); Property::Index shaderImageIntensityPropertyIndex = mCompositeShader.GetPropertyIndex(IMAGE_INTENSITY_PROPERTY_NAME); - Constraint imageIntensityConstraint = Constraint::New( shaderImageIntensityPropertyIndex, Source(self, mImageIntensityPropertyIndex), EqualToConstraintFloat()); - mCompositeShader.ApplyConstraint(imageIntensityConstraint); + Constraint imageIntensityConstraint = Constraint::New( mCompositeShader, shaderImageIntensityPropertyIndex, EqualToConstraint()); + imageIntensityConstraint.AddSource( Source(self, mImageIntensityPropertyIndex) ); + imageIntensityConstraint.Apply(); //////////////////////////////////////////// @@ -561,8 +539,9 @@ void BloomView::SetupProperties() mImageSaturationPropertyIndex = self.RegisterProperty(IMAGE_SATURATION_PROPERTY_NAME, IMAGE_SATURATION_DEFAULT); mCompositeShader.SetUniform( IMAGE_SATURATION_PROPERTY_NAME, IMAGE_SATURATION_DEFAULT ); Property::Index shaderImageSaturationPropertyIndex = mCompositeShader.GetPropertyIndex(IMAGE_SATURATION_PROPERTY_NAME); - Constraint imageSaturationConstraint = Constraint::New( shaderImageSaturationPropertyIndex, Source(self, mImageSaturationPropertyIndex), EqualToConstraintFloat()); - mCompositeShader.ApplyConstraint(imageSaturationConstraint); + Constraint imageSaturationConstraint = Constraint::New( mCompositeShader, shaderImageSaturationPropertyIndex, EqualToConstraint()); + imageSaturationConstraint.AddSource( Source(self, mImageSaturationPropertyIndex) ); + imageSaturationConstraint.Apply(); } } // namespace Internal