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=c05e9549e83edc6eedb0897b13cdb60dc9e80195;hp=e64289e2e3dbc47eeac92948522f3364181293b7;hb=3b814d1a154260d5d83923ec3b876aac095eee94;hpb=d00a250741411c386d988e7ac34525cf94a1918e 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 e64289e..c05e954 100644 --- a/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp +++ b/dali-toolkit/internal/controls/bloom-view/bloom-view-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -32,9 +32,10 @@ #include // INTERNAL INCLUDES -#include +#include #include -#include "../gaussian-blur-view/gaussian-blur-view-impl.h" +#include +#include namespace Dali { @@ -137,49 +138,49 @@ const char* const COMPOSITE_FRAGMENT_SOURCE = BloomView::BloomView() - : 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) - , mDownsampleWidthScale(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_WIDTH_SCALE) - , mDownsampleHeightScale(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE) - , mDownsampledWidth( 0.0f ) - , mDownsampledHeight( 0.0f ) - , mTargetSize(Vector2::ZERO) - , mLastSize(Vector2::ZERO) - , mChildrenRoot(Actor::New()) - , mInternalRoot(Actor::New() ) - , mBloomThresholdPropertyIndex(Property::INVALID_INDEX) - , mBlurStrengthPropertyIndex(Property::INVALID_INDEX) - , mBloomIntensityPropertyIndex(Property::INVALID_INDEX) - , mBloomSaturationPropertyIndex(Property::INVALID_INDEX) - , mImageIntensityPropertyIndex(Property::INVALID_INDEX) - , mImageSaturationPropertyIndex(Property::INVALID_INDEX) - , mActivated( false ) +: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ), + 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), + mDownsampleWidthScale(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_WIDTH_SCALE), + mDownsampleHeightScale(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE), + mDownsampledWidth( 0.0f ), + mDownsampledHeight( 0.0f ), + mTargetSize(Vector2::ZERO), + mLastSize(Vector2::ZERO), + mChildrenRoot(Actor::New()), + mInternalRoot(Actor::New() ), + mBloomThresholdPropertyIndex(Property::INVALID_INDEX), + mBlurStrengthPropertyIndex(Property::INVALID_INDEX), + mBloomIntensityPropertyIndex(Property::INVALID_INDEX), + mBloomSaturationPropertyIndex(Property::INVALID_INDEX), + mImageIntensityPropertyIndex(Property::INVALID_INDEX), + mImageSaturationPropertyIndex(Property::INVALID_INDEX), + mActivated( false ) { } BloomView::BloomView( const unsigned int blurNumSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat, const float downsampleWidthScale, const float downsampleHeightScale) - : Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ) - , mBlurNumSamples(blurNumSamples) - , mBlurBellCurveWidth(blurBellCurveWidth) - , mPixelFormat(renderTargetPixelFormat) - , mDownsampleWidthScale(downsampleWidthScale) - , mDownsampleHeightScale(downsampleHeightScale) - , mDownsampledWidth( 0.0f ) - , mDownsampledHeight( 0.0f ) - , mTargetSize(Vector2::ZERO) - , mLastSize(Vector2::ZERO) - , mChildrenRoot(Actor::New()) - , mInternalRoot(Actor::New()) - , mBloomThresholdPropertyIndex(Property::INVALID_INDEX) - , mBlurStrengthPropertyIndex(Property::INVALID_INDEX) - , mBloomIntensityPropertyIndex(Property::INVALID_INDEX) - , mBloomSaturationPropertyIndex(Property::INVALID_INDEX) - , mImageIntensityPropertyIndex(Property::INVALID_INDEX) - , mImageSaturationPropertyIndex(Property::INVALID_INDEX) - , mActivated( false ) +: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ), + mBlurNumSamples(blurNumSamples), + mBlurBellCurveWidth(blurBellCurveWidth), + mPixelFormat(renderTargetPixelFormat), + mDownsampleWidthScale(downsampleWidthScale), + mDownsampleHeightScale(downsampleHeightScale), + mDownsampledWidth( 0.0f ), + mDownsampledHeight( 0.0f ), + mTargetSize(Vector2::ZERO), + mLastSize(Vector2::ZERO), + mChildrenRoot(Actor::New()), + mInternalRoot(Actor::New()), + mBloomThresholdPropertyIndex(Property::INVALID_INDEX), + mBlurStrengthPropertyIndex(Property::INVALID_INDEX), + mBloomIntensityPropertyIndex(Property::INVALID_INDEX), + mBloomSaturationPropertyIndex(Property::INVALID_INDEX), + mImageIntensityPropertyIndex(Property::INVALID_INDEX), + mImageSaturationPropertyIndex(Property::INVALID_INDEX), + mActivated( false ) { } @@ -276,8 +277,6 @@ void BloomView::OnInitialize() void BloomView::OnSizeSet(const Vector3& targetSize) { - Control::OnSizeSet( targetSize ); - mTargetSize = Vector2(targetSize); mChildrenRoot.SetSize(targetSize); mCompositeImageView.SetSize(targetSize); @@ -299,16 +298,18 @@ void BloomView::OnSizeSet(const Vector3& targetSize) Deactivate(); Activate(); } + + Control::OnSizeSet( targetSize ); } void BloomView::OnChildAdd( Actor& child ) { - Control::OnChildAdd( child ); - if( child != mChildrenRoot && child != mInternalRoot) { mChildrenRoot.Add( child ); } + + Control::OnChildAdd( child ); } void BloomView::OnChildRemove( Actor& child ) @@ -357,15 +358,16 @@ void BloomView::AllocateResources() mGaussianBlurView.SetSize(mTargetSize); GetImpl(mGaussianBlurView).AllocateResources(); + mGaussianBlurView.SetVisible( true ); ////////////////////////////////////////////////////// // 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 ); - FrameBufferImage mBlurExtractTarget = 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 ); + mBloomExtractTarget = FrameBufferImage::New( mDownsampledWidth, mDownsampledHeight, mPixelFormat ); + FrameBufferImage mBlurExtractTarget = FrameBufferImage::New( mDownsampledWidth, mDownsampledHeight, mPixelFormat ); + mOutputRenderTarget = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat ); ////////////////////////////////////////////////////// @@ -375,10 +377,10 @@ void BloomView::AllocateResources() mBloomExtractImageView.SetSize(mDownsampledWidth, mDownsampledHeight); // size needs to match render target // Create shader used for extracting the bright parts of an image Property::Map customShader; - customShader[ "fragmentShader" ] = BLOOM_EXTRACT_FRAGMENT_SOURCE; - Property::Map rendererMap; - rendererMap.Insert( "shader", customShader ); - mBloomExtractImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap ); + customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = BLOOM_EXTRACT_FRAGMENT_SOURCE; + Property::Map visualMap; + visualMap.Insert( Toolkit::Visual::Property::SHADER, customShader ); + mBloomExtractImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap ); // set GaussianBlurView to blur our extracted bloom mGaussianBlurView.SetUserImageAndOutputRenderTarget(mBloomExtractTarget, mBlurExtractTarget); @@ -386,9 +388,9 @@ void BloomView::AllocateResources() // use the completed blur in the first buffer and composite with the original child actors render mCompositeImageView.SetImage( mRenderTargetForRenderingChildren ); // Create shader used to composite bloom and original image to output render target - customShader[ "fragmentShader" ] = COMPOSITE_FRAGMENT_SOURCE; - rendererMap[ "shader" ] = customShader; - mCompositeImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, rendererMap ); + customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = COMPOSITE_FRAGMENT_SOURCE; + visualMap[ Toolkit::Visual::Property::SHADER ] = customShader; + mCompositeImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, visualMap ); TextureSet textureSet = mCompositeImageView.GetRendererAt(0).GetTextures(); TextureSetImage( textureSet, 1u, mBlurExtractTarget ); @@ -457,9 +459,18 @@ void BloomView::Deactivate() // stop render tasks processing // Note: render target resources are automatically freed since we set the Image::Unused flag RemoveRenderTasks(); + mRenderTargetForRenderingChildren.Reset(); mBloomExtractTarget.Reset(); mOutputRenderTarget.Reset(); + + // Reset children + mBloomExtractImageView.SetImage( "" ); + mTargetImageView.SetImage( "" ); + mCompositeImageView.SetImage( "" ); + + mGaussianBlurView.SetVisible( false ); + mActivated = false; }