Select BGRA shader for colored emojis 10/36610/3
authorRichard Underhill <r.underhill@partner.samsung.com>
Tue, 10 Mar 2015 16:11:23 +0000 (16:11 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Wed, 11 Mar 2015 13:14:32 +0000 (06:14 -0700)
Change-Id: Ic85b2235c4eae0f4fdfa99c3fb057559795388b7
Signed-off-by: Richard Underhill <r.underhill@partner.samsung.com>
dali-toolkit/internal/file.list
dali-toolkit/internal/text/rendering/basic/text-basic-renderer.cpp
dali-toolkit/internal/text/rendering/shaders/text-bgra-shader.cpp [new file with mode: 0644]
dali-toolkit/internal/text/rendering/shaders/text-bgra-shader.h [new file with mode: 0644]

index 09eb7c8..e7a40ec 100644 (file)
@@ -91,6 +91,7 @@ toolkit_src_files = \
    $(toolkit_src_dir)/text/rendering/text-renderer.cpp \
    $(toolkit_src_dir)/text/rendering/basic/text-basic-renderer.cpp \
    $(toolkit_src_dir)/text/rendering/shaders/text-basic-shader.cpp \
+   $(toolkit_src_dir)/text/rendering/shaders/text-bgra-shader.cpp \
    $(toolkit_src_dir)/text/rendering/text-backend-impl.cpp \
    $(toolkit_src_dir)/transition-effects/cube-transition-effect-impl.cpp \
    $(toolkit_src_dir)/transition-effects/cube-transition-cross-effect-impl.cpp \
index ac95892..31ab53f 100644 (file)
@@ -25,6 +25,8 @@
 #include <dali/public-api/images/atlas.h>
 #include <dali/public-api/geometry/mesh.h>
 #include <dali-toolkit/internal/text/rendering/shaders/text-basic-shader.h>
+#include <dali-toolkit/internal/text/rendering/shaders/text-bgra-shader.h>
+
 
 using namespace Dali;
 using namespace Dali::Toolkit;
@@ -367,7 +369,7 @@ RenderableActor BasicRenderer::Render( Text::ViewInterface& view )
       actorBGRA8888 = MeshActor::New( mImpl->CreateMesh( glyphs, positions, Pixel::BGRA8888, mImpl->mAtlasBGRA8888 ) );
       actorBGRA8888.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
 
-      ShaderEffect shader = BasicShader::New();
+      ShaderEffect shader = BGRAShader::New();
       actorBGRA8888.SetShaderEffect( shader );
     }
 
diff --git a/dali-toolkit/internal/text/rendering/shaders/text-bgra-shader.cpp b/dali-toolkit/internal/text/rendering/shaders/text-bgra-shader.cpp
new file mode 100644 (file)
index 0000000..43f61d5
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ *
+ */
+
+// INTERNAL HEADERS
+#include <dali-toolkit/internal/text/rendering/text-renderer.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Text
+{
+
+namespace BGRAShader
+{
+
+Dali::ShaderEffect New()
+{
+  std::string vertexShader = DALI_COMPOSE_SHADER(
+      uniform mediump vec4 uTextureRect;\n
+      void main()\n
+      {\n
+        gl_Position = uMvpMatrix * vec4( aPosition.xy, 0.0, 1.0 );\n
+        vTexCoord = aTexCoord.xy;\n
+      }\n
+  );
+
+  std::string fragmentShader = DALI_COMPOSE_SHADER(
+      void main()\n
+      {\n
+        gl_FragColor = texture2D( sTexture, vTexCoord );
+      }\n
+  );
+
+  Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New( vertexShader, fragmentShader,
+                                                             Dali::GeometryType( Dali::GEOMETRY_TYPE_TEXTURED_MESH ),
+                                                             Dali::ShaderEffect::GeometryHints( Dali::ShaderEffect::HINT_NONE ) );
+  return shaderEffect;
+}
+
+} // namespace BGRAShader
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
diff --git a/dali-toolkit/internal/text/rendering/shaders/text-bgra-shader.h b/dali-toolkit/internal/text/rendering/shaders/text-bgra-shader.h
new file mode 100644 (file)
index 0000000..70e3c67
--- /dev/null
@@ -0,0 +1,54 @@
+
+#ifndef __DALI_TOOLKIT_TEXT_BGRA_SHADER_H__
+#define __DALI_TOOLKIT_TEXT_BGRA_SHADER_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 Text
+{
+
+/**
+ * @brief A BGRA shader for rendering glyphs.
+ */
+namespace BGRAShader
+{
+
+/**
+ * Create a basic text shader.
+ * @return A handle to a newly allocated ShaderEffect
+ */
+Dali::ShaderEffect New();
+
+} // namespace BGRAShader
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_TEXT_BGRA_SHADER_H__