From eabd0e3a4b1475d76be02035c450c482993be0f9 Mon Sep 17 00:00:00 2001 From: Richard Underhill Date: Tue, 10 Mar 2015 16:11:23 +0000 Subject: [PATCH] Select BGRA shader for colored emojis Change-Id: Ic85b2235c4eae0f4fdfa99c3fb057559795388b7 Signed-off-by: Richard Underhill --- dali-toolkit/internal/file.list | 1 + .../text/rendering/basic/text-basic-renderer.cpp | 4 +- .../text/rendering/shaders/text-bgra-shader.cpp | 64 ++++++++++++++++++++++ .../text/rendering/shaders/text-bgra-shader.h | 54 ++++++++++++++++++ 4 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 dali-toolkit/internal/text/rendering/shaders/text-bgra-shader.cpp create mode 100644 dali-toolkit/internal/text/rendering/shaders/text-bgra-shader.h diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index 09eb7c8..e7a40ec 100644 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -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 \ diff --git a/dali-toolkit/internal/text/rendering/basic/text-basic-renderer.cpp b/dali-toolkit/internal/text/rendering/basic/text-basic-renderer.cpp index ac95892..31ab53f 100644 --- a/dali-toolkit/internal/text/rendering/basic/text-basic-renderer.cpp +++ b/dali-toolkit/internal/text/rendering/basic/text-basic-renderer.cpp @@ -25,6 +25,8 @@ #include #include #include +#include + 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 index 0000000..43f61d5 --- /dev/null +++ b/dali-toolkit/internal/text/rendering/shaders/text-bgra-shader.cpp @@ -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 + +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 index 0000000..70e3c67 --- /dev/null +++ b/dali-toolkit/internal/text/rendering/shaders/text-bgra-shader.h @@ -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 + +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__ -- 2.7.4