[dali_2.3.19] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / page-turn-view / page-turn-book-spine-effect.h
index 100c2c8..e5e95f8 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H
 
 /*
- * Copyright (c) 2017 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.
  */
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 #include <dali-toolkit/public-api/visuals/visual-properties.h>
 
-#define DALI_COMPOSE_SHADER(STR) #STR
-
 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::Visual::Property::SHADER ] = customShader;
+  map[Toolkit::Visual::Property::SHADER] = customShader;
   return map;
 }