X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fpage-turn-view%2Fpage-turn-book-spine-effect.h;h=e5e95f80a788767c0b8ef0dae159ef7bf7edd01c;hp=2af39469e4cd57d3e893e42456b2ee4f14eedfdc;hb=HEAD;hpb=9217ec0c1d483607ed6c8f08a1d9c238657ba5d6 diff --git a/dali-toolkit/internal/controls/page-turn-view/page-turn-book-spine-effect.h b/dali-toolkit/internal/controls/page-turn-view/page-turn-book-spine-effect.h index 2af39469..e5e95f8 100644 --- a/dali-toolkit/internal/controls/page-turn-view/page-turn-book-spine-effect.h +++ b/dali-toolkit/internal/controls/page-turn-view/page-turn-book-spine-effect.h @@ -2,7 +2,7 @@ #define DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H /* - * Copyright (c) 2016 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. @@ -19,19 +19,15 @@ */ // INTERNAL INCLUDES -#include - -#define DALI_COMPOSE_SHADER(STR) #STR +#include +#include 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. @@ -52,59 +48,14 @@ namespace Internal **/ inline Property::Map CreatePageTurnBookSpineEffect() { - const char* vertexSource = DALI_COMPOSE_SHADER( - precision mediump float;\n - attribute mediump vec2 aPosition;\n - uniform mediump mat4 uMvpMatrix;\n - uniform vec3 uSize;\n - uniform float uTextureWidth;\n - varying vec2 vTexCoord;\n - void main()\n - {\n - mediump vec4 vertexPosition = vec4(aPosition*uSize.xy, 0.0, 1.0);\n - gl_Position = uMvpMatrix * vertexPosition;\n - vTexCoord = aPosition + vec2(0.5);\n - vTexCoord.x /= uTextureWidth; - }\n); - - // the simplified version of the fragment shader of page turn effect - const char* fragmentSource = DALI_COMPOSE_SHADER( - precision mediump float;\n - varying mediump vec2 vTexCoord;\n - uniform vec3 uSize;\n - uniform vec2 uSpineShadowParameter;\n - uniform sampler2D sTexture;\n - uniform lowp vec4 uColor;\n - - void main()\n - {\n - if( gl_FrontFacing )\n // display front side - {\n - gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n - }\n - else\n // display back side, flip the image horizontally by changing the x component of the texture coordinate - {\n - gl_FragColor = texture2D( sTexture, vec2( 1.0 - vTexCoord.x, vTexCoord.y ) ) * uColor;\n - }\n - // display book spine, a stripe of shadowed texture - float pixelPos = vTexCoord.x * uSize.x;\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 - } ); - Property::Map map; Property::Map customShader; - customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = vertexSource; - customShader[ Toolkit::Visual::Shader::Property::FRAGMENT_SHADER ] = fragmentSource; + customShader[Toolkit::Visual::Shader::Property::VERTEX_SHADER] = SHADER_PAGE_TURN_BOOK_SPINE_EFFECT_VERT.data(); + customShader[Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = SHADER_PAGE_TURN_BOOK_SPINE_EFFECT_FRAG.data(); - map[ Toolkit::DevelVisual::Property::SHADER ] = customShader; + map[Toolkit::Visual::Property::SHADER] = customShader; return map; }