-#ifndef __DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H__
-#define __DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H__
+#ifndef DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H
+#define DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H
/*
- * 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.
*
*/
-#define DALI_COMPOSE_SHADER(STR) #STR
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.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.
**/
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[ "vertexShader" ] = vertexSource;
- customShader[ "fragmentShader" ] = 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[ "shader" ] = customShader;
+ map[Toolkit::Visual::Property::SHADER] = customShader;
return map;
}
} // namespace Dali
-#endif /* __DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H__ */
+#endif // DALI_PAGE_TURN_BOOK_SPINE_EFFECT_H