X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fimage-view%2Fmasked-image-view-impl.cpp;h=97c405387680965ebbf174cd392f15bce045eac9;hp=57b13b8a7887b0e2403088ffe9fcb470156368c7;hb=d69d0761421e562cd4780c07499cae61963559bd;hpb=e2eda444afbe82e9591fe198eef339227f90a616 diff --git a/dali-toolkit/internal/controls/image-view/masked-image-view-impl.cpp b/dali-toolkit/internal/controls/image-view/masked-image-view-impl.cpp index 57b13b8..97c4053 100644 --- a/dali-toolkit/internal/controls/image-view/masked-image-view-impl.cpp +++ b/dali-toolkit/internal/controls/image-view/masked-image-view-impl.cpp @@ -1,24 +1,30 @@ -// -// 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 // EXTERNAL INCLUDES #include - -// INTERNAL INCLUDES -#include +#include +#include +#include +#include +#include namespace Dali { @@ -91,11 +97,6 @@ const char* const MASKED_IMAGE_VIEW_FRAGMENT_SOURCE = " gl_FragColor = texture2D(sTexture, vTexCoord) * vec4(1,1,1,mask.a); \n" "}"; -Vector2 EqualToConstraintVector2( const Vector2& current, const PropertyInput& property ) -{ - return property.GetVector2(); -} - Vector2 GetSizeForAspectRatio( const Vector2& targetSize, float aspectRatio ) { Vector2 sizeToKeepAspectRatio( targetSize ); @@ -261,7 +262,14 @@ void MaskedImageView::Resume() bool MaskedImageView::IsPaused() const { - return !mRenderTask; // RenderTask is discarded during Pause() + if( mRenderTask.GetRefreshRate() ) // REFRESH_ALWAYS + { + return false; + } + else // REFRESH_ONCE + { + return true; + } } void MaskedImageView::SetEditMode( Dali::Toolkit::MaskedImageView::EditMode editMode ) @@ -343,7 +351,7 @@ void MaskedImageView::OnPropertySet( Property::Index index, Property::Value prop } } -void MaskedImageView::OnPan(Actor source, PanGesture gesture) +void MaskedImageView::OnPan(Actor source, const PanGesture& gesture) { // Used to flag whether edit mode is setting properties mSelfPropertySetting = true; @@ -368,7 +376,7 @@ void MaskedImageView::OnPan(Actor source, PanGesture gesture) mSelfPropertySetting = false; } -void MaskedImageView::OnPinch(Actor actor, PinchGesture pinch) +void MaskedImageView::OnPinch(Actor actor, const PinchGesture& pinch) { // Used to flag whether edit mode is setting properties mSelfPropertySetting = true; @@ -467,7 +475,7 @@ Dali::Toolkit::MaskedImageView::MaskedImageViewSignal& MaskedImageView::MaskFini } MaskedImageView::MaskedImageView() -: ControlImpl(true), +: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ), mEditMode( Dali::Toolkit::MaskedImageView::EDIT_DISABLED ), mSelfPropertySetting( false ), mSourceRotation( Dali::Toolkit::MaskedImageView::ROTATE_0 ), @@ -510,7 +518,7 @@ void MaskedImageView::Initialize( unsigned int targetWidth, self.Add( mSourceImageActor ); mSourceImageActor.SetParentOrigin( ParentOrigin::CENTER ); mSourceImageActor.SetPositionInheritanceMode( DONT_INHERIT_POSITION ); - mSourceImageActor.SetInheritRotation( false ); + mSourceImageActor.SetInheritOrientation( false ); mSourceImageActor.SetInheritScale( false ); mSourceImageActor.SetColorMode( USE_OWN_COLOR ); mSourceImageActor.SetSize( Vector3::ONE ); @@ -522,7 +530,6 @@ void MaskedImageView::Initialize( unsigned int targetWidth, // Create actor to display result of off-screen rendering mDestinationImageActor = ImageActor::New( mDestinationImage ); self.Add( mDestinationImageActor ); - mDestinationImageActor.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); mDestinationImageActor.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); // Start the masking operation @@ -532,9 +539,10 @@ void MaskedImageView::Initialize( unsigned int targetWidth, mRenderTask.SetInputEnabled( false ); mRenderTask.SetExclusive( true ); mRenderTask.SetClearEnabled( true ); - mRenderTask.ApplyConstraint( Constraint::New( RenderTask::CLEAR_COLOR, - Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::BACKGROUND_COLOR ] ), - EqualToConstraint() ) ); + + Constraint clearColorConstraint = Constraint::New( mRenderTask, RenderTask::Property::CLEAR_COLOR, EqualToConstraint() ); + clearColorConstraint.AddSource( Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::BACKGROUND_COLOR ] ) ); + clearColorConstraint.Apply(); mRenderTask.FinishedSignal().Connect( this, &MaskedImageView::OnRenderTaskFinished ); // Edit mode initialization @@ -572,22 +580,26 @@ void MaskedImageView::ApplyMaskedImageShader( ImageRotation rotation ) ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) ); shader.SetUniform( "uTargetSize", mTargetSize ); + shader.SetUniform( "uSourceSize", mTargetSize ); - shader.ApplyConstraint( Constraint::New( shader.GetPropertyIndex( "uSourceSize" ), - Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_SIZE ] ), - EqualToConstraintVector2 ) ); + Constraint sourceSizeConstraint = Constraint::New( shader, shader.GetPropertyIndex( "uSourceSize" ), EqualToConstraint() ); + sourceSizeConstraint.AddSource( Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_SIZE ] ) ); + sourceSizeConstraint.Apply(); + shader.SetUniform( "uSourceOffset", Vector2::ZERO ); - shader.ApplyConstraint( Constraint::New( shader.GetPropertyIndex( "uSourceOffset" ), - Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_OFFSET ] ), - EqualToConstraintVector2 ) ); + Constraint sourceOffsetConstraint = Constraint::New( shader, shader.GetPropertyIndex( "uSourceOffset" ), EqualToConstraint() ); + sourceOffsetConstraint.AddSource( Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_OFFSET ] ) ); + sourceOffsetConstraint.Apply(); + shader.SetUniform( "uMaskSize", mTargetSize ); - shader.ApplyConstraint( Constraint::New( shader.GetPropertyIndex( "uMaskSize" ), - Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_SIZE ] ), - EqualToConstraintVector2 ) ); + Constraint maskSizeConstraint = Constraint::New( shader, shader.GetPropertyIndex( "uMaskSize" ), EqualToConstraint() ); + maskSizeConstraint.AddSource( Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_SIZE ] ) ); + maskSizeConstraint.Apply(); + shader.SetUniform( "uMaskOffset", mTargetSize ); - shader.ApplyConstraint( Constraint::New( shader.GetPropertyIndex( "uMaskOffset" ), - Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_OFFSET ] ), - EqualToConstraintVector2 ) ); + Constraint maskOffsetConstraint = Constraint::New( shader, shader.GetPropertyIndex( "uMaskOffset" ), EqualToConstraint() ); + maskOffsetConstraint.AddSource( Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_OFFSET ] ) ); + maskOffsetConstraint.Apply(); shader.SetEffectImage( mMaskImage ); mSourceImageActor.SetShaderEffect( shader ); @@ -621,6 +633,11 @@ MaskedImageView::~MaskedImageView() } } +void MaskedImageView::OnControlSizeSet( const Vector3& targetSize ) +{ + mDestinationImageActor.SetSize(targetSize); +} + void MaskedImageView::OnRenderTaskFinished( Dali::RenderTask& renderTask ) { Toolkit::MaskedImageView handle( GetOwner() );