X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ffilters%2Femboss-filter.cpp;h=8f444acb97d85783ed133f778d2cce9aea16d618;hp=4993cdf1c486431c11e160f9367b911259d5abdd;hb=ee51def60c1b22fb65d9f6f027339e207a38a46f;hpb=e2eda444afbe82e9591fe198eef339227f90a616 diff --git a/dali-toolkit/internal/filters/emboss-filter.cpp b/dali-toolkit/internal/filters/emboss-filter.cpp index 4993cdf..8f444ac 100644 --- a/dali-toolkit/internal/filters/emboss-filter.cpp +++ b/dali-toolkit/internal/filters/emboss-filter.cpp @@ -1,24 +1,29 @@ -// -// 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 "emboss-filter.h" // EXTERNAL INCLUDES #include +#include +#include +#include +#include // INTERNAL INCLUDES @@ -38,6 +43,7 @@ const float ARBITRARY_FIELD_OF_VIEW = Math::PI / 4.0f; const char* EMBOSS_FRAGMENT_SOURCE1 = { + "precision highp float;\n" "uniform vec2 uTexScale;\n" "\n" "void main()\n" @@ -67,6 +73,7 @@ const char* EMBOSS_FRAGMENT_SOURCE1 = const char* EMBOSS_FRAGMENT_SOURCE2 = { + "precision highp float;\n" "uniform vec2 uTexScale;\n" "\n" "void main()\n" @@ -118,37 +125,37 @@ void EmbossFilter::Enable() mCameraActor = CameraActor::New(); mCameraActor.SetParentOrigin(ParentOrigin::CENTER); - mImageForEmboss1 = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Image::Unused ); - mImageForEmboss2 = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Image::Unused ); + mImageForEmboss1 = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Image::UNUSED ); + mImageForEmboss2 = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat, Image::UNUSED ); // create actor to render input with applied emboss effect mActorForInput1 = ImageActor::New( mInputImage ); mActorForInput1.SetParentOrigin( ParentOrigin::CENTER ); - mActorForInput1.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); + mActorForInput1.SetSize(mTargetSize); mActorForInput1.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); mActorForInput1.SetColor( Color::WHITE ); mActorForInput2 = ImageActor::New( mInputImage ); mActorForInput2.SetParentOrigin( ParentOrigin::CENTER ); - mActorForInput2.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); + mActorForInput2.SetSize(mTargetSize); mActorForInput2.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); mActorForInput2.SetColor( Color::WHITE ); mActorForEmboss1 = ImageActor::New( mImageForEmboss1 ); mActorForEmboss1.SetParentOrigin( ParentOrigin::CENTER ); - mActorForEmboss1.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); + mActorForEmboss1.SetSize(mTargetSize); mActorForEmboss1.SetColor( Color::BLACK ); mActorForEmboss1.SetShaderEffect( ShaderEffect::New( "", COMPOSITE_FRAGMENT_SOURCE ) ); mActorForEmboss2 = ImageActor::New( mImageForEmboss2 ); mActorForEmboss2.SetParentOrigin( ParentOrigin::CENTER ); - mActorForEmboss2.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); + mActorForEmboss2.SetSize(mTargetSize); mActorForEmboss2.SetColor( Color::WHITE ); mActorForEmboss2.SetShaderEffect( ShaderEffect::New( "", COMPOSITE_FRAGMENT_SOURCE ) ); mActorForComposite = Actor::New(); mActorForComposite.SetParentOrigin( ParentOrigin::CENTER ); - mActorForComposite.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) ); + mActorForComposite.SetSize(mTargetSize); mActorForComposite.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // create custom shader effect @@ -240,6 +247,31 @@ void EmbossFilter::Refresh() } } +void EmbossFilter::SetSize( const Vector2& size ) +{ + mTargetSize = size; + if( mActorForInput1 ) + { + mActorForInput1.SetSize(mTargetSize); + } + if( mActorForInput2 ) + { + mActorForInput2.SetSize(mTargetSize); + } + if( mActorForEmboss1 ) + { + mActorForEmboss1.SetSize(mTargetSize); + } + if( mActorForEmboss2 ) + { + mActorForEmboss2.SetSize(mTargetSize); + } + if( mActorForComposite ) + { + mActorForComposite.SetSize(mTargetSize); + } +} + void EmbossFilter::SetupCamera() { // Create and place a camera for the embossing render, corresponding to its render target size