X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fdevel-api%2Fshader-effects%2Fimage-region-effect.cpp;h=2d446d3316bc46d81de6e1a5adff9ba7d0c943a4;hp=1a16481efa69b0c664b938a7a892bab488c10848;hb=HEAD;hpb=f58b8383147de70affa1e3949cf1c6757d705d3c diff --git a/dali-toolkit/devel-api/shader-effects/image-region-effect.cpp b/dali-toolkit/devel-api/shader-effects/image-region-effect.cpp index 1a16481..2d446d3 100644 --- a/dali-toolkit/devel-api/shader-effects/image-region-effect.cpp +++ b/dali-toolkit/devel-api/shader-effects/image-region-effect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -12,87 +12,28 @@ * 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 +// INTERNAL INCLUDES +#include +#include + 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) +Property::Map CreateImageRegionEffect() { - SetUniform( BOTTOM_RIGHT_PROPERTY_NAME, point ); -} + Property::Map map; -const std::string& ImageRegionEffect::GetTopLeftPropertyName() const -{ - return TOP_LEFT_PROPERTY_NAME; -} + Property::Map customShader; + customShader[Visual::Shader::Property::VERTEX_SHADER] = SHADER_IMAGE_REGION_EFFECT_VERT.data(); -const std::string& ImageRegionEffect::GetBottomRightPropertyName() const -{ - return BOTTOM_RIGHT_PROPERTY_NAME; + map[Toolkit::Visual::Property::SHADER] = customShader; + return map; } } // namespace Toolkit