-//
-// 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 <sstream>
+#include <dali/public-api/animation/constraints.h>
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/render-tasks/render-task-list.h>
+#include <dali/public-api/shader-effects/shader-effect.h>
// INTERNAL INCLUDES
const char* EMBOSS_FRAGMENT_SOURCE1 =
{
+ "precision highp float;\n"
"uniform vec2 uTexScale;\n"
"\n"
"void main()\n"
const char* EMBOSS_FRAGMENT_SOURCE2 =
{
+ "precision highp float;\n"
"uniform vec2 uTexScale;\n"
"\n"
"void main()\n"
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<Vector3>( 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<Vector3>( 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<Vector3>( 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<Vector3>( 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<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+ mActorForComposite.SetSize(mTargetSize);
mActorForComposite.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) );
// create custom shader effect
}
}
+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
mCameraActor.SetNearClippingPlane(1.0f);
mCameraActor.SetAspectRatio(mTargetSize.width / mTargetSize.height);
mCameraActor.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor
- mCameraActor.SetRotation(Quaternion(M_PI, Vector3::YAXIS));
mCameraActor.SetPosition(0.0f, 0.0f, ((mTargetSize.height * 0.5f) / tanf(ARBITRARY_FIELD_OF_VIEW * 0.5f)));
}