X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fshadow-view%2Fshadow-view-impl.cpp;h=23f1f0fa3b14f74a2297a2eed8d643ff28a899a9;hp=fbc2e1c7b5e0cf91edc4efe5c83b9f6de3fc228e;hb=d011049f576aaf534d52180829398b917e08de04;hpb=e2eda444afbe82e9591fe198eef339227f90a616 diff --git a/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp b/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp index fbc2e1c..23f1f0f 100644 --- a/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp +++ b/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp @@ -1,18 +1,19 @@ -// -// 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 "shadow-view-impl.h" @@ -20,11 +21,17 @@ // EXTERNAL INCLUDES #include #include +#include +#include +#include +#include +#include +#include +#include // INTERNAL INCLUDES #include #include -#include // TODO: // pixel format / size - set from JSON @@ -63,8 +70,8 @@ BaseHandle Create() return Toolkit::ShadowView::New(); } -TypeRegistration mType( typeid(Toolkit::ShadowView), typeid(Toolkit::Control), Create ); - +DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ShadowView, Toolkit::Control, Create ) +DALI_TYPE_REGISTRATION_END() const float BLUR_STRENGTH_DEFAULT = 1.0f; @@ -73,12 +80,11 @@ const float DEFAULT_FIELD_OF_VIEW_RADIANS = Math::PI / 4.0f; // 45 degrees const Vector4 DEFAULT_SHADOW_COLOR = Vector4(0.2f, 0.2f, 0.2f, 0.8f); -const std::string SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME( "uLightCameraProjectionMatrix" ); -const std::string SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME( "uLightCameraViewMatrix" ); -const std::string SHADER_SHADOW_COLOR_PROPERTY_NAME( "uShadowColor" ); - -const std::string BLUR_STRENGTH_PROPERTY_NAME( "BlurStrengthProperty" ); -const std::string SHADOW_COLOR_PROPERTY_NAME( "ShadowColorProperty" ); +const char* const SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME = "uLightCameraProjectionMatrix"; +const char* const SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME = "uLightCameraViewMatrix"; +const char* const SHADER_SHADOW_COLOR_PROPERTY_NAME = "uShadowColor"; +const char* const BLUR_STRENGTH_PROPERTY_NAME = "BlurStrengthProperty"; +const char* const SHADOW_COLOR_PROPERTY_NAME = "ShadowColorProperty"; const char* const RENDER_SHADOW_VERTEX_SOURCE = " uniform mediump mat4 uLightCameraProjectionMatrix;\n" @@ -116,7 +122,7 @@ struct EqualToConstraintMatrix } // namespace ShadowView::ShadowView( float downsampleWidthScale, float downsampleHeightScale ) -: ControlImpl( false ), // doesn't require touch events +: Control( CONTROL_BEHAVIOUR_NONE ), mChildrenRoot(Actor::New()), mCachedShadowColor(DEFAULT_SHADOW_COLOR), mCachedBackgroundColor(DEFAULT_SHADOW_COLOR.r, DEFAULT_SHADOW_COLOR.g, DEFAULT_SHADOW_COLOR.b, 0.0f), @@ -176,9 +182,9 @@ void ShadowView::SetShadowPlane(Actor shadowPlane) ConstrainCamera(); - mShadowPlane.ApplyConstraint( Constraint::New( Actor::SIZE, Source( mShadowPlaneBg, Actor::SIZE ), EqualToConstraint() ) ); + mShadowPlane.SetSizeMode( SIZE_EQUAL_TO_PARENT ); - mBlurRootActor.ApplyConstraint( Constraint::New( Actor::SIZE, Source( mShadowPlane, Actor::SIZE ), EqualToConstraint() ) ); + mBlurRootActor.SetSizeMode( SIZE_EQUAL_TO_PARENT ); } void ShadowView::SetPointLight(Actor pointLight) @@ -233,16 +239,17 @@ void ShadowView::OnInitialize() { // root actor to parent all user added actors. Used as source actor for shadow render task. mChildrenRoot.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - mChildrenRoot.ApplyConstraint(Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() )); + mChildrenRoot.SetSizeMode( SIZE_EQUAL_TO_PARENT ); Vector2 stageSize = Stage::GetCurrent().GetSize(); mCameraActor = CameraActor::New(stageSize); + mCameraActor.SetParentOrigin( ParentOrigin::CENTER ); // Target is constrained to point at the shadow plane origin mCameraActor.SetNearClippingPlane( 1.0f ); mCameraActor.SetType( Dali::Camera::FREE_LOOK ); // Camera orientation constrained to point at shadow plane world position - mCameraActor.SetInvertYAxis(false); + mCameraActor.SetOrientation(Radian(Degree(180)), Vector3::YAXIS); mCameraActor.SetPosition(DEFAULT_LIGHT_POSITION); mShadowRenderShader = ShaderEffect::New( RENDER_SHADOW_VERTEX_SOURCE, RENDER_SHADOW_FRAGMENT_SOURCE, @@ -270,7 +277,7 @@ void ShadowView::OnInitialize() // Turn off inheritance to ensure filter renders properly mBlurRootActor.SetPositionInheritanceMode(USE_PARENT_POSITION); - mBlurRootActor.SetInheritRotation(false); + mBlurRootActor.SetInheritOrientation(false); mBlurRootActor.SetInheritScale(false); mBlurRootActor.SetColorMode(USE_OWN_COLOR); @@ -308,15 +315,15 @@ void ShadowView::ConstrainCamera() // is under control of application, can't use transform inheritance) Constraint cameraOrientationConstraint = - Constraint::New ( Actor::ROTATION, - Source( mShadowPlane, Actor::WORLD_POSITION ), - Source( mPointLight, Actor::WORLD_POSITION ), - Source( mShadowPlane, Actor::WORLD_ROTATION ), + Constraint::New ( Actor::Property::ORIENTATION, + Source( mShadowPlane, Actor::Property::WORLD_POSITION ), + Source( mPointLight, Actor::Property::WORLD_POSITION ), + Source( mShadowPlane, Actor::Property::WORLD_ORIENTATION ), &LookAt ); mCameraActor.ApplyConstraint( cameraOrientationConstraint ); - Constraint pointLightPositionConstraint = Constraint::New( Actor::POSITION, Source( mPointLight, Actor::WORLD_POSITION ), EqualToConstraint() ); + Constraint pointLightPositionConstraint = Constraint::New( Actor::Property::POSITION, Source( mPointLight, Actor::Property::WORLD_POSITION ), EqualToConstraint() ); mCameraActor.ApplyConstraint( pointLightPositionConstraint ); } @@ -364,8 +371,8 @@ void ShadowView::SetShaderConstants() Property::Index lightCameraProjectionMatrixPropertyIndex = mShadowRenderShader.GetPropertyIndex(SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME); Property::Index lightCameraViewMatrixPropertyIndex = mShadowRenderShader.GetPropertyIndex(SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME); - Constraint projectionMatrixConstraint = Constraint::New( lightCameraProjectionMatrixPropertyIndex, Source( mCameraActor, CameraActor::PROJECTION_MATRIX ), EqualToConstraintMatrix()); - Constraint viewMatrixConstraint = Constraint::New( lightCameraViewMatrixPropertyIndex, Source( mCameraActor, CameraActor::VIEW_MATRIX ), EqualToConstraintMatrix()); + Constraint projectionMatrixConstraint = Constraint::New( lightCameraProjectionMatrixPropertyIndex, Source( mCameraActor, CameraActor::Property::PROJECTION_MATRIX ), EqualToConstraintMatrix()); + Constraint viewMatrixConstraint = Constraint::New( lightCameraViewMatrixPropertyIndex, Source( mCameraActor, CameraActor::Property::VIEW_MATRIX ), EqualToConstraintMatrix()); mShadowRenderShader.ApplyConstraint(projectionMatrixConstraint); mShadowRenderShader.ApplyConstraint(viewMatrixConstraint);