# List of test case sources (Only these get parsed for test cases)
SET(TC_SOURCES
utc-Dali-Alignment.cpp
- utc-Dali-BendyEffect.cpp
- utc-Dali-BlindEffect.cpp
utc-Dali-BloomView.cpp
utc-Dali-BubbleEmitter.cpp
utc-Dali-Builder.cpp
- utc-Dali-CarouselEffect.cpp
utc-Dali-CheckBoxButton.cpp
utc-Dali-CubeTransitionEffect.cpp
- utc-Dali-DisplacementEffect.cpp
- utc-Dali-DistanceFieldEffect.cpp
utc-Dali-GaussianBlurView.cpp
utc-Dali-JsonParser.cpp
utc-Dali-KeyInputFocusManager.cpp
- utc-Dali-OverlayEffect.cpp
- utc-Dali-PageTurnEffect.cpp
utc-Dali-PageTurnView.cpp
utc-Dali-ScrollBar.cpp
utc-Dali-ScrollView.cpp
+ utc-Dali-ShaderEffects.cpp
utc-Dali-ShadowView.cpp
- utc-Dali-ShearEffect.cpp
utc-Dali-Slider.cpp
- utc-Dali-SoftButtonEffect.cpp
- utc-Dali-SpotEffect.cpp
- utc-Dali-SquareDissolveEffect.cpp
utc-Dali-TableView.cpp
utc-Dali-TextField.cpp
utc-Dali-TextLabel.cpp
utc-Dali-ToolBar.cpp
- utc-Dali-WaterEffect.cpp
utc-Dali-Button.cpp
utc-Dali-Control.cpp
utc-Dali-ControlImpl.cpp
utc-Dali-DefaultControls.cpp
- utc-Dali-DissolveEffect.cpp
utc-Dali-FocusManager.cpp
- utc-Dali-IrisEffect.cpp
utc-Dali-ItemLayout.cpp
utc-Dali-ItemView.cpp
utc-Dali-KeyboardFocusManager.cpp
- utc-Dali-MaskEffect.cpp
utc-Dali-NinePatchMaskEffect.cpp
utc-Dali-Popup.cpp
utc-Dali-PushButton.cpp
utc-Dali-RadioButton.cpp
- utc-Dali-Ripple2DEffect.cpp
- utc-Dali-RippleEffect.cpp
utc-Dali-ScrollViewEffect.cpp
utc-Dali-StyleManager.cpp
utc-Dali-SuperBlurView.cpp
- utc-Dali-SwirlEffect.cpp
)
# Append list of test harness files (Won't get parsed for test cases)
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-
-using namespace Dali;
-
-
-void bendy_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void bendy_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-int UtcDaliBendyUninitializedEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::BendyEffect effect;
-
- try
- {
- // New() must be called to create a BendyEffect or it wont be valid.
- effect.SetRadius( 2.0f );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK(!effect);
- }
- END_TEST;
-}
-
-int UtcDaliBendyPropertyNamesEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::BendyEffect effect = Toolkit::BendyEffect::New();
-
- // Check the names, this names are used in the shaders code,
- // if they change the shader code has to be updated
- DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetDirectionPropertyName(), "uDirection", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliBendyDefaultValuesEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::BendyEffect effect = Toolkit::BendyEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- Vector2 topLeft( Stage::GetCurrent().GetSize() * 0.5f );
- topLeft.y = -topLeft.y;
-
- // Gets converted to opengl view space
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetCenterPropertyName().c_str(),
- topLeft ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetDirectionPropertyName().c_str(),
- Vector2(0.0f, 0.0f) ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetRadiusPropertyName().c_str(),
- 0.0f ) );
- END_TEST;
-}
-
-int UtcDaliBendyCustomValuesEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::BendyEffect effect = Toolkit::BendyEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
-
- Vector2 direction(1.0f, 1.0f);
- effect.SetCenter( Vector2(480.0f, 800.0f) );
- effect.SetDirection( direction );
- effect.SetRadius( 2.0f );
-
- actor.SetShaderEffect(effect);
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render();
-
- Vector2 bottomRight( Stage::GetCurrent().GetSize() * 0.5f );
- bottomRight.x = -bottomRight.x;
-
- // Gets converted to opengl viewport coordinates
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetCenterPropertyName().c_str(),
- bottomRight ) );
-
- direction.Normalize();
- direction.x *= -1.0f;
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetDirectionPropertyName().c_str(),
- direction ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetRadiusPropertyName().c_str(),
- 2.0f ) );
- END_TEST;
-}
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-
-using namespace Dali;
-
-
-void blind_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void blind_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-int UtcDaliBlindEffectUninitialized(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::BlindEffect effect;
-
- try
- {
- // New() must be called to create a BlindEffect or it wont be valid.
- effect.SetStep( 2.0f );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK(!effect);
- }
- END_TEST;
-}
-
-int UtcDaliBlindEffectPropertyNames(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::BlindEffect effect = Toolkit::BlindEffect::New();
-
- // Check the names, this names are used in the shaders code,
- // if they change the shader code has to be updated
- DALI_TEST_EQUALS( effect.GetStepPropertyName(), "uStep", TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliBlindEffectDefaultValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::BlindEffect effect = Toolkit::BlindEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- // Gets converted to opengl viewport coordinates
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetStepPropertyName().c_str(),
- 0.0f ) );
- END_TEST;
-}
-
-int UtcDaliBlindEffectCustomValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::BlindEffect effect = Toolkit::BlindEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
-
- effect.SetStep( 2.0f );
-
- actor.SetShaderEffect(effect);
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render();
-
- // Gets converted to opengl viewport coordinates
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetStepPropertyName().c_str(),
- 2.0f ) );
- END_TEST;
-}
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-
-
-void carousel_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void carousel_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-int UtcDaliCarouselEffectUninitialized(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::CarouselEffect effect;
-
- try
- {
- // New() must be called to create a CarouselEffect or it wont be valid.
- effect.SetRadius( 100.0f );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK(!effect);
- }
- END_TEST;
-}
-
-int UtcDaliCarouselEffectPropertyNames(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
-
- // Check the names, these names are used in the shaders code,
- // if they change the shader code has to be updated
- DALI_TEST_EQUALS( effect.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetAnglePerUnitPropertyName(), "uAnglePerUnit", TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliCarouselEffectDefaultValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
-
- const float radiusValue(0.0f);
- const Vector2 centerValue(0.0f, 0.0f);
- const Vector2 anglePerUnitValue(0.0f, 0.0f);
-
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- TestGlAbstraction& gl = application.GetGlAbstraction();
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAnglePerUnitPropertyName().c_str(), anglePerUnitValue ) );
- END_TEST;
-}
-
-int UtcDaliCarouselEffectCustomValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
-
- const float radiusValue(100.0f);
- const Vector2 centerValue(150.0f, 200.0f);
- const Vector2 anglePerUnitValue(0.1f, 0.25f);
-
- effect.SetRadius( radiusValue );
- effect.SetCenter( centerValue );
- effect.SetAnglePerUnit( anglePerUnitValue );
-
- actor.SetShaderEffect(effect);
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render();
-
- TestGlAbstraction& gl = application.GetGlAbstraction();
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAnglePerUnitPropertyName().c_str(), anglePerUnitValue ) );
- END_TEST;
-}
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-namespace
-{
-const char* TEST_IMAGE_FILE_NAME = "gallery_image_01.jpg";
-} // namespace
-
-
-void utc_displacement_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_displacement_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-// Negative test case for a method
-int UtcDaliDisplacementEffectUninitialized(void)
-{
- ToolkitTestApplication application;
- tet_infoline("UtcDaliDisplacementEffectUninitialized");
-
- Toolkit::DisplacementEffect effect;
-
- try
- {
- // New() must be called to create a GaussianBlurView or it wont be valid.
- effect.SetStateProperty( 1.0f );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK(!effect);
- }
- END_TEST;
-}
-
-// Positive test case for a method
-int UtcDaliDisplacementEffectNew(void)
-{
- ToolkitTestApplication application;
- tet_infoline("UtcDaliDisplacementEffectNew");
-
- Toolkit::DisplacementEffect effect = Toolkit::DisplacementEffect::New(Toolkit::DisplacementEffect::DISPLACED);
- DALI_TEST_CHECK( effect );
-
- Toolkit::DisplacementEffect effect2 = Toolkit::DisplacementEffect::New(Toolkit::DisplacementEffect::FIXED);
- DALI_TEST_CHECK( effect2 );
- END_TEST;
-}
-
-// Positive test case for a method
-int UtcDaliDisplacementEffectPropertyNames(void)
-{
- ToolkitTestApplication application;
- tet_infoline("UtcDaliDisplacementEffectPropertyNames");
-
- Toolkit::DisplacementEffect effect = Toolkit::DisplacementEffect::New(Toolkit::DisplacementEffect::DISPLACED);
- DALI_TEST_CHECK( effect );
-
- // Check the names, this names are used in the shaders code,
- // if they change the shader code has to be updated
- DALI_TEST_EQUALS( effect.GetLightDirectionPropertyName(), "uLightDirection", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetAmbientLightColorPropertyName(), "uAmbientLightColor", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetDiffuseLightColorPropertyName(), "uDiffuseLightColor", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetLightingMultiplierPropertyName(), "uLightMultiplier", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetStatePropertyName(), "uState", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetHeightScalePropertyName(), "uHightScale", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetFixedNormalPropertyName(), "uFixedNormal", TEST_LOCATION );
- END_TEST;
-}
-
-// Positive test case for a method
-int UtcDaliDisplacementEffectTestSetProperty(void)
-{
- ToolkitTestApplication application;
- tet_infoline("UtcDaliDisplacementEffectTestSetProperty");
-
- Toolkit::DisplacementEffect effect = Toolkit::DisplacementEffect::New(Toolkit::DisplacementEffect::DISPLACED);
- DALI_TEST_CHECK( effect );
-
- ImageActor actor = ImageActor::New( ResourceImage::New(TEST_IMAGE_FILE_NAME) );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- Toolkit::DisplacementEffect effect2 = Toolkit::DisplacementEffect::New(Toolkit::DisplacementEffect::FIXED);
- DALI_TEST_CHECK( effect );
-
- ImageActor actor2 = ImageActor::New( ResourceImage::New(TEST_IMAGE_FILE_NAME) );
- actor2.SetSize( 100.0f, 100.0f );
- actor2.SetShaderEffect( effect2 );
- Stage::GetCurrent().Add( actor2 );
-
- Vector3 testVector3 = Vector3(45.0f, 55.0f, 65.0f);
- float testFloat = 0.623f;
- effect.SetLightDirection(testVector3);
- effect.SetAmbientLightColorProperty(testVector3);
- effect.SetDiffuseLightColorProperty(testVector3);
- effect.SetStateProperty(testFloat);
- effect.SetLightingMultiplierProperty(testFloat);
- effect.SetHeightScaleProperty(testFloat);
-
- effect2.SetFixedNormalProperty(testVector3);
-
- application.SendNotification();
- application.Render(0);
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetLightDirectionPropertyName() ) ).Get<Vector3>(), testVector3, TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetAmbientLightColorPropertyName() ) ).Get<Vector3>(), testVector3, TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetDiffuseLightColorPropertyName() ) ).Get<Vector3>(), testVector3, TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetStatePropertyName().c_str() ) ).Get<float>(), testFloat, TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetLightingMultiplierPropertyName().c_str() ) ).Get<float>(), testFloat, TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetHeightScalePropertyName().c_str() ) ).Get<float>(), testFloat, TEST_LOCATION );
-
- Vector3 normalizedVector3(testVector3);
- normalizedVector3.Normalize();
- DALI_TEST_EQUALS( effect2.GetProperty( effect2.GetPropertyIndex( effect2.GetFixedNormalPropertyName() ) ).Get<Vector3>(), normalizedVector3, TEST_LOCATION );
- END_TEST;
-}
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-
-// Need to override adaptor classes for toolkit test harness, so include
-// test harness headers before dali headers.
-#include <dali-toolkit-test-suite-utils.h>
-
-#include <dali.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-
-using namespace Dali;
-
-void utc_dali_toolkit_dissolve_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_toolkit_dissolve_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-int UtcDaliDissolveUninitializedEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::DissolveEffect effect;
-
- try
- {
- // New() must be called to create a DissolveEffect or it wont be valid.
- effect.SetDistortion( 2.0f );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK(!effect);
- }
- END_TEST;
-}
-
-int UtcDaliDissolvePropertyNamesEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::DissolveEffect effectHighPrecision = Toolkit::DissolveEffect::New();
- Toolkit::DissolveEffect effectMediumPrecision = Toolkit::DissolveEffect::New( false );
-
- // Check the names, this names are used in the shaders code,
- // if they change the shader code has to be updated
- DALI_TEST_EQUALS( effectHighPrecision.GetDistortionPropertyName(), "uPercentage", TEST_LOCATION );
- DALI_TEST_EQUALS( effectMediumPrecision.GetDistortionPropertyName(), "uPercentage", TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliDissolveDefaultValuesEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::DissolveEffect effect = Toolkit::DissolveEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- effect.SetCentralLine( Vector2(0.0,0.5), Vector2(1.0, -0.1) );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- Property::Index index = effect.GetPropertyIndex( effect.GetDistortionPropertyName());
- float value;
- (effect.GetProperty(index)).Get( value );
- DALI_TEST_EQUALS(value, 0.f, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliDissolveCustomValuesEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::DissolveEffect effect = Toolkit::DissolveEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
-
- effect.SetDistortion( 0.5f );
-
- actor.SetShaderEffect(effect);
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render();
-
- Property::Index index = effect.GetPropertyIndex( effect.GetDistortionPropertyName());
- float value;
- (effect.GetProperty(index)).Get( value );
- DALI_TEST_EQUALS(value, 0.5f, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliSetEffectImageEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::DissolveEffect effect = Toolkit::DissolveEffect::New();
- DALI_TEST_CHECK( effect );
-
- Image effectImage = CreateBufferImage();
- effect.SetEffectImage(effectImage);
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- Property::Index index = effect.GetPropertyIndex( effect.GetDistortionPropertyName());
- float value;
- (effect.GetProperty(index)).Get( value );
- DALI_TEST_EQUALS(value, 0.f, TEST_LOCATION );
- END_TEST;
-}
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-
-void utc_distance_field_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_distance_field_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-namespace
-{
-// Create buffer image
-BufferImage CreateDistanceField()
-{
- BufferImage image = BufferImage::New(256, 256, Pixel::RGBA8888);
- BufferImage distanceFieldImage = BufferImage::New(256, 256, Pixel::L8);
-
- PixelBuffer* pixbuf = image.GetBuffer();
-
- for(size_t i=0; i<16; i++)
- {
- pixbuf[i*4+0] = 0xFF;
- pixbuf[i*4+1] = 0xFF;
- pixbuf[i*4+2] = 0xFF;
- pixbuf[i*4+3] = 0xFF;
- }
-
- // GenerateDistanceFieldMap(distanceFieldImage.GetBuffer(), Size(256, 256), pixbuf, Size(256, 256), 8, 4);
-
- return distanceFieldImage;
-}
-}
-
-int UtcDaliDistanceFieldEffectUninitialized(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::DistanceFieldEffect effect;
-
- try
- {
- // New() must be called to create a DistanceField effect or it wont be valid.
- effect.SetShadow( true );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK(!effect);
- }
- END_TEST;
-}
-
-int UtcDaliDistanceFieldEffectPropertyNames(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::DistanceFieldEffect effect = Toolkit::DistanceFieldEffect::New();
-
- // Check the names, this names are used in the shaders code,
- // if they change the shader code has to be updated
- DALI_TEST_EQUALS( effect.GetColorPropertyName(), "uColor", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetSmoothingPropertyName(), "uSmoothing", TEST_LOCATION );
-
- // control flags
- DALI_TEST_EQUALS( effect.GetOutlineEnablePropertyName(), "uDoOutline", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetGlowEnablePropertyName(), "uDoGlow", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetShadowEnablePropertyName(), "uDoShadow", TEST_LOCATION );
-
- DALI_TEST_EQUALS( effect.GetGlowBoundaryPropertyName(), "uGlowBoundary", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetGlowColorPropertyName(), "uGlowColor", TEST_LOCATION );
-
- DALI_TEST_EQUALS( effect.GetOutlineColorPropertyName(), "uOutlineColor", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetOutlineSizePropertyName(), "uOutlineParams", TEST_LOCATION );
-
- DALI_TEST_EQUALS( effect.GetShadowColorPropertyName(), "uShadowColor", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetShadowOffsetPropertyName(), "uShadowOffset", TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliDistanceFieldEffectDefaultValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::DistanceFieldEffect effect = Toolkit::DistanceFieldEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateDistanceField();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetOutlineEnablePropertyName().c_str(),
- 0.0f ));
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetGlowEnablePropertyName().c_str(),
- 0.0f ));
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetShadowEnablePropertyName().c_str(),
- 0.0f ));
- END_TEST;
-}
-
-int UtcDaliDistanceFieldEffectCustomValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::DistanceFieldEffect effect = Toolkit::DistanceFieldEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateDistanceField();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
-
- effect.SetShadowColor(Color::YELLOW);
- effect.SetGlowColor(Color::BLUE);
-
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- // Gets converted to opengl viewport coordinates
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetShadowColorPropertyName().c_str(),
- Color::YELLOW ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetGlowColorPropertyName().c_str(),
- Color::BLUE ) );
- END_TEST;
-}
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-
-// Need to override adaptor classes for toolkit test harness, so include
-// test harness headers before dali headers.
-#include <dali-toolkit-test-suite-utils.h>
-
-#include <dali.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-
-void utc_dali_toolkit_iris_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_toolkit_iris_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-int UtcDaliIrisEffectUninitialized(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::IrisEffect effect;
-
- try
- {
- // New() must be called to create a IrisEffect or it wont be valid.
- effect.SetRadius( 2.0f );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK(!effect);
- }
- END_TEST;
-}
-
-int UtcDaliIrisEffectPropertyNames(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::IrisEffect effect = Toolkit::IrisEffect::New();
-
- // Check the names, this names are used in the shaders code,
- // if they change the shader code has to be updated
- DALI_TEST_EQUALS( effect.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetBlendFactorPropertyName(), "uBlendFactor", TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliIrisEffectDefaultValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::IrisEffect effect = Toolkit::IrisEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
-
- const float radiusValue(0.0f);
- const Vector2 centerValue(0.5f, 0.5f);
- const float blendFactorValue(100.0f);
-
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- TestGlAbstraction& gl = application.GetGlAbstraction();
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetBlendFactorPropertyName().c_str(), blendFactorValue ) );
- END_TEST;
-}
-
-int UtcDaliIrisEffectCustomValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::IrisEffect effect = Toolkit::IrisEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
-
- const float radiusValue(23.0f);
- const Vector2 centerValue(0.2f, 0.7f);
- const float blendFactorValue(10.0f);
-
- effect.SetRadius( radiusValue );
- effect.SetCenter( centerValue );
- effect.SetBlendFactor( blendFactorValue );
-
- actor.SetShaderEffect(effect);
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render();
-
- TestGlAbstraction& gl = application.GetGlAbstraction();
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetBlendFactorPropertyName().c_str(), blendFactorValue ) );
- END_TEST;
-}
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-
-// Need to override adaptor classes for toolkit test harness, so include
-// test harness headers before dali headers.
-#include <dali-toolkit-test-suite-utils.h>
-
-#include <dali.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-
-void utc_dali_toolkit_mask_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_toolkit_mask_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-int UtcDaliMaskEffectCreateEffect(void)
-{
- ToolkitTestApplication application;
-
- BufferImage image = CreateBufferImage();
-
- ShaderEffect effect = Toolkit::MaskEffect::New( image );
- DALI_TEST_CHECK( effect );
- END_TEST;
-}
-
-int UtcDaliMaskEffectDestructor(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::MaskEffect* effect = new Toolkit::MaskEffect();
- delete effect;
-
- DALI_TEST_CHECK( true );
- END_TEST;
-}
#include <dali.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/public-api/shader-effects/nine-patch-mask-effect.h>
using namespace Dali;
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-void overlay_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void overlay_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-int UtcDaliOverlayConstructor(void)
-{
- ToolkitTestApplication application;
-
- BufferImage image = CreateBufferImage();
-
- Toolkit::OverlayEffect effect = Toolkit::OverlayEffect::New( image );
- DALI_TEST_CHECK( effect );
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- END_TEST;
-}
-
-int UtcDaliOverlayUninitializedEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::OverlayEffect effect;
-
- try
- {
- BufferImage image = CreateBufferImage();
-
- // New() must be called to create a OverlayEffect or it wont be valid.
- effect.SetEffectImage( image );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK(!effect);
- }
- END_TEST;
-}
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-
-using namespace Dali;
-
-void page_turn_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void page_turn_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-int UtcDaliPageTurnEffectApply(void)
-{
- ToolkitTestApplication application;
-
- BufferImage image = CreateBufferImage();
-
- Toolkit::PageTurnEffect pageTurnEffect = Toolkit::PageTurnEffect::New();
- Toolkit::PageTurnEffect pageTurnEffect2 = Toolkit::PageTurnEffect::New(false);
-
- ImageActor pageActor = ImageActor::New( image );
- ImageActor backPageActor = ImageActor::New( image );
- pageActor.Add( backPageActor );
-
- pageTurnEffect.SetIsTurningBack( true );
- pageTurnEffect.SetShadowWidth( 0.0f );
- pageTurnEffect.SetSpineShadowParameter( Vector2( 0.0f, 0.0f ) );
-
- pageActor.SetShaderEffect( pageTurnEffect );
- Stage::GetCurrent().Add( pageActor );
-
- application.SendNotification();
- application.Render();
-
- const Vector2 pageSize( 0.0f, 0.0f );
- pageTurnEffect.SetPageSize( pageSize );
-
- const Vector2 originalCenter( 0.0f, 0.0f );
- pageTurnEffect.SetOriginalCenter( originalCenter );
-
- const Vector2 currentCenter( 0.0f, 0.0f );
- pageTurnEffect.SetCurrentCenter( currentCenter );
-
- application.SendNotification();
- application.Render();
-
- TestGlAbstraction& gl = application.GetGlAbstraction();
- DALI_TEST_CHECK( gl.CheckUniformValue( pageTurnEffect.GetPageSizePropertyName().c_str(), pageSize ) );
- DALI_TEST_CHECK( gl.CheckUniformValue( pageTurnEffect.GetOriginalCenterPropertyName().c_str(), originalCenter ) );
- DALI_TEST_CHECK( gl.CheckUniformValue( pageTurnEffect.GetCurrentCenterPropertyName().c_str(), currentCenter ) );
- END_TEST;
-}
-
-int UtcDaliPageTurnEffectConstruct(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::PageTurnEffect* effect = new Toolkit::PageTurnEffect();
- delete effect;
-
- DALI_TEST_CHECK( true );
- END_TEST;
-}
factory.EnableOffscreenRendering( );
PageTurnView pageTurnView = PageTurnLandscapeView::New( factory, PAGE_SIZE );
- pageTurnView.SetRelayoutEnabled( false );
pageTurnView.SetPositionInheritanceMode( USE_PARENT_POSITION );
Stage::GetCurrent().Add( pageTurnView );
factory.EnableOffscreenRendering( );
PageTurnView pageTurnView = PageTurnPortraitView::New( factory, PAGE_SIZE );
- pageTurnView.SetRelayoutEnabled( false );
pageTurnView.SetParentOrigin( ParentOrigin::TOP_LEFT );
pageTurnView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
Stage::GetCurrent().Add( pageTurnView );
TestPageFactory factory(application);
factory.EnableOffscreenRendering( );
PageTurnView pageTurnView = PageTurnPortraitView::New( factory, PAGE_SIZE );
- pageTurnView.SetRelayoutEnabled( false );
pageTurnView.SetParentOrigin( ParentOrigin::TOP_LEFT );
pageTurnView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
Stage::GetCurrent().Add( pageTurnView );
TestPageFactory factory(application);
Vector2 size = Stage::GetCurrent().GetSize();
PageTurnView portraitView = PageTurnPortraitView::New( factory, size );
- portraitView.SetRelayoutEnabled( false );
portraitView.SetPositionInheritanceMode( USE_PARENT_POSITION );
Stage::GetCurrent().Add( portraitView );
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-
-// Need to override adaptor classes for toolkit test harness, so include
-// test harness headers before dali headers.
-#include <dali-toolkit-test-suite-utils.h>
-
-#include <dali.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-
-
-void utc_dali_toolkit_ripple_2d_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_toolkit_ripple_2d_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-int UtcDaliRipple2DEffectUninitialized(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::Ripple2DEffect effect;
-
- try
- {
- // New() must be called to create a Ripple2DEffect or it wont be valid.
- effect.SetAmplitude( 0.5f );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK(!effect);
- }
- END_TEST;
-}
-
-int UtcDaliRipple2DEffectPropertyNames(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::Ripple2DEffect effect = Toolkit::Ripple2DEffect::New();
-
- // Check the names, this names are used in the shaders code,
- // if they change the shader code has to be updated
- DALI_TEST_EQUALS( effect.GetAmplitudePropertyName(), "uAmplitude", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetTimePropertyName(), "uTime", TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliRipple2DEffectDefaultValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::Ripple2DEffect effect = Toolkit::Ripple2DEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetAmplitudePropertyName().c_str(),
- 0.0f ) );
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetTimePropertyName().c_str(),
- 0.0f ) );
- END_TEST;
-}
-
-int UtcDaliRipple2DEffectCustomValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::Ripple2DEffect effect = Toolkit::Ripple2DEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
-
- effect.SetAmplitude( 5.0f );
- effect.SetTime( 2.0f );
-
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetAmplitudePropertyName().c_str(),
- 5.0f ) );
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetTimePropertyName().c_str(),
- 2.0f ) );
- END_TEST;
-}
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-
-// Need to override adaptor classes for toolkit test harness, so include
-// test harness headers before dali headers.
-#include <dali-toolkit-test-suite-utils.h>
-
-#include <dali.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-
-void utc_dali_toolkit_ripple_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_toolkit_ripple_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-int UtcDaliRippleUninitializedEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::RippleEffect effect;
-
- try
- {
- // New() must be called to create a RippleEffect or it wont be valid.
- effect.SetAmplitude( 0.5f );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK(!effect);
- }
- END_TEST;
-}
-
-int UtcDaliRipplePropertyNamesEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::RippleEffect effect = Toolkit::RippleEffect::New();
-
- // Check the names, this names are used in the shaders code,
- // if they change the shader code has to be updated
- DALI_TEST_EQUALS( effect.GetAmplitudePropertyName(), "uAmplitude", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetTimePropertyName(), "uTime", TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliRippleDefaultValuesEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::RippleEffect effect = Toolkit::RippleEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetAmplitudePropertyName().c_str(),
- 0.0f ) );
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetCenterPropertyName().c_str(),
- Vector2( 0.0f, 0.0f ) ) );
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetTimePropertyName().c_str(),
- 0.0f ) );
- END_TEST;
-}
-
-int UtcDaliRippleCustomValuesEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::RippleEffect effect = Toolkit::RippleEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
-
- effect.SetAmplitude( 0.5f );
- effect.SetCenter( Vector2( 10.0f, 10.0f ) );
- effect.SetTime( 2.0f );
-
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetAmplitudePropertyName().c_str(),
- 0.5f ) );
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetCenterPropertyName().c_str(),
- Vector2( 10.0f, 10.0f ) ) );
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetTimePropertyName().c_str(),
- 2.0f ) );
- END_TEST;
-}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+
+using namespace Dali;
+
+int UtcDaliCreateAlphaDiscardEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateAlphaDiscardEffect();
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateBendyEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateBendyEffect();
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateBlindEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateBlindEffect();
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateBouncingEffect(void)
+{
+ ToolkitTestApplication application;
+
+ Vector4 color(1.0f,1.0f,1.0f,1.0f);
+
+ ShaderEffect effect = Toolkit::CreateBouncingEffect(color);
+ DALI_TEST_CHECK( effect );
+
+ Property::Value value = effect.GetProperty( effect.GetPropertyIndex("uAssignedColor"));
+ DALI_TEST_EQUALS( value.Get<Vector4>(), color, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliCreateCarouselEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateCarouselEffect();
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateDisplacementEffectDisplaced(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateDisplacementEffect(Toolkit::DISPLACEMENT_EFFECT_DISPLACED);
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateDisplacementEffectFixed(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateDisplacementEffect(Toolkit::DISPLACEMENT_EFFECT_FIXED);
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateDissolveEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateDissolveEffect();
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateDissolveEffectMediumPrecision(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateDissolveEffect(false);
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateDissolveLocalEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateDissolveLocalEffect(0);
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateDistanceFieldEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateDistanceFieldEffect();
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateImageRegionEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateImageRegionEffect();
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateIrisEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateIrisEffect();
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateMaskEffect(void)
+{
+ ToolkitTestApplication application;
+
+ BufferImage image = CreateBufferImage();
+ ShaderEffect effect = Toolkit::CreateMaskEffect(image);
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateMirrorEffect(void)
+{
+ ToolkitTestApplication application;
+
+ BufferImage image = CreateBufferImage();
+ ShaderEffect effect = Toolkit::CreateMirrorEffect();
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateMotionBlurEffect(void)
+{
+ ToolkitTestApplication application;
+
+ unsigned int sampleCount(4);
+ ShaderEffect effect = Toolkit::CreateMotionBlurEffect(sampleCount);
+ DALI_TEST_CHECK( effect );
+
+ Property::Value value = effect.GetProperty( effect.GetPropertyIndex("uNumSamples"));
+ DALI_TEST_EQUALS( value.Get<float>(), (float)sampleCount, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliCreateMotionStretchEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateMotionStretchEffect();
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateOverlayEffect(void)
+{
+ ToolkitTestApplication application;
+
+ BufferImage image = CreateBufferImage();
+ ShaderEffect effect = Toolkit::CreateOverlayEffect(image);
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateQuadraticBezier(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateQuadraticBezier(3,false);
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateQuadraticBezierFilled(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateQuadraticBezier(3,true);
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateRipple2DEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateRipple2DEffect();
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateRippleEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateRippleEffect();
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateShearEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateShearEffect();
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliSoftButtonEffectElliptical(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateSoftButtonEffect(Toolkit::SOFT_BUTTON_ELLIPTICAL);
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliSoftButtonEffectRectangular(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateSoftButtonEffect(Toolkit::SOFT_BUTTON_RECTANGULAR);
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliSoftButtonEffectFixed(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateSoftButtonEffect(Toolkit::SOFT_BUTTON_FIXED);
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateSpotEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateSpotEffect();
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliCreateSquareDissolveEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateSquareDissolveEffect();
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliSwirlEffect(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateSwirlEffect(false);
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+
+int UtcDaliSwirlEffectWrap(void)
+{
+ ToolkitTestApplication application;
+
+ ShaderEffect effect = Toolkit::CreateSwirlEffect(true);
+ DALI_TEST_CHECK( effect );
+
+ END_TEST;
+}
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-
-void shear_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void shear_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-int UtcDaliShearEffectUninitialized(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::ShearEffect effect;
-
- try
- {
- // New() must be called to create a ShearEffect or it wont be valid.
- effect.SetAngleXAxis( 45.0f );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK(!effect);
- }
- END_TEST;
-}
-
-int UtcDaliShearEffectPropertyNames(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::ShearEffect effect = Toolkit::ShearEffect::New();
-
- // Check the names, these names are used in the shaders code,
- // if they change the shader code has to be updated
- DALI_TEST_EQUALS( effect.GetAngleXAxisPropertyName(), "uAngleXAxis", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetAngleYAxisPropertyName(), "uAngleYAxis", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
- END_TEST;
-}
-
-namespace
-{
-
-/**
- * Converts value to screen position in the same way that
- * the core does under COORDINATE_TYPE_SCREEN_POSITION
- *
- * @param[in] value the input position value.
- * @return The translated position value ready for gl.
- */
-Vector2 ToScreenPosition(Vector2 value)
-{
- Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
- value.x = stageSize.x * 0.5f - value.x;
- value.y = value.y - stageSize.y * 0.5f;
-
- return value;
-}
-
-}// namespace
-
-int UtcDaliShearEffectDefaultValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::ShearEffect effect = Toolkit::ShearEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
-
- const float angleXAxis(0.0f);
- const float angleYAxis(0.0f);
- const Vector2 centerValue(0.0f, 0.0f);
-
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- TestGlAbstraction& gl = application.GetGlAbstraction();
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAngleXAxisPropertyName().c_str(), angleXAxis ) );
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAngleYAxisPropertyName().c_str(), angleYAxis ) );
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), ToScreenPosition(centerValue) ) );
- END_TEST;
-}
-
-int UtcDaliShearEffectCustomValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::ShearEffect effect = Toolkit::ShearEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
-
- const float angleXAxis(10.0f);
- const float angleYAxis(22.5f);
- const Vector2 centerValue(50.0f, 100.0f);
-
- effect.SetAngleXAxis( angleXAxis );
- effect.SetAngleYAxis( angleYAxis );
- effect.SetCenter( centerValue );
-
- actor.SetShaderEffect(effect);
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render();
-
- TestGlAbstraction& gl = application.GetGlAbstraction();
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAngleXAxisPropertyName().c_str(), angleXAxis ) );
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAngleYAxisPropertyName().c_str(), angleYAxis ) );
- DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), ToScreenPosition(centerValue) ) );
- END_TEST;
-}
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-using namespace Dali::Toolkit;
-
-void soft_button_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void soft_button_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-// Negative test case for a method
-int UtcDaliSoftButtonEffectUninitialized(void)
-{
- ToolkitTestApplication application;
- tet_infoline("UtcDaliSoftButtonEffectUninitialized");
-
- Toolkit::SoftButtonEffect effect;
-
- // New() must be called to create a SoftButtonEffect or it wont be valid.
-
- DALI_TEST_CHECK(!effect);
- END_TEST;
-}
-
-// Positive test case for a method
-int UtcDaliSoftButtonEffectNew(void)
-{
- ToolkitTestApplication application;
- tet_infoline("UtcDaliGaussianBlurViewNew");
-
- Toolkit::SoftButtonEffect effect = Toolkit::SoftButtonEffect::New(Toolkit::SoftButtonEffect::ELLIPTICAL);
- DALI_TEST_CHECK( effect );
- END_TEST;
-}
-
-// Positive test case for a method
-int UtcDaliSoftButtonEffectPropertyNames(void)
-{
- ToolkitTestApplication application;
- tet_infoline("UtcDaliSoftButtonEffectPropertyNames");
-
- Toolkit::SoftButtonEffect effect = Toolkit::SoftButtonEffect::New(Toolkit::SoftButtonEffect::ELLIPTICAL);
- DALI_TEST_CHECK( effect );
-
- // Check the names, this names are used in the shader code,
- // if they change in the shader code, then it has to be updated here.
- DALI_TEST_EQUALS( effect.GetLightingIndentationAmountPropertyName(), "uLightingIndentationAmount", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetTextureDistortionAmountPropertyName(), "uTextureDistortAmount", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetAmbientLightAmountPropertyName(), "uAmbientLight", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetDiffuseLightPropertyName(), "uDiffuseLight", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetLightingMultiplierPropertyName(), "uLightMultiplier", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetInsideShapeSizeScalePropertyName(), "uInsideCircleSizeScale", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetOutsideShapeDepthPropertyName(), "uOutsideCircleDepth", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetEffectPixelAreaPropertyName(), "uEffectRegion", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetRectangleSizeScalePropertyName(), "uRectangleSizeScale", TEST_LOCATION );
- END_TEST;
-}
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-
-using namespace Dali;
-
-void spot_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void spot_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-int UtcDaliSpotUninitializedEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::SpotEffect effect;
-
- try
- {
- // New() must be called to create a SpotEffect or it wont be valid.
- effect.SetRadius( 0.5f );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK(!effect);
- }
- END_TEST;
-}
-
-int UtcDaliSpotPropertyNamesEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::SpotEffect effect = Toolkit::SpotEffect::New();
-
- // Check the names, this names are used in the shaders code,
- // if they change the shader code has to be updated
- DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliSpotDefaultValuesEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::SpotEffect effect = Toolkit::SpotEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- // Gets converted to opengl viewport coordinates
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetCenterPropertyName().c_str(),
- Vector2(0.0f, 0.0f) ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetRadiusPropertyName().c_str(),
- 0.0f ) );
- END_TEST;
-}
-
-int UtcDaliSpotCustomValuesEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::SpotEffect effect = Toolkit::SpotEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
-
- effect.SetCenter( Vector2(480.0f, 800.0f) );
- effect.SetRadius( 5.0f );
-
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- // Gets converted to opengl viewport coordinates
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetCenterPropertyName().c_str(),
- Vector2(480.0f, 800.0f) ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetRadiusPropertyName().c_str(),
- 5.0f ) );
- END_TEST;
-}
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-
-using namespace Dali;
-
-void square_dissolve_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void square_dissolve_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-int UtcDaliSquareDissolveEffectUninitialized(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::SquareDissolveEffect effect;
-
- try
- {
- // New() must be called to create a SquareDissolveEffect or it wont be valid.
- effect.SetStep( 2.0f );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK(!effect);
- }
- END_TEST;
-}
-
-int UtcDaliSquareDissolveEffectPropertyNames(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::SquareDissolveEffect effect = Toolkit::SquareDissolveEffect::New();
-
- // Check the names, this names are used in the shaders code,
- // if they change the shader code has to be updated
- DALI_TEST_EQUALS( effect.GetStepPropertyName(), "uStep", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetRowsPropertyName(), "uRows", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetColumnsPropertyName(), "uColumns", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetTexSizePropertyName(), "texSize", TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliSquareDissolveEffectDefaultValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::SquareDissolveEffect effect = Toolkit::SquareDissolveEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- // Gets converted to opengl viewport coordinates
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetStepPropertyName().c_str(),
- 0.1f ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetRowsPropertyName().c_str(),
- 25.0f ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetColumnsPropertyName().c_str(),
- 25.0f ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetTexSizePropertyName().c_str(),
- Vector2(1.0f, 1.0f) ) );
- END_TEST;
-}
-
-int UtcDaliSquareDissolveEffectCustomValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::SquareDissolveEffect effect = Toolkit::SquareDissolveEffect::New();
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
-
- effect.SetStep( 2.0f );
- effect.SetRows( 3.0f );
- effect.SetColumns( 4.0f );
- effect.SetTextureSize( Vector2(12.0f, 13.0f) );
-
- actor.SetShaderEffect(effect);
- Stage::GetCurrent().Add(actor);
-
- application.SendNotification();
- application.Render();
-
- // Gets converted to opengl viewport coordinates
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetStepPropertyName().c_str(),
- 2.0f ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetRowsPropertyName().c_str(),
- 3.0f ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetColumnsPropertyName().c_str(),
- 4.0f ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetTexSizePropertyName().c_str(),
- Vector2(12.0f, 13.0f) ) );
- END_TEST;
-}
tet_infoline( "UtcDaliSuperBlurViewGetBlurredImage" );
SuperBlurView blurView = SuperBlurView::New( BLUR_LEVELS );
- blurView.SetRelayoutEnabled( false );
blurView.SetSize( 100.f,100.f );
Image inputImage = CreateSolidColorImage( application, Color::GREEN, 100, 100 );
blurView.SetImage( inputImage );
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-
-// Need to override adaptor classes for toolkit test harness, so include
-// test harness headers before dali headers.
-#include <dali-toolkit-test-suite-utils.h>
-
-#include <dali.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-
-
-void utc_dali_toolkit_swirl_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_toolkit_swirl_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-int UtcDaliSwirlUninitializedEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::SwirlEffect effect;
-
- try
- {
- // New() must be called to create a SwirlEffect or it wont be valid.
- effect.SetRadius( 0.5f );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK(!effect);
- }
- END_TEST;
-}
-
-int UtcDaliSwirlPropertyNamesEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::SwirlEffect effect = Toolkit::SwirlEffect::New(false);
-
- // Check the names, this names are used in the shaders code,
- // if they change the shader code has to be updated
- DALI_TEST_EQUALS( effect.GetAnglePropertyName(), "uAngle", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliSwirlDefaultValuesEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::SwirlEffect effect = Toolkit::SwirlEffect::New(true);
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- // Gets converted to opengl viewport coordinates
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetAnglePropertyName().c_str(),
- 0.0f ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetCenterPropertyName().c_str(),
- Vector2(0.5f, 0.5f) ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetRadiusPropertyName().c_str(),
- 1.0f ) );
- END_TEST;
-}
-
-int UtcDaliSwirlCustomValuesEffect(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::SwirlEffect effect = Toolkit::SwirlEffect::New(false);
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
-
- effect.SetAngle( 1.0f );
- effect.SetCenter( Vector2(0.3f, 0.7f) );
- effect.SetRadius( 2.0f );
-
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- // Gets converted to opengl viewport coordinates
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetAnglePropertyName().c_str(),
- 1.0f ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetCenterPropertyName().c_str(),
- Vector2(0.3f, 0.7f) ) );
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetRadiusPropertyName().c_str(),
- 2.0f ) );
- END_TEST;
-}
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <dali-toolkit-test-suite-utils.h>
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-
-void dali_water_effect_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void dali_water_effect_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-
-int UtcDaliWaterEffectUninitialized(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::WaterEffect effect;
-
- try
- {
- // New() must be called to create a RippleEffect or it wont be valid.
- effect.SetAmplitude( 0, 0.5f );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK(!effect);
- }
- END_TEST;
-}
-
-int UtcDaliWaterEffectPropertyNames(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::WaterEffect effect = Toolkit::WaterEffect::New(4);
- DALI_TEST_CHECK( effect );
-
- // Check the names, this names are used in the shaders code,
- // if they change the shader code has to be updated
- DALI_TEST_EQUALS( effect.GetAmplitudePropertyName( 0 ), "uDrops[0].amplitude", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetCenterPropertyName( 0 ), "uDrops[0].center", TEST_LOCATION );
- DALI_TEST_EQUALS( effect.GetPropagationPropertyName( 0 ), "uDrops[0].radius", TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliWaterEffectOutOfBounds(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::WaterEffect effect = Toolkit::WaterEffect::New(4);
- DALI_TEST_CHECK( effect );
-
- try
- {
- // the highest index acceptable is (GetNumberOfWaves() - 1)
- effect.SetAmplitude( effect.GetNumberOfWaves(), 0 );
- DALI_TEST_CHECK( false );
- }
- catch (Dali::DaliException& e)
- {
- // Tests that a negative test of an assertion succeeds
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_CHECK( true );
- }
- END_TEST;
-}
-
-int UtcDaliWaterEffectDefaultValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::WaterEffect effect = Toolkit::WaterEffect::New(4);
- DALI_TEST_CHECK( effect );
-
- // Check that the effect has the number of waves it was requested
- DALI_TEST_CHECK( effect.GetNumberOfWaves() == 4 );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- application.SendNotification();
- application.Render();
-
- Vector2 topLeft( Stage::GetCurrent().GetSize() * 0.5f );
- topLeft.y = -topLeft.y;
-
- for ( unsigned int i = 0; i < effect.GetNumberOfWaves(); ++i )
- {
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetAmplitudePropertyName(i).c_str(),
- 0.0f ) );
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetCenterPropertyName(i).c_str(),
- topLeft ) );
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetPropagationPropertyName(i).c_str(),
- 0.0f ) );
- }
- END_TEST;
-}
-
-int UtcDaliWaterEffectCustomValues(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::WaterEffect effect = Toolkit::WaterEffect::New(4);
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- effect.SetAmplitude( 0, 0.5f );
- effect.SetCenter( 0, Vector2 ( 10.0f, 10.0f ) );
- effect.SetPropagation( 0, 2.0f );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetAmplitudePropertyName(0).c_str(),
- 0.5f ) );
-
- Vector2 centerPoint( Stage::GetCurrent().GetSize() * 0.5f );
- centerPoint.y = -centerPoint.y;
-
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetCenterPropertyName(0).c_str(),
- Vector2( centerPoint.x - 10.0f, centerPoint.y + 10.0f ) ) );
- DALI_TEST_CHECK(
- application.GetGlAbstraction().CheckUniformValue(
- effect.GetPropagationPropertyName(0).c_str(),
- 2.0f ) );
- END_TEST;
-}
-
-int UtcDaliWaterEffectGetAmplitudePositive(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::WaterEffect effect = Toolkit::WaterEffect::New(4);
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- float amplitude(0.5f);
- DALI_TEST_CHECK(effect.GetAmplitude(0) != amplitude);
- effect.SetAmplitude( 0, amplitude );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS(amplitude, effect.GetAmplitude(0), TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliWaterEffectGetAmplitudeNegative(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::WaterEffect effect = Toolkit::WaterEffect::New(4);
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- try
- {
- effect.GetAmplitude(9999);
- tet_result(TET_FAIL);
- }
- catch(DaliException& e)
- {
- DALI_TEST_ASSERT(e, "index < mNumberOfWaves", TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliWaterEffectGetCenterPositive(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::WaterEffect effect = Toolkit::WaterEffect::New(4);
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- Vector2 center(10.0f, 20.0f);
- DALI_TEST_CHECK(effect.GetCenter(0) != center);
- effect.SetCenter( 0, center );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS(center, effect.GetCenter(0), TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliWaterEffectGetCenterNegative(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::WaterEffect effect = Toolkit::WaterEffect::New(4);
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- try
- {
- effect.GetCenter(9999);
- tet_result(TET_FAIL);
- }
- catch(DaliException& e)
- {
- DALI_TEST_ASSERT(e, "index < mNumberOfWaves", TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliWaterEffectGetPropagationPositive(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::WaterEffect effect = Toolkit::WaterEffect::New(4);
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- float propagation(0.5f);
- DALI_TEST_CHECK(effect.GetPropagation(0) != propagation);
- effect.SetPropagation( 0, propagation );
-
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS(propagation, effect.GetPropagation(0), TEST_LOCATION);
- END_TEST;
-}
-
-int UtcDaliWaterEffectGetPropagationNegative(void)
-{
- ToolkitTestApplication application;
-
- Toolkit::WaterEffect effect = Toolkit::WaterEffect::New(4);
- DALI_TEST_CHECK( effect );
-
- BufferImage image = CreateBufferImage();
-
- ImageActor actor = ImageActor::New( image );
- actor.SetSize( 100.0f, 100.0f );
- actor.SetShaderEffect( effect );
- Stage::GetCurrent().Add( actor );
-
- try
- {
- effect.GetPropagation(9999);
- tet_result(TET_FAIL);
- }
- catch(DaliException& e)
- {
- DALI_TEST_ASSERT(e, "index < mNumberOfWaves", TEST_LOCATION );
- }
- END_TEST;
-}
publicapibuilder_HEADERS = $(public_api_builder_header_files)
publicapifocusmanager_HEADERS = $(public_api_focus_manager_header_files)
publicapishadereffects_HEADERS = $(public_api_shader_effects_header_files)
-publicapibubbleeffect_HEADERS = $(public_api_bubble_effect_header_files)
publicapistyling_HEADERS = $(public_api_styling_header_files)
publicapitransitioneffects_HEADERS = $(public_api_transition_effects_header_files)
publicapiscripting_HEADERS = $(public_api_scripting_header_files)
#include <dali-toolkit/public-api/shader-effects/soft-button-effect.h>
#include <dali-toolkit/public-api/shader-effects/spot-effect.h>
#include <dali-toolkit/public-api/shader-effects/square-dissolve-effect.h>
-#include <dali-toolkit/public-api/shader-effects/water-effect.h>
-#include <dali-toolkit/public-api/shader-effects/bubble-effect/bubble-effect.h>
-#include <dali-toolkit/public-api/shader-effects/bubble-effect/color-adjuster.h>
#include <dali-toolkit/public-api/shader-effects/dissolve-effect.h>
#include <dali-toolkit/public-api/shader-effects/image-region-effect.h>
#include <dali-toolkit/public-api/shader-effects/iris-effect.h>
#include <dali-toolkit/public-api/shader-effects/mask-effect.h>
#include <dali-toolkit/public-api/shader-effects/nine-patch-mask-effect.h>
-#include <dali-toolkit/public-api/shader-effects/page-turn-book-spine-effect.h>
-#include <dali-toolkit/public-api/shader-effects/page-turn-effect.h>
#include <dali-toolkit/public-api/shader-effects/quadratic-bezier.h>
#include <dali-toolkit/public-api/shader-effects/ripple-effect.h>
#include <dali-toolkit/public-api/shader-effects/ripple2d-effect.h>
#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/object/type-registry.h>
+//INTERNAL INCLUDES
+#include <dali-toolkit/public-api/shader-effects/image-region-effect.h>
+
namespace Dali
{
if( !mTickUVEffect )
{
ImageActor imageActor = ImageActor::DownCast( actor );
- mTickUVEffect = ImageRegionEffect::New();
+ mTickUVEffect = CreateImageRegionEffect();
imageActor.SetShaderEffect( mTickUVEffect );
}
actor.SetScale( Vector3( 0.0f, 1.0f, 1.0f ) );
- mTickUVEffect.SetBottomRight( Vector2( 0.0f, 1.0f ) );
+ mTickUVEffect.SetUniform("uBottomRight", Vector2( 0.0f, 1.0f ) );
if( !mTransitionAnimation )
{
}
// UV anim
- mTransitionAnimation.AnimateTo( Property( mTickUVEffect, mTickUVEffect.GetBottomRightPropertyName() ), Vector2( 1.0f, 1.0f ) );
+ mTransitionAnimation.AnimateTo( Property( mTickUVEffect, "uBottomRight" ), Vector2( 1.0f, 1.0f ) );
// Actor size anim
mTransitionAnimation.AnimateTo( Property( actor, Actor::Property::SCALE_X ), 1.0f );
// EXTERNAL INCLUDES
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/animation/animation.h>
+#include <dali/public-api/shader-effects/shader-effect.h>
+
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/buttons/check-box-button.h>
-#include <dali-toolkit/public-api/shader-effects/image-region-effect.h>
#include "button-impl.h"
private:
Animation mTransitionAnimation; ///< Animation used in the state transitions.
- ImageRegionEffect mTickUVEffect; ///< ImageRegionEffect to expand the tick across
+ ShaderEffect mTickUVEffect; ///< ImageRegionEffect to expand the tick across
};
} // namespace Internal
--- /dev/null
+#ifndef __DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H__
+#define __DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H__
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/shader-effects/shader-effect.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+/**
+ * @brief Creates a new PageTurnBookSpineEffect
+ * This is an assisting effect of PageTurnEffect to display a book spine on _static_ pages, and also to flip the image horizontally when needed.
+ *
+ * When the page is turned over in landscape, call
+ * SetIsBackImageVisible(true), this effect can display the back image
+ * correctly after the imageActor been rotated 180 degrees. To
+ * display the pages visually consistent with its turning state,
+ * please set the uniforms with the same values as the PageTurnEffect.
+ *
+ * Animatable/Constrainable uniforms:
+ * "uShadowWidth" - The width of shadow to be pageSize * shadowWidth. This shadow appears at the edges of the actor
+ * which is not visible on static pages
+ * "uSpineShadowParameter" - The two parameters are the major&minor radius (in pixels) to form an ellipse shape. The top-left
+ * quarter of this ellipse is used to calculate spine normal for simulating shadow
+ * "uIsBackImageVisible" - Set whether the current page is with its backside visible. Need to pass the parameter as true for
+ * the page which is turned over but still visible in Landscape
+ * "uPageWidth" - The page width of the PageTurnBookSpineEffect
+ *
+ * @return A handle to a newly allocated ShaderEffect
+ **/
+inline ShaderEffect CreatePageTurnBookSpineEffect()
+{
+ std::string vertexSource(
+ "precision mediump float;\n"
+ "uniform float uShadowWidth;\n"
+ " void main()\n"
+ " {\n"
+ " gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n"
+ " vTexCoord.x = (aTexCoord.x-sTextureRect.s) /( 1.0 - uShadowWidth ) + sTextureRect.s;\n"
+ " vTexCoord.y = ( aTexCoord.y-sTextureRect.t-0.5*uShadowWidth*(sTextureRect.q-sTextureRect.t) )/( 1.0 - uShadowWidth ) + sTextureRect.t;\n"
+ " }");
+
+ // the simplified version of the fragment shader of page turn effect
+ std::string fragmentSource(
+ "precision mediump float;\n"
+ "uniform float uIsBackImageVisible;\n"
+ "uniform float uPageWidth;\n"
+ "uniform vec2 uSpineShadowParameter;\n"
+ " void main()\n"
+ " {\n"
+ // leave the border for display shadow, not visible( out of the screen ) when the page is static
+ " if( vTexCoord.y > sTextureRect.q || vTexCoord.y < sTextureRect.t || vTexCoord.x > sTextureRect.p )\n"
+ " {\n"
+ " gl_FragColor = vec4( 0.0 );\n"
+ " }\n"
+ " else \n"
+ " { \n"
+ // flip the image horizontally by changing the x component of the texture coordinate
+ " if( uIsBackImageVisible == 1.0 ) gl_FragColor = texture2D( sTexture, vec2( sTextureRect.p+sTextureRect.s-vTexCoord.x, vTexCoord.y ) ) * uColor; \n"
+ " else gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n"
+ " \n"
+ // display book spine, a stripe of shadowed texture
+ " float pixelPos = (vTexCoord.x-sTextureRect.s)*uPageWidth; \n"
+ " if(pixelPos < uSpineShadowParameter.x) \n"
+ " {\n"
+ " float x = pixelPos - uSpineShadowParameter.x;\n"
+ " float y = sqrt( uSpineShadowParameter.x*uSpineShadowParameter.x - x*x );\n"
+ " vec2 spineNormal = normalize(vec2(uSpineShadowParameter.y*x/uSpineShadowParameter.x, y));\n"
+ " gl_FragColor.rgb *= spineNormal.y; \n"
+ " }"
+ " }\n"
+ " }" );
+
+ const float DEFAULT_SHADOW_WIDTH(0.15f);
+ const Vector2 DEFAULT_SPINE_SHADOW_PARAMETER(50.0f, 20.0f);
+
+ ShaderEffect shaderEffect = ShaderEffect::New( vertexSource, fragmentSource );
+
+ shaderEffect.SetUniform( "uIsBackImageVisible", -1.f );
+ shaderEffect.SetUniform( "uShadowWidth", DEFAULT_SHADOW_WIDTH );
+ shaderEffect.SetUniform( "uSpineShadowParameter", DEFAULT_SPINE_SHADOW_PARAMETER );
+
+ float defaultPageWidth = Dali::Stage::GetCurrent().GetSize().x;
+ shaderEffect.SetUniform( "uPageWidth", defaultPageWidth/(1.f-DEFAULT_SHADOW_WIDTH) );
+
+ return shaderEffect;
+}
+
+} //namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif /* __DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#include <dali-toolkit/internal/controls/page-turn-view/page-turn-effect.h>
+#include <dali/public-api/math/matrix.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+void CommonParametersConstraint( Dali::Matrix& current, const PropertyInputContainer& inputs )
+{
+ const Vector2& originalCenter = inputs[0]->GetVector2();
+ Vector2 currentCenter = inputs[1]->GetVector2();
+ const Vector2& pageSize = inputs[2]->GetVector2();
+
+ // calculate the curve direction and the vanishing point
+ // here, the vanishing point is the intersection of spine with the line passing through original center and vertical to curve direction
+ Vector2 curveDirection( currentCenter - originalCenter );
+ curveDirection.Normalize();
+ if( fabs(curveDirection.y) < 0.01f) // eliminate the possibility of division by zero in the next step
+ {
+ curveDirection.y = 0.01f;
+ }
+ float vanishingPointY = originalCenter.y + curveDirection.x * originalCenter.x / curveDirection.y;
+
+ float curveEndY, cosTheta ,sinTheta ,translateX, translateY;
+ // when the vanishing point is very far away, make it infinitely, in this case, the page bent horizontally
+ const float THRESHOLD(20.0);
+ if( fabs(vanishingPointY-pageSize.y*0.5f) >= pageSize.y*THRESHOLD )
+ {
+ curveDirection = Vector2(-1.f,0.f);
+ currentCenter.y = originalCenter.y;
+
+ curveEndY = originalCenter.y;
+ cosTheta = 1.f;
+ sinTheta = 0.f;
+ translateX = currentCenter.x - originalCenter.x;
+ translateY = vanishingPointY;
+ }
+ else
+ {
+ curveEndY = currentCenter.y - curveDirection.y * (currentCenter.x/curveDirection.x) ;
+ Vector2 v1( currentCenter.x, currentCenter.y - vanishingPointY );
+ v1.Normalize();
+ Vector2 v2( originalCenter.x, originalCenter.y - vanishingPointY );
+ v2.Normalize();
+ cosTheta = v1.x*v2.x + v1.y*v2.y;
+ sinTheta = ( vanishingPointY > pageSize.y*0.5f ) ? sqrt(1.0-cosTheta*cosTheta) : -sqrt(1.0-cosTheta*cosTheta);
+ translateX = currentCenter.x - cosTheta*originalCenter.x - sinTheta*( originalCenter.y-vanishingPointY );
+ translateY = currentCenter.y + sinTheta*originalCenter.x - cosTheta*( originalCenter.y-vanishingPointY );
+ }
+
+ float originalLength = fabs(originalCenter.x/curveDirection.x);
+ float currentLength = fabs(currentCenter.x/curveDirection.x);
+ float curveHeight = 0.45f*sqrt(originalLength*originalLength - currentLength*currentLength);
+
+ float* parameterArray = current.AsFloat();
+ parameterArray[0] = cosTheta;
+ parameterArray[1] = -sinTheta;
+ parameterArray[2] = originalCenter.x;
+ parameterArray[3] = originalCenter.y;
+ parameterArray[4] = sinTheta;
+ parameterArray[5] = cosTheta;
+ parameterArray[6] = currentCenter.x;
+ parameterArray[7] = currentCenter.y;
+ parameterArray[8] = translateX;
+ parameterArray[9] = translateY;
+ parameterArray[10] = vanishingPointY;
+ parameterArray[11] = curveEndY;
+ parameterArray[12] = curveDirection.x;
+ parameterArray[13] = curveDirection.y;
+ parameterArray[14] = curveHeight;
+ parameterArray[15] = currentLength;
+}
+
+void Dali::Toolkit::Internal::PageTurnApplyInternalConstraint( ShaderEffect& shaderEffect)
+{
+ Constraint constraint = Constraint::New<Dali::Matrix>( shaderEffect, shaderEffect.GetPropertyIndex( "uCommonParameters" ), CommonParametersConstraint );
+ constraint.AddSource( LocalSource( shaderEffect.GetPropertyIndex( "uOriginalCenter" ) ) );
+ constraint.AddSource( LocalSource( shaderEffect.GetPropertyIndex( "uCurrentCenter" ) ) );
+ constraint.AddSource( LocalSource( shaderEffect.GetPropertyIndex( "uPageSize" ) ) );
+ constraint.Apply();
+}
+
+ShaderEffect Dali::Toolkit::Internal::CreatePageTurnEffect(bool enableBlending)
+{
+ std::string vertexShader = DALI_COMPOSE_SHADER(
+ /*
+ * The common parameters for all the vertices, calculate in CPU then pass into the shader as uniforms
+ *
+ * first part of the page, (outside the the line passing through original center and vertical to curve direction)
+ * no Z change, only 2D rotation and translation
+ * ([0][0],[0][1],[1][0],[1][1]) mat2 rotateMatrix
+ * ([2][0],[2][1]) vec2 translationVector
+ *
+ * ([0][2],[0][3]) vec2 originalCenter: Typically the press down position of the Pan Gesture
+ * ([1][2],[1][3]) vec2 currentCenter: Typically the current position of the Pan Gesture
+ * ([3][0],[3][1]) vec2 curveDirection: The normalized vector pointing from original center to current center
+ * ([2][2]) float vanishingPointY: The Y coordinate of the intersection of the spine
+ * and the line which goes through the original center and is vertical to the curveDirection
+ * ([2][3]) float curveEndY: The Y coordinate of intersection of the spine and the line through both original and current center
+ * ([3][2]) float curveHeight: The height of the interpolated hermite curve.
+ * ([3][3]) float currentLength: The length from the current center to the curveEnd.
+ */
+ precision mediump float;\n
+ uniform mat4 uCommonParameters;\n
+ \n
+ uniform vec2 uPageSize;\n
+ uniform float uIsTurningBack;\n
+ uniform float uShadowWidth;\n
+ varying vec3 vNormal;\n
+ varying vec4 vPosition;\n
+ varying float vEdgeShadow;\n
+ \n
+ void main()\n
+ {\n
+ vec4 position = vec4( aPosition.xy, 0.0, 1.0);\n
+ vec2 currentCenter = vec2( uCommonParameters[1][2], uCommonParameters[1][3]);\n
+ vec2 originalCenter = vec2( uCommonParameters[0][2], uCommonParameters[0][3]);\n
+ vec3 normal = vec3(0.0,0.0,1.0);\n
+ \n
+ if(currentCenter.x < originalCenter.x)\n
+ {\n
+ // change the coordinate origin from the center of the page to its top-left
+ position.xy += uPageSize * 0.5;\n
+ vec2 curveDirection = vec2( uCommonParameters[3]);\n
+ vec3 vanishingPoint = vec3(0.0, uCommonParameters[2][2], 0.0);\n
+ // first part of the page, (outside the the line passing through original center and vertical to curve direction)
+ //no Z change, only 2D rotation and translation
+ if( dot(curveDirection, position.xy - originalCenter) < 0.0 )
+ {\n
+ position.y -= vanishingPoint.y;\n
+ position.xy = mat2(uCommonParameters)*position.xy + vec2( uCommonParameters[2]);\n
+ }\n
+ // second part of the page, bent as a ruled surface
+ else\n
+ {\n
+ // calculate on the flat plane, between
+ // the first line passing through current vertex and vanishing point
+ // the second line passing through original center and current center
+ vec2 curveEnd = vec2( 0.0, uCommonParameters[2][3] );\n
+ vec2 curFlatDirection = vec2(0.0,1.0);\n
+ float lengthFromCurve = position.y - originalCenter.y;\n
+ float lengthOnCurve = position.x;\n
+ if(currentCenter.y != originalCenter.y)\n
+ {\n
+ curFlatDirection = normalize(position.xy - vanishingPoint.xy);\n
+ lengthFromCurve = (curveEnd.x*curveDirection.y-curveEnd.y*curveDirection.x-position.x*curveDirection.y+position.y*curveDirection.x)
+ / (curFlatDirection.x*curveDirection.y-curFlatDirection.y*curveDirection.x);\n
+ lengthOnCurve = length(position.xy+lengthFromCurve*curFlatDirection-curveEnd);\n
+ }\n
+ \n
+ // define the control points of hermite curve, composed with two segments
+ // calulation is carried out on the 2D plane which is passing through both current and original center and vertical to the image plane
+ float currentLength = uCommonParameters[3][3];\n
+ float originalLength = abs(originalCenter.x/curveDirection.x);\n
+ float height = uCommonParameters[3][2];\n
+ float percentage = currentLength/originalLength;\n
+ //vec2 SegmentOneControlPoint0 = vec2(0.0, 0.0);
+ vec2 SegmentOneControlPoint1 = vec2((0.65*percentage - 0.15)*originalLength, (0.8 + 0.2 * percentage)*height); \n
+ vec2 SegmentTwoControlPoint0 = SegmentOneControlPoint1;\n
+ vec2 SegmentTwoControlPoint1 = vec2(currentLength, 0.0); \n
+ vec2 SegmentOneTangentVector0 = SegmentOneControlPoint1;\n
+ vec2 SegmentOneTangentVector1 = vec2(0.5*originalLength,0.0);\n
+ vec2 SegmentTwoTangentVector0 = SegmentOneTangentVector1;\n
+ vec2 SegmentTwoTangentVector1 = SegmentOneTangentVector1;\n
+ \n
+ // calulate the corresponding curve point position and its tangent vector
+ // it is a linear mapping onto nonlinear curves, might cause some unwanted deformation
+ // but as there are no analytical method to calculate the curve length on arbitrary segment
+ // no efficient way to solve this nonlinear mapping, Numerical approximation would cost too much computation in shader
+ vec2 curvePoint2D;\n
+ vec2 tangent;\n
+ float t0 = lengthOnCurve / originalLength;\n
+ if(t0<=0.5)\n
+ {\n
+ float t = 2.0*t0;\n
+ float t_2 = t*t;\n
+ float t_3 = t*t_2;\n
+ curvePoint2D = (-2.0*t_3+3.0*t_2)*SegmentOneControlPoint1
+ + (t_3-2.0*t_2+t)*SegmentOneTangentVector0 + (t_3-t_2)*SegmentOneTangentVector1;\n
+ tangent = (-6.0*t_2+6.0*t)*SegmentOneControlPoint1
+ + (3.0*t_2-4.0*t+1.0)*SegmentOneTangentVector0 + (3.0*t_2-2.0*t)*SegmentOneTangentVector1;\n
+ }\n
+ else\n
+ {\n
+ float t = 2.0*t0-1.0;\n
+ float t_2 = t*t;\n
+ float t_3 = t*t_2;\n
+ curvePoint2D = (2.0*t_3-3.0*t_2+1.0)*SegmentTwoControlPoint0 + (-2.0*t_3+3.0*t_2)*SegmentTwoControlPoint1
+ + (t_3-2.0*t_2+t)*SegmentTwoTangentVector0 + (t_3-t_2)*SegmentTwoTangentVector1;\n
+ tangent = (6.0*t_2-6.0*t)*SegmentTwoControlPoint0 + (-6.0*t_2+6.0*t)*SegmentTwoControlPoint1
+ + (3.0*t_2-4.0*t+1.0)*SegmentTwoTangentVector0 + (3.0*t_2-2.0*t)*SegmentTwoTangentVector1;\n
+ // a trick to eliminate some optical illusion caused by the gradient matter of normal in per-fragment shading
+ // which is caused by linear interpolation of normal vs. nonlinear lighting
+ // will notice some artifact in the areas with dramatically normal changes, so compress the normal differences here
+ tangent.y *= min(1.0, length(position.xyz - vanishingPoint) / uPageSize.y ); \n
+ }\n
+ vec3 curvePoint = vec3(curveEnd - curvePoint2D.x*curveDirection,max(0.0,curvePoint2D.y));\n
+ vec3 tangentVector = vec3(-tangent.x*curveDirection,tangent.y);\n
+ \n
+ // locate the new vertex position on the line passing through both vanishing point and the calculated curve point position
+ vec3 curLiftDirection = vec3(0.0,-1.0,0.0);\n
+ if(currentCenter.y != originalCenter.y)\n
+ {\n
+ curLiftDirection = normalize(curvePoint - vanishingPoint);\n
+ tangentVector *= (curveDirection.y > 0.0) ? -1.0 : 1.0;\n
+ // an heuristic adjustment here, to compensate the linear parameter mapping onto the nonlinear curve
+ float Y0 = position.y - curveDirection.y * (position.x/curveDirection.x); \n
+ float proportion;
+ float refLength;\n
+ if(abs(Y0-vanishingPoint.y) > abs(curveEnd.y-vanishingPoint.y)) \n
+ {\n
+ proportion = abs(curveEnd.y - Y0) / (abs(curveEnd.y-Y0)+abs(curveEnd.y - vanishingPoint.y)); \n
+ refLength = proportion*length(originalCenter-vanishingPoint.xy) / (proportion-1.0); \n
+ }\n
+ else\n
+ {\n
+ proportion = abs(curveEnd.y - Y0) / abs(curveEnd.y - vanishingPoint.y);\n
+ refLength = proportion*length(originalCenter-vanishingPoint.xy); \n
+ }\n
+ float Y1 = currentCenter.y - (normalize(currentCenter-vanishingPoint.xy)).y * refLength; \n
+ position.y = mix(Y0, Y1, t0); \n
+ }\n
+ position.xz = curvePoint.xz - lengthFromCurve*curLiftDirection.xz;\n
+ // calculate the normal vector, will be used for lighting
+ normal = cross(curLiftDirection, normalize(tangentVector));\n
+ // the signature of Z is decided by the page turning direction:
+ // from left to right(negative); from right to left (positive)
+ position.z *= -uIsTurningBack;\n
+ normal.xy *= -uIsTurningBack;\n
+ }\n
+ // change the coordinate origin from the top-left of the page to its center
+ position.xy -= uPageSize * 0.5; \n
+ }\n
+ position.z += aPosition.z;\n
+ gl_Position = uMvpMatrix * position;\n
+ // varying parameters for fragment shader
+ vTexCoord = aTexCoord;
+ vNormal = uNormalMatrix*normal;\n
+ vPosition = uModelView * position;\n
+ );
+
+ std::string vertexShaderWithFakedShadow = DALI_COMPOSE_SHADER(
+ // display shadow, the fake shadow value is calculated according to the height and the distance from page edge
+ vTexCoord.x = (aTexCoord.x-sTextureRect.s) /( 1.0 - uShadowWidth ) + sTextureRect.s;\n
+ vTexCoord.y = ( aTexCoord.y-sTextureRect.t-0.5*uShadowWidth*(sTextureRect.q-sTextureRect.t) )/( 1.0 - uShadowWidth ) + sTextureRect.t;\n
+ float heightCoef = (1.0 + position.z*uIsTurningBack*3.0 / uPageSize.x) * 0.6;
+ vEdgeShadow = clamp(0.9 - heightCoef, 0.0, 0.9 ); \n
+ if( vTexCoord.y >= sTextureRect.q || vTexCoord.y <= sTextureRect.t || vTexCoord.x >= sTextureRect.p )\n
+ {\n
+ float inversedShadowWidth = (1.0-uShadowWidth) / uShadowWidth ;\n
+ float alpha1 = (vTexCoord.x-sTextureRect.p) * inversedShadowWidth / (sTextureRect.p - sTextureRect.s);\n
+ inversedShadowWidth = 2.0 * inversedShadowWidth / (sTextureRect.q - sTextureRect.t); \n
+ float alpha2 = (vTexCoord.y-sTextureRect.q) * inversedShadowWidth;\n
+ float alpha3 = (sTextureRect.t-vTexCoord.y) * inversedShadowWidth;\n
+ float alpha;\n
+ if(alpha1 > 0.0 && alpha2 > 0.0) alpha = sqrt(alpha2*alpha2+alpha1*alpha1)/sqrt(1.0 + max(alpha1,alpha2)*max(alpha1,alpha2));\n //bottom-right corner
+ else if(alpha1 > 0.0 && alpha3 > 0.0) alpha = sqrt(alpha3*alpha3+alpha1*alpha1)/sqrt(1.0+max(alpha1,alpha3)*max(alpha1,alpha3));\n //top-right corner
+ else alpha = max(alpha1,max(alpha2,alpha3)); \n
+ alpha = 0.9 - alpha*0.9;\n
+ vEdgeShadow = clamp(alpha - heightCoef, 0.0, 0.9 ); \n
+ }\n
+ );
+
+ std::string vertexShaderEnd("}");
+
+ std::string fragmentShaderPartOne = DALI_COMPOSE_SHADER(
+ precision mediump float;\n
+ uniform vec2 uPageSize;\n
+ uniform vec2 uSpineShadowParameter;\n
+ varying vec3 vNormal;\n
+ varying vec4 vPosition;\n
+ varying float vEdgeShadow;\n
+ \n
+ void main()\n
+ {\n
+ // need to re-normalize the interpolated normal
+ vec3 normal = normalize(vNormal);\n
+ vec4 texel;\n
+ float spineShadowCoef = 1.0; \n
+ );
+
+ std::string fragmentShaderWithFakedShadow = DALI_COMPOSE_SHADER(
+ if( vTexCoord.y > sTextureRect.q || vTexCoord.y < sTextureRect.t || vTexCoord.x > sTextureRect.p )\n
+ texel = vec4(0.0,0.0,0.0,vEdgeShadow);
+ else \n
+ );
+
+ std::string fragmentShaderPartTwo = DALI_COMPOSE_SHADER(
+ { \n
+ // display page content
+ // display back image of the page, flip the texture
+ if( dot(vPosition.xyz, normal) > 0.0 ) texel = texture2D( sTexture, vec2( sTextureRect.p+sTextureRect.s-vTexCoord.x, vTexCoord.y ) );\n
+ // display front image of the page
+ else texel = texture2D( sTexture, vTexCoord );\n
+ // display book spine, a stripe of shadowed texture
+ float pixelPos = (vTexCoord.x-sTextureRect.s)*uPageSize.x; \n
+ if(pixelPos < uSpineShadowParameter.x) \n
+ {\n
+ float x = pixelPos - uSpineShadowParameter.x;\n
+ float y = sqrt( uSpineShadowParameter.x*uSpineShadowParameter.x - x*x);\n
+ spineShadowCoef = normalize( vec2( uSpineShadowParameter.y*x/uSpineShadowParameter.x, y ) ).y;\n
+ }\n
+ }\n
+ // calculate the lighting
+ // set the ambient color as vec3(0.4);
+ float lightColor = abs( normal.z ) * 0.6 + 0.4;\n
+ gl_FragColor = vec4( ( spineShadowCoef* lightColor)* texel.rgb , texel.a ) * uColor;\n
+ }
+ );
+
+ // Create the implementation, temporarily owned on stack,
+ Dali::ShaderEffect shaderEffectCustom;
+ std::ostringstream vertexShaderStringStream;
+ std::ostringstream fragmentShaderStringStream;
+ if( enableBlending )
+ {
+ vertexShaderStringStream<< vertexShader << vertexShaderWithFakedShadow << vertexShaderEnd;
+ fragmentShaderStringStream<< fragmentShaderPartOne << fragmentShaderWithFakedShadow << fragmentShaderPartTwo;
+ shaderEffectCustom = Dali::ShaderEffect::New( vertexShaderStringStream.str(), fragmentShaderStringStream.str(), GeometryType( GEOMETRY_TYPE_IMAGE ),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_DEPTH_BUFFER | ShaderEffect::HINT_BLENDING) );
+ }
+ else
+ {
+ vertexShaderStringStream<< vertexShader << vertexShaderEnd;
+ fragmentShaderStringStream<< fragmentShaderPartOne << fragmentShaderPartTwo;
+ shaderEffectCustom = Dali::ShaderEffect::New( vertexShaderStringStream.str(), fragmentShaderStringStream.str(), GeometryType( GEOMETRY_TYPE_IMAGE ),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_DEPTH_BUFFER ) );
+ }
+
+ static const float DEFAULT_SHADOW_WIDTH(0.15f);
+ static const Vector2 DEFAULT_SPINE_SHADOW_PARAMETER(50.0f, 20.0f);
+
+ Vector2 defaultPageSize = Dali::Stage::GetCurrent().GetSize();
+ Dali::Matrix zeroMatrix(true);
+ shaderEffectCustom.SetUniform( "uCommonParameters", zeroMatrix );
+ shaderEffectCustom.SetUniform( "uPageSize", defaultPageSize/(1.f-DEFAULT_SHADOW_WIDTH) );
+ shaderEffectCustom.SetUniform( "uShadowWidth", DEFAULT_SHADOW_WIDTH );
+ shaderEffectCustom.SetUniform( "uSpineShadowParameter", DEFAULT_SPINE_SHADOW_PARAMETER );
+
+ shaderEffectCustom.RegisterProperty( "uOriginalCenter", Vector2( defaultPageSize[0], defaultPageSize[1]*0.5f ) );
+ shaderEffectCustom.RegisterProperty( "uCurrentCenter", Vector2( defaultPageSize[0], defaultPageSize[1]*0.5f ) );
+
+ PageTurnApplyInternalConstraint(shaderEffectCustom);
+
+ // setting isTurningBack to -1.0f here means turning page forward
+ shaderEffectCustom.SetUniform( "uIsTurningBack", -1.0f );
+
+ return shaderEffectCustom;
+}
+
--- /dev/null
+#ifndef __DALI_PAGE_TURN_EFFECT_H_
+#define __DALI_PAGE_TURN_EFFECT_H_
+
+/*
+ * Copyright (c) 2015 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/animation/constraint.h>
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/object/property-input.h>
+#include <dali/public-api/shader-effects/shader-effect.h>
+#include <sstream>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+
+/**
+ * @brief Re-applies PageTurnEffect internal constraints
+ * The internal constraint uses the OriginalCenter property and the CurrentCenter Property
+ * to update the variety of common parameters which are with the same value for all the vertices.
+ * Note: For each actor, the constraints are applied in the same order as the calls to Actor::ApplyConstraint().
+ * So if there are other contraints applied to the OriginalCenter or CurrentCenter while when using this effect,
+ * call this method to get the internal constraints and re-apply it afterwards.
+ *
+ * @param[in] shaderEffect The page turn effect to which internal constraints should be re-applied
+ */
+void PageTurnApplyInternalConstraint( ShaderEffect& shaderEffect);
+
+/**
+ * @brief Create a new PageTurnEffect
+ * PageTurnEffect is a custom shader effect to achieve page turn effect for Image actors.
+ *
+ * Usage example:-
+ *
+ * // create shader used for doing page-turn effect\n
+ * ShaderEffect pageTurnEffect = CreatePageTurnEffect();
+ *
+ * // set image actor shader to the page-turn one\n
+ * // for portrait view, one image actor for each page\n
+ * // for landscape view, the page turned over is still visible, so back image is needed \n
+ * // in this case, create another image Actor using the back image and added to the page actor \n
+ * ImageActor pageActor = ImageActor::New(....); \n
+ * ImageActor backImageActor = ImageActor::New(....); \n
+ * pageActor.Add(backPageActor);\n
+ * pageActor.SetShaderEffect ( pageTurnEffect ); \n
+ *
+ * //set initial values
+ * pageTurnEffect.SetUniform("uPageSize", Vector2);\n
+ * pageTurnEffect.SetUniform("uOriginalCenter", Vector2);\n
+ * pageTurnEffect.SetUniform("uIsTurningBack", bool) SetIsTurningBack();\n
+ * pageTurnEffect.SetUniform("uCurrentCenter",Vector2);\n
+ *
+ * //Animate it with the current center property\n
+ * Animation animation[mAnimationIndex] = Animation::New( ... );\n
+ * animation.AnimateTo(Property( pageTurnEffect, "uCurrentCenter" ),
+ * currentCenter,
+ * AlphaFunction::...);\n
+ * animation[mAnimationIndex].Play(); \n
+ *
+ * Animatable/Constrainable uniforms:
+ *
+ * @param[in] enableBlending If true, apply HINT_BLENDING when creating the shader object; If false, disable the HINT_BLENDING
+ * @return A handle to a newly allocated ShaderEffect
+ */
+ShaderEffect CreatePageTurnEffect(bool enableBlending = true);
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif /* __DALI_TOOLKIT_SC_CURVE_EFFECT_H_ */
#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/object/type-registry-helper.h>
+//INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/page-turn-view/page-turn-effect.h>
+
namespace Dali
{
// Add the page to tuning page layer and set up PageTurnEffect
mShadowView.Add( actor );
actor.SetShaderEffect( mTurnEffect[mIndex] );
- GetImpl( mTurnEffect[mIndex] ).ApplyInternalConstraint();
+ PageTurnApplyInternalConstraint(mTurnEffect[mIndex]);
mIsAnimating[mIndex] = true;
- mTurnEffect[mIndex].SetIsTurningBack( true );
+ mTurnEffect[mIndex].SetUniform("uIsTurningBack", true );
Vector2 originalCenter( mPageSize.width*1.5f, 0.5f*mPageSize.height );
- mTurnEffect[mIndex].SetOriginalCenter( originalCenter );
- mTurnEffect[mIndex].SetCurrentCenter( Vector2( mPageSize.width*0.5f, mPageSize.height*0.5f ));
+ mTurnEffect[mIndex].SetUniform("uOriginalCenter", originalCenter );
+ mTurnEffect[mIndex].SetUniform("uCurrentCenter", Vector2( mPageSize.width*0.5f, mPageSize.height*0.5f ) );
// Start an animation to turn the previous page back
Animation animation = Animation::New( PAGE_TURN_OVER_ANIMATION_DURATION );
mAnimationActorPair[animation] = actor;
mAnimationIndexPair[animation] = mIndex;
- animation.AnimateTo( Property( mTurnEffect[mIndex], mTurnEffect[mIndex].PageTurnEffect::GetCurrentCenterPropertyName() ),
+ animation.AnimateTo( Property( mTurnEffect[mIndex], "uCurrentCenter" ),
originalCenter,
AlphaFunction::EASE_OUT, TimePeriod(PAGE_TURN_OVER_ANIMATION_DURATION*0.75f) );
animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), AngleAxis( Degree( 180.0f ), Vector3::YAXIS ) ,AlphaFunction::EASE_OUT );
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
+#include <dali-toolkit/internal/controls/page-turn-view/page-turn-effect.h>
+#include <dali-toolkit/internal/controls/page-turn-view/page-turn-book-spine-effect.h>
using namespace Dali;
void PageTurnView::OnInitialize()
{
// create the two book spine effect for static images, left and right side pages respectively
- mSpineEffectFront = PageTurnBookSpineEffect::New();
- mSpineEffectFront.SetIsBackImageVisible( false );
- mSpineEffectFront.SetPageWidth( mPageSize.width );
- mSpineEffectFront.SetShadowWidth( 0.f );
- mSpineEffectFront.SetSpineShadowParameter( mSpineShadowParameter );
-
- mSpineEffectBack = PageTurnBookSpineEffect::New();
- mSpineEffectBack.SetIsBackImageVisible( true );
- mSpineEffectBack.SetPageWidth( mPageSize.width );
- mSpineEffectBack.SetShadowWidth( 0.f );
- mSpineEffectBack.SetSpineShadowParameter( mSpineShadowParameter );
+ mSpineEffectFront = CreatePageTurnBookSpineEffect();
+ mSpineEffectFront.SetUniform("uIsBackImageVisible", false );
+ mSpineEffectFront.SetUniform("uPageWidth", mPageSize.width );
+ mSpineEffectFront.SetUniform("uShadowWidth", 0.f );
+ mSpineEffectFront.SetUniform("uSpineShadowParameter", mSpineShadowParameter );
+
+ mSpineEffectBack = CreatePageTurnBookSpineEffect();
+ mSpineEffectBack.SetUniform("uIsBackImageVisible", true );
+ mSpineEffectBack.SetUniform("uPageWidth", mPageSize.width );
+ mSpineEffectBack.SetUniform("uShadowWidth", 0.f );
+ mSpineEffectBack.SetUniform("uSpineShadowParameter", mSpineShadowParameter );
// create the page turn effect objects
for( int i = 0; i < MAXIMUM_TURNING_NUM; i++ )
{
- mTurnEffect[i] = Toolkit::PageTurnEffect::New( false );
+ mTurnEffect[i] = CreatePageTurnEffect( false );
mTurnEffect[i].SetProperty( ShaderEffect::Property::GRID_DENSITY, Property::Value( DEFAULT_GRID_DENSITY ) );
- mTurnEffect[i].SetPageSize( mPageSize );
- mTurnEffect[i].SetShadowWidth(0.f);
- mTurnEffect[i].SetSpineShadowParameter( mSpineShadowParameter );
+ mTurnEffect[i].SetUniform( "uPageSize", mPageSize );
+ mTurnEffect[i].SetUniform( "uShadowWidth", 0.f);
+ mTurnEffect[i].SetUniform( "uSpineShadowParameter", mSpineShadowParameter );
mIsAnimating[i] = false;
mIsSliding[i] = false;
mPropertyPanDisplacement[i] = Self().RegisterProperty("PAN_DISPLACEMENT_PROPERTY_"+i, 0.0f);
mSpineShadowParameter = spineShadowParameter;
// set spine shadow parameter to all the shader effects
- mSpineEffectFront.SetSpineShadowParameter( mSpineShadowParameter );
- mSpineEffectBack.SetSpineShadowParameter( mSpineShadowParameter );
+ mSpineEffectFront.SetUniform("uSpineShadowParameter", mSpineShadowParameter );
+ mSpineEffectBack.SetUniform("uSpineShadowParameter", mSpineShadowParameter );
for( int i = 0; i < MAXIMUM_TURNING_NUM; i++ )
{
- mTurnEffect[i].SetSpineShadowParameter( mSpineShadowParameter );
+ mTurnEffect[i].SetUniform("uSpineShadowParameter", mSpineShadowParameter );
}
}
}
mOriginalCenter = gesturePosition;
- mTurnEffect[mIndex].SetIsTurningBack( mIsTurnBack[ mPanActor] );
+ mTurnEffect[mIndex].SetUniform("uIsTurningBack", mIsTurnBack[ mPanActor] );
mPress = false;
mPageUpdated = false;
mDistanceBottomCorner = ( mOriginalCenter - Vector2( 0.0f, mPageSize.height ) ).Length();
mShadowView.Add( mPanActor );
SetShaderEffect( mPanActor, mTurnEffect[mIndex] );
- mTurnEffect[mIndex].SetOriginalCenter( mOriginalCenter );
+ mTurnEffect[mIndex].SetUniform("uOriginalCenter", mOriginalCenter );
mCurrentCenter = mOriginalCenter;
- mTurnEffect[mIndex].SetCurrentCenter( mCurrentCenter );
+ mTurnEffect[mIndex].SetUniform("uCurrentCenter", mCurrentCenter );
mPanDisplacement = 0.f;
mConstraints = true;
mPress = true;
self.SetProperty( mPropertyPanDisplacement[mIndex], 0.f );
Constraint shadowBlurStrengthConstraint = Constraint::New<float>( mShadowView, mShadowView.GetBlurStrengthPropertyIndex(), ShadowBlurStrengthConstraint( mPageSize.width*PAGE_TURN_OVER_THRESHOLD_RATIO ) );
- shadowBlurStrengthConstraint.AddSource( Source(mTurnEffect[mIndex], mTurnEffect[mIndex].GetPropertyIndex(mTurnEffect[mIndex].PageTurnEffect::GetCurrentCenterPropertyName())) );
- shadowBlurStrengthConstraint.AddSource( Source(mTurnEffect[mIndex], mTurnEffect[mIndex].GetPropertyIndex(mTurnEffect[mIndex].PageTurnEffect::GetOriginalCenterPropertyName())) );
+ shadowBlurStrengthConstraint.AddSource( Source(mTurnEffect[mIndex], mTurnEffect[mIndex].GetPropertyIndex("uCurrentCenter")) );
+ shadowBlurStrengthConstraint.AddSource( Source(mTurnEffect[mIndex], mTurnEffect[mIndex].GetPropertyIndex("uOriginalCenter")) );
shadowBlurStrengthConstraint.AddSource( Source( self, mPropertyPanDisplacement[mIndex] ) );
shadowBlurStrengthConstraint.Apply();
}
offset *= k;
Actor self = Self();
- Property::Index shaderOriginalCenterPropertyIndex = mTurnEffect[mIndex].GetPropertyIndex(mTurnEffect[mIndex].PageTurnEffect::GetOriginalCenterPropertyName());
+ Property::Index shaderOriginalCenterPropertyIndex = mTurnEffect[mIndex].GetPropertyIndex("uOriginalCenter");
Constraint originalCenterConstraint = Constraint::New<Vector2>( mTurnEffect[mIndex], shaderOriginalCenterPropertyIndex, OriginalCenterConstraint( mOriginalCenter, offset ));
originalCenterConstraint.AddSource( Source( self, mPropertyPanDisplacement[mIndex] ) );
originalCenterConstraint.Apply();
- Property::Index shaderCurrentCenterPropertyIndex = mTurnEffect[mIndex].GetPropertyIndex(mTurnEffect[mIndex].PageTurnEffect::GetCurrentCenterPropertyName());
+ Property::Index shaderCurrentCenterPropertyIndex = mTurnEffect[mIndex].GetPropertyIndex("uCurrentCenter");
Constraint currentCenterConstraint = Constraint::New<Vector2>( mTurnEffect[mIndex], shaderCurrentCenterPropertyIndex, CurrentCenterConstraint(mPageSize.width));
currentCenterConstraint.AddSource( Source(self, mPropertyCurrentCenter[mIndex]) );
currentCenterConstraint.AddSource( Source(mTurnEffect[mIndex], shaderOriginalCenterPropertyIndex) );
currentCenterConstraint.Apply();
- GetImpl( mTurnEffect[mIndex] ).ApplyInternalConstraint();
+ PageTurnApplyInternalConstraint(mTurnEffect[mIndex]);
float distance = offset.Length();
Constraint rotationConstraint = Constraint::New<Quaternion>( mPanActor, Actor::Property::ORIENTATION, RotationConstraint(distance, mPageSize.width, mIsTurnBack[mPanActor]));
{
mPanActor.RemoveConstraints();
mTurnEffect[mIndex].RemoveConstraints();
- mTurnEffect[mIndex].SetOriginalCenter( mOriginalCenter );
+ mTurnEffect[mIndex].SetUniform("uOriginalCenter",mOriginalCenter );
mConstraints = true;
mPanDisplacement = 0.f;
}
- mTurnEffect[mIndex].SetCurrentCenter( currentCenter );
+ mTurnEffect[mIndex].SetUniform("uCurrentCenter", currentCenter );
mCurrentCenter = currentCenter;
- GetImpl( mTurnEffect[mIndex] ).ApplyInternalConstraint();
+ PageTurnApplyInternalConstraint(mTurnEffect[mIndex]);
}
}
}
else // the pan finished position is far away from the spine, set up an animation to slide the page back instead of turning over
{
Animation animation= Animation::New( PAGE_SLIDE_BACK_ANIMATION_DURATION * (mOriginalCenter.x - mCurrentCenter.x) / mPageSize.width / PAGE_TURN_OVER_THRESHOLD_RATIO );
- animation.AnimateTo( Property( mTurnEffect[mIndex], mTurnEffect[mIndex].PageTurnEffect::GetCurrentCenterPropertyName() ),
+ animation.AnimateTo( Property( mTurnEffect[mIndex], "uCurrentCenter" ),
mOriginalCenter, AlphaFunction::LINEAR );
mAnimationActorPair[animation] = actor;
mAnimationIndexPair[animation] = mIndex;
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/page-turn-view/page-turn-view.h>
-#include <dali-toolkit/internal/shader-effects/page-turn-effect-impl.h>
-#include <dali-toolkit/public-api/shader-effects/page-turn-effect.h>
-#include <dali-toolkit/public-api/shader-effects/page-turn-book-spine-effect.h>
#include <dali-toolkit/public-api/controls/page-turn-view/page-factory.h>
#include <dali-toolkit/public-api/controls/shadow-view/shadow-view.h>
CameraActor mCameraActor; ///< The camera actor attached to the off screen tasks
bool mPanning; ///< The boolean to indicate whether the pan gesture is continuing
- std::vector<Toolkit::PageTurnEffect> mTurnEffect; ///< The group of PageTurnEffects
- PageTurnBookSpineEffect mSpineEffectFront; ///< The book spine shader effect without flipping image content
- PageTurnBookSpineEffect mSpineEffectBack; ///< The book spine shader effect with image content flipped
+ std::vector<ShaderEffect> mTurnEffect; ///< The group of PageTurnEffects
+ ShaderEffect mSpineEffectFront; ///< The book spine shader effect without flipping image content
+ ShaderEffect mSpineEffectBack; ///< The book spine shader effect with image content flipped
Vector2 mSpineShadowParameter; ///< The spine shadow parameter for all the above shader effects
Vector2 mOriginalCenter; ///< The original center set to the PageTurnEffect
Vector2 mCurrentCenter; ///< The current center set to the PageTurnEffect
$(toolkit_src_dir)/controls/popup/popup-impl.cpp \
$(toolkit_src_dir)/controls/popup/popup-style-impl.cpp \
$(toolkit_src_dir)/controls/page-turn-view/page-turn-portrait-view-impl.cpp \
+ $(toolkit_src_dir)/controls/page-turn-view/page-turn-effect.cpp \
$(toolkit_src_dir)/controls/page-turn-view/page-turn-landscape-view-impl.cpp \
$(toolkit_src_dir)/controls/page-turn-view/page-turn-view-impl.cpp \
$(toolkit_src_dir)/controls/scroll-bar/scroll-bar-impl.cpp \
$(toolkit_src_dir)/filters/emboss-filter.cpp \
$(toolkit_src_dir)/filters/image-filter.cpp \
$(toolkit_src_dir)/filters/spread-filter.cpp \
- $(toolkit_src_dir)/shader-effects/page-turn-effect-impl.cpp \
- $(toolkit_src_dir)/shader-effects/water-effect-impl.cpp \
$(toolkit_src_dir)/styling/style-manager-impl.cpp \
$(toolkit_src_dir)/text/bidirectional-support.cpp \
$(toolkit_src_dir)/text/character-set-conversion.cpp \
+++ /dev/null
-/*
- * 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 "page-turn-effect-impl.h"
-
-// EXTERNAL HEADERS
-#include <sstream>
-#include <dali/public-api/animation/constraint.h>
-#include <dali/public-api/common/stage.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-namespace
-{
-#define MAKE_STRING(A)#A
-
-const std::string CURRENT_CENTER_PROPERTY_NAME("uCurrentCenter");
-const std::string ORIGINAL_CENTER_PROPERTY_NAME("uOriginalCenter");
-const std::string PAGE_SIZE_PROPERTY_NAME("uPageSize");
-const std::string IS_TURNING_BACK_PROPERTY_NAME("uIsTurningBack");
-const std::string SHADOW_WIDTH_PROPERTY_NAME("uShadowWidth");
-const std::string SPINE_SHADOW_PARAMETER_PROPERTY_NAME("uSpineShadowParameter");
-
-// fake shadow is used to enhance the effect, with its default maximum width to be pageSize * 0.15
-const float DEFAULT_SHADOW_WIDTH(0.15f);
-
-// the major&minor radius (in pixels) to form an ellipse shape
-// the top-left quarter of this ellipse is used to calculate spine normal for simulating shadow
-const Vector2 DEFAULT_SPINE_SHADOW_PARAMETER(50.0f, 20.0f);
-
-// when the vanishing point is very far away(pageHeight*THRESHOLD), make it infinitely, in this case, the page bent horizontally
-const float THRESHOLD(20.0);
-
-void CommonParametersConstraint( Matrix& current, const PropertyInputContainer& inputs )
-{
- const Vector2& originalCenter = inputs[0]->GetVector2();
- Vector2 currentCenter = inputs[1]->GetVector2();
- const Vector2& pageSize = inputs[2]->GetVector2();
-
- // calculate the curve direction and the vanishing point
- // here, the vanishing point is the intersection of spine with the line passing through original center and vertical to curve direction
- Vector2 curveDirection( currentCenter - originalCenter );
- curveDirection.Normalize();
- if( fabs(curveDirection.y) < 0.01f) // eliminate the possibility of division by zero in the next step
- {
- curveDirection.y = 0.01f;
- }
- float vanishingPointY = originalCenter.y + curveDirection.x * originalCenter.x / curveDirection.y;
-
- float curveEndY, cosTheta ,sinTheta ,translateX, translateY;
- // when the vanishing point is very far away, make it infinitely, in this case, the page bent horizontally
- if( fabs(vanishingPointY-pageSize.y*0.5f) >= pageSize.y*THRESHOLD )
- {
- curveDirection = Vector2(-1.f,0.f);
- currentCenter.y = originalCenter.y;
-
- curveEndY = originalCenter.y;
- cosTheta = 1.f;
- sinTheta = 0.f;
- translateX = currentCenter.x - originalCenter.x;
- translateY = vanishingPointY;
- }
- else
- {
- curveEndY = currentCenter.y - curveDirection.y * (currentCenter.x/curveDirection.x) ;
- Vector2 v1( currentCenter.x, currentCenter.y - vanishingPointY );
- v1.Normalize();
- Vector2 v2( originalCenter.x, originalCenter.y - vanishingPointY );
- v2.Normalize();
- cosTheta = v1.x*v2.x + v1.y*v2.y;
- sinTheta = ( vanishingPointY > pageSize.y*0.5f ) ? sqrt(1.0-cosTheta*cosTheta) : -sqrt(1.0-cosTheta*cosTheta);
- translateX = currentCenter.x - cosTheta*originalCenter.x - sinTheta*( originalCenter.y-vanishingPointY );
- translateY = currentCenter.y + sinTheta*originalCenter.x - cosTheta*( originalCenter.y-vanishingPointY );
- }
-
- float originalLength = fabs(originalCenter.x/curveDirection.x);
- float currentLength = fabs(currentCenter.x/curveDirection.x);
- float curveHeight = 0.45f*sqrt(originalLength*originalLength - currentLength*currentLength);
-
- float* parameterArray = current.AsFloat();
- parameterArray[0] = cosTheta;
- parameterArray[1] = -sinTheta;
- parameterArray[2] = originalCenter.x;
- parameterArray[3] = originalCenter.y;
- parameterArray[4] = sinTheta;
- parameterArray[5] = cosTheta;
- parameterArray[6] = currentCenter.x;
- parameterArray[7] = currentCenter.y;
- parameterArray[8] = translateX;
- parameterArray[9] = translateY;
- parameterArray[10] = vanishingPointY;
- parameterArray[11] = curveEndY;
- parameterArray[12] = curveDirection.x;
- parameterArray[13] = curveDirection.y;
- parameterArray[14] = curveHeight;
- parameterArray[15] = currentLength;
-}
-
-}//namespace
-
-PageTurnEffect::PageTurnEffect()
-: mOriginalCenterPropertyIndex(Property::INVALID_INDEX),
- mCurrentCenterPropertyIndex(Property::INVALID_INDEX)
-{
-}
-
-PageTurnEffect::~PageTurnEffect()
-{
-}
-
-Toolkit::PageTurnEffect PageTurnEffect::CreateShaderEffect( bool enableBlending )
-{
- std::string vertexShader = MAKE_STRING(
- /*
- * The common parameters for all the vertices, calculate in CPU then pass into the shader as uniforms
- *
- * first part of the page, (outside the the line passing through original center and vertical to curve direction)
- * no Z change, only 2D rotation and translation
- * ([0][0],[0][1],[1][0],[1][1]) mat2 rotateMatrix
- * ([2][0],[2][1]) vec2 translationVector
- *
- * ([0][2],[0][3]) vec2 originalCenter: Typically the press down position of the Pan Gesture
- * ([1][2],[1][3]) vec2 currentCenter: Typically the current position of the Pan Gesture
- * ([3][0],[3][1]) vec2 curveDirection: The normalized vector pointing from original center to current center
- * ([2][2]) float vanishingPointY: The Y coordinate of the intersection of the spine
- * and the line which goes through the original center and is vertical to the curveDirection
- * ([2][3]) float curveEndY: The Y coordinate of intersection of the spine and the line through both original and current center
- * ([3][2]) float curveHeight: The height of the interpolated hermite curve.
- * ([3][3]) float currentLength: The length from the current center to the curveEnd.
- */
- precision mediump float;\n
- uniform mat4 uCommonParameters;\n
- \n
- uniform vec2 uPageSize;\n
- uniform float uIsTurningBack;\n
- uniform float uShadowWidth;\n
- varying vec3 vNormal;\n
- varying vec4 vPosition;\n
- varying float vEdgeShadow;\n
- \n
- void main()\n
- {\n
- vec4 position = vec4( aPosition.xy, 0.0, 1.0);\n
- vec2 currentCenter = vec2( uCommonParameters[1][2], uCommonParameters[1][3]);\n
- vec2 originalCenter = vec2( uCommonParameters[0][2], uCommonParameters[0][3]);\n
- vec3 normal = vec3(0.0,0.0,1.0);\n
- \n
- if(currentCenter.x < originalCenter.x)\n
- {\n
- // change the coordinate origin from the center of the page to its top-left
- position.xy += uPageSize * 0.5;\n
- vec2 curveDirection = vec2( uCommonParameters[3]);\n
- vec3 vanishingPoint = vec3(0.0, uCommonParameters[2][2], 0.0);\n
- // first part of the page, (outside the the line passing through original center and vertical to curve direction)
- //no Z change, only 2D rotation and translation
- if( dot(curveDirection, position.xy - originalCenter) < 0.0 )
- {\n
- position.y -= vanishingPoint.y;\n
- position.xy = mat2(uCommonParameters)*position.xy + vec2( uCommonParameters[2]);\n
- }\n
- // second part of the page, bent as a ruled surface
- else\n
- {\n
- // calculate on the flat plane, between
- // the first line passing through current vertex and vanishing point
- // the second line passing through original center and current center
- vec2 curveEnd = vec2( 0.0, uCommonParameters[2][3] );\n
- vec2 curFlatDirection = vec2(0.0,1.0);\n
- float lengthFromCurve = position.y - originalCenter.y;\n
- float lengthOnCurve = position.x;\n
- if(currentCenter.y != originalCenter.y)\n
- {\n
- curFlatDirection = normalize(position.xy - vanishingPoint.xy);\n
- lengthFromCurve = (curveEnd.x*curveDirection.y-curveEnd.y*curveDirection.x-position.x*curveDirection.y+position.y*curveDirection.x)
- / (curFlatDirection.x*curveDirection.y-curFlatDirection.y*curveDirection.x);\n
- lengthOnCurve = length(position.xy+lengthFromCurve*curFlatDirection-curveEnd);\n
- }\n
- \n
- // define the control points of hermite curve, composed with two segments
- // calulation is carried out on the 2D plane which is passing through both current and original center and vertical to the image plane
- float currentLength = uCommonParameters[3][3];\n
- float originalLength = abs(originalCenter.x/curveDirection.x);\n
- float height = uCommonParameters[3][2];\n
- float percentage = currentLength/originalLength;\n
- //vec2 SegmentOneControlPoint0 = vec2(0.0, 0.0);
- vec2 SegmentOneControlPoint1 = vec2((0.65*percentage - 0.15)*originalLength, (0.8 + 0.2 * percentage)*height); \n
- vec2 SegmentTwoControlPoint0 = SegmentOneControlPoint1;\n
- vec2 SegmentTwoControlPoint1 = vec2(currentLength, 0.0); \n
- vec2 SegmentOneTangentVector0 = SegmentOneControlPoint1;\n
- vec2 SegmentOneTangentVector1 = vec2(0.5*originalLength,0.0);\n
- vec2 SegmentTwoTangentVector0 = SegmentOneTangentVector1;\n
- vec2 SegmentTwoTangentVector1 = SegmentOneTangentVector1;\n
- \n
- // calulate the corresponding curve point position and its tangent vector
- // it is a linear mapping onto nonlinear curves, might cause some unwanted deformation
- // but as there are no analytical method to calculate the curve length on arbitrary segment
- // no efficient way to solve this nonlinear mapping, Numerical approximation would cost too much computation in shader
- vec2 curvePoint2D;\n
- vec2 tangent;\n
- float t0 = lengthOnCurve / originalLength;\n
- if(t0<=0.5)\n
- {\n
- float t = 2.0*t0;\n
- float t_2 = t*t;\n
- float t_3 = t*t_2;\n
- curvePoint2D = (-2.0*t_3+3.0*t_2)*SegmentOneControlPoint1
- + (t_3-2.0*t_2+t)*SegmentOneTangentVector0 + (t_3-t_2)*SegmentOneTangentVector1;\n
- tangent = (-6.0*t_2+6.0*t)*SegmentOneControlPoint1
- + (3.0*t_2-4.0*t+1.0)*SegmentOneTangentVector0 + (3.0*t_2-2.0*t)*SegmentOneTangentVector1;\n
- }\n
- else\n
- {\n
- float t = 2.0*t0-1.0;\n
- float t_2 = t*t;\n
- float t_3 = t*t_2;\n
- curvePoint2D = (2.0*t_3-3.0*t_2+1.0)*SegmentTwoControlPoint0 + (-2.0*t_3+3.0*t_2)*SegmentTwoControlPoint1
- + (t_3-2.0*t_2+t)*SegmentTwoTangentVector0 + (t_3-t_2)*SegmentTwoTangentVector1;\n
- tangent = (6.0*t_2-6.0*t)*SegmentTwoControlPoint0 + (-6.0*t_2+6.0*t)*SegmentTwoControlPoint1
- + (3.0*t_2-4.0*t+1.0)*SegmentTwoTangentVector0 + (3.0*t_2-2.0*t)*SegmentTwoTangentVector1;\n
- // a trick to eliminate some optical illusion caused by the gradient matter of normal in per-fragment shading
- // which is caused by linear interpolation of normal vs. nonlinear lighting
- // will notice some artifact in the areas with dramatically normal changes, so compress the normal differences here
- tangent.y *= min(1.0, length(position.xyz - vanishingPoint) / uPageSize.y ); \n
- }\n
- vec3 curvePoint = vec3(curveEnd - curvePoint2D.x*curveDirection,max(0.0,curvePoint2D.y));\n
- vec3 tangentVector = vec3(-tangent.x*curveDirection,tangent.y);\n
- \n
- // locate the new vertex position on the line passing through both vanishing point and the calculated curve point position
- vec3 curLiftDirection = vec3(0.0,-1.0,0.0);\n
- if(currentCenter.y != originalCenter.y)\n
- {\n
- curLiftDirection = normalize(curvePoint - vanishingPoint);\n
- tangentVector *= (curveDirection.y > 0.0) ? -1.0 : 1.0;\n
- // an heuristic adjustment here, to compensate the linear parameter mapping onto the nonlinear curve
- float Y0 = position.y - curveDirection.y * (position.x/curveDirection.x); \n
- float proportion;
- float refLength;\n
- if(abs(Y0-vanishingPoint.y) > abs(curveEnd.y-vanishingPoint.y)) \n
- {\n
- proportion = abs(curveEnd.y - Y0) / (abs(curveEnd.y-Y0)+abs(curveEnd.y - vanishingPoint.y)); \n
- refLength = proportion*length(originalCenter-vanishingPoint.xy) / (proportion-1.0); \n
- }\n
- else\n
- {\n
- proportion = abs(curveEnd.y - Y0) / abs(curveEnd.y - vanishingPoint.y);\n
- refLength = proportion*length(originalCenter-vanishingPoint.xy); \n
- }\n
- float Y1 = currentCenter.y - (normalize(currentCenter-vanishingPoint.xy)).y * refLength; \n
- position.y = mix(Y0, Y1, t0); \n
- }\n
- position.xz = curvePoint.xz - lengthFromCurve*curLiftDirection.xz;\n
- // calculate the normal vector, will be used for lighting
- normal = cross(curLiftDirection, normalize(tangentVector));\n
- // the signature of Z is decided by the page turning direction:
- // from left to right(negative); from right to left (positive)
- position.z *= -uIsTurningBack;\n
- normal.xy *= -uIsTurningBack;\n
- }\n
- // change the coordinate origin from the top-left of the page to its center
- position.xy -= uPageSize * 0.5; \n
- }\n
- position.z += aPosition.z;\n
- gl_Position = uMvpMatrix * position;\n
- // varying parameters for fragment shader
- vTexCoord = aTexCoord;
- vNormal = uNormalMatrix*normal;\n
- vPosition = uModelView * position;\n
- );
-
- std::string vertexShaderWithFakedShadow = MAKE_STRING(
- // display shadow, the fake shadow value is calculated according to the height and the distance from page edge
- vTexCoord.x = (aTexCoord.x-sTextureRect.s) /( 1.0 - uShadowWidth ) + sTextureRect.s;\n
- vTexCoord.y = ( aTexCoord.y-sTextureRect.t-0.5*uShadowWidth*(sTextureRect.q-sTextureRect.t) )/( 1.0 - uShadowWidth ) + sTextureRect.t;\n
- float heightCoef = (1.0 + position.z*uIsTurningBack*3.0 / uPageSize.x) * 0.6;
- vEdgeShadow = clamp(0.9 - heightCoef, 0.0, 0.9 ); \n
- if( vTexCoord.y >= sTextureRect.q || vTexCoord.y <= sTextureRect.t || vTexCoord.x >= sTextureRect.p )\n
- {\n
- float inversedShadowWidth = (1.0-uShadowWidth) / uShadowWidth ;\n
- float alpha1 = (vTexCoord.x-sTextureRect.p) * inversedShadowWidth / (sTextureRect.p - sTextureRect.s);\n
- inversedShadowWidth = 2.0 * inversedShadowWidth / (sTextureRect.q - sTextureRect.t); \n
- float alpha2 = (vTexCoord.y-sTextureRect.q) * inversedShadowWidth;\n
- float alpha3 = (sTextureRect.t-vTexCoord.y) * inversedShadowWidth;\n
- float alpha;\n
- if(alpha1 > 0.0 && alpha2 > 0.0) alpha = sqrt(alpha2*alpha2+alpha1*alpha1)/sqrt(1.0 + max(alpha1,alpha2)*max(alpha1,alpha2));\n //bottom-right corner
- else if(alpha1 > 0.0 && alpha3 > 0.0) alpha = sqrt(alpha3*alpha3+alpha1*alpha1)/sqrt(1.0+max(alpha1,alpha3)*max(alpha1,alpha3));\n //top-right corner
- else alpha = max(alpha1,max(alpha2,alpha3)); \n
- alpha = 0.9 - alpha*0.9;\n
- vEdgeShadow = clamp(alpha - heightCoef, 0.0, 0.9 ); \n
- }\n
- );
-
- std::string vertexShaderEnd("}");
-
- std::string fragmentShaderPartOne = MAKE_STRING(
- precision mediump float;\n
- uniform vec2 uPageSize;\n
- uniform vec2 uSpineShadowParameter;\n
- varying vec3 vNormal;\n
- varying vec4 vPosition;\n
- varying float vEdgeShadow;\n
- \n
- void main()\n
- {\n
- // need to re-normalize the interpolated normal
- vec3 normal = normalize(vNormal);\n
- vec4 texel;\n
- float spineShadowCoef = 1.0; \n
- );
-
- std::string fragmentShaderWithFakedShadow = MAKE_STRING(
- if( vTexCoord.y > sTextureRect.q || vTexCoord.y < sTextureRect.t || vTexCoord.x > sTextureRect.p )\n
- texel = vec4(0.0,0.0,0.0,vEdgeShadow);
- else \n
- );
-
- std::string fragmentShaderPartTwo = MAKE_STRING(
- { \n
- // display page content
- // display back image of the page, flip the texture
- if( dot(vPosition.xyz, normal) > 0.0 ) texel = texture2D( sTexture, vec2( sTextureRect.p+sTextureRect.s-vTexCoord.x, vTexCoord.y ) );\n
- // display front image of the page
- else texel = texture2D( sTexture, vTexCoord );\n
- // display book spine, a stripe of shadowed texture
- float pixelPos = (vTexCoord.x-sTextureRect.s)*uPageSize.x; \n
- if(pixelPos < uSpineShadowParameter.x) \n
- {\n
- float x = pixelPos - uSpineShadowParameter.x;\n
- float y = sqrt( uSpineShadowParameter.x*uSpineShadowParameter.x - x*x);\n
- spineShadowCoef = normalize( vec2( uSpineShadowParameter.y*x/uSpineShadowParameter.x, y ) ).y;\n
- }\n
- }\n
- // calculate the lighting
- // set the ambient color as vec3(0.4);
- float lightColor = abs( normal.z ) * 0.6 + 0.4;\n
- gl_FragColor = vec4( ( spineShadowCoef* lightColor)* texel.rgb , texel.a ) * uColor;\n
- }
- );
-
- // Create the implementation, temporarily owned on stack,
- Dali::ShaderEffect shaderEffectCustom;
- std::ostringstream vertexShaderStringStream;
- std::ostringstream fragmentShaderStringStream;
- if( enableBlending )
- {
- vertexShaderStringStream<< vertexShader << vertexShaderWithFakedShadow << vertexShaderEnd;
- fragmentShaderStringStream<< fragmentShaderPartOne << fragmentShaderWithFakedShadow << fragmentShaderPartTwo;
- shaderEffectCustom = Dali::ShaderEffect::New( vertexShaderStringStream.str(), fragmentShaderStringStream.str(), GeometryType( GEOMETRY_TYPE_IMAGE ),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_DEPTH_BUFFER | ShaderEffect::HINT_BLENDING) );
- }
- else
- {
- vertexShaderStringStream<< vertexShader << vertexShaderEnd;
- fragmentShaderStringStream<< fragmentShaderPartOne << fragmentShaderPartTwo;
- shaderEffectCustom = Dali::ShaderEffect::New( vertexShaderStringStream.str(), fragmentShaderStringStream.str(), GeometryType( GEOMETRY_TYPE_IMAGE ),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_DEPTH_BUFFER ) );
- }
-
- PageTurnEffect* shaderImpl = new PageTurnEffect();
- Dali::Toolkit::PageTurnEffect handle = Toolkit::PageTurnEffect( shaderEffectCustom, shaderImpl );
-
- shaderImpl->Initialize( handle );
-
- Vector2 defaultPageSize = Dali::Stage::GetCurrent().GetSize();
- Matrix zeroMatrix(true);
- handle.SetUniform( "uCommonParameters", zeroMatrix );
- handle.SetUniform( PAGE_SIZE_PROPERTY_NAME, defaultPageSize/(1.f-DEFAULT_SHADOW_WIDTH) );
- handle.SetUniform( SHADOW_WIDTH_PROPERTY_NAME, DEFAULT_SHADOW_WIDTH );
- handle.SetUniform( SPINE_SHADOW_PARAMETER_PROPERTY_NAME, DEFAULT_SPINE_SHADOW_PARAMETER );
-
- shaderImpl->mOriginalCenterPropertyIndex = handle.RegisterProperty( ORIGINAL_CENTER_PROPERTY_NAME, Vector2( defaultPageSize[0], defaultPageSize[1]*0.5f ) );
- shaderImpl->mCurrentCenterPropertyIndex = handle.RegisterProperty( CURRENT_CENTER_PROPERTY_NAME, Vector2( defaultPageSize[0], defaultPageSize[1]*0.5f ) );
-
- shaderImpl->ApplyInternalConstraint();
-
- // setting isTurningBack to -1.0f here means turning page forward
- handle.SetUniform( IS_TURNING_BACK_PROPERTY_NAME, -1.0f );
-
- return handle;
-}
-
-void PageTurnEffect::SetPageSize(const Vector2& pageSize)
-{
- mShaderEffect.SetUniform(PAGE_SIZE_PROPERTY_NAME, pageSize);
-}
-
-void PageTurnEffect::SetOriginalCenter(const Vector2& originalCenter)
-{
- mShaderEffect.SetProperty( mOriginalCenterPropertyIndex, originalCenter );
-}
-
-void PageTurnEffect::SetCurrentCenter(const Vector2& currentCenter)
-{
- mShaderEffect.SetProperty( mCurrentCenterPropertyIndex, currentCenter );
-}
-
-void PageTurnEffect::SetIsTurningBack(bool isTurningBack)
-{
- float direction = isTurningBack ? 1.0f : -1.0f;
- mShaderEffect.SetUniform(IS_TURNING_BACK_PROPERTY_NAME, direction);
-}
-
-void PageTurnEffect::SetShadowWidth(float shadowWidth)
-{
- mShaderEffect.SetUniform( SHADOW_WIDTH_PROPERTY_NAME, shadowWidth );
-}
-
-void PageTurnEffect::SetSpineShadowParameter(const Vector2& spineShadowParameter)
-{
- mShaderEffect.SetUniform( SPINE_SHADOW_PARAMETER_PROPERTY_NAME, spineShadowParameter);
-}
-
-void PageTurnEffect::ApplyInternalConstraint()
-{
- Constraint constraint = Constraint::New<Matrix>( mShaderEffect, mShaderEffect.GetPropertyIndex( "uCommonParameters" ), CommonParametersConstraint );
- constraint.AddSource( LocalSource( mOriginalCenterPropertyIndex ) );
- constraint.AddSource( LocalSource( mCurrentCenterPropertyIndex ) );
- constraint.AddSource( LocalSource( mShaderEffect.GetPropertyIndex( PAGE_SIZE_PROPERTY_NAME ) ) );
- constraint.Apply();
-}
-
-const std::string& PageTurnEffect::GetPageSizePropertyName() const
-{
- return PAGE_SIZE_PROPERTY_NAME;
-}
-
-const std::string& PageTurnEffect::GetOriginalCenterPropertyName() const
-{
- return ORIGINAL_CENTER_PROPERTY_NAME;
-}
-
-const std::string& PageTurnEffect::GetCurrentCenterPropertyName() const
-{
- return CURRENT_CENTER_PROPERTY_NAME;
-}
-
-void PageTurnEffect::Initialize( Dali::ShaderEffect shaderEffect )
-{
- // Save a reference to the shader handle
- mShaderEffect = shaderEffect;
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_INTERNAL_PAGE_TURN_EFFECT_H__
-#define __DALI_TOOLKIT_INTERNAL_PAGE_TURN_EFFECT_H__
-
-/*
- * 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/animation/constraint.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/shader-effects/page-turn-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-/**
- * PageTurnEffect implementation class
- */
-class PageTurnEffect : public ShaderEffect::Extension
-{
-public:
-
- PageTurnEffect();
- /**
- * Virtual destructor.
- */
- virtual ~PageTurnEffect();
-
- /**
- * @copydoc Dali::Toolkit::PageTurnEffect::New
- */
- static Toolkit::PageTurnEffect CreateShaderEffect( bool enableBlending );
-
- /**
- * @copydoc Dali::Toolkit::PageTurnEffect::SetPageSize
- */
- void SetPageSize(const Vector2& pageSize);
-
- /**
- * @copydoc Dali::Toolkit::PageTurnEffect::SetOriginalCenter
- */
- void SetOriginalCenter(const Vector2& originalCenter);
-
- /**
- * @copydoc Dali::Toolkit::PageTurnEffect::SetCurrentCenter
- */
- void SetCurrentCenter(const Vector2& currentCenter);
-
- /**
- * @copydoc Dali::Toolkit::PageTurnEffect::SetIsTurningBack
- */
- void SetIsTurningBack(bool isTurningBack);
-
- /**
- * @copydoc Dali::Toolkit::PageTurnEffect::SetShadowWidth
- */
- void SetShadowWidth(float shadowWidth);
-
- /**
- *@copydoc Dali::Toolkit::PageTurnEffect::SetSpineShadowParameter
- */
- void SetSpineShadowParameter(const Vector2& spineShadowParameter);
-
- /**
- * The internal constraint uses the OriginalCenter property and the CurrentCenter Property
- * to update the variety of common parameters which are with the same value for all the vertices.
- * Note: For each actor, the constraints are applied in the same order as the calls to Actor::ApplyConstraint().
- * So if there are other contraints applied to the OriginalCenter or CurrentCenter while when using this effect,
- * call this method to get the internal constraints and re-apply it afterwards.
- */
- void ApplyInternalConstraint();
-
- /**
- * @copydoc Dali::Toolkit::PageTurnEffect::GetPageSizePropertyName
- */
- const std::string& GetPageSizePropertyName() const;
-
- /**
- * @copydoc Dali::Toolkit::PageTurnEffect::GetOriginalCenterPropertyName
- */
- const std::string& GetOriginalCenterPropertyName() const;
-
- /**
- * @copydoc Dali::Toolkit::PageTurnEffect::GetCurrentCenterPropertyName
- */
- const std::string& GetCurrentCenterPropertyName() const;
-
-private:
-
- void Initialize( ShaderEffect shaderEffect );
-
-private:
- ShaderEffect mShaderEffect;
-
- Property::Index mOriginalCenterPropertyIndex;
- Property::Index mCurrentCenterPropertyIndex;
-
-private:
- //undefined copy constructor.
- PageTurnEffect( const PageTurnEffect& );
-
- //Undefined assignment operator.
- PageTurnEffect& operator=( const PageTurnEffect& );
-
-};
-
-} // namespace Internal
-
-//Helpers for public-api forwarding methods
-inline Toolkit::Internal::PageTurnEffect& GetImpl( Toolkit::PageTurnEffect& effect )
-{
- DALI_ASSERT_ALWAYS( effect );
- return static_cast<Internal::PageTurnEffect&>( effect.GetExtension() );
-}
-
-inline const Toolkit::Internal::PageTurnEffect& GetImpl( const Toolkit::PageTurnEffect& effect )
-{
- DALI_ASSERT_ALWAYS( effect );
- return static_cast<const Internal::PageTurnEffect&>( effect.GetExtension() );
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif /* __DALI_TOOLKIT_INTERNAL_PAGE_TURN_EFFECT_H__*/
+++ /dev/null
-/*
- * 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 "water-effect-impl.h"
-
-// EXTERNAL INCLUDES
-#include <sstream>
-#include <iomanip>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/shader-effects/water-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-namespace
-{
-
-static const unsigned int LIGHT_MAP_SIZE = 512; ///< Size of the bitmap created for the pre-calculated wave function
-static const float MAX_WAVE_RADIUS = 80.0f; ///< Maximum radius of the wave in percentage of the texture coordinates
-
-} // namespace
-
-WaterEffect::WaterEffect( unsigned int numberOfWaves )
-: mNumberOfWaves( numberOfWaves )
-{
-}
-
-WaterEffect::~WaterEffect()
-{
-}
-
-unsigned int WaterEffect::GetNumberOfWaves() const
-{
- return mNumberOfWaves;
-}
-
-
-Dali::Toolkit::WaterEffect WaterEffect::CreateShaderEffect( unsigned int numberOfWaves )
-{
- std::ostringstream vertexShaderStringStream;
- vertexShaderStringStream << "#define NUMBER_OF_DROPS " << numberOfWaves << "\n";
- vertexShaderStringStream << "#define MAX_WAVE_RADIUS " << std::setprecision(1) << MAX_WAVE_RADIUS << "\n";
-
- std::string vertexShader(
- "mediump vec4 position = vec4( aPosition, 1.0 );\n"
- "\n"
- "struct Drops\n"
- "{\n"
- " mediump vec2 center;\n"
- " mediump float radius;\n"
- " mediump float amplitude;\n"
- "};\n"
- "uniform Drops uDrops[NUMBER_OF_DROPS];\n"
- "varying mediump vec4 vColor;\n"
- "void main()\n"
- "{\n"
- " position = uModelView * position;\n"
- " mediump float refraction = 0.0;\n"
- " for (int i=0; i<NUMBER_OF_DROPS; ++i)\n"
- " {\n"
- " mediump float distance = distance( uDrops[i].center, position.xy );\n"
- " mediump float attenuation = clamp(distance / uDrops[i].radius, 0.0, 1.0) * 1.57;\n"
- " refraction += uDrops[i].amplitude * cos( (distance - uDrops[i].radius) *0.075 ) * cos(attenuation);\n"
- " }\n"
- " vColor = uColor + vec4(vec3(clamp(refraction, -0.1, 1.0)), 1.0);\n"
- " vTexCoord = aTexCoord + vec2( sin(refraction)/MAX_WAVE_RADIUS );\n"
- " gl_Position = uProjection * position;\n"
- "}\n");
- vertexShaderStringStream << vertexShader;
-
- std::ostringstream fragmentShaderStringStream;
-
- std::string fragmentShader(
- "varying mediump vec4 vColor;\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = texture2D( sTexture, vTexCoord)*vColor;\n"
- "}\n");
- fragmentShaderStringStream << fragmentShader;
-
- // Create the implementation, temporarily owned on stack
- ShaderEffect shaderEffect = ShaderEffect::New(
- vertexShaderStringStream.str(),
- fragmentShaderStringStream.str(),
- GEOMETRY_TYPE_IMAGE,
- ShaderEffect::HINT_GRID );
-
- WaterEffect* shaderImpl = new WaterEffect( numberOfWaves );
-
- Dali::Toolkit::WaterEffect handle = Dali::Toolkit::WaterEffect( shaderEffect, shaderImpl );
-
- shaderImpl->Initialize( handle );
-
- for ( unsigned int index = 0; index < shaderImpl->mNumberOfWaves; ++index )
- {
- handle.SetUniform( shaderImpl->GetAmplitudePropertyName( index ), 0.0f );
- handle.SetUniform( shaderImpl->GetCenterPropertyName( index ), Vector2(0.0f, 0.0f), ShaderEffect::COORDINATE_TYPE_VIEWPORT_POSITION );
- handle.SetUniform( shaderImpl->GetPropagationPropertyName( index ), 0.0f );
- }
-
- return handle;
-}
-
-void WaterEffect::SetAmplitude( unsigned int index, float amplitude )
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfWaves );
- mShaderEffect.SetUniform( GetAmplitudePropertyName( index ), amplitude );
-}
-
-void WaterEffect::SetCenter( unsigned int index, const Vector2& center )
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfWaves );
- mShaderEffect.SetUniform( GetCenterPropertyName( index ), center, ShaderEffect::COORDINATE_TYPE_VIEWPORT_POSITION );
-}
-
-void WaterEffect::SetPropagation( unsigned int index, float radius )
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfWaves );
- mShaderEffect.SetUniform( GetPropagationPropertyName( index ) , radius );
-}
-
-float WaterEffect::GetAmplitude( unsigned int index ) const
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfWaves );
- Property::Index propertyIndex = mShaderEffect.GetPropertyIndex( GetAmplitudePropertyName( index ) );
- return mShaderEffect.GetProperty( propertyIndex ).Get<float>();
-}
-
-Vector2 WaterEffect::GetCenter( unsigned int index ) const
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfWaves );
- Property::Index propertyIndex = mShaderEffect.GetPropertyIndex( GetCenterPropertyName( index ) );
- return mShaderEffect.GetProperty( propertyIndex ).Get<Vector2>();
-}
-
-float WaterEffect::GetPropagation( unsigned int index ) const
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfWaves );
- Property::Index propertyIndex = mShaderEffect.GetPropertyIndex( GetPropagationPropertyName( index ) );
- return mShaderEffect.GetProperty( propertyIndex ).Get<float>();
-}
-
-std::string WaterEffect::GetAmplitudePropertyName( unsigned int index ) const
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfWaves );
- std::ostringstream oss;
- oss << "uDrops[" << index << "].amplitude";
- return oss.str();
-}
-
-std::string WaterEffect::GetCenterPropertyName( unsigned int index ) const
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfWaves );
- std::ostringstream oss;
- oss << "uDrops[" << index << "].center";
- return oss.str();
-}
-
-std::string WaterEffect::GetPropagationPropertyName( unsigned int index ) const
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfWaves );
- std::ostringstream oss;
- oss << "uDrops[" << index << "].radius";
- return oss.str();
-}
-
-void WaterEffect::Initialize( Dali::ShaderEffect shaderEffect )
-{
- // Save a reference to the shader handle
- mShaderEffect = shaderEffect;
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_INTERNAL_WATER_EFFECT_H__
-#define __DALI_TOOLKIT_INTERNAL_WATER_EFFECT_H__
-
-/*
- * 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <sstream>
-#include <cmath>
-#include <dali/public-api/shader-effects/shader-effect.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/shader-effects/water-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-/**
- * WaterEffect implementation class
- */
-class WaterEffect : public ShaderEffect::Extension
-{
-public:
-
- /**
- * @copydoc Dali::Toolkit::WaterEffect::WaterEffect
- */
- WaterEffect( unsigned int numberOfWaves );
-
- /**
- * @copydoc Dali::Toolkit::WaterEffect::~WaterEffect
- */
- virtual ~WaterEffect();
-
- /**
- * @copydoc Dali::Toolkit::WaterEffect::GetNumberOfWaves
- */
- unsigned int GetNumberOfWaves() const;
-
- /**
- * @copydoc Dali::Toolkit::WaterEffect::CreateShaderEffect
- */
- static Dali::Toolkit::WaterEffect CreateShaderEffect( unsigned int numberOfWaves );
-
- /**
- * @copydoc Dali::Toolkit::WaterEffect::SetAmplitude
- */
- void SetAmplitude( unsigned int index, float amplitude );
-
- /**
- * @copydoc Dali::Toolkit::WaterEffect::SetCenter
- */
- void SetCenter( unsigned int index, const Vector2& center );
-
- /**
- * @copydoc Dali::Toolkit::WaterEffect::SetPropagation
- */
- void SetPropagation( unsigned int index, float radius );
-
- /**
- * @copydoc Dali::Toolkit::WaterEffect::GetPropagation
- */
- float GetPropagation( unsigned int index ) const;
-
- /**
- * @copydoc Dali::Toolkit::WaterEffect::GetAmplitude
- */
- float GetAmplitude( unsigned int index ) const;
-
- /**
- * @copydoc Dali::Toolkit::WaterEffect::GetCenter
- */
- Vector2 GetCenter( unsigned int index ) const;
-
- /**
- * @copydoc Dali::Toolkit::WaterEffect::GetAmplitudePropertyName
- */
- std::string GetAmplitudePropertyName( unsigned int index ) const;
-
- /**
- * @copydoc Dali::Toolkit::WaterEffect::GetCenterPropertyName
- */
- std::string GetCenterPropertyName( unsigned int index ) const;
-
- /**
- * @copydoc Dali::Toolkit::WaterEffect::GetPropagationPropertyName
- */
- std::string GetPropagationPropertyName( unsigned int index ) const;
-
-private:
-
- void Initialize( ShaderEffect shaderEffect );
-
-private:
-
- ShaderEffect mShaderEffect;
-
- unsigned int mNumberOfWaves;
-
-
-private:
-
- // Undefined copy constructor.
- WaterEffect( const WaterEffect& );
-
- // Undefined assignment operator.
- WaterEffect& operator=( const WaterEffect& );
-
-};
-
-} // namespace Internal
-
-inline Internal::WaterEffect& GetImpl( Toolkit::WaterEffect& waterEffect )
-{
- return static_cast<Internal::WaterEffect&>( waterEffect.GetExtension() );
-}
-
-inline const Internal::WaterEffect& GetImpl( const Toolkit::WaterEffect& waterEffect )
-{
- return static_cast<const Internal::WaterEffect&>( waterEffect.GetExtension() );
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_INTERNAL_WATER_EFFECT_H__
$(public_api_src_dir)/focus-manager/focus-manager.cpp \
$(public_api_src_dir)/focus-manager/keyboard-focus-manager.cpp \
$(public_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \
- $(public_api_src_dir)/shader-effects/bubble-effect/bubble-effect.cpp \
- $(public_api_src_dir)/shader-effects/bubble-effect/color-adjuster.cpp \
- $(public_api_src_dir)/shader-effects/alpha-discard-effect.cpp \
- $(public_api_src_dir)/shader-effects/bendy-effect.cpp \
- $(public_api_src_dir)/shader-effects/blind-effect.cpp \
- $(public_api_src_dir)/shader-effects/bouncing-effect.cpp \
- $(public_api_src_dir)/shader-effects/carousel-effect.cpp \
- $(public_api_src_dir)/shader-effects/displacement-effect.cpp \
- $(public_api_src_dir)/shader-effects/dissolve-effect.cpp \
- $(public_api_src_dir)/shader-effects/dissolve-local-effect.cpp \
- $(public_api_src_dir)/shader-effects/distance-field-effect.cpp \
- $(public_api_src_dir)/shader-effects/image-region-effect.cpp \
- $(public_api_src_dir)/shader-effects/iris-effect.cpp \
- $(public_api_src_dir)/shader-effects/mask-effect.cpp \
- $(public_api_src_dir)/shader-effects/mirror-effect.cpp \
- $(public_api_src_dir)/shader-effects/motion-blur-effect.cpp \
- $(public_api_src_dir)/shader-effects/motion-stretch-effect.cpp \
- $(public_api_src_dir)/shader-effects/nine-patch-mask-effect.cpp \
- $(public_api_src_dir)/shader-effects/overlay-effect.cpp \
- $(public_api_src_dir)/shader-effects/page-turn-book-spine-effect.cpp \
- $(public_api_src_dir)/shader-effects/page-turn-effect.cpp \
- $(public_api_src_dir)/shader-effects/quadratic-bezier.cpp \
- $(public_api_src_dir)/shader-effects/ripple-effect.cpp \
- $(public_api_src_dir)/shader-effects/ripple2d-effect.cpp \
- $(public_api_src_dir)/shader-effects/shear-effect.cpp \
- $(public_api_src_dir)/shader-effects/soft-button-effect.cpp \
- $(public_api_src_dir)/shader-effects/spot-effect.cpp \
- $(public_api_src_dir)/shader-effects/square-dissolve-effect.cpp \
- $(public_api_src_dir)/shader-effects/swirl-effect.cpp \
- $(public_api_src_dir)/shader-effects/water-effect.cpp \
$(public_api_src_dir)/styling/style-manager.cpp \
$(public_api_src_dir)/transition-effects/cube-transition-cross-effect.cpp \
$(public_api_src_dir)/transition-effects/cube-transition-effect.cpp \
$(public_api_src_dir)/shader-effects/motion-stretch-effect.h \
$(public_api_src_dir)/shader-effects/nine-patch-mask-effect.h \
$(public_api_src_dir)/shader-effects/overlay-effect.h \
- $(public_api_src_dir)/shader-effects/page-turn-book-spine-effect.h \
- $(public_api_src_dir)/shader-effects/page-turn-effect.h \
$(public_api_src_dir)/shader-effects/quadratic-bezier.h \
$(public_api_src_dir)/shader-effects/ripple-effect.h \
$(public_api_src_dir)/shader-effects/ripple2d-effect.h \
$(public_api_src_dir)/shader-effects/soft-button-effect.h \
$(public_api_src_dir)/shader-effects/spot-effect.h \
$(public_api_src_dir)/shader-effects/square-dissolve-effect.h \
- $(public_api_src_dir)/shader-effects/swirl-effect.h \
- $(public_api_src_dir)/shader-effects/water-effect.h
-
-public_api_bubble_effect_header_files = \
- $(public_api_src_dir)/shader-effects/bubble-effect/bubble-effect.h \
- $(public_api_src_dir)/shader-effects/bubble-effect/color-adjuster.h
+ $(public_api_src_dir)/shader-effects/swirl-effect.h
public_api_styling_header_files = \
$(public_api_src_dir)/styling/style-manager.h
+++ /dev/null
-/*
- * Copyright (c) 2015 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 <dali-toolkit/public-api/shader-effects/alpha-discard-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-AlphaDiscardEffect::AlphaDiscardEffect()
-{
-}
-
-AlphaDiscardEffect::~AlphaDiscardEffect()
-{
-}
-
-AlphaDiscardEffect AlphaDiscardEffect::New()
-{
- const char* ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE =
- "void main() \n"
- "{ \n"
- " mediump vec4 color = texture2D( sTexture, vTexCoord ); \n"
- " if(color.a <= 0.0001) \n"
- " { \n"
- " discard; \n"
- " } \n"
- " gl_FragColor = color * uColor; \n"
- "} \n";
-
- ShaderEffect shader = ShaderEffect::New( "", // Use default
- ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE );
- return AlphaDiscardEffect( shader );
-}
-
-//Call the Parent copy constructor to add reference to the implementation for this object
-AlphaDiscardEffect::AlphaDiscardEffect( ShaderEffect handle )
-: ShaderEffect( handle )
-{
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
{
/**
+ * @brief Creates a new Alpha discard effect
+ *
* Alpha discard effect is used to discard fragments when the alpha colour value is below a threshold.
* This is useful for stenciling.
*
* Usage example:
*
* ImageActor actor = ImageActor::New( Image( EXAMPLE_IMAGE_PATH ) );
- * AlphaDiscardEffect alphaDiscardEffect = AlphaDiscardEffect::New();
+ * ShaderEffect alphaDiscardEffect = CreateAlphaDiscardEffect();
* actor.SetShaderEffect( alphaDiscardEffect );
+ *
+ * @return A handle to a newly allocated ShaderEffect.
*/
-class DALI_IMPORT_API AlphaDiscardEffect : public ShaderEffect
+inline ShaderEffect CreateAlphaDiscardEffect()
{
-public:
-
- /**
- * Create an empty AlphaDiscardEffect handle.
- */
- AlphaDiscardEffect();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~AlphaDiscardEffect();
-
- /**
- * Create a AlphaDiscardEffect.
- * @return A handle to a newly allocated AlphaDiscardEffect.
- */
- static AlphaDiscardEffect New();
-
-private: // Not intended for application developers
+ const char* ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE =
+ "void main() \n"
+ "{ \n"
+ " mediump vec4 color = texture2D( sTexture, vTexCoord ); \n"
+ " if(color.a <= 0.0001) \n"
+ " { \n"
+ " discard; \n"
+ " } \n"
+ " gl_FragColor = color * uColor; \n"
+ "} \n";
- DALI_INTERNAL AlphaDiscardEffect( ShaderEffect handle );
-};
+ return ShaderEffect::New( "", // Use default
+ ALPHA_DISCARD_FRAGMENT_SHADER_SOURCE );
+}
} // namespace Toolkit
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- *
- */
-
-#include <dali-toolkit/public-api/shader-effects/bendy-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace
-{
-
-const std::string CENTER_PROPERTY_NAME( "uCenter" );
-const std::string DIRECTION_PROPERTY_NAME( "uDirection" );
-const std::string RADIUS_PROPERTY_NAME( "uRadius" );
-
-} // namespace
-
-BendyEffect::BendyEffect()
-{
-}
-
-//Call the Parent copy constructor to add reference to the implementation for this object
-BendyEffect::BendyEffect(ShaderEffect handle)
-:ShaderEffect(handle)
-{
-}
-
-BendyEffect::~BendyEffect()
-{
-}
-
-
-BendyEffect BendyEffect::New()
-{
- // append the default version
- std::string vertextShader(
- "uniform mediump vec2 uCenter;\n"
- "uniform mediump vec2 uDirection;\n"
- "uniform mediump float uRadius;\n"
- "\n"
- "varying mediump float vShade;\n"
- "\n"
- "void main()\n"
- "{\n"
- " mediump float lighting = 0.25;\n"
- " mediump vec4 position = uModelView * vec4(aPosition,1.0);\n"
- "\n"
- " mediump vec2 d = position.xy - uCenter;\n"
- " mediump float dist = max( 0.0, dot(d,uDirection) );\n"
- " mediump float radius = max(0.0, uRadius - dist * 0.01);\n"
- "\n"
- " mediump float cs = cos(dist / radius / 2.0);\n"
- " mediump float sn = sin(dist / radius / 2.0);\n"
- "\n"
- "position.xy = position.xy - uDirection * dist;\n"
- "\n"
- "position.xy += uDirection * sn * radius;\n"
- "position.z += (1.0 - cs) * radius;\n"
- "\n"
- "gl_Position = uProjection * position;\n"
- "\n"
- "vShade = 1.0 - abs(sn) * lighting;\n"
- "\n"
- "vTexCoord = aTexCoord;\n"
- "}" );
-
- std::string fragmentShader(
- "varying mediump float vShade;\n"
- "\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = texture2D(sTexture, vTexCoord) * uColor * vec4(vShade,vShade,vShade,1.0);\n"
- "}" );
-
- // Create the implementation, temporarily owned on stack,
- Dali::ShaderEffect shaderEffectCustom = Dali::ShaderEffect::New(
- vertextShader,
- fragmentShader,
- GeometryType( GEOMETRY_TYPE_IMAGE ),
- ShaderEffect::GeometryHints( HINT_GRID | HINT_DEPTH_BUFFER ));
-
- /* Pass ownership to BendyEffect through overloaded constructor, So that it now has access to the
- Dali::ShaderEffect implementation */
- Dali::Toolkit::BendyEffect handle( shaderEffectCustom );
-
- handle.SetUniform( CENTER_PROPERTY_NAME, Vector2(0.0f, 0.0f), COORDINATE_TYPE_VIEWPORT_POSITION );
- handle.SetUniform( DIRECTION_PROPERTY_NAME, Vector2(0.0f, 0.0f), COORDINATE_TYPE_VIEWPORT_DIRECTION );
- handle.SetUniform( RADIUS_PROPERTY_NAME, 0.0f );
-
- return handle;
-}
-
-void BendyEffect::SetCenter( const Vector2& center )
-{
- SetUniform( CENTER_PROPERTY_NAME, center, ShaderEffect::COORDINATE_TYPE_VIEWPORT_POSITION );
-}
-
-void BendyEffect::SetDirection( const Vector2& direction )
-{
- Vector2 temp(direction);
- temp.Normalize();
-
- Vector2 newDirection(temp.x, temp.y);
-
- SetUniform( DIRECTION_PROPERTY_NAME, newDirection, ShaderEffect::COORDINATE_TYPE_VIEWPORT_DIRECTION );
-}
-
-void BendyEffect::SetRadius( float radius )
-{
- SetUniform( RADIUS_PROPERTY_NAME, radius );
-}
-
-const std::string& BendyEffect::GetCenterPropertyName() const
-{
- return CENTER_PROPERTY_NAME;
-}
-
-const std::string& BendyEffect::GetDirectionPropertyName() const
-{
- return DIRECTION_PROPERTY_NAME;
-}
-
-const std::string& BendyEffect::GetRadiusPropertyName() const
-{
- return RADIUS_PROPERTY_NAME;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
{
/**
+ * Creates a new Bendy effect
+ *
* BendyEffect is a custom shader effect to achieve bendy effects in Image actors
+ *
+ * Animatable/Constrainable uniforms:
+ * "uCenter" - The center point of the bendy effect
+ * "uDirection" - The direction of the bendy effect
+ * "uRadius" - The radius of the bendy effect
+ *
+ * @return A handle to a newly allocated ShaderEffect.
*/
-class DALI_IMPORT_API BendyEffect : public ShaderEffect
+inline ShaderEffect CreateBendyEffect()
{
-public:
-
- /**
- * Create an uninitialized BendyEffect; this can be initialized with BendyEffect::New()
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- BendyEffect();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~BendyEffect();
-
- /**
- * Create an initialized BendyEffect.
- * @return A handle to a newly allocated Dali resource.
- */
- static BendyEffect New();
-
- /**
- * Set the center point of the bendy effect.
- * @param [in] center The new center point.
- */
- void SetCenter(const Vector2& center);
-
- /**
- * Set the direction of the bendy effect.
- * @param [in] direction The new direction.
- */
- void SetDirection(const Vector2& direction);
-
- /**
- * Set the radius of the bendy effect.
- * @param [in] radius The new radius.
- */
- void SetRadius(float radius);
-
- /**
- * Get the name for the center property
- * @return A std::string containing the property name
- */
- const std::string& GetCenterPropertyName() const;
-
- /**
- * Get the name for the direction property
- * which can be used in Animation API's
- * @return A std::string containing the property name
- */
- const std::string& GetDirectionPropertyName() const;
-
- /**
- * Get the name for the radius property
- * which can be used in Animation API's
- * @return A std::string containing the property name
- */
- const std::string& GetRadiusPropertyName() const;
-
-
-private: // Not intended for application developers
- DALI_INTERNAL BendyEffect(ShaderEffect handle);
-};
+ // append the default version
+ std::string vertextShader(
+ "uniform mediump vec2 uCenter;\n"
+ "uniform mediump vec2 uDirection;\n"
+ "uniform mediump float uRadius;\n"
+ "\n"
+ "varying mediump float vShade;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " mediump float lighting = 0.25;\n"
+ " mediump vec4 position = uModelView * vec4(aPosition,1.0);\n"
+ "\n"
+ " mediump vec2 d = position.xy - uCenter;\n"
+ " mediump float dist = max( 0.0, dot(d,uDirection) );\n"
+ " mediump float radius = max(0.0, uRadius - dist * 0.01);\n"
+ "\n"
+ " mediump float cs = cos(dist / radius / 2.0);\n"
+ " mediump float sn = sin(dist / radius / 2.0);\n"
+ "\n"
+ "position.xy = position.xy - uDirection * dist;\n"
+ "\n"
+ "position.xy += uDirection * sn * radius;\n"
+ "position.z += (1.0 - cs) * radius;\n"
+ "\n"
+ "gl_Position = uProjection * position;\n"
+ "\n"
+ "vShade = 1.0 - abs(sn) * lighting;\n"
+ "\n"
+ "vTexCoord = aTexCoord;\n"
+ "}" );
+
+ std::string fragmentShader(
+ "varying mediump float vShade;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " gl_FragColor = texture2D(sTexture, vTexCoord) * uColor * vec4(vShade,vShade,vShade,1.0);\n"
+ "}" );
+
+ // Create the implementation, temporarily owned on stack,
+ Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New(
+ vertextShader,
+ fragmentShader,
+ GeometryType( GEOMETRY_TYPE_IMAGE ),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_DEPTH_BUFFER ));
+
+ shaderEffect.SetUniform( "uCenter", Vector2(0.0f, 0.0f), ShaderEffect::COORDINATE_TYPE_VIEWPORT_POSITION );
+ shaderEffect.SetUniform( "uDirection", Vector2(0.0f, 0.0f), ShaderEffect::COORDINATE_TYPE_VIEWPORT_DIRECTION );
+ shaderEffect.SetUniform( "uRadius", 0.0f );
+
+
+ return shaderEffect;
+}
} // namespace Toolkit
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- *
- */
-
-#include <dali-toolkit/public-api/shader-effects/blind-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace
-{
-
-const std::string STEP_PROPERTY_NAME( "uStep" );
-
-} // namespace
-
-BlindEffect::BlindEffect()
-{
-}
-
-//Call the Parent copy constructor to add reference to the implementation for this object
-BlindEffect::BlindEffect(ShaderEffect handle)
-:ShaderEffect(handle)
-{
-}
-
-BlindEffect::~BlindEffect()
-{
-}
-
-
-BlindEffect BlindEffect::New()
-{
- std::string fragmentShader(
- "uniform mediump float uStep; \n"
- "void main() \n"
- "{ \n"
- " mediump vec4 alphaColor; \n"
- " mediump vec4 baseColor; \n"
- " baseColor = texture2D( sTexture, vTexCoord); \n"
- " alphaColor = vec4(0.1,0.1,0.1,1.0); \n"
- " lowp float index = 0.0; \n"
- " index = floor(vTexCoord.y/0.1); \n"
- " if((vTexCoord.y < (index * 0.1 + uStep * 0.005)) && (vTexCoord.y > index * 0.1))\n"
- " { \n"
- " gl_FragColor = alphaColor; \n"
- " } \n"
- " else \n"
- " { \n"
- " gl_FragColor = baseColor; \n"
- " } \n"
- " gl_FragColor*=uColor; \n"
- "} \n"
- );
-
- Dali::ShaderEffect shaderEffectCustom = Dali::ShaderEffect::New(
- "",
- fragmentShader,
- Dali::GeometryType( GEOMETRY_TYPE_IMAGE ),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID ));
-
- Dali::Toolkit::BlindEffect handle( shaderEffectCustom );
-
- handle.SetUniform( STEP_PROPERTY_NAME, 0.0f );
-
- return handle;
-}
-
-void BlindEffect::SetStep(float step)
-{
- SetUniform( STEP_PROPERTY_NAME, step );
-}
-
-const std::string& BlindEffect::GetStepPropertyName() const
-{
- return STEP_PROPERTY_NAME;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
{
/**
- * BlindEffect is a custom shader effect to achieve blind effects in Image actors
+ * @brief BlindEffect is a custom shader effect to achieve blind effects in Image actors
+ *
+ * Animatable/Constrainable uniforms:
+ * "uStep" - The step of the blind effect.
+ *
+ * @return A handle to a newly allocated ShaderEffect
*/
-class DALI_IMPORT_API BlindEffect : public ShaderEffect
-{
-public:
-
- /**
- * Create an uninitialized BlindEffect; this can be initialized with BlindEffect::New()
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- BlindEffect();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~BlindEffect();
-
- /**
- * Create an initialized ~BlindEffect.
- * @return A handle to a newly allocated Dali resource.
- */
- static BlindEffect New();
+inline ShaderEffect CreateBlindEffect()
+{
+ std::string fragmentShader(
+ "uniform mediump float uStep; \n"
+ "void main() \n"
+ "{ \n"
+ " mediump vec4 alphaColor; \n"
+ " mediump vec4 baseColor; \n"
+ " baseColor = texture2D( sTexture, vTexCoord); \n"
+ " alphaColor = vec4(0.1,0.1,0.1,1.0); \n"
+ " lowp float index = 0.0; \n"
+ " index = floor(vTexCoord.y/0.1); \n"
+ " if((vTexCoord.y < (index * 0.1 + uStep * 0.005)) && (vTexCoord.y > index * 0.1))\n"
+ " { \n"
+ " gl_FragColor = alphaColor; \n"
+ " } \n"
+ " else \n"
+ " { \n"
+ " gl_FragColor = baseColor; \n"
+ " } \n"
+ " gl_FragColor*=uColor; \n"
+ "} \n"
+ );
- /**
- * Set the step of the blind effect.
- * @param [in] step The step
- */
- void SetStep(float step);
+ Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New(
+ "",
+ fragmentShader,
+ GeometryType( GEOMETRY_TYPE_IMAGE ),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING | ShaderEffect::HINT_GRID ));
- /**
- * Get the name for the step property
- * which can be used in Animation API's
- * @return A std::string containing the property name
- */
- const std::string& GetStepPropertyName() const;
+ shaderEffect.SetUniform( "uStep", 0.0f );
-private: // Not intended for application developers
- DALI_INTERNAL BlindEffect(ShaderEffect handle);
-};
+ return shaderEffect;
+}
} // namespace Toolkit
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- *
- */
-
-#include <dali-toolkit/public-api/shader-effects/bouncing-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace
-{
-
-#define MAKE_STRING(A)#A
-
-const std::string PROGRESS_RATE_PROPERTY_NAME( "uProgressRate" );
-
-} // namespace
-
-BouncingEffect::BouncingEffect()
-{
-}
-
-BouncingEffect::BouncingEffect( ShaderEffect handle )
-:ShaderEffect( handle )
-{
-}
-
-BouncingEffect::~BouncingEffect()
-{
-}
-
-BouncingEffect BouncingEffect::New( const Vector4& color )
-{
- std::string fragmentShader = MAKE_STRING(
- precision mediump float;\n
- uniform float uProgressRate;\n
- uniform vec4 uAssignedColor;\n
- void main()\n
- {\n
- float progressRate = abs(uProgressRate)*0.5;\n
- float amplitude = 0.15 - progressRate*0.15 ;\n
- float x1 = 7.5 * (vTexCoord.x - progressRate);\n
- float x2 = 7.5 * (vTexCoord.x - 1.0 + progressRate);\n
- float height1 = max(0.00001, 0.3 - amplitude * ( exp(x1) + exp(-x1) ) );\n
- float height2 = max(0.00001, 0.3 - amplitude * ( exp(x2) + exp(-x2) ) );\n
- float height3 = max(0.00001, 1.0 - 3.0 * amplitude * ( exp(x1*0.5) + exp(-x1*0.5) ) );\n
- float height4 = max(0.00001, 1.0 - 3.0 * amplitude * ( exp(x2*0.5) + exp(-x2*0.5) ) );\n
- vec4 fragColor = vec4(0.0);\n
- float y = vTexCoord.y/(height1+height2);\n
- float y2 = vTexCoord.y/max(height3,height4);\n
- float coef = max(height1,height2)*5.0/( 1.0+exp(y*12.0-6.0) );\n
- float alpha = pow( max(0.0,(1.0-y2))*(1.0-min(abs(x1),abs(x2))/5.0), 2.0);\n
- if( vTexCoord.y < 0.075 )\n
- {\n
- fragColor= mix(uAssignedColor, vec4(1.0), coef);\n
- fragColor += (vec4(1.0)-fragColor) * alpha;\n
- }\n
- else if (y2<1.0)\n
- {\n
- fragColor =vec4(1.0,1.0,1.0, alpha + (1.0-alpha)*coef);\n
- fragColor.rgb -= ( vec3(1.0)-uAssignedColor.rgb )*min(clamp(y*1.2-0.3, 0.0, 0.3),clamp(0.9-y*1.2,0.0,0.3));\n
- }\n
- fragColor.a *= 10.0*min(min(vTexCoord.x, 1.0-vTexCoord.x),0.1)*min(1.0, progressRate/0.2);\n
- gl_FragColor = fragColor;\n
- }
- );
-
- ShaderEffect shaderEffect;
- shaderEffect = ShaderEffect::New( "", fragmentShader,
- GeometryType( GEOMETRY_TYPE_IMAGE),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
- BouncingEffect handle( shaderEffect );
-
- handle.SetUniform( "uAssignedColor", color );
- handle.SetProgressRate( 0.f );
-
- return handle;
-}
-
-void BouncingEffect::SetProgressRate( float progress )
-{
- SetUniform( PROGRESS_RATE_PROPERTY_NAME, progress );
-}
-
-const std::string& BouncingEffect::GetProgressRatePropertyName() const
-{
- return PROGRESS_RATE_PROPERTY_NAME;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
{
/**
- * @brief BouncingEffect is a custom overscroll effect with two waves appearing at two sides then moving towards center and overlapping.
+ * @brief Creates a new bouncing effect
+ *
+ * BouncingEffect is a custom overscroll effect with two waves appearing at two sides then moving towards center and overlapping.
*
* Usage Example:
*
* // Create the an imageActor, set shader effect, and add it to the stage
* ImageActor imageActor = ImageActor::New( BufferImage::New( 1, 1 ) );
* imageActor.SetSize(720.f,58.f);
- * Toolkit::BouncingEffect bouncingEffect = Toolkit::BouncingEffect::New( Vector4(0.f,1.f,1.f,0.5f) );
+ * Toolkit::ShaderEffect bouncingEffect = CreateBouncingEffect( Vector4(0.f,1.f,1.f,0.5f) );
* imageActor.SetShaderEffect( bouncingEffect );
* imageActor.SetParentOrigin( ParentOrigin::CENTER );
* Stage::GetCurrent().Add( imageActor );
*
* // Start the animation
* Animation animation = Animation::New(1.f);
- * animation.AnimateTo( Property( bouncingEffect, bouncingEffect.GetProgressRatePropertyName() ),
+ * animation.AnimateTo( Property( bouncingEffect,"uProgressRate" ),
* 1.f, AlphaFunction::BOUNCE );
* animation.Play();
+ *
+ * Animatable/Constrainable uniforms:
+ * "uProgressRate" - The progress rate to the effect
+ *
+ * @param[in] color The color used on the bouncing stripe
+ * @return A handle to a newly allocated ShaderEffect
*/
-class DALI_IMPORT_API BouncingEffect : public ShaderEffect
-{
-public:
-
- /**
- * @brief Creates an empty BouncingEffect handle
- */
- BouncingEffect();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~BouncingEffect();
- /**
- * @brief Create a BouncingEffect object
- *
- * @param[in] color The color used on the bouncing stripe
- * @return A handle to a newly allocated Dali resource.
- */
- static BouncingEffect New( const Vector4& color );
-
- /**
- * @brief Set the progress rate to the effect.
- *
- * The whole progress ( with progress rate from 0.0 to 1.0 ):
- * two waves appear at two sides; move towards center and overlap.
- * @param[in] progressRate The progress rate value.
- */
- void SetProgressRate( float progressRate );
-
- /**
- * @brief Get the name for the progress rate property.
- *
- * @return A std::string containing the property name.
- */
- const std::string& GetProgressRatePropertyName() const;
-
-
-private: // Not intended for application developers
- DALI_INTERNAL BouncingEffect( ShaderEffect handle );
+inline ShaderEffect CreateBouncingEffect(const Vector4& color)
+{
+ std::string fragmentShader = DALI_COMPOSE_SHADER(
+ precision mediump float;\n
+ uniform float uProgressRate;\n
+ uniform vec4 uAssignedColor;\n
+ void main()\n
+ {\n
+ float progressRate = abs(uProgressRate)*0.5;\n
+ float amplitude = 0.15 - progressRate*0.15 ;\n
+ float x1 = 7.5 * (vTexCoord.x - progressRate);\n
+ float x2 = 7.5 * (vTexCoord.x - 1.0 + progressRate);\n
+ float height1 = max(0.00001, 0.3 - amplitude * ( exp(x1) + exp(-x1) ) );\n
+ float height2 = max(0.00001, 0.3 - amplitude * ( exp(x2) + exp(-x2) ) );\n
+ float height3 = max(0.00001, 1.0 - 3.0 * amplitude * ( exp(x1*0.5) + exp(-x1*0.5) ) );\n
+ float height4 = max(0.00001, 1.0 - 3.0 * amplitude * ( exp(x2*0.5) + exp(-x2*0.5) ) );\n
+ vec4 fragColor = vec4(0.0);\n
+ float y = vTexCoord.y/(height1+height2);\n
+ float y2 = vTexCoord.y/max(height3,height4);\n
+ float coef = max(height1,height2)*5.0/( 1.0+exp(y*12.0-6.0) );\n
+ float alpha = pow( max(0.0,(1.0-y2))*(1.0-min(abs(x1),abs(x2))/5.0), 2.0);\n
+ if( vTexCoord.y < 0.075 )\n
+ {\n
+ fragColor= mix(uAssignedColor, vec4(1.0), coef);\n
+ fragColor += (vec4(1.0)-fragColor) * alpha;\n
+ }\n
+ else if (y2<1.0)\n
+ {\n
+ fragColor =vec4(1.0,1.0,1.0, alpha + (1.0-alpha)*coef);\n
+ fragColor.rgb -= ( vec3(1.0)-uAssignedColor.rgb )*min(clamp(y*1.2-0.3, 0.0, 0.3),clamp(0.9-y*1.2,0.0,0.3));\n
+ }\n
+ fragColor.a *= 10.0*min(min(vTexCoord.x, 1.0-vTexCoord.x),0.1)*min(1.0, progressRate/0.2);\n
+ gl_FragColor = fragColor;\n
+ }
+ );
+
+ ShaderEffect shaderEffect;
+ shaderEffect = ShaderEffect::New( "", fragmentShader,
+ GeometryType( GEOMETRY_TYPE_IMAGE),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
+
+ shaderEffect.SetUniform( "uAssignedColor", color );
+ shaderEffect.SetUniform( "uProgressRate", 0.0f );
+
+ return shaderEffect;
+}
-};
} // namespace Toolkit
+++ /dev/null
-/*
- * Copyright (c) 2015 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 "bubble-effect.h"
-
-// EXTERNAL HEADERS
-#include <sstream>
-#include <dali/public-api/common/stage.h>
-#include <dali/public-api/images/image.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace
-{
-
-const std::string MAGNIFICATIOB_PROPERTY_NAME( "uMagnification" );
-const float EACH_WIDTH_PER_SHAPE(32.0f);
-
-} // namespace
-
-BubbleEffect::BubbleEffect()
-: mNumberOfBubbles(0)
-{
-}
-
-BubbleEffect::BubbleEffect( ShaderEffect handle )
-: ShaderEffect( handle ),
- mNumberOfBubbles(0)
-{
-}
-
-BubbleEffect::~BubbleEffect()
-{
-}
-
-BubbleEffect BubbleEffect::New( unsigned int numberOfBubble)
-{
- std::ostringstream vertexShaderStringStream;
- vertexShaderStringStream << "#define NUMBER_OF_BUBBLE "<< numberOfBubble << "\n";
- std::string vertexShader(
- " precision mediump float;\n"
- // the gravity applied to the y direction
- " uniform float uGravity; \n"
- // xy: the emit position of the bubble; zw: the destinationof the bubble.
- // The bubble is moving from (xy) to (zw plus the y drop influenced by gravity).
- " uniform vec4 uStartAndEndPos[NUMBER_OF_BUBBLE];\n"
- // The undergoing percentage of the bubble movement. 0.0: start from emit position, 1.0: reach the destination
- " uniform float uPercentage[NUMBER_OF_BUBBLE];\n"
- " uniform vec2 uInvertedMovementArea; \n"
- // The bubble number is restricted by the available uniform num.
- // To increase the displayed bubble, every uStartAndEndPos and uPercentage uniform is applied to a small bunch of bubbles (9 here)
- // The offset defines the random offset between bubbles within the bunch.
- " uniform vec2 offset[9]; \n"
- // This uniform is specially for increase part of the bubble size and spread the bubble to the whole screen when unlock to home screen
- " uniform float uMagnification; \n"
- // This uniform is used to change the bubble size during running time
- " uniform float uDynamicScale; \n"
- " varying float vPercentage;\n"
- " varying vec2 vEffectTexCoord;\n"
- " void main()\n"
- " {\n"
- " mediump vec4 position = vec4( aPosition.xy, 0.0, 1.0 );\n"
- // The Z coordinate is used to record the bubble index within current mesh actor
- " int zCoord = int(aPosition.z); \n"
- // for some i between 0 ~ NUMBER_OF_BUBBLE-1: i,i+NUMBER_OF_BUBBLE, i+NUMBER_OF_BUBBLE*2, ... (up to i+NUMBER_OF_BUBBLE*8) belongs to the same bunch.
- " int groupIdx = zCoord / NUMBER_OF_BUBBLE;\n"
- // The bubbles within the same bunch applies the same uniforms uStartAndEndPos[idx] & uPercentage[idx]
- " int idx = zCoord - groupIdx*NUMBER_OF_BUBBLE;\n"
- // early out if uPercentage is (zero || one) setting position to zero (zero sized triangles)
- " if( uPercentage[idx] <= 0.0 || uPercentage[idx] >= 1.0 )\n"
- " {\n"
- " gl_Position = vec4(0.0);\n"
- " return;\n"
- " }\n"
- " vec4 startAndEnd = uStartAndEndPos[idx]; \n"
- // The final position is added up different offset for bubbles
- " startAndEnd.zw += offset[groupIdx];\n"
- // Notice: Only animate the uMagnification for unlock (bubble explosion animation)!
- // In other cases, uMagnification = 1.0!
- // Increase the Size of part of bubbles and increase the speed of movement for unlock.
- // Performance acceptable: Branch on a uniform variable.
- " if( uMagnification > 1.0)\n"
- " {\n"
- " if(mod(aPosition.z,24.0) < 1.0 )\n"
- " {\n"
- " position.xy *= uMagnification;\n"
- " }\n"
- " }\n"
- " float percentage = uPercentage[idx]*min(uMagnification,2.5);\n"
- "\n"
- // increase the bubble size from 0% to 100% during the first 1/5 of movement & apply the dynamic scale
- // the new xy value containes both the new scale and new bubble position
- " position.xy *= uDynamicScale*min(percentage*5.0, 1.0);\n"
- " position.xy += mix(startAndEnd.xy, startAndEnd.zw, percentage*uMagnification);\n"
- // The gravity is g*t*t on the y direction
- " position.y += uGravity * pow(percentage, 2.0);\n"
- " gl_Position = uMvpMatrix * position;\n"
- "\n"
- // Add multiple bubble shapes in the effect
- " vTexCoord = aTexCoord;\n"
- " vPercentage = percentage;\n"
- // Use the emit position color for the bubble
- " vEffectTexCoord = startAndEnd.xy * uInvertedMovementArea;\n"
- " }\n" );
- vertexShaderStringStream << vertexShader;
-
- std::string fragmentShader(
- " precision mediump float;\n"
- " varying float vPercentage;\n"
- " varying vec2 vEffectTexCoord;\n"
- "\n"
- " void main()\n"
- " {\n"
- // Get the emit pisition color, and Mix with the actor color
- " vec4 fragColor = texture2D(sEffect, vEffectTexCoord)*uColor;\n"
- // Apply the shape defined by the texture contained in the material
- // And make the opacity being 0.7, and animate from 0.7 to 0 during the last 1/5 of movement
- " fragColor.a *= texture2D(sTexture, vTexCoord).a * ( 3.5 - max( vPercentage*3.5, 2.8 ) );\n"
- " gl_FragColor = fragColor;\n"
- " }\n");
-
- ShaderEffect shaderEffect = ShaderEffect::New(
- vertexShaderStringStream.str(),
- fragmentShader,
- GeometryType( GEOMETRY_TYPE_TEXTURED_MESH),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
-
- BubbleEffect handle( shaderEffect );
-
- handle.mNumberOfBubbles = numberOfBubble;
- handle.SetMovementArea( Stage::GetCurrent().GetSize() );
-
- handle.SetUniform( "uGravity", 50.f );
- handle.SetUniform( "uMagnification", 1.f );
- handle.SetUniform( "uDynamicScale", 1.f );
-
- Vector4 zeroVector;
- for( unsigned int i=0; i<numberOfBubble; i++ )
- {
- handle.SetPercentage( i, 0.f);
- handle.SetStartAndEndPosition( i, zeroVector );
- }
-
- return handle;
-}
-
-void BubbleEffect::SetMovementArea( const Vector2& movementArea )
-{
- if( movementArea == mMovementArea )
- {
- return;
- }
-
- mMovementArea = movementArea;
- SetUniform( "uInvertedMovementArea", Vector2(1.f,1.f) / mMovementArea );
-
- srand(time(NULL));
- int offset = mMovementArea.Length() / 10.f;
- SetUniform("offset[0]", Vector2(0.f,0.f));
- SetUniform("offset[1]", Vector2(rand()%offset,rand()%offset) );
- SetUniform("offset[2]", Vector2(rand()%offset,-rand()%offset) );
- SetUniform("offset[3]", Vector2(-rand()%offset,rand()%offset) );
- SetUniform("offset[4]", Vector2(-rand()%offset,-rand()%offset) );
- SetUniform("offset[5]", Vector2(rand()%offset,0.f));
- SetUniform("offset[6]", Vector2(-rand()%offset,0.f));
- SetUniform("offset[7]", Vector2(0.f,rand()%offset));
- SetUniform("offset[8]", Vector2(0.f,-rand()%offset));
-}
-
-void BubbleEffect::SetStartAndEndPosition( unsigned int index, const Vector4& startAndEndPosition )
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfBubbles );
- std::ostringstream oss;
- oss<< "uStartAndEndPos["<< index << "]";
- SetUniform( oss.str(), startAndEndPosition );
-}
-
-void BubbleEffect::SetPercentage( unsigned int index, float percentage )
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfBubbles );
- SetUniform( GetPercentagePropertyName(index), percentage );
-}
-
-void BubbleEffect::SetGravity( float gravity )
-{
- SetUniform( "uGravity", gravity );
-}
-
-void BubbleEffect::SetDynamicScale( float scale )
-{
- SetUniform( "uDynamicScale", scale );
-}
-
-void BubbleEffect::SetMagnification( float magnification )
-{
- SetUniform( MAGNIFICATIOB_PROPERTY_NAME, magnification );
-}
-
-std::string BubbleEffect::GetPercentagePropertyName( unsigned int index ) const
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfBubbles );
- std::ostringstream oss;
- oss<< "uPercentage["<< index << "]";
- return oss.str();
-}
-
-std::string BubbleEffect::GetMagnificationPropertyName() const
-{
- return MAGNIFICATIOB_PROPERTY_NAME;
-}
-
-void BubbleEffect::ResetParameters()
-{
- SetMagnification( 1.f );
- Vector4 zeroVector;
- for( unsigned int i=0; i<mNumberOfBubbles; i++ )
- {
- SetPercentage( i, 1.f);
- SetStartAndEndPosition( i, zeroVector );
- }
-}
-
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHADER_BUBBLE_EFFECT_H__
-#define __DALI_TOOLKIT_SHADER_BUBBLE_EFFECT_H__
-
-/*
- * Copyright (c) 2015 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * BubbleEffect is a custom shader to achieve similar effect of particle system by applying on a specially created MeshActor
- * Each bubble is rendered on a patch with two triangles; and each mesh can contain multiple such patches.
- */
-class DALI_IMPORT_API BubbleEffect : public ShaderEffect
-{
-public:
-
- /**
- * Create an empty BubbleEffect handle
- */
- BubbleEffect();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~BubbleEffect();
-
- /**
- * Create an initialized BubbleEffect
- * @param[in] numberOfBubble How many groups of uniforms are used to control the bubble movement.
- * Note: Limited by the maximum available uniforms, this parameter cannot be bigger than 100.
- * Ideally use one group of uniform to control one bubble.
- * If the num of patches in the MeshActor is more than groups of uniforms,
- * the uniform values will be shared by multiple bubbles. Allow up to 9 times.
- * @return A handle to a newly allocated Dali resource.
- */
- static BubbleEffect New( unsigned int numberOfBubble);
-
- /**
- * Set the bubble movement area for the BubbleEffect
- * @param[in] movementArea The size of bubble movement area; by default, it is the stage size
- */
- void SetMovementArea( const Vector2& movementArea );
-
- /**
- * Set the start and end positions of the index-th bubble's movement.
- * @param[in] index Indicate which bubble these properties are applied on.
- * @param[in] startAndEndPosition The start and the end position of movement.
- */
- void SetStartAndEndPosition( unsigned int index, const Vector4& startAndEndPosition );
-
- /**
- * Set the movement completed percentage of the index-th bubble.
- * The bubble will appear at start position when percentage equals to zero,
- * and disappear near end position (affected by gravity) when percentage equals to one.
- * This percentage property is used to animate the bubble movement.
- * @param[in] index Indicate which bubble this property is applied on.
- * @param[in] percentage Set the percentage property value ( between zero and one ).
- */
- void SetPercentage( unsigned int index, float percentage );
-
- /**
- * Set the gravity applied to the y direction, which makes the bubbles no longer moving on a straight line.
- * @param[in] gravity The gravity on the y direction.
- */
- void SetGravity( float gravity );
-
- /**
- * Set the scale factor applied to the bubbles
- * @param[in] scale The scale factor applied on all bubbles.
- */
- void SetDynamicScale( float scale );
-
- /**
- * Increase both the bubble size and moving speed.
- * Animate this peoperty to create special effect such as all the bubbles blow up on the screen.
- * @param[in] magnification The manified factor applied on the bubble size and moving speed.
- */
- void SetMagnification( float magnification );
-
- /**
- * Get the name for the idx-th percentage property.
- * @param[in] index The percentage property index.
- * @return std::string containing the property name.
- */
- std::string GetPercentagePropertyName( unsigned int index ) const;
-
- /**
- * Get the name for the magnification property.
- * @return std::string containinf the property name.
- */
- std::string GetMagnificationPropertyName() const;
-
- /**
- * Reset the uniform values to default.
- */
- void ResetParameters();
-
-private:// Not intended for application developers
-
- DALI_INTERNAL BubbleEffect( ShaderEffect handle );
-
-private:
-
- unsigned int mNumberOfBubbles;
- Vector2 mMovementArea;
-};
-
-} // namespace Toolkit
-
-} // namespace Dali
-#endif /* __DALI_TOOLKIT_SHADER_BUBBLE_EFFECT_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2015 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 "color-adjuster.h"
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace
-{
-const std::string HSVDELTA_PROPERTY_NAME("uHSVDelta");
-}
-
-ColorAdjuster::ColorAdjuster()
-{
-}
-
-//Call the Parent copy constructor to add reference to the implementation for this object
-ColorAdjuster::ColorAdjuster( ShaderEffect handle )
-: ShaderEffect( handle )
-{
-}
-
-ColorAdjuster::~ColorAdjuster()
-{
-}
-
-ColorAdjuster ColorAdjuster::New( const Vector3& hsvDelta, bool ignoreAlpha )
-{
- std::string fragmentShader(
- " precision highp float;\n"
- " uniform vec3 uHSVDelta;\n"
- " uniform float uIgnoreAlpha;\n"
- " float rand(vec2 co) \n"
- " {\n"
- " return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); \n"
- " }\n"
- " vec3 rgb2hsv(vec3 c)\n"
- " {\n"
- " vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n"
- " vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n"
- " vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n"
- " \n"
- " float d = q.x - min(q.w, q.y);\n"
- " float e = 1.0e-10;\n"
- " return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n"
- " }\n"
- " vec3 hsv2rgb(vec3 c)\n"
- " {\n"
- " vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n"
- " vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n"
- " return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n"
- " }\n"
- " void main() {\n"
- " vec4 color = texture2D(sTexture, vTexCoord); \n"
- " vec3 hsvColor = rgb2hsv( color.rgb );\n"
- // modify the hsv Value
- " hsvColor += uHSVDelta * rand(vTexCoord); \n"
- // if the new vale exceeds one, then decrease it
- " hsvColor -= max(hsvColor*2.0 - vec3(2.0), 0.0);\n"
- // if the new vale drops below zero, then increase it
- " hsvColor -= min(hsvColor*2.0, 0.0);\n"
- " color.rgb = hsv2rgb( hsvColor ); \n"
- // uIgnoreAlpha decide the result alpha will be 1.0 or source's alpha
- " color.a = clamp(color.a + uIgnoreAlpha, 0.0, 1.0);\n"
- " gl_FragColor = color; \n"
- " }\n");
-
- ShaderEffect effect = ShaderEffect::New("", fragmentShader);
- ColorAdjuster handle( effect );
- handle.SetUniform( "uHSVDelta", hsvDelta );
- handle.SetUniform( "uIgnoreAlpha", ignoreAlpha?1.0f:0.0f );
- return handle;
-}
-
-std::string ColorAdjuster::GetHsvDeltaPropertyName() const
-{
- return HSVDELTA_PROPERTY_NAME;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_SHADER_COLOR_ADJUSTER_H__
-#define __DALI_TOOLKIT_SHADER_COLOR_ADJUSTER_H__
-
-/*
- * Copyright (c) 2015 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/math/vector3.h>
-#include <dali/public-api/shader-effects/shader-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-/**
- * ColorAdjuster is a custom shader effect to adjust the image color in HSV space.
- */
-class DALI_IMPORT_API ColorAdjuster : public ShaderEffect
-{
-public:
-
- /**
- * Create an empty ColorAdjuster handle.
- */
- ColorAdjuster();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~ColorAdjuster();
-
- /**
- * Create an initialized ColorAdjuster.
- * @param[in] hsvDelta The color difference to apply to the HSV channel.
- * @param[in] ignoreAlpha If true, the result color will be opaque even though source has alpha value
- * @return A handle to a newly allocated Dali resource.
- */
- static ColorAdjuster New( const Vector3& hsvDelta, bool ignoreAlpha = false );
-
- /**
- * Get the name of the uHSVDelta uniform so that it can be animated
- */
- std::string GetHsvDeltaPropertyName() const;
-
-private: // Not intended for application developers
-
- DALI_INTERNAL ColorAdjuster( ShaderEffect handle );
-};
-
-} // namespace Toolkit
-
-} // namespace Dali
-#endif /* __DALI_TOOLKIT_COLOR_ADJUSTER_EFFECT_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- *
- */
-
-#include <dali-toolkit/public-api/shader-effects/carousel-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace
-{
-
-const std::string RADIUS_PROPERTY_NAME( "uRadius" );
-const std::string ANGLE_PER_UNIT_PROPERTY_NAME( "uAnglePerUnit" );
-const std::string CENTER_PROPERTY_NAME( "uCenter" );
-
-} // namespace
-
-CarouselEffect::CarouselEffect()
-{
-}
-
-//Call the Parent copy constructor to add reference to the implementation for this object
-CarouselEffect::CarouselEffect(ShaderEffect handle)
-:ShaderEffect(handle)
-{
-}
-
-CarouselEffect::~CarouselEffect()
-{
-}
-
-
-CarouselEffect CarouselEffect::New()
-{
- // append the default version
- std::string vertexShader(
- "uniform float uRadius;\n"
- "uniform mediump vec2 uCenter;\n"
- "uniform mediump vec2 uAnglePerUnit;\n"
- "\n"
- "void main()\n"
- "{\n"
- " mediump vec4 world = uModelView * vec4(aPosition,1.0);\n"
- " mediump vec2 d = (world.xy - uCenter) * uAnglePerUnit;\n"
- " mediump float a = length(d);\n"
- " mediump float cs = cos(radians(a));\n"
- " world.z -= cs * uRadius;\n"
- " gl_Position = uProjection * world;\n"
- " \n"
- " vTexCoord = aTexCoord;\n"
- "}\n");
-
- ShaderEffect shaderEffectCustom = ShaderEffect::New(vertexShader,
- "",
- GeometryType( GEOMETRY_TYPE_IMAGE ),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_DEPTH_BUFFER ));
-
- // Pass ownership to CarouselEffect through overloaded constructor, So that it now has access to the
- // Dali::ShaderEffect implementation
- CarouselEffect handle( shaderEffectCustom );
-
- handle.SetUniform( RADIUS_PROPERTY_NAME, 0.0f );
- handle.SetUniform( CENTER_PROPERTY_NAME, Vector2( 0.0f, 0.0f ) );
- handle.SetUniform( ANGLE_PER_UNIT_PROPERTY_NAME, Vector2( 0.0f, 0.0f ) );
-
- return handle;
-}
-
-void CarouselEffect::SetRadius( float radius)
-{
- SetUniform( RADIUS_PROPERTY_NAME, radius );
-}
-
-void CarouselEffect::SetCenter( const Vector2& center )
-{
- SetUniform( CENTER_PROPERTY_NAME, center );
-}
-
-void CarouselEffect::SetAnglePerUnit( const Vector2& angle )
-{
- SetUniform( ANGLE_PER_UNIT_PROPERTY_NAME, angle );
-}
-
-const std::string& CarouselEffect::GetRadiusPropertyName() const
-{
- return RADIUS_PROPERTY_NAME;
-}
-
-const std::string& CarouselEffect::GetCenterPropertyName() const
-{
- return CENTER_PROPERTY_NAME;
-}
-
-const std::string& CarouselEffect::GetAnglePerUnitPropertyName() const
-{
- return ANGLE_PER_UNIT_PROPERTY_NAME;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
{
/**
+ * @brief Creates a new Carousel effect
+ *
* CarouselEffect is a custom shader effect to achieve Carousel effects in actors
*
* A Carousel has a Radius property which can be +ve (appear as if viewing from the outside of
*
* Finally, the carousel's center position can be specified as a Screen coordinate (top-left being
* the origin).
+ *
+ * Animatable/Constrainable uniforms:
+ * "uRadius" - The radius of the Carousel effect. A positive Radius will bend toward the camera,
+ * while a negative Radius will bend away from the camera.
+ * "uAnglePerUnit" - The angle deviation of Carousel in degrees per geometric unit for each axis
+ For example if you wish for the horizontal angle deviation to vary from +/- 10
+ degrees, then a Value of 20.0f / stageWidth for the X component should be specified.
+ * "uCenter" - The center point of the carousel (in screen coordinates) this is where the peek of the carousel should appear.
+ * Defaults value is top-left corner (0.0f, 0.0f).
+ *
+ * @return A handle to a newly allocated ShaderEffect
*/
-class DALI_IMPORT_API CarouselEffect : public ShaderEffect
+inline ShaderEffect CreateCarouselEffect()
{
-public:
-
- /**
- * Create an uninitialized CarouselEffect; this can be initialized with CarouselEffect::New()
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- CarouselEffect();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~CarouselEffect();
-
- /**
- * Create an initialized CarouselEffect.
- * @return A handle to a newly allocated Dali resource.
- */
- static CarouselEffect New();
-
- /**
- * Set the radius of the Carousel effect.
- * A positive Radius will bend toward the camera,
- * while a negative Radius will bend away from the camera.
- * @param[in] radius The new radius.
- */
- void SetRadius( float radius);
-
- /**
- * Sets the center point of the carousel (in screen coordinates)
- * this is where the peek of the carousel should appear.
- * this defaults to top-left corner (0.0f, 0.0f).
- *
- * @param[in] center The center point.
- */
- void SetCenter( const Vector2& center );
-
- /**
- * Set the angle deviation of Carousel in degrees per
- * geometric unit for each axis. For example if you
- * wish for the horizontal angle deviation to vary from +/- 10
- * degrees, then a Value of 20.0f / stageWidth for the X
- * component should be specified.
- *
- * @param[in] angle the Angle Spread in X and Y axes.
- */
- void SetAnglePerUnit( const Vector2& angle );
-
- /**
- * Get the name for the radius property
- * @return A std::string containing the property name
- */
- const std::string& GetRadiusPropertyName() const;
-
- /**
- * Get the name for the center property
- * @return A std::string containing the property name
- */
- const std::string& GetCenterPropertyName() const;
-
- /**
- * Get the name for the angle spread property
- * @return A std::string containing the property name
- */
- const std::string& GetAnglePerUnitPropertyName() const;
-
-
-private: // Not intended for application developers
- DALI_INTERNAL CarouselEffect(ShaderEffect handle);
-};
+ // append the default version
+ std::string vertexShader(
+ "uniform float uRadius;\n"
+ "uniform mediump vec2 uCenter;\n"
+ "uniform mediump vec2 uAnglePerUnit;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " mediump vec4 world = uModelView * vec4(aPosition,1.0);\n"
+ " mediump vec2 d = (world.xy - uCenter) * uAnglePerUnit;\n"
+ " mediump float a = length(d);\n"
+ " mediump float cs = cos(radians(a));\n"
+ " world.z -= cs * uRadius;\n"
+ " gl_Position = uProjection * world;\n"
+ " \n"
+ " vTexCoord = aTexCoord;\n"
+ "}\n");
+
+ ShaderEffect shaderEffect = ShaderEffect::New(
+ vertexShader,
+ "",
+ GeometryType( GEOMETRY_TYPE_IMAGE ),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_DEPTH_BUFFER ));
+
+
+ shaderEffect.SetUniform( "uRadius", 0.0f );
+ shaderEffect.SetUniform( "uCenter", Vector2( 0.0f, 0.0f ) );
+ shaderEffect.SetUniform( "uAnglePerUnit", Vector2( 0.0f, 0.0f ) );
+
+ return shaderEffect;
+}
} // namespace Toolkit
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- *
- */
-
-#include <dali-toolkit/public-api/shader-effects/displacement-effect.h>
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace
-{
-
-const std::string DISPLACEMENT_EFFECT_LIGHT_DIRECTION_PROPERTY_NAME( "uLightDirection" );
-const std::string DISPLACEMENT_EFFECT_AMBIENT_LIGHT_COLOR_PROPERTY_NAME( "uAmbientLightColor" );
-const std::string DISPLACEMENT_EFFECT_DIFFUSE_LIGHT_COLOR_PROPERTY_NAME( "uDiffuseLightColor" );
-const std::string DISPLACEMENT_EFFECT_LIGHT_MULTIPLIER_PROPERTY_NAME( "uLightMultiplier" );
-const std::string DISPLACEMENT_EFFECT_STATE_PROPERTY_NAME( "uState" );
-const std::string DISPLACEMENT_EFFECT_HEIGHT_SCALE_PROPERTY_NAME( "uHightScale" );
-const std::string DISPLACEMENT_EFFECT_FIXED_NORMAL_PROPERTY_NAME( "uFixedNormal" );
-
-// factors that scale the look, defaults
-const Vector3 DISPLACEMENT_EFFECT_LIGHT_DIRECTION_DEFAULT = Vector3(0.0, 0.7070168f, 0.7071068f);
-const Vector3 DISPLACEMENT_EFFECT_AMBIENT_LIGHT_COLOR_DEFAULT = Vector3(0.15f, 0.15f, 0.15f);
-const Vector3 DISPLACEMENT_EFFECT_DIFFUSE_LIGHT_COLOR_DEFAULT = Vector3(1.0f, 1.0f, 1.0f);
-const float DISPLACEMENT_EFFECT_LIGHT_MULTIPLIER_DEFAULT = 1.0f;
-const float DISPLACEMENT_EFFECT_STATE_DEFAULT = 0.0f;
-const float DISPLACEMENT_EFFECT_HEIGHT_SCALE_DEFAULT = 0.1f;
-const Vector3 DISPLACEMENT_EFFECT_FIXED_NORMAL_DEFAULT = Vector3(0.0f, 0.0f, 1.0f);
-
-} // namespace
-
-
-////////////////////////////////////////////////////
-//
-// Soft button shader / actor tweaking parameters
-//
-
-
-DisplacementEffect::DisplacementEffect()
-{
-}
-
-//Call the Parent copy constructor to add reference to the implementation for this object
-DisplacementEffect::DisplacementEffect(ShaderEffect handle)
-:ShaderEffect(handle)
-{
-}
-
-DisplacementEffect::~DisplacementEffect()
-{
-}
-
-DisplacementEffect DisplacementEffect::New(Type type)
-{
-
- std::string fragmentSourceFixed;
- fragmentSourceFixed = "precision mediump float;\n"
- "uniform vec3 uLightDirection;\n"
- "uniform vec3 uAmbientLightColor;\n"
- "uniform vec3 uDiffuseLightColor;\n"
- "uniform float uLightMultiplier;\n"
- "uniform float uState;\n"
- "uniform float uHightScale;\n"
- "uniform vec3 uFixedNormal;\n"
-
- "void main()\n"
- "{\n"
- " vec4 col = texture2D(sTexture, vTexCoord);\n"
- // calc lighting
- " float intensity = dot(uLightDirection, uFixedNormal);"
- " vec3 lighting = (intensity * uDiffuseLightColor) + uAmbientLightColor;\n"
- " lighting *= uLightMultiplier;\n"
- // output col = image * light
- " gl_FragColor = vec4(col.rgb * lighting * uColor.rgb, col.a * uColor.a);\n"
- "}\n";
-
-
-
- std::string fragmentSourceDisplaced(
- "precision mediump float;\n"
- "uniform vec3 uLightDirection;\n"
- "uniform vec3 uAmbientLightColor;\n"
- "uniform vec3 uDiffuseLightColor;\n"
- "uniform float uLightMultiplier;\n"
- "uniform float uState;\n"
- "uniform float uHightScale;\n"
- "void main()\n"
- "{\n"
- " highp vec4 displacementMap1 = texture2D(sEffect, vec2(vTexCoord.s, vTexCoord.t/2.0));\n"
- " highp vec4 displacementMap2 = texture2D(sEffect, vec2(vTexCoord.s, 0.5+vTexCoord.t/2.0));\n"
- " highp vec4 displacementMap = mix(displacementMap1, displacementMap2, uState);\n"
-
- " vec3 normalAdjusted = normalize(displacementMap.rgb*2.0-1.0);\n"
- " float height = uHightScale * (displacementMap.a*2.0 - 1.0);\n"
- " vec2 displacement = vec2(0.0);\n"
- " displacement += (vec2(0.5)-vTexCoord.st)*height;\n"
- " vec2 newCoord = vTexCoord.st + displacement.xy;\n"
-
- " vec4 col = texture2D(sTexture, newCoord);\n"
- // Y-Axis for the normal map is taken as in Y-Down format, So inverting it for GL
- " float intensity = dot(uLightDirection, vec3(1.0,-1.0, 1.0) * normalAdjusted);"
- " vec3 lighting = (intensity * uDiffuseLightColor) + uAmbientLightColor;\n"
- " lighting *= uLightMultiplier;\n"
- " vec3 color = col.rgb * lighting * uColor.rgb;\n"
- " gl_FragColor = vec4(color, col.a * uColor.a);\n"
- "}\n");
-
- //////////////////////////////////////
- // Create shader effect
- //
- //
-
- ShaderEffect shader;
- switch(type)
- {
- case DISPLACED:
- shader = ShaderEffect::New( "", fragmentSourceDisplaced);
- break;
-
- case FIXED:
- default:
- shader = ShaderEffect::New( "", fragmentSourceFixed);
- break;
- }
- DisplacementEffect handle( shader );
-
-
- //////////////////////////////////////
- // Register uniform properties
- //
- //
- // factors that scale the look, defaults
-
- handle.SetLightDirection(DISPLACEMENT_EFFECT_LIGHT_DIRECTION_DEFAULT);
- handle.SetAmbientLightColorProperty(DISPLACEMENT_EFFECT_AMBIENT_LIGHT_COLOR_DEFAULT);
- handle.SetDiffuseLightColorProperty(DISPLACEMENT_EFFECT_DIFFUSE_LIGHT_COLOR_DEFAULT);
- handle.SetLightingMultiplierProperty(DISPLACEMENT_EFFECT_LIGHT_MULTIPLIER_DEFAULT);
- handle.SetStateProperty(DISPLACEMENT_EFFECT_STATE_DEFAULT);
- handle.SetHeightScaleProperty(DISPLACEMENT_EFFECT_HEIGHT_SCALE_DEFAULT);
-
- if(type == FIXED)
- {
- handle.SetFixedNormalProperty(DISPLACEMENT_EFFECT_FIXED_NORMAL_DEFAULT);
- }
-
-
- return handle;
-}
-
-const std::string& DisplacementEffect::GetLightDirectionPropertyName() const
-{
- return DISPLACEMENT_EFFECT_LIGHT_DIRECTION_PROPERTY_NAME;
-}
-
-const std::string& DisplacementEffect::GetAmbientLightColorPropertyName() const
-{
- return DISPLACEMENT_EFFECT_AMBIENT_LIGHT_COLOR_PROPERTY_NAME;
-}
-
-const std::string& DisplacementEffect::GetDiffuseLightColorPropertyName() const
-{
- return DISPLACEMENT_EFFECT_DIFFUSE_LIGHT_COLOR_PROPERTY_NAME;
-}
-
-const std::string& DisplacementEffect::GetLightingMultiplierPropertyName() const
-{
- return DISPLACEMENT_EFFECT_LIGHT_MULTIPLIER_PROPERTY_NAME;
-}
-
-const std::string& DisplacementEffect::GetStatePropertyName() const
-{
- return DISPLACEMENT_EFFECT_STATE_PROPERTY_NAME;
-}
-
-const std::string& DisplacementEffect::GetHeightScalePropertyName() const
-{
- return DISPLACEMENT_EFFECT_HEIGHT_SCALE_PROPERTY_NAME;
-}
-
-const std::string& DisplacementEffect::GetFixedNormalPropertyName() const
-{
- return DISPLACEMENT_EFFECT_FIXED_NORMAL_PROPERTY_NAME;
-}
-
-void DisplacementEffect::SetLightDirection(const Vector3 lightDirection)
-{
- SetUniform( DISPLACEMENT_EFFECT_LIGHT_DIRECTION_PROPERTY_NAME, lightDirection);
-}
-
-void DisplacementEffect::SetAmbientLightColorProperty(const Vector3 ambientLight)
-{
- SetUniform( DISPLACEMENT_EFFECT_AMBIENT_LIGHT_COLOR_PROPERTY_NAME, ambientLight);
-}
-
-void DisplacementEffect::SetDiffuseLightColorProperty(const Vector3 diffuseLight)
-{
- SetUniform( DISPLACEMENT_EFFECT_DIFFUSE_LIGHT_COLOR_PROPERTY_NAME, diffuseLight);
-}
-
-void DisplacementEffect::SetLightingMultiplierProperty(const float lightMultiplier)
-{
- SetUniform( DISPLACEMENT_EFFECT_LIGHT_MULTIPLIER_PROPERTY_NAME, lightMultiplier);
-}
-
-void DisplacementEffect::SetStateProperty(const float state)
-{
- SetUniform( DISPLACEMENT_EFFECT_STATE_PROPERTY_NAME, state);
-}
-
-void DisplacementEffect::SetHeightScaleProperty(const float heightScale)
-{
- SetUniform( DISPLACEMENT_EFFECT_HEIGHT_SCALE_PROPERTY_NAME, heightScale);
-}
-
-void DisplacementEffect::SetFixedNormalProperty(const Vector3 fixedNormal)
-{
- Vector3 newFixedNormal(fixedNormal);
- newFixedNormal.Normalize();
-
- SetUniform( DISPLACEMENT_EFFECT_FIXED_NORMAL_PROPERTY_NAME, newFixedNormal);
-}
-
-}
-
-}
{
/**
+ * @brief Creates a new displacement effect
*
- * Class for two state displacement effect shader that works on a per object basis. By passing a height-normal map as an effect image, the user can create
+ * Two state displacement effect shader that works on a per object basis. By passing a height-normal map as an effect image, the user can create
* various styles of buttons on an image actor. The shader requires two height-normal maps in one image, one for each state.
*
* The normals and height information for the two states of the button should be strictly specified in this format:
* Usage example:-
*
* // Create shader used for doing soft button\n
- * DisplacementEffect buttonEffect = DisplacementEffect::New();
+ * ShaderEffect buttonEffect = CreateDisplacementEffect();
* buttonEffect.SetEffectImage(Image::New( FANCY_BUTTON_HEIGHT_MAP_IMAGE_PATH ););
*
* // set shader to the soft button\n
*
*
* Animation animation = Animation::New( ... );\n
- * animation.AnimateTo( Property(buttonEffect, buttonEffect.GetStatePropertyName()), 1.0f, AlphaFunction::BOUNCE, ... );\n
+ * animation.AnimateTo( Property(buttonEffect, "uState"), 1.0f, AlphaFunction::BOUNCE, ... );\n
* animation.Play();\n
*
+ * Animatable/Constrainable uniforms:
+ * "uLightDirection" - The light direction is used in the lighting calculation. The angle of incidence directly affects the amount of light reflected.
+ * Default (0.0f, 0.7070168f, 0.7071068f), i.e angled at the surface from in front and above.
+ * "uAmbientLightColor" - The ambient light is used in the lighting calculation. Care must be taken to not saturate the image by setting this value too high,
+ * or the indentation will not look correct. Default 0.15.
+ * "uDiffuseLightColor" - The diffuse light is used in the lighting calculation. Default is (1.0f, 1.0f, 1.0f).
+ * "uLightMultiplier" - The ambient and diffuse lighting is multiplied by this factor. Since a diffuse light at an angle will cause the whole image to darken,
+ * this property can be used to scale the image back up closer to the pixel values of the original diffuse texture. Care must be taken
+ * to not saturate the image,or the indentation will not look correct. Default 1.0
+ * "uState" - The shader can have a maximum of two end states 0 or 1, Animate between these two values to do the transitions
+ * between states. Default 0.0
+ * "uHightScale" - The height displacement is multiplied by this factor. Tweak this to get the required level of depth. Default 0.1
+ * "uFixedNormal" - The Fixed normal will be used for the light calculation. Tweak this to get the required level of light.
+ * Only applicable for the FIXED type shader and not for DISPLACED type
+ *
+ * @param type The type of the effect, can be either DISPLACED, or FIXED.
+ * @return A handle to a newly allocated ShaderEffect
+ *
*/
-class DALI_IMPORT_API DisplacementEffect : public ShaderEffect
-{
-public:
+typedef enum
+{
+ DISPLACEMENT_EFFECT_DISPLACED = 0, /// Image gets displaced
+ DISPLACEMENT_EFFECT_FIXED /// Image does not displace. Useful for matching lighting between areas that do not displace and those that do, e.g for backgrounds which are visible between buttons.
+}DisplacementEffectType;
- typedef enum
+inline ShaderEffect CreateDisplacementEffect(DisplacementEffectType type)
+{
+ std::string fragmentSourceFixed;
+ fragmentSourceFixed = "precision mediump float;\n"
+ "uniform vec3 uLightDirection;\n"
+ "uniform vec3 uAmbientLightColor;\n"
+ "uniform vec3 uDiffuseLightColor;\n"
+ "uniform float uLightMultiplier;\n"
+ "uniform float uState;\n"
+ "uniform float uHightScale;\n"
+ "uniform vec3 uFixedNormal;\n"
+
+ "void main()\n"
+ "{\n"
+ " vec4 col = texture2D(sTexture, vTexCoord);\n"
+ // calc lighting
+ " float intensity = dot(uLightDirection, uFixedNormal);"
+ " vec3 lighting = (intensity * uDiffuseLightColor) + uAmbientLightColor;\n"
+ " lighting *= uLightMultiplier;\n"
+ // output col = image * light
+ " gl_FragColor = vec4(col.rgb * lighting * uColor.rgb, col.a * uColor.a);\n"
+ "}\n";
+
+
+
+ std::string fragmentSourceDisplaced(
+ "precision mediump float;\n"
+ "uniform vec3 uLightDirection;\n"
+ "uniform vec3 uAmbientLightColor;\n"
+ "uniform vec3 uDiffuseLightColor;\n"
+ "uniform float uLightMultiplier;\n"
+ "uniform float uState;\n"
+ "uniform float uHightScale;\n"
+ "void main()\n"
+ "{\n"
+ " highp vec4 displacementMap1 = texture2D(sEffect, vec2(vTexCoord.s, vTexCoord.t/2.0));\n"
+ " highp vec4 displacementMap2 = texture2D(sEffect, vec2(vTexCoord.s, 0.5+vTexCoord.t/2.0));\n"
+ " highp vec4 displacementMap = mix(displacementMap1, displacementMap2, uState);\n"
+
+ " vec3 normalAdjusted = normalize(displacementMap.rgb*2.0-1.0);\n"
+ " float height = uHightScale * (displacementMap.a*2.0 - 1.0);\n"
+ " vec2 displacement = vec2(0.0);\n"
+ " displacement += (vec2(0.5)-vTexCoord.st)*height;\n"
+ " vec2 newCoord = vTexCoord.st + displacement.xy;\n"
+
+ " vec4 col = texture2D(sTexture, newCoord);\n"
+ // Y-Axis for the normal map is taken as in Y-Down format, So inverting it for GL
+ " float intensity = dot(uLightDirection, vec3(1.0,-1.0, 1.0) * normalAdjusted);"
+ " vec3 lighting = (intensity * uDiffuseLightColor) + uAmbientLightColor;\n"
+ " lighting *= uLightMultiplier;\n"
+ " vec3 color = col.rgb * lighting * uColor.rgb;\n"
+ " gl_FragColor = vec4(color, col.a * uColor.a);\n"
+ "}\n");
+
+ //////////////////////////////////////
+ // Create shader effect
+ //
+ //
+
+ ShaderEffect shaderEffect;
+ switch(type)
{
- DISPLACED = 0, /// Image gets displaced
- FIXED /// Image does not displace. Useful for matching lighting between areas that do not displace and those that do, e.g for backgrounds which are visible between buttons.
- }Type;
-
- /**
- * Create an uninitialized DisplacementEffect; this can be initialized with DisplacementEffect::New()
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- DisplacementEffect();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~DisplacementEffect();
-
- /**
- * Create an initialized DisplacementEffect
- * @param type The type of the effect, can be either DISPLACED, or FIXED.
- * @return A handle to a newly allocated Dali resource.
- */
- static DisplacementEffect New(Type type);
-
- /**
- * Get the name for the light direction property (Vector3)
- * The light direction is used in the lighting calculation. The angle of incidence directly affects the amount of light reflected.
- * Default (0.0f, 0.7070168f, 0.7071068f), i.e angled at the surface from in front and above.
- * @return A std::string containing the property name
- */
- const std::string& GetLightDirectionPropertyName() const;
-
- /**
- * Get the name for the ambient lighting color property (Vector3)
- * The ambient light is used in the lighting calculation. Care must be taken to not saturate the image by setting this value too high,
- * or the indentation will not look correct. Default 0.15.
- * @return A std::string containing the property name
- */
- const std::string& GetAmbientLightColorPropertyName() const;
-
- /**
- * Get the name for the diffuse light color property (Vector3).
- * The diffuse light is used in the lighting calculation. Default is (1.0f, 1.0f, 1.0f).
- * @return A std::string containing the property name
- */
- const std::string& GetDiffuseLightColorPropertyName() const;
-
- /**
- * Get the name for the lighting multiplier property (float).
- * The ambient and diffuse lighting is multiplied by this factor. Since a diffuse light at an angle will cause the whole image to darken,
- * this property can be used to scale the image back up closer to the pixel values of the original diffuse texture. Care must be taken to not saturate the image,
- * or the indentation will not look correct. Default 1.0
- * @return A std::string containing the property name
- */
- const std::string& GetLightingMultiplierPropertyName() const;
-
- /**
- * Get the name for the state property (float).
- * The shader can have a maximum of two end states 0 or 1, Animate between these two values to do the transitions between states.
- * Default 0.0
- * @return A std::string containing the property name.
- */
- const std::string& GetStatePropertyName() const;
-
- /**
- * Get the name for the height scale property (float).
- * The height displacement is multiplied by this factor. Tweak this to get the required level of depth.
- * Default 0.1
- * @return A std::string containing the property name.
- */
- const std::string& GetHeightScalePropertyName() const;
-
- /**
- * Get the name for the fixed normal property (Vector3).
- * Only applicable for the FIXED type shader and not for DISPLACEMENT type.
- * The Fixed normal will be used for the light calculation. Tweak this to get the required level of light.
- * Default (0.0f, 0.0f, 1.0f)
- * @return A std::string containing the property name.
- */
- const std::string& GetFixedNormalPropertyName() const;
-
- /**
- * Set the light direction property
- * The light direction is used in the lighting calculation. The angle of incidence directly affects the amount of light reflected.
- * Default (0.0f, 0.7070168f, 0.7071068f), i.e angled at the surface from in front and above.
- * @param [in] lightDirection The new light direction.
- */
- void SetLightDirection(Vector3 lightDirection);
-
- /**
- * Set the ambient light color property
- * The ambient light is used in the lighting calculation. Care must be taken to not saturate the image by setting this value too high,
- * or the indentation will not look correct. Default (0.15f, 0.15f, 0.15f).
- * @param [in] ambientLight The new ambient light value.
- */
- void SetAmbientLightColorProperty(Vector3 ambientLight);
-
- /**
- * Set the diffuse light color property.
- * The diffuse light is used in the lighting calculation. Default is (1.0f, 1.0f, 1.0f), i.e. a white light so the natural image color is shown.
- * @param [in] diffuseLight The new diffuse light value.
- */
- void SetDiffuseLightColorProperty(Vector3 diffuseLight);
-
- /**
- * Get the name for the lighting multiplier property.
- * The ambient and diffuse lighting is multiplied by this factor. Since a diffuse light at an angle will cause the whole image to darken,
- * this property can be used to scale the image back up closer to the pixel values of the original diffuse texture. Care must be taken to not saturate the image,
- * or the indentation will not look correct. Default 1.0
- * @param [in] lightMultiplier The new light multiplier value.
- */
- void SetLightingMultiplierProperty(float lightMultiplier);
-
- /**
- * Get the name for the state property.
- * The shader can only be in or in between two states 0 or 1, Animate between these two values to do the transitions between states.
- * @param [in] state The new state value.
- */
- void SetStateProperty(float state);
-
- /**
- * Set the name for the height scale property.
- * The height displacement is multiplied by this factor. Tweak this to get the required level of depth. Default 0.1
- * @param [in] heightScale The new height scale.
- */
- void SetHeightScaleProperty(float heightScale);
-
- /**
- * Set the name for fixed normal property, Only applicable for the FIXED type shader and not for DISPLACEMENT type.
- * The Fixed normal will be used for the light calculation. Tweak this to get the required level of light.
- * @param [in] fixedNormal The new normal for the fixed type shader effect.
- */
- void SetFixedNormalProperty(Vector3 fixedNormal);
-
-private:
- // Not intended for application developers
- DALI_INTERNAL DisplacementEffect(ShaderEffect handle);
-};
+ case DISPLACEMENT_EFFECT_DISPLACED:
+ shaderEffect = ShaderEffect::New( "", fragmentSourceDisplaced);
+ break;
+
+ case DISPLACEMENT_EFFECT_FIXED:
+ default:
+ shaderEffect = ShaderEffect::New( "", fragmentSourceFixed);
+ break;
+ }
+
+
+ //////////////////////////////////////
+ // Register uniform properties
+ //
+ //
+ // factors that scale the look, defaults
+ shaderEffect.SetUniform("uLightDirection",Vector3(0.0, 0.7070168f, 0.7071068f));
+ shaderEffect.SetUniform("uAmbientLightColor",Vector3(0.15f, 0.15f, 0.15f));
+ shaderEffect.SetUniform("uDiffuseLightColor",Vector3(1.0f, 1.0f, 1.0f));
+ shaderEffect.SetUniform("uLightMultiplier",1.0f);
+ shaderEffect.SetUniform("uState",0.0f);
+ shaderEffect.SetUniform("uHightScale",0.1f);
+
+ if(type == DISPLACEMENT_EFFECT_FIXED)
+ {
+ shaderEffect.SetUniform("uFixedNormal",Vector3(0.0f, 0.0f, 1.0f) );
+ }
+
+ return shaderEffect;
+}
}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- *
- */
-
-#include <dali-toolkit/public-api/shader-effects/dissolve-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace
-{
-
-const std::string DISTORTION_PROPERTY_NAME( "uPercentage" );
-
-} // namespace
-
-DissolveEffect::DissolveEffect()
-{
-}
-
-//Call the Parent copy constructor to add reference to the implementation for this object
-DissolveEffect::DissolveEffect(ShaderEffect handle)
-:ShaderEffect(handle)
-{
-}
-
-DissolveEffect::~DissolveEffect()
-{
-}
-
-
-DissolveEffect DissolveEffect::New( bool useHighPrecision )
-{
- std::string prefixHighPrecision( "precision highp float;\n");
- std::string prefixMediumPrecision( "precision mediump float;\n" );
- std::string vertexShader(
- "uniform float uPercentage;\n"
- "uniform vec3 uSaddleParam;\n"
- "uniform vec2 uTranslation;\n"
- "uniform vec2 uRotation; \n"
- "uniform float uToNext;\n"
- "varying float vPercentage;\n"
- "void main()\n"
- "{\n"
- "gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n"
- "vTexCoord = aTexCoord;\n"
- //Calculate the distortion value given the dissolve central line
- "vec2 texCoor = vec2( (aTexCoord.s - sTextureRect.s ) / (sTextureRect.p - sTextureRect.s), (aTexCoord.t- sTextureRect.t)/(sTextureRect.q - sTextureRect.t) ); \n"
- "vec2 value = texCoor + uTranslation; \n"
- "mat2 rotateMatrix = mat2( uRotation.s, uRotation.t, -uRotation.t, uRotation.s ); \n"
- "value = rotateMatrix * value; \n"
- "if(uToNext == 1.0) \n"
- " value.s = uSaddleParam[2] + value.s; \n"
- "float delay = value.t*value.t / uSaddleParam[0] - value.s*value.s/uSaddleParam[1];\n"
- "vPercentage = clamp( uPercentage*2.0 - 0.5*sin(delay*1.571) - 0.5, 0.0, 1.0 ); \n"
- "}\n");
- std::string fragmentShader(
- "varying float vPercentage;\n"
- "float rand(vec2 co) \n"
- "{\n"
- " return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); \n"
- "}\n"
- "void main()\n"
- "{\n"
- //Calculate the randomness
- "float offsetS = rand( vTexCoord * vPercentage ) * (sTextureRect.p - sTextureRect.s) - vTexCoord.s + sTextureRect.s; \n"
- "float offsetT = rand( vec2(vTexCoord.t*vPercentage, vTexCoord.s * vPercentage) ) * (sTextureRect.q - sTextureRect.t) - vTexCoord.t + sTextureRect.t; \n"
- "vec2 lookupCoord = vTexCoord + vec2(offsetS, offsetT) * vPercentage; \n"
- "gl_FragColor = texture2D( sTexture, lookupCoord ) * uColor; \n"
- "gl_FragColor.a *= 1.0 - vPercentage; \n"
- "}" );
-
- // Create the implementation, temporarily owned on stack,
- Dali::ShaderEffect shaderEffectCustom;
- if( useHighPrecision )
- {
- shaderEffectCustom = Dali::ShaderEffect::New( prefixHighPrecision+vertexShader, prefixHighPrecision + fragmentShader,
- GeometryType( GEOMETRY_TYPE_IMAGE),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_BLENDING ) );
- }
- else
- {
- shaderEffectCustom = Dali::ShaderEffect::New( prefixMediumPrecision+vertexShader, prefixMediumPrecision + fragmentShader,
- GeometryType( GEOMETRY_TYPE_IMAGE),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_BLENDING ) );
- }
-
- /* Pass ownership to DissolveEffect through overloaded constructor, So that it now has access to the
- Dali::ShaderEffect implementation */
- Dali::Toolkit::DissolveEffect handle( shaderEffectCustom );
-
- handle.SetUniform( DISTORTION_PROPERTY_NAME, 0.0f );
- handle.SetProperty( ShaderEffect::Property::GRID_DENSITY, Dali::Property::Value(50.0f) );
-
- handle.SetCentralLine( Vector2(1.0f,0.5f), Vector2(-1.0f, 0.0f) );
-
- return handle;
-}
-
-void DissolveEffect::SetCentralLine( const Vector2& position, const Vector2& displacement )
-{
- // the line passes through 'position' and has the direction of 'displacement'
- float coefA, coefB, coefC; //line equation: Ax+By+C=0;
- coefA = displacement.y;
- coefB = -displacement.x;
- coefC = -displacement.y*position.x + displacement.x*position.y;
-
- float inversedAABB = 1.f / (coefA*coefA+coefB*coefB);
- float inversedSqrtAABB = sqrtf(inversedAABB);
- float saddleA;
-
- //saddle surface(Hyperbolic paraboloid)function, used to calculate the dissolve starting time
- //z = y*y/a/a - x*x/b/b
- //with our selection of parameters(a and b), this value for any texture coordinate is between -1.0 and 1.0
-
- Vector3 saddleParam; // [0]: a*a, [1]: b*b, [2] b
- Vector2 translation;
- Vector2 rotation;
- float toNext = -1.f;
- if( displacement.x > 0.f || (EqualsZero(displacement.x) && displacement.y > 0.f) )
- {
- toNext = 1.f;
- }
-
- if( (displacement.y * displacement.x < 0.0f) )
- {
- //distance from (0,0) to the line
- float distanceTopLeft = fabsf(coefC) * inversedSqrtAABB;
- //distance from (1, 1 ) to the line
- float distanceBottomRight = fabsf(coefA+coefB+coefC) * inversedSqrtAABB;
- saddleA = std::max( distanceTopLeft, distanceBottomRight );
-
- //foot of a perpendicular: (1,0) to the line
- float footX1 = ( coefB*coefB - coefA*coefC) * inversedAABB;
- float footY1 = (-coefA*coefB - coefB*coefC) * inversedAABB;
- //foot of a perpendicular: (0,1) to the line
- float footX2 = (-coefA*coefB - coefA*coefC) * inversedAABB;
- float footY2 = ( coefA*coefA - coefB*coefC) * inversedAABB;
- saddleParam[1] = (footX1-footX2)*(footX1-footX2) + (footY1-footY2)*(footY1-footY2);
- translation = Vector2(-footX2,-footY2);
- }
- else
- {
- //distance from(1,0) to the line
- float distanceTopRight = fabsf(coefA+coefC) * inversedSqrtAABB;
- //distance from(0,1) to the line
- float distanceBottomLeft = fabsf(coefB+coefC) * inversedSqrtAABB;
- saddleA = std::max( distanceTopRight, distanceBottomLeft );
- //foot of a perpendicular: (0,0) to the line
- float footX3 = (-coefA*coefC) * inversedAABB;
- float footY3 = (-coefB*coefC) * inversedAABB;
- //foot of a perpendicular: (1.0,1.0) to the line
- float footX4 = ( coefB*coefB - coefA*coefB - coefA*coefC) * inversedAABB;
- float footY4 = (-coefA*coefB + coefA*coefA- coefB*coefC) * inversedAABB;
- saddleParam[1] = (footX3-footX4)*(footX3-footX4) + (footY3-footY4)*(footY3-footY4);
- translation = Vector2(-footX3, -footY3);
- }
-
- saddleParam[2] = sqrtf(saddleParam[1]);
- saddleParam[0] = saddleA*saddleA;
- rotation = Vector2(-displacement.x, displacement.y);
- rotation.Normalize();
-
- SetUniform( "uSaddleParam", saddleParam );
- SetUniform( "uTranslation", translation );
- SetUniform( "uRotation", rotation );
- SetUniform( "uToNext", toNext );
-
-}
-
-void DissolveEffect::SetDistortion( float distortion )
-{
- SetUniform( DISTORTION_PROPERTY_NAME, distortion );
-}
-
-const std::string& DissolveEffect::GetDistortionPropertyName() const
-{
- return DISTORTION_PROPERTY_NAME;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
{
/**
- * @brief DissolveEffect is a custom shader effect to achieve Dissolve effects in Image actors.
+ * @brief Set the dissolve central line.
+ *
+ * Use one point (position) and one direction ( displacement ) vector to define this line
+ * As we use the texture coordinate as pixel position to calculate random offset,
+ * the line should passing through rectangle {(0,0),(0,1),(1,0),(1,1)},
+ * so make the position parameter with two component values between 0.0 to 1.0
+ * @param[in] dissolveEffect The shader effect
+ * @param[in] position The point ( locates within rectangle {(0,0),(0,1),(1,0),(1,1)} ) passed through by the central line
+ * @param[in] displacement The direction of the central line
+ */
+inline void DissolveEffectSetCentralLine( ShaderEffect& dissolveEffect, const Vector2& position, const Vector2& displacement )
+{
+ // the line passes through 'position' and has the direction of 'displacement'
+ float coefA, coefB, coefC; //line equation: Ax+By+C=0;
+ coefA = displacement.y;
+ coefB = -displacement.x;
+ coefC = -displacement.y*position.x + displacement.x*position.y;
+
+ float inversedAABB = 1.f / (coefA*coefA+coefB*coefB);
+ float inversedSqrtAABB = sqrtf(inversedAABB);
+ float saddleA;
+
+ //saddle surface(Hyperbolic paraboloid)function, used to calculate the dissolve starting time
+ //z = y*y/a/a - x*x/b/b
+ //with our selection of parameters(a and b), this value for any texture coordinate is between -1.0 and 1.0
+
+ Vector3 saddleParam; // [0]: a*a, [1]: b*b, [2] b
+ Vector2 translation;
+ Vector2 rotation;
+ float toNext = -1.f;
+ if( displacement.x > 0.f || (EqualsZero(displacement.x) && displacement.y > 0.f) )
+ {
+ toNext = 1.f;
+ }
+
+ if( (displacement.y * displacement.x < 0.0f) )
+ {
+ //distance from (0,0) to the line
+ float distanceTopLeft = fabsf(coefC) * inversedSqrtAABB;
+ //distance from (1, 1 ) to the line
+ float distanceBottomRight = fabsf(coefA+coefB+coefC) * inversedSqrtAABB;
+ saddleA = std::max( distanceTopLeft, distanceBottomRight );
+
+ //foot of a perpendicular: (1,0) to the line
+ float footX1 = ( coefB*coefB - coefA*coefC) * inversedAABB;
+ float footY1 = (-coefA*coefB - coefB*coefC) * inversedAABB;
+ //foot of a perpendicular: (0,1) to the line
+ float footX2 = (-coefA*coefB - coefA*coefC) * inversedAABB;
+ float footY2 = ( coefA*coefA - coefB*coefC) * inversedAABB;
+ saddleParam[1] = (footX1-footX2)*(footX1-footX2) + (footY1-footY2)*(footY1-footY2);
+ translation = Vector2(-footX2,-footY2);
+ }
+ else
+ {
+ //distance from(1,0) to the line
+ float distanceTopRight = fabsf(coefA+coefC) * inversedSqrtAABB;
+ //distance from(0,1) to the line
+ float distanceBottomLeft = fabsf(coefB+coefC) * inversedSqrtAABB;
+ saddleA = std::max( distanceTopRight, distanceBottomLeft );
+ //foot of a perpendicular: (0,0) to the line
+ float footX3 = (-coefA*coefC) * inversedAABB;
+ float footY3 = (-coefB*coefC) * inversedAABB;
+ //foot of a perpendicular: (1.0,1.0) to the line
+ float footX4 = ( coefB*coefB - coefA*coefB - coefA*coefC) * inversedAABB;
+ float footY4 = (-coefA*coefB + coefA*coefA- coefB*coefC) * inversedAABB;
+ saddleParam[1] = (footX3-footX4)*(footX3-footX4) + (footY3-footY4)*(footY3-footY4);
+ translation = Vector2(-footX3, -footY3);
+ }
+
+ saddleParam[2] = sqrtf(saddleParam[1]);
+ saddleParam[0] = saddleA*saddleA;
+ rotation = Vector2(-displacement.x, displacement.y);
+ rotation.Normalize();
+
+ dissolveEffect.SetUniform( "uSaddleParam", saddleParam );
+ dissolveEffect.SetUniform( "uTranslation", translation );
+ dissolveEffect.SetUniform( "uRotation", rotation );
+ dissolveEffect.SetUniform( "uToNext", toNext );
+}
+/**
+ * @brief Create a new Dissolve effect
+ *
+ * DissolveEffect is a custom shader effect to achieve Dissolve effects in Image actors.
+ *
+ * Animatable/Constrainable uniforms:
+ * "uPercentage" - This value is proportional to the distortion applied; a value of zero means no distortion.
+ *
+ * @param[in] useHighPrecision True if using high precision in fragment shader for fully random noise, false otherwise
+ * @return A handle to a newly allocated ShaderEffect
*/
-class DALI_IMPORT_API DissolveEffect : public ShaderEffect
+
+inline ShaderEffect CreateDissolveEffect(bool useHighPrecision = true)
{
-public:
-
- /**
- * @brief Create an uninitialized DissolveEffect; this can be initialized with DissolveEffect::New().
- *
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- DissolveEffect();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~DissolveEffect();
-
- /**
- * @brief Create an initialized DissolveEffect.
- *
- * @param[in] useHighPrecision True if using high precision in fragment shader for fully random noise, false otherwise
- * @return A handle to a newly allocated Dali resource.
- */
- static DissolveEffect New( bool useHighPrecision = true);
-
- /**
- * @brief Set the dissolve central line.
- *
- * Use one point (position) and one direction ( displacement ) vector to define this line
- * As we use the texture coordinate as pixel position to calculate random offset,
- * the line should passing through rectangle {(0,0),(0,1),(1,0),(1,1)},
- * so make the position parameter with two component values between 0.0 to 1.0
- * @param[in] position The point ( locates within rectangle {(0,0),(0,1),(1,0),(1,1)} ) passed through by the central line
- * @param[in] displacement The direction of the central line
- */
- void SetCentralLine( const Vector2& position, const Vector2& displacement );
-
- /**
- * @brief Sets the distortion applied to the effect texture.
- *
- * This value is proportional to the distortion applied; a value of zero means no distortion.
- * @param [in] distortion The distortion value.
- */
- void SetDistortion( float distortion );
-
- /**
- * @brief Get the name for the distortion property.
- *
- * @return A std::string containing the property name
- */
- const std::string& GetDistortionPropertyName() const;
-
-private: // Not intended for application developers
- DALI_INTERNAL DissolveEffect(ShaderEffect handle);
-};
+ std::string prefixHighPrecision( "precision highp float;\n");
+ std::string prefixMediumPrecision( "precision mediump float;\n" );
+ std::string vertexShader(
+ "uniform float uPercentage;\n"
+ "uniform vec3 uSaddleParam;\n"
+ "uniform vec2 uTranslation;\n"
+ "uniform vec2 uRotation; \n"
+ "uniform float uToNext;\n"
+ "varying float vPercentage;\n"
+ "void main()\n"
+ "{\n"
+ "gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n"
+ "vTexCoord = aTexCoord;\n"
+ //Calculate the distortion value given the dissolve central line
+ "vec2 texCoor = vec2( (aTexCoord.s - sTextureRect.s ) / (sTextureRect.p - sTextureRect.s), (aTexCoord.t- sTextureRect.t)/(sTextureRect.q - sTextureRect.t) ); \n"
+ "vec2 value = texCoor + uTranslation; \n"
+ "mat2 rotateMatrix = mat2( uRotation.s, uRotation.t, -uRotation.t, uRotation.s ); \n"
+ "value = rotateMatrix * value; \n"
+ "if(uToNext == 1.0) \n"
+ " value.s = uSaddleParam[2] + value.s; \n"
+ "float delay = value.t*value.t / uSaddleParam[0] - value.s*value.s/uSaddleParam[1];\n"
+ "vPercentage = clamp( uPercentage*2.0 - 0.5*sin(delay*1.571) - 0.5, 0.0, 1.0 ); \n"
+ "}\n");
+ std::string fragmentShader(
+ "varying float vPercentage;\n"
+ "float rand(vec2 co) \n"
+ "{\n"
+ " return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); \n"
+ "}\n"
+ "void main()\n"
+ "{\n"
+ //Calculate the randomness
+ "float offsetS = rand( vTexCoord * vPercentage ) * (sTextureRect.p - sTextureRect.s) - vTexCoord.s + sTextureRect.s; \n"
+ "float offsetT = rand( vec2(vTexCoord.t*vPercentage, vTexCoord.s * vPercentage) ) * (sTextureRect.q - sTextureRect.t) - vTexCoord.t + sTextureRect.t; \n"
+ "vec2 lookupCoord = vTexCoord + vec2(offsetS, offsetT) * vPercentage; \n"
+ "gl_FragColor = texture2D( sTexture, lookupCoord ) * uColor; \n"
+ "gl_FragColor.a *= 1.0 - vPercentage; \n"
+ "}" );
+
+ // Create the implementation, temporarily owned on stack,
+ Dali::ShaderEffect shaderEffect;
+ if( useHighPrecision )
+ {
+ shaderEffect = Dali::ShaderEffect::New(
+ prefixHighPrecision+vertexShader, prefixHighPrecision + fragmentShader,
+ GeometryType( GEOMETRY_TYPE_IMAGE),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_BLENDING ) );
+ }
+ else
+ {
+ shaderEffect = Dali::ShaderEffect::New(
+ prefixMediumPrecision+vertexShader, prefixMediumPrecision + fragmentShader,
+ GeometryType( GEOMETRY_TYPE_IMAGE),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_BLENDING ) );
+ }
+
+ shaderEffect.SetUniform( "uPercentage", 0.0f );
+ shaderEffect.SetProperty( ShaderEffect::Property::GRID_DENSITY, Dali::Property::Value(50.0f) );
+
+ DissolveEffectSetCentralLine( shaderEffect, Vector2(1.0f,0.5f), Vector2(-1.0f, 0.0f) );
+
+ return shaderEffect;
+
+}
} // namespace Toolkit
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- *
- */
-
-#include <sstream>
-
-#include <dali-toolkit/public-api/shader-effects/dissolve-local-effect.h>
-
-#include <dali-toolkit/public-api/shader-effects/dissolve-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace
-{
- const std::string DISTORTION_PROPERTY_NAME( "uPercentage" );
- const std::string CENTER_PROPERTY_NAME( "uCenter" );
- const std::string RADIUS_PROPERTY_NAME( "uRadius" );
- const std::string TRANSPARENCY_PROPERTY_NAME( "uTransparency" );
-}
-
-DissolveLocalEffect::DissolveLocalEffect()
-: mNumberOfDimples( 1 )
-{
-}
-
-//Call the Parent copy constructor to add reference to the implementation for this object
-DissolveLocalEffect::DissolveLocalEffect( ShaderEffect handle )
-: ShaderEffect( handle ),
- mNumberOfDimples( 1 )
-{
-}
-
-DissolveLocalEffect::~DissolveLocalEffect()
-{
-}
-
-DissolveLocalEffect DissolveLocalEffect::New( unsigned int numberOfDimples )
-{
- std::ostringstream vertexShaderStringStream;
- vertexShaderStringStream << "#define NUMBER_OF_DIMPLE "<< numberOfDimples << "\n";
- std::string vertexShader(
- "precision highp float;\n"
- "uniform vec2 uCenter[ NUMBER_OF_DIMPLE ];\n"
- "uniform float uRadius[ NUMBER_OF_DIMPLE ]; \n"
- "uniform float uPercentage[ NUMBER_OF_DIMPLE ]; \n"
- "varying float vPercentage;\n"
- "void main()\n"
- "{\n"
- " vec4 position = uModelView * vec4( aPosition, 1.0 );\n"
- " float percentage = 0.0;\n"
- " for( int i=0; i<NUMBER_OF_DIMPLE; ++i )\n"
- " {\n"
- " float distance = distance(uCenter[i], position.xy);\n"
- " percentage = max(percentage, uPercentage[i] * cos(clamp( distance/uRadius[i], 0.0, 1.0 )*1.57) );"
- " }\n"
- " vPercentage = clamp( percentage, 0.0, 1.0 );\n"
- " gl_Position = uProjection * position;\n"
- " vTexCoord = aTexCoord;\n"
- "}\n");
- vertexShaderStringStream << vertexShader;
-
- std::string fragmentShader(
- "precision highp float;\n"
- "uniform float uTransparency;\n"
- "varying float vPercentage;\n"
- "float rand(vec2 co) \n"
- "{\n"
- " return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); \n"
- "}\n"
- "void main()\n"
- "{\n"
- //Calculate the randomness
- " float offsetS = rand( vTexCoord * vPercentage ); \n"
- " float offsetT = rand( vec2(vTexCoord.t*vPercentage, vTexCoord.s * vPercentage) ); \n"
- " vec2 lookupCoord = vTexCoord + vec2(offsetS, offsetT) * vPercentage; \n"
- " gl_FragColor = texture2D( sTexture, lookupCoord ) * uColor; \n"
- " gl_FragColor.a *= 1.0 - uTransparency*vPercentage; \n"
- "}\n");
-
- ShaderEffect shaderEffect = ShaderEffect::New( vertexShaderStringStream.str(), fragmentShader,
- GeometryType( GEOMETRY_TYPE_IMAGE),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_BLENDING ) );
-
- DissolveLocalEffect handle( shaderEffect );
- handle.mNumberOfDimples = numberOfDimples;
-
- //Register uniform properties
- for( unsigned int i = 0; i < numberOfDimples; i++ )
- {
- handle.SetCenter(i, Vector2(0.f,0.f));
- handle.SetRadius(i, 0.f);
- handle.SetDistortion( i, 0.f );
- }
- handle.SetProperty( ShaderEffect::Property::GRID_DENSITY, Dali::Property::Value(5.f) );
- handle.SetTransparency( 0.5f );
-
- return handle;
-}
-
-unsigned int DissolveLocalEffect::GetNumberOfDimples() const
-{
- return mNumberOfDimples;
-}
-
-void DissolveLocalEffect::SetTransparency( float transparency)
-{
- SetUniform( TRANSPARENCY_PROPERTY_NAME, transparency );
-}
-
-void DissolveLocalEffect::SetCenter( unsigned int index, const Vector2& center )
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfDimples );
- SetUniform( GetCenterPropertyName( index ), center, ShaderEffect::COORDINATE_TYPE_VIEWPORT_POSITION );
-}
-
-void DissolveLocalEffect::SetRadius( unsigned int index, float radius )
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfDimples );
- SetUniform( GetRadiusPropertyName( index ), radius );
-}
-
-void DissolveLocalEffect::SetDistortion( unsigned int index, float distortion )
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfDimples );
- SetUniform( GetDistortionPropertyName( index ), distortion );
-}
-
-std::string DissolveLocalEffect::GetCenterPropertyName( unsigned int index ) const
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfDimples );
- std::ostringstream oss;
- oss<< CENTER_PROPERTY_NAME << "[" << index << "]";
- return oss.str();
-}
-
-std::string DissolveLocalEffect::GetRadiusPropertyName( unsigned int index ) const
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfDimples );
- std::ostringstream oss;
- oss<< RADIUS_PROPERTY_NAME << "[" << index << "]";
- return oss.str();
-}
-
-std::string DissolveLocalEffect::GetDistortionPropertyName( unsigned int index ) const
-{
- DALI_ASSERT_ALWAYS( index < mNumberOfDimples );
- std::ostringstream oss;
- oss<< DISTORTION_PROPERTY_NAME << "["<< index << "]";
- return oss.str();
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
// EXTERNAL INCLUDES
#include <dali/public-api/shader-effects/shader-effect.h>
+#include <sstream>
namespace Dali
{
{
/**
+ * @brief Create a new DissolveLocalEffect
+ *
* DissolveLocalEffect is a custom shader effect to achieve Dissolve effects in multiple small areas of Image actors
+ *
+ * Animatable/Constrainable uniforms:
+ * "uTransparency"
+ * "uCenter" - The center positions of each dimples
+ * "uRadius" - The propagation radius of each dimple
+ * "uPercentage" - The distortion applied to the effect texture. A value of zero means no distortion
+ *
+ * @param[in] numberOfDimples The number of dimples
+ * @return A handle to a newly allocated ShaderEffect
*/
-class DALI_IMPORT_API DissolveLocalEffect : public ShaderEffect
+inline ShaderEffect CreateDissolveLocalEffect( unsigned int numberOfDimples )
{
-public:
-
- /**
- * Create an uninitialized DissolveLocalEffect; this can be initialized with DissolveLocalEffect::New()
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- DissolveLocalEffect();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~DissolveLocalEffect();
-
- /**
- * Create an initialized DissolveLocalEffect.
- * @param[in] numberOfDimples The number of dimples
- * @return A handle to a newly allocated Dali resource.
- */
- static DissolveLocalEffect New( unsigned int numberOfDimples );
-
- /**
- * Get the number of dimples the shader supports.
- * @return The number of dimples in the shader.
- */
- unsigned int GetNumberOfDimples() const;
-
- /**
- * Set the transparency of the drifted pixels.
- * @param[in] transparency The transparency of the drifted pixels.
- */
- void SetTransparency( float transparency);
-
- /**
- * Set the certer position of a dimple.
- * @param[in] index The index of the dimple to change.
- * @param[in] center The center position of the dimple.
- * @pre index has to be between 0 and GetNumberOfDimples() - 1
- */
- void SetCenter( unsigned int index, const Vector2& center );
-
- /**
- * Set the propogation radius of a dimple.
- * @param[in] index The index of the dimple to change.
- * @param[in] radius The propagation radius of the dimple.
- * @pre index has to be between 0 and GetNumberOfDimples() - 1
- */
- void SetRadius( unsigned int index, float radius );
-
- /**
- * Sets the distortion applied to the effect texture.
- * This value is proportional to the distortion applied; a value of zero means no distortion.
- * @param[in] index The index of the dimple to change.
- * @param[in] distortion The distortion value.
- * @pre index has to be between 0 and GetNumberOfDimples() - 1
- */
- void SetDistortion( unsigned int index, float distortion );
-
- /**
- * Get the name of the center property of a dimple.
- * @param[in] index The index of the dimple.
- * @return A std::string containing the property name.
- * @pre index has to be between 0 and GetNumberOfDimples() - 1
- */
- std::string GetCenterPropertyName( unsigned int index ) const;
-
- /**
- * Get the name of the radius property of a dimple.
- * @param[in] index The index of the dimple.
- * @return A std::string containing the property name
- * @pre index has to be between 0 and GetNumberOfDimples() - 1
- */
- std::string GetRadiusPropertyName( unsigned int index ) const;
-
- /**
- * Get the name for the distortion property of a dimple
- * @param[in] index the index of a dimple.
- * @return A std::string containing the property name
- * @pre index has to be between 0 and GetNumberOfDimples() - 1
- */
- std::string GetDistortionPropertyName( unsigned int index ) const;
-
-private: // Not intended for application developers
-
- DALI_INTERNAL DissolveLocalEffect( ShaderEffect handle );
-
-private:
-
- unsigned int mNumberOfDimples; ///< The number of dimples the shader supports
-
-};
+ std::ostringstream vertexShaderStringStream;
+ vertexShaderStringStream << "#define NUMBER_OF_DIMPLE "<< numberOfDimples << "\n";
+ std::string vertexShader(
+ "precision highp float;\n"
+ "uniform vec2 uCenter[ NUMBER_OF_DIMPLE ];\n"
+ "uniform float uRadius[ NUMBER_OF_DIMPLE ]; \n"
+ "uniform float uPercentage[ NUMBER_OF_DIMPLE ]; \n"
+ "varying float vPercentage;\n"
+ "void main()\n"
+ "{\n"
+ " vec4 position = uModelView * vec4( aPosition, 1.0 );\n"
+ " float percentage = 0.0;\n"
+ " for( int i=0; i<NUMBER_OF_DIMPLE; ++i )\n"
+ " {\n"
+ " float distance = distance(uCenter[i], position.xy);\n"
+ " percentage = max(percentage, uPercentage[i] * cos(clamp( distance/uRadius[i], 0.0, 1.0 )*1.57) );"
+ " }\n"
+ " vPercentage = clamp( percentage, 0.0, 1.0 );\n"
+ " gl_Position = uProjection * position;\n"
+ " vTexCoord = aTexCoord;\n"
+ "}\n");
+ vertexShaderStringStream << vertexShader;
+
+ std::string fragmentShader(
+ "precision highp float;\n"
+ "uniform float uTransparency;\n"
+ "varying float vPercentage;\n"
+ "float rand(vec2 co) \n"
+ "{\n"
+ " return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); \n"
+ "}\n"
+ "void main()\n"
+ "{\n"
+ //Calculate the randomness
+ " float offsetS = rand( vTexCoord * vPercentage ); \n"
+ " float offsetT = rand( vec2(vTexCoord.t*vPercentage, vTexCoord.s * vPercentage) ); \n"
+ " vec2 lookupCoord = vTexCoord + vec2(offsetS, offsetT) * vPercentage; \n"
+ " gl_FragColor = texture2D( sTexture, lookupCoord ) * uColor; \n"
+ " gl_FragColor.a *= 1.0 - uTransparency*vPercentage; \n"
+ "}\n");
+
+ ShaderEffect shaderEffect = ShaderEffect::New(
+ vertexShaderStringStream.str(), fragmentShader,
+ GeometryType( GEOMETRY_TYPE_IMAGE),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_GRID | ShaderEffect::HINT_BLENDING ) );
+
+ //Register uniform properties
+ std::ostringstream oss;
+ for( unsigned int i = 0; i < numberOfDimples; i++ )
+ {
+ oss.str("");
+ oss<< "uCenter["<< i << "]";
+ shaderEffect.SetUniform(oss.str(), Vector2(0.f,0.f));
+
+ oss.str("");
+ oss<< "uRadius["<< i << "]";
+ shaderEffect.SetUniform(oss.str(), 0.f);
+
+ oss.str("");
+ oss<< "uPercentage["<< i << "]";
+ shaderEffect.SetUniform( oss.str(), 0.f );
+ }
+
+ shaderEffect.SetProperty( ShaderEffect::Property::GRID_DENSITY, Dali::Property::Value(5.f) );
+ shaderEffect.SetUniform( "uTransparency", 0.5f );
+
+ return shaderEffect;
+}
} // namespace Toolkit
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- *
- */
-
-#include <dali-toolkit/public-api/shader-effects/distance-field-effect.h>
-
-#define STRINGIFY(...) #__VA_ARGS__
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace
-{
-// generic uniforms
-const std::string COLOR_PROPERTY_NAME( "uColor" );
-const std::string SMOOTHING_PROPERTY_NAME( "uSmoothing" );
-
-// outline uniforms
-const std::string OUTLINE_ENABLE_PROPERTY_NAME( "uDoOutline" );
-const std::string OUTLINECOLOR_PROPERTY_NAME( "uOutlineColor" );
-const std::string OUTLINE_SIZE_PROPERTY_NAME( "uOutlineParams" );
-
-// glow related
-const std::string GLOW_ENABLE_PROPERTY_NAME( "uDoGlow" );
-const std::string GLOW_COLOR_PROPERTY_NAME( "uGlowColor" );
-const std::string GLOW_BOUNDARY_PROPERTY_NAME( "uGlowBoundary" );
-
-// shadow related
-const std::string SHADOW_ENABLE_PROPERTY_NAME( "uDoShadow" );
-const std::string SHADOW_COLOR_PROPERTY_NAME( "uShadowColor" );
-const std::string SHADOW_OFFSET_PROPERTY_NAME( "uShadowOffset" );
-} // namespace
-
-DistanceFieldEffect::DistanceFieldEffect()
-{
-}
-
-//Call the Parent copy constructor to add reference to the implementation for this object
-DistanceFieldEffect::DistanceFieldEffect(ShaderEffect handle)
-:ShaderEffect(handle)
-{
-}
-
-DistanceFieldEffect::~DistanceFieldEffect()
-{
-}
-
-DistanceFieldEffect DistanceFieldEffect::New()
-{
- std::string fragmentShaderPrefix(
- "#extension GL_OES_standard_derivatives : enable\n"
- "\n"
- );
-
- std::string fragmentShader(
- "uniform mediump float uSmoothing;\n"
- "uniform mediump float uGlowBoundary;\n"
- "uniform mediump vec2 uOutlineParams;\n"
- "uniform lowp vec4 uOutlineColor;\n"
- "uniform lowp vec4 uShadowColor;\n"
- "uniform mediump vec2 uShadowOffset;\n"
- "uniform lowp vec4 uGlowColor;\n"
- "uniform lowp float uDoOutline;\n"
- "uniform lowp float uDoShadow;\n"
- "uniform lowp float uDoGlow;\n"
- "\n"
- "void main()\n"
- "{\n"
- " // sample distance field\n"
- " mediump float distance = texture2D(sTexture, vTexCoord).a;\n"
- " mediump float smoothWidth = fwidth(distance);\n"
- " mediump float alphaFactor = smoothstep(uSmoothing - smoothWidth, uSmoothing + smoothWidth, distance);\n"
- " lowp vec4 color;\n"
- " if (uDoShadow == 0.0)\n"
- " {\n"
- " mediump float alpha = uColor.a * alphaFactor;\n"
- " lowp vec4 rgb = uColor;\n"
- "\n"
- " if (uDoOutline > 0.0)\n"
- " {\n"
- " mediump float outlineWidth = uOutlineParams[1] + smoothWidth;\n"
- " mediump float outlineBlend = smoothstep(uOutlineParams[0] - outlineWidth, uOutlineParams[0] + outlineWidth, distance);\n"
- " alpha = smoothstep(uSmoothing - smoothWidth, uSmoothing + smoothWidth, distance);\n"
- " rgb = mix(uOutlineColor, uColor, outlineBlend);\n"
- " }\n"
- "\n"
- " if (uDoGlow > 0.0)\n"
- " {\n"
- " rgb = mix(uGlowColor, rgb, alphaFactor);\n"
- " alpha = smoothstep(uGlowBoundary, uSmoothing, distance);\n"
- " }\n"
- "\n"
- " // set fragment color\n"
- " color = vec4(rgb.rgb, alpha);\n"
- " }\n"
- "\n"
- " else // (uDoShadow > 0.0)\n"
- " {\n"
- " mediump float shadowDistance = texture2D(sTexture, vTexCoord - uShadowOffset).a;\n"
- " mediump float inText = alphaFactor;\n"
- " mediump float inShadow = smoothstep(uSmoothing - smoothWidth, uSmoothing + smoothWidth, shadowDistance);\n"
- "\n"
- " // inside object, outside shadow\n"
- " if (inText == 1.0)\n"
- " {\n"
- " color = uColor;\n"
- " }\n"
- " // inside object, outside shadow\n"
- " else if ((inText != 0.0) && (inShadow == 0.0))\n"
- " {\n"
- " color = uColor;\n"
- " color.a *= inText;\n"
- " }\n"
- " // outside object, completely inside shadow\n"
- " else if ((inText == 0.0) && (inShadow == 1.0))\n"
- " {\n"
- " color = uShadowColor;\n"
- " }\n"
- " // inside object, completely inside shadow\n"
- " else if ((inText != 0.0) && (inShadow == 1.0))\n"
- " {\n"
- " color = mix(uShadowColor, uColor, inText);\n"
- " color.a = uShadowColor.a;\n"
- " }\n"
- " // inside object, inside shadow's border\n"
- " else if ((inText != 0.0) && (inShadow != 0.0))\n"
- " {\n"
- " color = mix(uShadowColor, uColor, inText);\n"
- " color.a *= max(inText, inShadow);\n"
- " }\n"
- " // inside shadow's border\n"
- " else if (inShadow != 0.0)\n"
- " {\n"
- " color = uShadowColor;\n"
- " color.a *= inShadow;\n"
- " }\n"
- " // outside shadow and object\n"
- " else \n"
- " {\n"
- " color.a = 0.0;\n"
- " }\n"
- "\n"
- " }\n"
- "\n"
- " gl_FragColor = color;\n"
- "\n"
- "}\n"
- );
-
- // Create the implementation, temporarily owned on stack
- Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::NewWithPrefix("", "",
- fragmentShaderPrefix, fragmentShader,
- Dali::GeometryType( GEOMETRY_TYPE_IMAGE ),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING));
-
- /* Pass ownership to DistanceFieldEffect through overloaded constructor, So that it now has access to the
- Dali::ShaderEffect implementation */
-
- // TODO: move default values to... Constants?
- Dali::Toolkit::DistanceFieldEffect handle( shaderEffect );
-
- handle.SetSmoothingEdge(0.5f);
- handle.SetOutlineColor(Color::BLACK);
- handle.SetOutlineParams(Vector2(0.51f, 0.0f));
- handle.SetGlowBoundary(0.4f);
- handle.SetGlowColor(Color::GREEN);
- handle.SetShadowColor(Vector4(0.0f, 0.0f, 0.0f, 0.4f));
-
- // TODO: find a way to set the shadow offset in texel coordinates instead of UVs.
- handle.SetShadowOffset(Vector2(0.05f, 0.05f));
-
- // Default:
- handle.SetOutline(false);
- handle.SetGlow(false);
- handle.SetShadow(false);
-
- return handle;
-
-}
-
-void DistanceFieldEffect::SetGlowColor(const Vector4& color)
-{
- SetUniform(GLOW_COLOR_PROPERTY_NAME, color);
-}
-
-void DistanceFieldEffect::SetGlow(bool glowEnable)
-{
- const float a = glowEnable ? 1.0f : 0.0f;
- SetUniform(GLOW_ENABLE_PROPERTY_NAME, a);
-}
-
-void DistanceFieldEffect::SetGlowBoundary(float glowBoundary)
-{
- SetUniform(GLOW_BOUNDARY_PROPERTY_NAME, glowBoundary);
-}
-
-void DistanceFieldEffect::SetOutline(bool outlineEnable)
-{
- const float a = outlineEnable ? 1.0f : 0.0f;
- SetUniform(OUTLINE_ENABLE_PROPERTY_NAME, a);
-}
-
-void DistanceFieldEffect::SetOutlineColor(const Vector4& color)
-{
- SetUniform(OUTLINECOLOR_PROPERTY_NAME, color);
-}
-
-void DistanceFieldEffect::SetOutlineParams(const Vector2& outlineParams)
-{
- SetUniform(OUTLINE_SIZE_PROPERTY_NAME, outlineParams);
-}
-
-void DistanceFieldEffect::SetShadow(bool shadowEnable)
-{
- if (shadowEnable)
- {
- SetGlow(false);
- SetOutline(false);
- }
-
- const float a = shadowEnable ? 1.0f : 0.0f;
- SetUniform(SHADOW_ENABLE_PROPERTY_NAME, a);
-}
-
-void DistanceFieldEffect::SetShadowColor(const Vector4& color)
-{
- SetUniform(SHADOW_COLOR_PROPERTY_NAME, color);
-}
-
-void DistanceFieldEffect::SetShadowOffset(const Vector2& offset)
-{
- SetUniform(SHADOW_OFFSET_PROPERTY_NAME, offset);
-}
-
-void DistanceFieldEffect::SetSmoothingEdge(const float smoothing)
-{
- SetUniform(SMOOTHING_PROPERTY_NAME, smoothing);
-}
-
-const std::string& DistanceFieldEffect::GetColorPropertyName() const
-{
- return COLOR_PROPERTY_NAME;
-}
-
-const std::string& DistanceFieldEffect::GetOutlineColorPropertyName() const
-{
- return OUTLINECOLOR_PROPERTY_NAME;
-}
-
-const std::string& DistanceFieldEffect::GetShadowColorPropertyName() const
-{
- return SHADOW_COLOR_PROPERTY_NAME;
-}
-
-const std::string& DistanceFieldEffect::GetShadowOffsetPropertyName() const
-{
- return SHADOW_OFFSET_PROPERTY_NAME;
-}
-
-const std::string& DistanceFieldEffect::GetGlowColorPropertyName() const
-{
- return GLOW_COLOR_PROPERTY_NAME;
-}
-
-const std::string& DistanceFieldEffect::GetGlowBoundaryPropertyName() const
-{
- return GLOW_BOUNDARY_PROPERTY_NAME;
-}
-
-const std::string& DistanceFieldEffect::GetOutlineSizePropertyName() const
-{
- return OUTLINE_SIZE_PROPERTY_NAME;
-}
-
-const std::string& DistanceFieldEffect::GetOutlineEnablePropertyName() const
-{
- return OUTLINE_ENABLE_PROPERTY_NAME;
-}
-
-const std::string& DistanceFieldEffect::GetGlowEnablePropertyName() const
-{
- return GLOW_ENABLE_PROPERTY_NAME;
-}
-
-const std::string& DistanceFieldEffect::GetShadowEnablePropertyName() const
-{
- return SHADOW_ENABLE_PROPERTY_NAME;
-}
-
-const std::string& DistanceFieldEffect::GetSmoothingPropertyName() const
-{
- return SMOOTHING_PROPERTY_NAME;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
{
/**
+ * Creates a new DistanceFieldEffect
+ *
* DistanceFieldEffect is a custom shader effect to achieve distance field on Image actors
+ *
+ * Animatable/Constrainable uniforms:
+ *
+ * "uSmoothing" - Soft edge smoothing. Specify the distance field value for the center of the edge.
+
+ * "uDoGlow" - The glow state. If true, glow is enabled
+ * "uGlowBoundary" - The glow boundary factor
+ * "uGlowColor" - The glow color multiplier
+
+ * "uDoShadow" - The shadow state. If true, shadows is enabled. Cannot be used with glow/and or outline
+ * "uShadowColor" - The shadow color multiplier
+ * "uShadowOffset" - The shadow offset
+
+ * "uDoOutline" - The outline state. If true, outline is enabled
+ * "uOutlineColor" - The outline color multiplier
+ * "uOutlineParams"- Thickness of outline. The outline thickness is determined by two values.
+ * First value [0-1] Specifies the distance field value for the center of the outline.
+ * Second value [0-1] Specifies the softness/width/anti-aliasing of the outlines inner edge.
+ *
+ * @return A handle to a newly allocated ShaderEffect
*/
-class DALI_IMPORT_API DistanceFieldEffect : public ShaderEffect
+inline ShaderEffect CreateDistanceFieldEffect()
{
-public:
-
- /**
- * Create an uninitialized DistanceFieldEffect; this can be initialized with DistanceFieldEffect::New()
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- DistanceFieldEffect();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~DistanceFieldEffect();
-
- /**
- * Create an initialized DistanceFieldEffect.
- * @return A handle to a newly allocated Dali resource.
- */
- static DistanceFieldEffect New();
-
- /**
- * Set the shadow state
- * @param[in] shadowEnable value - true, enable shadow.
- * @note Shadow cannot be used with glow/and or outline.
- */
- void SetShadow(bool shadowEnable);
-
- /**
- * Set the shadow color multiplier (e.g. output RGB)
- * @param[in] color Shadow color value
- */
- void SetShadowColor(const Vector4& color);
-
- /**
- * Set the shadow offset
- * @param[in] color shadow offset value
- */
- void SetShadowOffset(const Vector2& color);
-
- /**
- * Set the glow state
- * @param[in] glowEnable value - true, enable glow.
- */
-
- void SetGlow(bool glowEnable);
-
- /**
- * Set the glow color multiplier (e.g. output RGB)
- * @param[in] color Glow color value
- */
- void SetGlowColor(const Vector4& color);
-
- /**
- * Set the glow boundary factor
- * @param[in] glowBoundary glow boundary
- */
- void SetGlowBoundary(float glowBoundary);
-
- /**
- * Set the outline state
- * @param[in] outlineEnable value - true, enable outline.
- */
-
- void SetOutline(bool outlineEnable);
-
- /**
- * Set the outline color multiplier (e.g. output RGB)
- * @param[in] color Outline color value
- */
- void SetOutlineColor(const Vector4& color);
-
- /**
- * Sets the outline parameters.
- * @param[in] outlineParams Thickness of outline. The outline thickness is determined by two parameters.
- * params[0] (0-1) Specifies the distance field value for the center of the outline.
- * 0 <= params[0] <= 1
- * params[1] (0-1) Specifies the softness/width/anti-aliasing of the outlines inner edge.
- * 0 <= params[0] <= 1
- */
- void SetOutlineParams(const Vector2& outlineParams);
-
- /**
- * Set soft edge smoothing
- * @param[in] smoothing Specify the distance field value for the center of the edge.
- * 0 <= params <= 1
- */
- void SetSmoothingEdge(float smoothing);
-
- /**
- * Get the name for the outline-enable property
- * @return A std::string containing the property name
- */
- const std::string& GetOutlineEnablePropertyName() const;
-
- /**
- * Get the name for the glow-enable property
- * @return A std::string containing the property name
- */
- const std::string& GetGlowEnablePropertyName() const;
-
- /**
- * Get the name for the shadow-enable property
- * @return A std::string containing the property name
- */
- const std::string& GetShadowEnablePropertyName() const;
-
- /**
- * Get the name for the radius property
- * @return A std::string containing the property name
- */
- const std::string& GetColorPropertyName() const;
-
- /**
- * Get the name for the smoothing property
- * @return A std::string containing the property name
- */
- const std::string& GetSmoothingPropertyName() const;
-
- /**
- * Get the name for the outline color property
- * @return A std::string containing the property name
- */
- const std::string& GetOutlineColorPropertyName() const;
-
- /**
- * Get the name for the outline size property
- * @return A std::string containing the property name
- */
- const std::string& GetOutlineSizePropertyName() const;
-
- /**
- * Get the name for the shadow color property
- * @return A std::string containing the property name
- */
- const std::string& GetShadowColorPropertyName() const;
-
- /**
- * Get the name for the shadow offset property
- * @return A std::string containing the property name
- */
- const std::string& GetShadowOffsetPropertyName() const;
-
- /**
- * Get the name for the glow color property
- * @return A std::string containing the property name
- */
- const std::string& GetGlowColorPropertyName() const;
-
- /**
- * Get the name for the glow boundary property
- * @return A std::string containing the property name
- */
- const std::string& GetGlowBoundaryPropertyName() const;
-
-private:
- DALI_INTERNAL DistanceFieldEffect(ShaderEffect handle);
-
-};
+ std::string fragmentShaderPrefix(
+ "#extension GL_OES_standard_derivatives : enable\n"
+ "\n"
+ );
+
+ std::string fragmentShader(
+ "uniform mediump float uSmoothing;\n"
+ "uniform mediump float uGlowBoundary;\n"
+ "uniform mediump vec2 uOutlineParams;\n"
+ "uniform lowp vec4 uOutlineColor;\n"
+ "uniform lowp vec4 uShadowColor;\n"
+ "uniform mediump vec2 uShadowOffset;\n"
+ "uniform lowp vec4 uGlowColor;\n"
+ "uniform lowp float uDoOutline;\n"
+ "uniform lowp float uDoShadow;\n"
+ "uniform lowp float uDoGlow;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " // sample distance field\n"
+ " mediump float distance = texture2D(sTexture, vTexCoord).a;\n"
+ " mediump float smoothWidth = fwidth(distance);\n"
+ " mediump float alphaFactor = smoothstep(uSmoothing - smoothWidth, uSmoothing + smoothWidth, distance);\n"
+ " lowp vec4 color;\n"
+ " if (uDoShadow == 0.0)\n"
+ " {\n"
+ " mediump float alpha = uColor.a * alphaFactor;\n"
+ " lowp vec4 rgb = uColor;\n"
+ "\n"
+ " if (uDoOutline > 0.0)\n"
+ " {\n"
+ " mediump float outlineWidth = uOutlineParams[1] + smoothWidth;\n"
+ " mediump float outlineBlend = smoothstep(uOutlineParams[0] - outlineWidth, uOutlineParams[0] + outlineWidth, distance);\n"
+ " alpha = smoothstep(uSmoothing - smoothWidth, uSmoothing + smoothWidth, distance);\n"
+ " rgb = mix(uOutlineColor, uColor, outlineBlend);\n"
+ " }\n"
+ "\n"
+ " if (uDoGlow > 0.0)\n"
+ " {\n"
+ " rgb = mix(uGlowColor, rgb, alphaFactor);\n"
+ " alpha = smoothstep(uGlowBoundary, uSmoothing, distance);\n"
+ " }\n"
+ "\n"
+ " // set fragment color\n"
+ " color = vec4(rgb.rgb, alpha);\n"
+ " }\n"
+ "\n"
+ " else // (uDoShadow > 0.0)\n"
+ " {\n"
+ " mediump float shadowDistance = texture2D(sTexture, vTexCoord - uShadowOffset).a;\n"
+ " mediump float inText = alphaFactor;\n"
+ " mediump float inShadow = smoothstep(uSmoothing - smoothWidth, uSmoothing + smoothWidth, shadowDistance);\n"
+ "\n"
+ " // inside object, outside shadow\n"
+ " if (inText == 1.0)\n"
+ " {\n"
+ " color = uColor;\n"
+ " }\n"
+ " // inside object, outside shadow\n"
+ " else if ((inText != 0.0) && (inShadow == 0.0))\n"
+ " {\n"
+ " color = uColor;\n"
+ " color.a *= inText;\n"
+ " }\n"
+ " // outside object, completely inside shadow\n"
+ " else if ((inText == 0.0) && (inShadow == 1.0))\n"
+ " {\n"
+ " color = uShadowColor;\n"
+ " }\n"
+ " // inside object, completely inside shadow\n"
+ " else if ((inText != 0.0) && (inShadow == 1.0))\n"
+ " {\n"
+ " color = mix(uShadowColor, uColor, inText);\n"
+ " color.a = uShadowColor.a;\n"
+ " }\n"
+ " // inside object, inside shadow's border\n"
+ " else if ((inText != 0.0) && (inShadow != 0.0))\n"
+ " {\n"
+ " color = mix(uShadowColor, uColor, inText);\n"
+ " color.a *= max(inText, inShadow);\n"
+ " }\n"
+ " // inside shadow's border\n"
+ " else if (inShadow != 0.0)\n"
+ " {\n"
+ " color = uShadowColor;\n"
+ " color.a *= inShadow;\n"
+ " }\n"
+ " // outside shadow and object\n"
+ " else \n"
+ " {\n"
+ " color.a = 0.0;\n"
+ " }\n"
+ "\n"
+ " }\n"
+ "\n"
+ " gl_FragColor = color;\n"
+ "\n"
+ "}\n"
+ );
+
+ // Create the implementation, temporarily owned on stack
+ Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::NewWithPrefix(
+ "", "",
+ fragmentShaderPrefix, fragmentShader,
+ GeometryType( GEOMETRY_TYPE_IMAGE ),
+ ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING));
+
+ shaderEffect.SetUniform("uSmoothing",0.5f);
+ shaderEffect.SetUniform("uOutlineColor",Color::BLACK);
+ shaderEffect.SetUniform("uOutlineParams",Vector2(0.51f, 0.0f));
+ shaderEffect.SetUniform("uGlowBoundary",0.4f);
+ shaderEffect.SetUniform("uGlowColor",Color::GREEN);
+ shaderEffect.SetUniform("uShadowColor",Vector4(0.0f, 0.0f, 0.0f, 0.4f));
+
+ // TODO: find a way to set the shadow offset in texel coordinates instead of UVs.
+ shaderEffect.SetUniform("uShadowOffset",Vector2(0.05f, 0.05f));
+
+ // Default:
+ shaderEffect.SetUniform("uDoOutline",false);
+ shaderEffect.SetUniform("uDoGlow",false);
+ shaderEffect.SetUniform("uDoShadow",false);
+
+ return shaderEffect;
+}
+
} // namespace Toolkit
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- *
- */
-
-#include <dali-toolkit/public-api/shader-effects/image-region-effect.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace
-{
-
-const std::string TOP_LEFT_PROPERTY_NAME( "uTopLeft" );
-const std::string BOTTOM_RIGHT_PROPERTY_NAME( "uBottomRight" );
-
-} // namespace
-
-ImageRegionEffect::ImageRegionEffect()
-{
-}
-
-//Call the Parent copy constructor to add reference to the implementation for this object
-ImageRegionEffect::ImageRegionEffect(ShaderEffect handle)
-:ShaderEffect(handle)
-{
-}
-
-ImageRegionEffect::~ImageRegionEffect()
-{
-}
-
-
-ImageRegionEffect ImageRegionEffect::New()
-{
- std::string vertexShader(
- "uniform mediump vec2 uTopLeft;\n"
- "uniform mediump vec2 uBottomRight;\n"
- "void main()\n"
- "{\n"
- " mediump vec4 position = vec4(aPosition,1.0);\n"
- " gl_Position = uMvpMatrix * position;\n"
- // The line below is doing the same as the following commented lines:
- //" vec2 imageSize = sTextureRect.zw - sTextureRect.xy;\n"
- //" vec2 topLeft = sTextureRect.xy + uTopLeft * imageSize;\n"
- //" vec2 bottomRight = sTextureRect.xy + uBottomRight * imageSize;\n"
- //" vec2 texCoord = (aTexCoord - sTextureRect.xy) / imageSize;\n"
- //" vTexCoord = topLeft + texCoord * ( bottomRight - topLeft );\n"
- " vTexCoord = sTextureRect.xy + uTopLeft * ( sTextureRect.zw - sTextureRect.xy ) + ( aTexCoord - sTextureRect.xy ) * ( uBottomRight - uTopLeft );\n"
- "}\n"
- );
-
- Dali::ShaderEffect shaderEffectCustom = Dali::ShaderEffect::New( vertexShader, "" );
-
- Dali::Toolkit::ImageRegionEffect handle( shaderEffectCustom );
-
- handle.SetUniform( TOP_LEFT_PROPERTY_NAME, Vector2( 0.f, 0.f ) );
- handle.SetUniform( BOTTOM_RIGHT_PROPERTY_NAME, Vector2( 1.f, 1.f ) );
-
- return handle;
-}
-
-void ImageRegionEffect::SetTopLeft(const Vector2& point)
-{
- SetUniform( TOP_LEFT_PROPERTY_NAME, point );
-}
-
-void ImageRegionEffect::SetBottomRight(const Vector2& point)
-{
- SetUniform( BOTTOM_RIGHT_PROPERTY_NAME, point );
-}
-
-const std::string& ImageRegionEffect::GetTopLeftPropertyName() const
-{
- return TOP_LEFT_PROPERTY_NAME;
-}
-
-const std::string& ImageRegionEffect::GetBottomRightPropertyName() const
-{
- return BOTTOM_RIGHT_PROPERTY_NAME;
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
{
/**
- * @brief ImageRegionEffect is a custom shader effect to show only a region of an Image actor.
+ * @brief Creates a new ImageRegionEffect
+ *
+ * ImageRegionEffect is a custom shader effect to show only a region of an Image actor.
+ *
+ * Animatable/Constrainable uniforms:
+ * "uTopLeft" - The top-left corner of the image region. The coordinates are in percentage,
+ * (0,0) being the top-left and (1,1) the bottom right of the original image
+ * "uBottomRight" - The bottom-right corner of the image region. The coordinates are in percentage,
+ * (0,0) being the top-left and (1,1) the bottom right of the original image
+ *
+ * @return A handle to a newly allocated ShaderEffect
*/
-class DALI_IMPORT_API ImageRegionEffect : public ShaderEffect
+inline ShaderEffect CreateImageRegionEffect()
{
-public:
-
- /**
- * @brief Create an uninitialized ImageRegionEffect; this can be initialized with ImageRegionEffect::New().
- *
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- ImageRegionEffect();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~ImageRegionEffect();
-
- /**
- * @brief Create an initialized ImageRegionEffect.
- *
- * @return A handle to a newly allocated Dali resource.
- */
- static ImageRegionEffect New();
-
- /**
- * @brief Set the top-left corner of the image region.
- *
- * The coordinates are in percentage, (0,0) being the top-left and (1,1) the bottom right of the original image.
- * @param [in] point The top-left corner of the region.
- */
- void SetTopLeft(const Vector2& point);
-
- /**
- * @brief Set the bottom-right corner of the image region.
- *
- * The coordinates are in percentage, (0,0) being the top-left and (1,1) the bottom right of the original image.
- * @param [in] point The bottom-right corner of the region.
- */
- void SetBottomRight(const Vector2& point);
-
- /**
- * @brief Get the name for the top-left point property.
- *
- * which can be used in Animation API's
- * @return A std::string containing the property name
- */
- const std::string& GetTopLeftPropertyName() const;
-
- /**
- * @brief Get the name for the bottom-right point property which can be used in Animation APIs.
- *
- * @return A std::string containing the property name
- */
- const std::string& GetBottomRightPropertyName() const;
-
-private: // Not intended for application developers
- DALI_INTERNAL ImageRegionEffect(ShaderEffect handle);
-};
+ std::string vertexShader(
+ "uniform mediump vec2 uTopLeft;\n"
+ "uniform mediump vec2 uBottomRight;\n"
+ "void main()\n"
+ "{\n"
+ " mediump vec4 position = vec4(aPosition,1.0);\n"
+ " gl_Position = uMvpMatrix * position;\n"
+ // The line below is doing the same as the following commented lines:
+ //" vec2 imageSize = sTextureRect.zw - sTextureRect.xy;\n"
+ //" vec2 topLeft = sTextureRect.xy + uTopLeft * imageSize;\n"
+ //" vec2 bottomRight = sTextureRect.xy + uBottomRight * imageSize;\n"
+ //" vec2 texCoord = (aTexCoord - sTextureRect.xy) / imageSize;\n"
+ //" vTexCoord = topLeft + texCoord * ( bottomRight - topLeft );\n"
+ " vTexCoord = sTextureRect.xy + uTopLeft * ( sTextureRect.zw - sTextureRect.xy ) + ( aTexCoord - sTextureRect.xy ) * ( uBottomRight - uTopLeft );\n"
+ "}\n"
+ );
+
+ Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New( vertexShader, "" );
+ shaderEffect.SetUniform( "uTopLeft", Vector2( 0.f, 0.f ) );
+ shaderEffect.SetUniform( "uBottomRight", Vector2( 1.f, 1.f ) );
+
+ return shaderEffect;
+}
} // namespace Toolkit
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- *
- */
-
-#include <dali-toolkit/public-api/shader-effects/iris-effect.h>
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace
-{
-const std::string RADIUS_PROPERTY_NAME( "uRadius" );
-const std::string CENTER_PROPERTY_NAME( "uCenter" );
-const std::string BLEND_FACTOR_PROPERTY_NAME( "uBlendFactor" );
-} // namespace
-
-IrisEffect::IrisEffect()
-{
-}
-
-//Call the Parent copy constructor to add reference to the implementation for this object
-IrisEffect::IrisEffect(ShaderEffect handle)
-:ShaderEffect(handle)
-{
-}
-
-IrisEffect::~IrisEffect()
-{
-}
-
-IrisEffect IrisEffect::New()
-{
- // append the default version
- std::string vertexShader(
- "uniform mediump vec2 uCenter;\n"
- "varying mediump vec2 vRelativePosition;\n"
- "\n"
- "void main()\n"
- "{\n"
- " mediump vec4 world = uModelView * vec4(aPosition,1.0);\n"
- " gl_Position = uProjection * world;\n"
- " \n"
- " vTexCoord = aTexCoord;\n"
- " vRelativePosition = aTexCoord - uCenter;\n"
- "}\n");
-
- std::string fragmentShader(
- "uniform mediump float uRadius; \n"
- "uniform mediump float uBlendFactor; \n"
- "varying mediump vec2 vRelativePosition; \n"
- "void main() \n"
- "{ \n"
- " mediump float delta = (length(vRelativePosition) - uRadius); \n"
- " delta = clamp(0.0 - delta * uBlendFactor, 0.0, 1.0); \n"
- " gl_FragColor = texture2D(sTexture, vTexCoord) * uColor; \n"
- " gl_FragColor.a *= delta; \n"
- "} \n"
- );
-
- Dali::ShaderEffect shaderEffectCustom = Dali::ShaderEffect::New(
- vertexShader,
- fragmentShader,
- GeometryType( GEOMETRY_TYPE_IMAGE ),
- ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ));
-
- Dali::Toolkit::IrisEffect handle( shaderEffectCustom );
- handle.SetUniform( RADIUS_PROPERTY_NAME, 0.0f );
- handle.SetUniform( BLEND_FACTOR_PROPERTY_NAME, 100.0f );
- handle.SetUniform( CENTER_PROPERTY_NAME, Vector2(0.5f, 0.5f) );
- return handle;
-}
-
-void IrisEffect::SetRadius( float radius )
-{
- SetUniform( RADIUS_PROPERTY_NAME, radius );
-}
-
-void IrisEffect::SetBlendFactor(float value )
-{
- SetUniform( BLEND_FACTOR_PROPERTY_NAME, value );
-}
-
-void IrisEffect::SetCenter( const Vector2& center )
-{
- SetUniform( CENTER_PROPERTY_NAME, center );
-}
-
-const std::string& IrisEffect::GetRadiusPropertyName() const
-{
- return RADIUS_PROPERTY_NAME;
-}
-
-const std::string& IrisEffect::GetBlendFactorPropertyName() const
-{
- return BLEND_FACTOR_PROPERTY_NAME;
-}
-
-const std::string& IrisEffect::GetCenterPropertyName() const
-{
- return CENTER_PROPERTY_NAME;
-}
-
-
-}
-}
{
/**
- * @brief IrisEffect is a custom shader effect to achieve iris effects in Image actors
+ * @brief Creates a new IrisEffect
+ *
+ * IrisEffect is a custom shader effect to achieve iris effects in Image actors
+ *
+ * Animatable/Constrainable uniforms:
+ *
+ * "uRadius" - The radius of the iris effect in texture coordinate distance,
+ * i.e. 0.0 (no circle) to 1.0 (complete circle), to > 1.0 (extending outside of texture).
+ * @note For Atlas Textures results may be unpredictable.
+ *
+ * "uBlendFactor" - The blend factor of the iris effect. The lower the value, the larger the blending portion
+ * (between Opaque & Transparent). Blending will account for 1 / blendFactor of the radius
+ * of the texture.
+ *
+ * "uCenter" - The center point of the iris (in texture coordinates)
+ *
+ * @return A handle to a newly allocated ShaderEffect
*/
-class DALI_IMPORT_API IrisEffect : public ShaderEffect
+inline ShaderEffect CreateIrisEffect()
{
-
-public:
-
- /**
- * @brief Create an uninitialized IrisEffect; this can be initialized with IrisEffect::New().
- *
- * Calling member functions with an uninitialized Dali::Object is not allowed.
- */
- IrisEffect();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~IrisEffect();
-
- /**
- * @brief Create an initialized IrisEffect.
- *
- * @return A handle to a newly allocated Dali resource.
- */
- static IrisEffect New();
-
- /**
- * @brief Set the radius of the iris effect in texture coordinate distance,
- * i.e. 0.0 (no circle) to 1.0 (complete circle), to > 1.0 (extending
- * outside of texture).
- *
- * @note For Atlas Textures results may be unpredictable.
- *
- * @param [in] radius The new radius.
- */
- void SetRadius(float radius);
-
- /**
- * @brief Set the blend factor of the iris effect.
- *
- * The lower the value, the larger the blending portion
- * (between Opaque & Transparent)
- *
- * Blending will account for 1 / blendFactor of the radius
- * of the texture.
- *
- * @param [in] value The new blend Factor.
- */
- void SetBlendFactor(float value);
-
- /**
- * @brief Sets the center point of the iris (in texture coordinates).
- *
- * @param[in] center The center point.
- */
- void SetCenter( const Vector2& center );
-
- /**
- * @brief Get the name for the radius property which can be used in Animation APIs.
- *
- * @return A std::string containing the property name
- */
- const std::string& GetRadiusPropertyName() const;
-
- /**
- * @brief Get the name for the blend factor property.
- *
- * @return A std::string containing the property name
- */
- const std::string& GetBlendFactorPropertyName() const;
-
- /**
- * @brief Get the name for the center property.
- *
- * @return A std::string containing the property name
- */
- const std::string& GetCenterPropertyName() const;
-
-
-private: // Not intended for application developers
- DALI_INTERNAL IrisEffect(ShaderEffect handle);
-};
+ // append the default version
+ std::string vertexShader(
+ "uniform mediump vec2 uCenter;\n"
+ "varying mediump vec2 vRelativePosition;\n"