From 63f98c6a1839a4cebdffc66a7462048f9fb0267f Mon Sep 17 00:00:00 2001 From: Paul Wisbey Date: Mon, 15 Dec 2014 13:14:04 +0000 Subject: [PATCH] Initial removal of Text features Change-Id: I1fcc7ce7000a6e18bccc93126afb57f439ba9409 --- automated-tests/src/dali-internal/CMakeLists.txt | 4 - .../dali-internal/utc-Dali-Internal-Character.cpp | 52 - .../src/dali-internal/utc-Dali-Internal-Font.cpp | 147 -- .../dali-internal/utc-Dali-Internal-Handles.cpp | 3 +- .../utc-Dali-Internal-Text-Culling.cpp | 573 ----- .../src/dali-internal/utc-Dali-Internal-Text.cpp | 113 - automated-tests/src/dali-unmanaged/CMakeLists.txt | 1 - .../test-platform-abstraction.cpp | 304 --- .../test-platform-abstraction.h | 119 - .../dali-unmanaged/utc-Dali-HitTestAlgorithm.cpp | 2 +- .../src/dali-unmanaged/utc-Dali-ObjectRegistry.cpp | 43 - .../src/dali-unmanaged/utc-Dali-Scripting.cpp | 20 +- .../src/dali-unmanaged/utc-Dali-TypeRegistry.cpp | 11 +- .../src/dali-unmanaged/utc-Dali-Utf8.cpp | 44 - automated-tests/src/dali/CMakeLists.txt | 6 - .../dali-test-suite-utils/dali-test-suite-utils.h | 35 - .../test-platform-abstraction.cpp | 319 +-- .../test-platform-abstraction.h | 119 - automated-tests/src/dali/utc-Dali-Character.cpp | 215 -- automated-tests/src/dali/utc-Dali-Font.cpp | 545 ----- .../src/dali/utc-Dali-FontParameters.cpp | 136 -- .../src/dali/utc-Dali-HoverProcessing.cpp | 8 +- automated-tests/src/dali/utc-Dali-ImageActor.cpp | 2 +- automated-tests/src/dali/utc-Dali-Layer.cpp | 4 +- .../src/dali/utc-Dali-RenderableActor.cpp | 47 +- automated-tests/src/dali/utc-Dali-ShaderEffect.cpp | 24 - automated-tests/src/dali/utc-Dali-Text.cpp | 503 ---- automated-tests/src/dali/utc-Dali-TextActor.cpp | 1079 --------- automated-tests/src/dali/utc-Dali-TextStyle.cpp | 1500 ------------ .../src/dali/utc-Dali-TouchProcessing.cpp | 8 +- dali/integration-api/file.list | 5 +- dali/integration-api/glyph-set.cpp | 88 - dali/integration-api/glyph-set.h | 186 -- dali/integration-api/platform-abstraction.h | 211 +- dali/integration-api/profiling.cpp | 12 - dali/integration-api/resource-cache.h | 1 - dali/integration-api/resource-types.h | 147 +- dali/integration-api/text-array.h | 42 - dali/internal/common/bitmap-upload.h | 2 +- dali/internal/common/core-impl.cpp | 23 - dali/internal/common/core-impl.h | 16 - dali/internal/common/text-parameters.cpp | 305 --- dali/internal/common/text-parameters.h | 264 -- dali/internal/common/text-vertex-buffer.h | 50 - .../actor-attachment-declarations.h | 2 - .../actor-attachments/text-attachment-impl.cpp | 631 ----- .../event/actor-attachments/text-attachment-impl.h | 409 ---- dali/internal/event/actors/actor-declarations.h | 2 - dali/internal/event/actors/text-actor-impl.cpp | 1075 --------- dali/internal/event/actors/text-actor-impl.h | 416 ---- .../internal/event/common/thread-local-storage.cpp | 10 - dali/internal/event/common/thread-local-storage.h | 14 - dali/internal/event/effects/shader-declarations.h | 10 +- dali/internal/event/effects/shader-effect-impl.cpp | 18 +- dali/internal/event/effects/shader-factory.cpp | 15 - dali/internal/event/images/emoji-factory.cpp | 109 - dali/internal/event/images/emoji-factory.h | 86 - dali/internal/event/resources/resource-client.cpp | 30 - dali/internal/event/resources/resource-client.h | 31 - .../event/resources/resource-type-path.cpp | 36 - .../event/text/atlas/atlas-rank-generator.cpp | 100 - .../event/text/atlas/atlas-rank-generator.h | 52 - dali/internal/event/text/atlas/atlas-ranking.cpp | 118 - dali/internal/event/text/atlas/atlas-ranking.h | 157 -- dali/internal/event/text/atlas/atlas-size.cpp | 110 - dali/internal/event/text/atlas/atlas-size.h | 68 - .../internal/event/text/atlas/atlas-uv-interface.h | 78 - dali/internal/event/text/atlas/atlas.cpp | 328 --- dali/internal/event/text/atlas/atlas.h | 253 -- .../event/text/atlas/debug/atlas-debug.cpp | 141 -- dali/internal/event/text/atlas/debug/atlas-debug.h | 94 - .../text/atlas/glyph-atlas-manager-interface.h | 141 -- .../event/text/atlas/glyph-atlas-manager.cpp | 341 --- .../event/text/atlas/glyph-atlas-manager.h | 202 -- dali/internal/event/text/atlas/glyph-atlas.cpp | 409 ---- dali/internal/event/text/atlas/glyph-atlas.h | 286 --- dali/internal/event/text/character-impl.cpp | 517 ---- dali/internal/event/text/character-impl.h | 148 -- dali/internal/event/text/font-declarations.h | 35 - dali/internal/event/text/font-factory.cpp | 150 -- dali/internal/event/text/font-factory.h | 135 -- dali/internal/event/text/font-impl.cpp | 401 ---- dali/internal/event/text/font-impl.h | 320 --- dali/internal/event/text/font-layout.cpp | 117 - dali/internal/event/text/font-layout.h | 148 -- dali/internal/event/text/font-metrics-interface.h | 173 -- dali/internal/event/text/font-metrics.cpp | 458 ---- dali/internal/event/text/font-metrics.h | 323 --- .../event/text/generator/text-vertex-generator.cpp | 428 ---- .../event/text/generator/text-vertex-generator.h | 71 - dali/internal/event/text/glyph-metric.cpp | 88 - dali/internal/event/text/glyph-metric.h | 110 - .../debug/glyph-status-container-debug.cpp | 112 - .../debug/glyph-status-container-debug.h | 79 - .../text/glyph-status/glyph-status-container.cpp | 424 ---- .../text/glyph-status/glyph-status-container.h | 241 -- .../event/text/glyph-status/glyph-status.cpp | 192 -- .../event/text/glyph-status/glyph-status.h | 255 -- .../text/resource/debug/glyph-resource-debug.cpp | 66 - .../text/resource/debug/glyph-resource-debug.h | 41 - dali/internal/event/text/resource/font-id.h | 40 - .../event/text/resource/font-lookup-interface.h | 83 - .../event/text/resource/glyph-load-observer.h | 83 - .../event/text/resource/glyph-resource-manager.cpp | 415 ---- .../event/text/resource/glyph-resource-manager.h | 236 -- .../event/text/resource/glyph-resource-observer.h | 143 -- .../event/text/resource/glyph-resource-request.cpp | 92 - .../event/text/resource/glyph-resource-request.h | 118 - .../event/text/resource/glyph-texture-observer.h | 83 - dali/internal/event/text/special-characters.h | 38 - dali/internal/event/text/text-format.cpp | 117 - dali/internal/event/text/text-format.h | 135 -- dali/internal/event/text/text-impl.cpp | 227 -- dali/internal/event/text/text-impl.h | 162 -- dali/internal/event/text/text-observer.h | 76 - dali/internal/event/text/text-request-helper.cpp | 148 -- dali/internal/event/text/text-request-helper.h | 128 - dali/internal/event/text/utf8-impl.cpp | 158 -- dali/internal/event/text/utf8-impl.h | 67 - dali/internal/file.list | 31 - .../render/renderers/scene-graph-text-renderer.cpp | 544 ----- .../render/renderers/scene-graph-text-renderer.h | 202 -- .../shader-source/text-distance-field-glow.txt | 58 - .../text-distance-field-outline-glow.txt | 68 - .../shader-source/text-distance-field-outline.txt | 57 - .../shader-source/text-distance-field-shadow.txt | 80 - .../render/shader-source/text-distance-field.txt | 69 - dali/internal/render/shaders/program.cpp | 14 +- dali/internal/render/shaders/program.h | 21 +- dali/internal/render/shaders/shader.cpp | 6 +- .../update/manager/prepare-render-instructions.cpp | 2 +- dali/internal/update/manager/update-algorithms.cpp | 2 +- .../scene-graph-text-attachment.cpp | 278 --- .../node-attachments/scene-graph-text-attachment.h | 298 --- .../update/resources/atlas-request-status.cpp | 148 -- .../update/resources/atlas-request-status.h | 113 - .../internal/update/resources/resource-manager.cpp | 112 - dali/internal/update/resources/resource-manager.h | 69 - dali/public-api/actors/mesh-actor.cpp | 1 + dali/public-api/actors/text-actor.cpp | 236 -- dali/public-api/actors/text-actor.h | 417 ---- dali/public-api/dali-core.h | 9 - dali/public-api/file.list | 20 - dali/public-api/images/glyph-image.cpp | 162 -- dali/public-api/images/glyph-image.h | 121 - dali/public-api/scripting/scripting.h | 4 - dali/public-api/shader-effects/shader-effect.cpp | 34 - dali/public-api/shader-effects/shader-effect.h | 77 +- dali/public-api/text/character.cpp | 92 - dali/public-api/text/character.h | 173 -- dali/public-api/text/font-parameters.cpp | 141 -- dali/public-api/text/font-parameters.h | 203 -- dali/public-api/text/font.cpp | 230 -- dali/public-api/text/font.h | 370 --- dali/public-api/text/text-actor-parameters.cpp | 110 - dali/public-api/text/text-actor-parameters.h | 105 - dali/public-api/text/text-style.cpp | 2512 -------------------- dali/public-api/text/text-style.h | 523 ---- dali/public-api/text/text.cpp | 288 --- dali/public-api/text/text.h | 237 -- dali/public-api/text/utf8.cpp | 31 - dali/public-api/text/utf8.h | 37 - 162 files changed, 56 insertions(+), 28940 deletions(-) delete mode 100644 automated-tests/src/dali-internal/utc-Dali-Internal-Character.cpp delete mode 100644 automated-tests/src/dali-internal/utc-Dali-Internal-Font.cpp delete mode 100644 automated-tests/src/dali-internal/utc-Dali-Internal-Text-Culling.cpp delete mode 100644 automated-tests/src/dali-internal/utc-Dali-Internal-Text.cpp delete mode 100644 automated-tests/src/dali-unmanaged/utc-Dali-Utf8.cpp delete mode 100644 automated-tests/src/dali/utc-Dali-Character.cpp delete mode 100644 automated-tests/src/dali/utc-Dali-Font.cpp delete mode 100644 automated-tests/src/dali/utc-Dali-FontParameters.cpp delete mode 100644 automated-tests/src/dali/utc-Dali-Text.cpp delete mode 100644 automated-tests/src/dali/utc-Dali-TextActor.cpp delete mode 100644 automated-tests/src/dali/utc-Dali-TextStyle.cpp delete mode 100644 dali/integration-api/glyph-set.cpp delete mode 100644 dali/integration-api/glyph-set.h delete mode 100644 dali/integration-api/text-array.h delete mode 100644 dali/internal/common/text-parameters.cpp delete mode 100644 dali/internal/common/text-parameters.h delete mode 100644 dali/internal/common/text-vertex-buffer.h delete mode 100644 dali/internal/event/actor-attachments/text-attachment-impl.cpp delete mode 100644 dali/internal/event/actor-attachments/text-attachment-impl.h delete mode 100644 dali/internal/event/actors/text-actor-impl.cpp delete mode 100644 dali/internal/event/actors/text-actor-impl.h delete mode 100644 dali/internal/event/images/emoji-factory.cpp delete mode 100644 dali/internal/event/images/emoji-factory.h delete mode 100644 dali/internal/event/text/atlas/atlas-rank-generator.cpp delete mode 100644 dali/internal/event/text/atlas/atlas-rank-generator.h delete mode 100644 dali/internal/event/text/atlas/atlas-ranking.cpp delete mode 100644 dali/internal/event/text/atlas/atlas-ranking.h delete mode 100644 dali/internal/event/text/atlas/atlas-size.cpp delete mode 100644 dali/internal/event/text/atlas/atlas-size.h delete mode 100644 dali/internal/event/text/atlas/atlas-uv-interface.h delete mode 100644 dali/internal/event/text/atlas/atlas.cpp delete mode 100644 dali/internal/event/text/atlas/atlas.h delete mode 100644 dali/internal/event/text/atlas/debug/atlas-debug.cpp delete mode 100644 dali/internal/event/text/atlas/debug/atlas-debug.h delete mode 100644 dali/internal/event/text/atlas/glyph-atlas-manager-interface.h delete mode 100644 dali/internal/event/text/atlas/glyph-atlas-manager.cpp delete mode 100644 dali/internal/event/text/atlas/glyph-atlas-manager.h delete mode 100644 dali/internal/event/text/atlas/glyph-atlas.cpp delete mode 100644 dali/internal/event/text/atlas/glyph-atlas.h delete mode 100644 dali/internal/event/text/character-impl.cpp delete mode 100644 dali/internal/event/text/character-impl.h delete mode 100644 dali/internal/event/text/font-declarations.h delete mode 100644 dali/internal/event/text/font-factory.cpp delete mode 100644 dali/internal/event/text/font-factory.h delete mode 100644 dali/internal/event/text/font-impl.cpp delete mode 100644 dali/internal/event/text/font-impl.h delete mode 100644 dali/internal/event/text/font-layout.cpp delete mode 100644 dali/internal/event/text/font-layout.h delete mode 100644 dali/internal/event/text/font-metrics-interface.h delete mode 100644 dali/internal/event/text/font-metrics.cpp delete mode 100644 dali/internal/event/text/font-metrics.h delete mode 100644 dali/internal/event/text/generator/text-vertex-generator.cpp delete mode 100644 dali/internal/event/text/generator/text-vertex-generator.h delete mode 100644 dali/internal/event/text/glyph-metric.cpp delete mode 100644 dali/internal/event/text/glyph-metric.h delete mode 100644 dali/internal/event/text/glyph-status/debug/glyph-status-container-debug.cpp delete mode 100644 dali/internal/event/text/glyph-status/debug/glyph-status-container-debug.h delete mode 100644 dali/internal/event/text/glyph-status/glyph-status-container.cpp delete mode 100644 dali/internal/event/text/glyph-status/glyph-status-container.h delete mode 100644 dali/internal/event/text/glyph-status/glyph-status.cpp delete mode 100644 dali/internal/event/text/glyph-status/glyph-status.h delete mode 100644 dali/internal/event/text/resource/debug/glyph-resource-debug.cpp delete mode 100644 dali/internal/event/text/resource/debug/glyph-resource-debug.h delete mode 100644 dali/internal/event/text/resource/font-id.h delete mode 100644 dali/internal/event/text/resource/font-lookup-interface.h delete mode 100644 dali/internal/event/text/resource/glyph-load-observer.h delete mode 100644 dali/internal/event/text/resource/glyph-resource-manager.cpp delete mode 100644 dali/internal/event/text/resource/glyph-resource-manager.h delete mode 100644 dali/internal/event/text/resource/glyph-resource-observer.h delete mode 100644 dali/internal/event/text/resource/glyph-resource-request.cpp delete mode 100644 dali/internal/event/text/resource/glyph-resource-request.h delete mode 100644 dali/internal/event/text/resource/glyph-texture-observer.h delete mode 100644 dali/internal/event/text/special-characters.h delete mode 100644 dali/internal/event/text/text-format.cpp delete mode 100644 dali/internal/event/text/text-format.h delete mode 100644 dali/internal/event/text/text-impl.cpp delete mode 100644 dali/internal/event/text/text-impl.h delete mode 100644 dali/internal/event/text/text-observer.h delete mode 100644 dali/internal/event/text/text-request-helper.cpp delete mode 100644 dali/internal/event/text/text-request-helper.h delete mode 100644 dali/internal/event/text/utf8-impl.cpp delete mode 100644 dali/internal/event/text/utf8-impl.h delete mode 100644 dali/internal/render/renderers/scene-graph-text-renderer.cpp delete mode 100644 dali/internal/render/renderers/scene-graph-text-renderer.h delete mode 100644 dali/internal/render/shader-source/text-distance-field-glow.txt delete mode 100644 dali/internal/render/shader-source/text-distance-field-outline-glow.txt delete mode 100644 dali/internal/render/shader-source/text-distance-field-outline.txt delete mode 100644 dali/internal/render/shader-source/text-distance-field-shadow.txt delete mode 100644 dali/internal/render/shader-source/text-distance-field.txt delete mode 100644 dali/internal/update/node-attachments/scene-graph-text-attachment.cpp delete mode 100644 dali/internal/update/node-attachments/scene-graph-text-attachment.h delete mode 100644 dali/internal/update/resources/atlas-request-status.cpp delete mode 100644 dali/internal/update/resources/atlas-request-status.h delete mode 100644 dali/public-api/actors/text-actor.cpp delete mode 100644 dali/public-api/actors/text-actor.h delete mode 100644 dali/public-api/images/glyph-image.cpp delete mode 100644 dali/public-api/images/glyph-image.h delete mode 100644 dali/public-api/text/character.cpp delete mode 100644 dali/public-api/text/character.h delete mode 100644 dali/public-api/text/font-parameters.cpp delete mode 100644 dali/public-api/text/font-parameters.h delete mode 100644 dali/public-api/text/font.cpp delete mode 100644 dali/public-api/text/font.h delete mode 100644 dali/public-api/text/text-actor-parameters.cpp delete mode 100644 dali/public-api/text/text-actor-parameters.h delete mode 100644 dali/public-api/text/text-style.cpp delete mode 100644 dali/public-api/text/text-style.h delete mode 100644 dali/public-api/text/text.cpp delete mode 100644 dali/public-api/text/text.h delete mode 100644 dali/public-api/text/utf8.cpp delete mode 100644 dali/public-api/text/utf8.h diff --git a/automated-tests/src/dali-internal/CMakeLists.txt b/automated-tests/src/dali-internal/CMakeLists.txt index 0b53213..e85f4ea 100644 --- a/automated-tests/src/dali-internal/CMakeLists.txt +++ b/automated-tests/src/dali-internal/CMakeLists.txt @@ -6,15 +6,11 @@ SET(RPM_NAME "core-${PKG_NAME}-tests") SET(CAPI_LIB "dali-internal") SET(TC_SOURCES - utc-Dali-Internal-Character.cpp - utc-Dali-Internal-Font.cpp utc-Dali-Internal-Handles.cpp utc-Dali-Internal-ImageFactory.cpp utc-Dali-Internal-Mesh.cpp - utc-Dali-Internal-Text.cpp utc-Dali-Internal-ResourceClient.cpp utc-Dali-Internal-Image-Culling.cpp - utc-Dali-Internal-Text-Culling.cpp utc-Dali-Internal-Constraint.cpp ) diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-Character.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-Character.cpp deleted file mode 100644 index e884843..0000000 --- a/automated-tests/src/dali-internal/utc-Dali-Internal-Character.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -#include - -#include -#include -#include - -using namespace Dali; - -void utc_dali_character_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_character_cleanup(void) -{ - test_return_value = TET_PASS; -} - -int UtcDaliCharacterGetImplementation(void) -{ - TestApplication application; - - Text text( std::string( "Hello world" ) ); - Character c = text[0]; - - const Internal::Character& characterImpl1 = c.GetImplementation(); - - DALI_TEST_CHECK( NULL != &characterImpl1 ); - - Internal::Character& characterImpl2 = c.GetImplementation(); - - DALI_TEST_CHECK( NULL != &characterImpl2 ); - - END_TEST; -} diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-Font.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-Font.cpp deleted file mode 100644 index 23b3099..0000000 --- a/automated-tests/src/dali-internal/utc-Dali-Internal-Font.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -#include - -#include -#include -#include - -#include - -// Internal headers are allowed here - -#include -#include -#include - -using namespace Dali; - -// Called only once before first test is run. -void utc_dali_internal_font_startup() -{ - test_return_value = TET_UNDEF; -} - -// Called only once after last test is run -void utc_dali_internal_font_cleanup() -{ - test_return_value = TET_PASS; -} - - -namespace -{ - -static const char* TestText = "Some text"; - - -Integration::GlyphMetrics characters[] = - { - {' ', 1, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f}, - {'S', 1, 10.0f, 20.0f, 0.0f, 1.0f, 12.0f}, - {'o', 1, 11.0f, 20.0f, 0.0f, 1.0f, 13.0f}, - {'m', 1, 12.0f, 20.0f, 0.0f, 1.0f, 14.0f}, - {'e', 1, 13.0f, 20.0f, 0.0f, 1.0f, 15.0f}, - {'t', 1, 14.0f, 20.0f, 0.0f, 1.0f, 16.0f}, - {'x', 1, 15.0f, 20.0f, 0.0f, 1.0f, 17.0f} }; - -static Integration::GlyphSet* BuildGlyphSet() -{ - Integration::GlyphSet* set = new Integration::GlyphSet(); - Integration::BitmapPtr bitmapData; - - for (unsigned int index = 0; index < sizeof(characters)/sizeof(characters[0]); index++) - { - set->AddCharacter(bitmapData, characters[index]); - } - - set->mLineHeight = 20.0f; - set->mUnitsPerEM = 2048.0f/64.0f; - - return set; -} - -static Font CreateFont(TestApplication& application) -{ - Integration::GlyphSet* glyphSet = BuildGlyphSet(); - Integration::ResourcePointer resourcePtr(glyphSet); // reference it - - // Don't use a font which could be cached otherwise cached values will be used making measure text test to fail. - Font font = Font::New(FontParameters("TET-FreeSans", "Book", PointSize(8))); - application.SendNotification(); // Send to update thread - application.Render(16); // Process request - application.Render(16); // Resource complete - application.SendNotification(); // Update event objects - application.GetPlatform().DiscardRequest(); // Ensure load request is discarded - return font; -} - -} //anonymous namespace - - -int UtcDaliFontMeasureTextWidth(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::MeasureTextWidth()"); - - Font testFont = CreateFont(application); - float width = testFont.MeasureTextWidth(TestText, 30.0f); - - DALI_TEST_EQUALS(width, 270.0f, 0.001f, TEST_LOCATION); - END_TEST; -} - -int UtcDaliFontMeasureTextWidthNegative(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::MeasureTextWidth() with negative height"); - - Font testFont = CreateFont(application); - float width = testFont.MeasureTextWidth(TestText, -30.0f); - - DALI_TEST_EQUALS(width, 0.0f, TEST_LOCATION); - END_TEST; -} - -int UtcDaliFontMeasureTextHeight(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::MeasureTextHeight()"); - - Font testFont = CreateFont(application); - float height = testFont.MeasureTextHeight(TestText, 200.0f); - - DALI_TEST_EQUALS(height, 22.2222f, 0.001f, TEST_LOCATION); - END_TEST; -} - -int UtcDaliFontMeasureTextHeightNegative(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::MeasureTextHeight() with negative width"); - - Font testFont = CreateFont(application); - float height = testFont.MeasureTextHeight(TestText, -200.0f); - - DALI_TEST_EQUALS(height, 0.0f, TEST_LOCATION); - END_TEST; -} diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-Handles.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-Handles.cpp index cb1ae63..36f2f54 100644 --- a/automated-tests/src/dali-internal/utc-Dali-Internal-Handles.cpp +++ b/automated-tests/src/dali-internal/utc-Dali-Internal-Handles.cpp @@ -19,7 +19,6 @@ #include #include -#include #include @@ -101,7 +100,7 @@ int UtcDaliTextActorConstructorRefObject(void) { TestApplication application; tet_infoline("Testing Dali::TextActor::TextActor(Internal::TextActor*)"); - TextActor actor(NULL); + ImageActor actor(NULL); DALI_TEST_CHECK(!actor); END_TEST; } diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-Text-Culling.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-Text-Culling.cpp deleted file mode 100644 index 3077397..0000000 --- a/automated-tests/src/dali-internal/utc-Dali-Internal-Text-Culling.cpp +++ /dev/null @@ -1,573 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -#include - -#include -#include - -#include - -using namespace Dali; - -void utc_dali_internal_text_culling_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_internal_text_culling_cleanup(void) -{ - test_return_value = TET_PASS; -} - - -namespace -{ -#define NUM_ROWS 9 -#define NUM_COLS 9 -#define NUM_ROWS_PER_PANE 3 -#define NUM_COLS_PER_PANE 3 - - -TextActor CreateOnStageActor(TestApplication& application, Text text, int width, int height, bool testDraw) -{ - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - TestPlatformAbstraction& platform = application.GetPlatform(); - TraceCallStack& drawTrace = glAbstraction.GetDrawTrace(); - - TextActor textActor = TextActor::New(text); - textActor.SetParentOrigin(ParentOrigin::CENTER); - textActor.SetSize(width, height); - Stage::GetCurrent().Add(textActor); - - application.SendNotification(); - application.Render(16); - - Integration::ResourceRequest* request = platform.GetRequest(); - DALI_TEST_CHECK( request != NULL ); - DALI_TEST_CHECK( request->GetType() != NULL ); - DALI_TEST_CHECK( request->GetType()->id == Integration::ResourceText ); - - Integration::TextResourceType* textRequest = static_cast(request->GetType()); - - std::string font("Font"); - Integration::GlyphSet* set = platform.GetGlyphData(*textRequest, font, true); - platform.SetResourceLoaded( request->GetId(), Integration::ResourceText, Integration::ResourcePointer(set) ); - - application.SendNotification(); - application.Render(16); - - platform.ClearReadyResources(); - - if(testDraw) - { - DALI_TEST_CHECK( drawTrace.FindMethod( "DrawElements" ) ); - } - return textActor; -} - - -void TestTextInside( TestApplication& application, int width, int height ) -{ - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - TraceCallStack& drawTrace = glAbstraction.GetDrawTrace(); - drawTrace.Enable(true); - - std::string text("Text"); - - TextActor textActor = CreateOnStageActor(application, text, width, height, true); - textActor.SetPosition(0.0f, 0.0f, 0.0f); - - Vector3 textSize = textActor.GetCurrentSize(); - DALI_TEST_EQUALS( textSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION); - - drawTrace.Reset(); - textActor.SetParentOrigin(ParentOrigin::TOP_LEFT); - application.SendNotification(); - application.Render(16); - DALI_TEST_CHECK( drawTrace.FindMethod( "DrawElements" ) ); - - drawTrace.Reset(); - textActor.SetParentOrigin(ParentOrigin::TOP_RIGHT); - application.SendNotification(); - application.Render(16); - DALI_TEST_CHECK( drawTrace.FindMethod( "DrawElements" ) ); - - drawTrace.Reset(); - textActor.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT); - application.SendNotification(); - application.Render(16); - DALI_TEST_CHECK( drawTrace.FindMethod( "DrawElements" ) ); - - drawTrace.Reset(); - textActor.SetParentOrigin(ParentOrigin::BOTTOM_LEFT); - application.SendNotification(); - application.Render(16); - DALI_TEST_CHECK( drawTrace.FindMethod( "DrawElements" ) ); -} - - -bool RepositionActor(TestApplication& application, Actor actor, float x, float y, bool inside) -{ - TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); - - drawTrace.Reset(); - actor.SetPosition( x, y, 0.0f); - application.SendNotification(); - application.Render(16); - - bool found = drawTrace.FindMethod( "DrawElements" ); - bool result = (inside && found) || (!inside && !found); - return result; -} - - -void RepositionActorWithAngle(TestApplication& application, Actor actor, float x, float y, float angle, bool inside) -{ - TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); - - drawTrace.Reset(); - actor.SetPosition( x, y, 0.0f); - actor.SetRotation( Degree(angle), Vector3::ZAXIS ); - application.SendNotification(); - application.Render(16); - if( inside ) - { - bool found = drawTrace.FindMethod( "DrawElements" ); - if( ! found ) tet_printf( "Not drawn: Position:(%3.0f, %3.0f)\n", x, y ); - DALI_TEST_CHECK( found ); - } - else - { - bool found = drawTrace.FindMethod( "DrawElements" ); - if( found ) tet_printf( "Drawn when not needed: Position:(%3.0f, %3.0f)\n", x, y ); - DALI_TEST_CHECK( ! found ); - } -} - -void RepositionActorOutside(TestApplication& application, Actor actor, float x, float y, bool drawn ) -{ - TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace(); - - drawTrace.Reset(); - actor.SetPosition( x, y, 0.0f); - application.SendNotification(); - application.Render(16); - if( drawn ) - { - bool found = drawTrace.FindMethod( "DrawElements" ); - if( ! found ) tet_printf( "Not drawn: Position:(%3.0f, %3.0f)\n", x, y ); - DALI_TEST_CHECK( found ); - } - else - { - bool found = drawTrace.FindMethod( "DrawElements" ); - if( found ) tet_printf( "Drawn unnecessarily: Position:(%3.0f, %3.0f)\n", x, y ); - DALI_TEST_CHECK( ! found ); - } -} - -void OBBTestTextAtBoundary( TestApplication& application, int width, int height ) -{ - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - TraceCallStack& drawTrace = glAbstraction.GetDrawTrace(); - drawTrace.Enable(true); - - Vector2 stageSize = Stage::GetCurrent().GetSize(); - - std::string text("Text"); - TextActor textActor = CreateOnStageActor(application, text, width, height, true); - - Vector3 textSize = textActor.GetCurrentSize(); - DALI_TEST_EQUALS( textSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION); - - textSize.z = 0.0f; - tet_printf("Testing Stage Size: (%3.0f, %3.0f) text size:(%3.0f, %3.0f) \n", - stageSize.x, stageSize.y, textSize.x, textSize.y); - - int successCount = 0; - int totalCount = 0; - for( int i=0; i<100; i++ ) - { - float x1 = -stageSize.x/2.0f - textSize.x*i/200.0f; - float x2 = stageSize.x/2.0f + textSize.x*i/200.0f; - float y1 = -stageSize.y/2.0f - textSize.y*i/200.0f; - float y2 = stageSize.y/2.0f + textSize.y*i/200.0f; - - //tet_printf("Testing i=%d\n",i); - - // Test paths marked with dots - // + . . . . . . - // .\_ ^ - // . \_ | within radius - // . \ v - // . +----- - // . | Stage - - for( int j=-10; j<=10; j++ ) - { - float x = ((stageSize.x+textSize.x/2.0f)/21.0f) * j; - float y = ((stageSize.y+textSize.y/2.0f)/21.0f) * j; - - if(RepositionActor( application, textActor, x1, y, true )) successCount++; - if(RepositionActor( application, textActor, x2, y, true )) successCount++; - if(RepositionActor( application, textActor, x, y1, true )) successCount++; - if(RepositionActor( application, textActor, x, y2, true )) successCount++; - - totalCount += 4; - } - } - DALI_TEST_EQUALS(successCount, totalCount, TEST_LOCATION); - tet_printf( "Test succeeded with %d passes out of %d tests\n", successCount, totalCount); -} - - -void OBBTestTextOutsideBoundary( TestApplication& application, int width, int height ) -{ - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - TraceCallStack& drawTrace = glAbstraction.GetDrawTrace(); - drawTrace.Enable(true); - - Vector2 stageSize = Stage::GetCurrent().GetSize(); - - std::string text("Text"); - - TextActor textActor = CreateOnStageActor(application, text, width, height, true); - Vector3 textSize = textActor.GetCurrentSize(); - DALI_TEST_EQUALS( textSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION); - - textSize.z = 0.0f; - tet_printf("Testing Stage Size: (%3.0f, %3.0f) text size:(%3.0f, %3.0f)\n", - stageSize.x, stageSize.y, textSize.x, textSize.y); - - int successCount=0; - int totalCount=0; - - for( int i=0; i<=100; i++ ) - { - float x1 = -stageSize.x/2.0f - textSize.x * (1.5f + i/100.0f); - float x2 = stageSize.x/2.0f + textSize.x * (1.5f + i/100.0f); - float y1 = -stageSize.y/2.0f - textSize.y * (1.5f + i/100.0f); - float y2 = stageSize.y/2.0f + textSize.y * (1.5f + i/100.0f); - - for( int j=-10; j<=10; j++ ) - { - float x = (stageSize.x/17.0f) * j; // use larger intervals to test more area - float y = (stageSize.y/17.0f) * j; - - if(RepositionActor( application, textActor, x1, y, false )) successCount++; - if(RepositionActor( application, textActor, x2, y, false )) successCount++; - if(RepositionActor( application, textActor, x, y1, false )) successCount++; - if(RepositionActor( application, textActor, x, y2, false )) successCount++; - totalCount+=4; - } - } - DALI_TEST_EQUALS(successCount, totalCount, TEST_LOCATION); - tet_printf( "Test succeeded with %d passes out of %d tests\n", successCount, totalCount); -} - - -} // namespace - -int UtcDaliTextCulling_Inside01(void) -{ - tet_infoline( "Testing that 80x80 text positioned inside the stage is drawn\n"); - - TestApplication application; - - TestTextInside(application, 80, 80); - - END_TEST; -} - -int UtcDaliTextCulling_Inside02(void) -{ - tet_infoline( "Testing that 120x40 text positioned inside the stage is drawn\n"); - - TestApplication application; - - TestTextInside(application, 120, 40); - - END_TEST; -} - -int UtcDaliTextCulling_Inside03(void) -{ - tet_infoline( "Testing that 40x120 text positioned inside the stage is drawn\n"); - - TestApplication application; - - TestTextInside(application, 40, 120); - - END_TEST; -} - -int UtcDaliTextCulling_Inside04(void) -{ - tet_infoline( "Testing that 500x2 text positioned inside the stage is drawn\n"); - TestApplication application; - TestTextInside(application, 500, 2); - END_TEST; -} - -int UtcDaliTextCulling_Inside05(void) -{ - tet_infoline( "Testing that 2x500 text positioned inside the stage is drawn\n"); - TestApplication application; - TestTextInside(application, 2, 500); - END_TEST; -} - - -int UtcDaliTextCulling_WithinBoundary01(void) -{ - tet_infoline("Test that 80x80 text positioned outside the stage but with bounding box intersecting the stage is drawn\n"); - - TestApplication application; - OBBTestTextAtBoundary( application, 80, 80); - END_TEST; -} -int UtcDaliTextCulling_WithinBoundary02(void) -{ - tet_infoline("Test that 120x40 text positioned outside the stage but with bounding box intersecting the stage is drawn\n"); - - TestApplication application; - OBBTestTextAtBoundary( application, 120, 40 ); - END_TEST; -} -int UtcDaliTextCulling_WithinBoundary03(void) -{ - tet_infoline("Test that 40x120 text positioned outside the stage but with bounding box intersecting the stage is drawn\n"); - - TestApplication application; - OBBTestTextAtBoundary( application, 40, 120); - END_TEST; -} - -int UtcDaliTextCulling_WithinBoundary04(void) -{ - tet_infoline("Test that 500x2 texts positioned outside the stage but with bounding box intersecting the stage is drawn\n"); - - TestApplication application; - OBBTestTextAtBoundary( application, 500, 2 ); - END_TEST; -} - -int UtcDaliTextCulling_WithinBoundary05(void) -{ - tet_infoline("Test that 2x500 texts positioned outside the stage but with bounding box intersecting the stage is drawn\n"); - - TestApplication application; - OBBTestTextAtBoundary( application, 2, 500 ); - END_TEST; -} - -int UtcDaliTextCulling_OutsideBoundary01(void) -{ - tet_infoline("Test that 80x80 text positioned outside the stage by more than 2 times\n" - "the radius of the bounding circle is not drawn\n"); - - TestApplication application; - OBBTestTextOutsideBoundary( application, 80, 80 ); - END_TEST; -} - -int UtcDaliTextCulling_OutsideBoundary02(void) -{ - tet_infoline("Test that 120x40 text positioned outside the stage by more than 2 times\n" - "the radius of the bounding circle is not drawn\n"); - - TestApplication application; - OBBTestTextOutsideBoundary( application, 120, 40 ); - END_TEST; -} -int UtcDaliTextCulling_OutsideBoundary03(void) -{ - tet_infoline("Test that 40x120 text positioned outside the stage by more than 2 times\n" - "the radius of the bounding circle is not drawn\n"); - - TestApplication application; - OBBTestTextOutsideBoundary( application, 40, 120 ); - END_TEST; -} - -int UtcDaliTextCulling_OutsideBoundary04(void) -{ - tet_infoline("Test that 500x2 text positioned outside the stage by more than 2 times\n" - "the radius of the bounding circle is not drawn\n"); - - TestApplication application; - OBBTestTextOutsideBoundary( application, 500, 2 ); - END_TEST; -} - -int UtcDaliTextCulling_OutsideBoundary05(void) -{ - tet_infoline("Test that 2x500 text positioned outside the stage by more than 2 times\n" - "the radius of the bounding circle is not drawn\n"); - - TestApplication application; - OBBTestTextOutsideBoundary( application, 2, 500 ); - END_TEST; -} - -int UtcDaliTextCulling_OutsideIntersect01(void) -{ - TestApplication application; - - tet_infoline("Test that actors positioned outside the stage with bounding boxes also\n" - "outside the stage but intersecting it are still drawn"); - - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - TraceCallStack& drawTrace = glAbstraction.GetDrawTrace(); - drawTrace.Enable(true); - Vector2 stageSize = Stage::GetCurrent().GetSize(); - - float width = stageSize.x*5.0f; - float height = stageSize.y*0.2f; - std::string text("Text"); - TextActor textActor = CreateOnStageActor(application, text, width, height, true); - - RepositionActor( application, textActor, stageSize.x*1.2f, 0.0f, true); - RepositionActor( application, textActor, stageSize.x*1.2f, -stageSize.y*0.55f, true); - RepositionActor( application, textActor, stageSize.x*1.2f, stageSize.y*0.55f, true); - END_TEST; -} - -int UtcDaliTextCulling_OutsideIntersect02(void) -{ - TestApplication application; - - tet_infoline("Test that actors positioned outside the stage with bounding boxes also\n" - "outside the stage that cross planes are not drawn"); - - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - TraceCallStack& drawTrace = glAbstraction.GetDrawTrace(); - drawTrace.Enable(true); - Vector2 stageSize = Stage::GetCurrent().GetSize(); - - float width = stageSize.x*5.0f; - float height = stageSize.y*0.2f; - std::string text("Text"); - TextActor textActor = CreateOnStageActor(application, text, width, height, true); - - RepositionActor( application, textActor, stageSize.x*10.0f, stageSize.y*0.5f, false); - RepositionActor( application, textActor, -stageSize.x*10.0f, stageSize.y*0.5f, false); - RepositionActor( application, textActor, stageSize.x*10.0f, -stageSize.y*0.5f, false); - RepositionActor( application, textActor, -stageSize.x*10.0f, -stageSize.y*0.5f, false); - END_TEST; -} - -int UtcDaliTextCulling_OutsideIntersect03(void) -{ - TestApplication application; - - tet_infoline("Test that text actor larger than the stage, positioned outside the stage \n" - "with bounding boxes also outside the stage but intersecting it is still drawn\n"); - - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - TraceCallStack& drawTrace = glAbstraction.GetDrawTrace(); - drawTrace.Enable(true); - Vector2 stageSize = Stage::GetCurrent().GetSize(); - - // Try an actor bigger than the stage, with center outside stage - float width = stageSize.x*5.0f; - float height = stageSize.y*5.0f; - std::string text("Text"); - TextActor textActor = CreateOnStageActor(application, text, width, height, true); - - RepositionActor( application, textActor, stageSize.x*1.2f, 0.0f, true); - RepositionActor( application, textActor, stageSize.x*1.2f, -stageSize.y*1.1f, true); - RepositionActor( application, textActor, stageSize.x*1.2f, stageSize.y*1.1f, true); - - END_TEST; -} - -int UtcDaliTextCulling_OutsideIntersect04(void) -{ - TestApplication application; - - tet_infoline("Test that text actors positioned outside the stage, with bounding boxes\n" - "also outside the stage but intersecting it, and angled at 45 degrees to\n" - "the corners are still drawn\n"); - - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - TraceCallStack& drawTrace = glAbstraction.GetDrawTrace(); - drawTrace.Enable(true); - Vector2 stageSize = Stage::GetCurrent().GetSize(); - - // Test text at 45 degrees outside corners of stage - float width = 400.0f; - float height = 200.0f; - std::string text("Text"); - TextActor textActor = CreateOnStageActor(application, text, width, height, true); - - RepositionActorWithAngle( application, textActor, -stageSize.x*0.55f, -stageSize.y*0.55, 135.0f, true); - RepositionActorWithAngle( application, textActor, -stageSize.x*0.55f, stageSize.y*0.55, 225.0f, true); - RepositionActorWithAngle( application, textActor, stageSize.x*0.55f, -stageSize.y*0.55, 45.0f, true); - RepositionActorWithAngle( application, textActor, stageSize.x*0.55f, stageSize.y*0.55, 315.0f, true); - - END_TEST; -} - - -int UtcDaliTextCulling_Disable(void) -{ - tet_infoline("Test that culling can be disabled"); - - TestApplication application; - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - - TraceCallStack& drawTrace = glAbstraction.GetDrawTrace(); - drawTrace.Enable(true); - - Vector2 stageSize = Stage::GetCurrent().GetSize(); - float width=80; - float height=80; - std::string text("Text"); - - - TextActor textActor = CreateOnStageActor(application, text, width, height, true); - Vector3 textSize = textActor.GetCurrentSize(); - DALI_TEST_EQUALS( textSize, Vector3(width, height, std::min(width, height)), TEST_LOCATION); - - textSize.z = 0.0f; - - tet_infoline("Setting cull mode to false\n"); - Stage::GetCurrent().GetRenderTaskList().GetTask(0).SetCullMode(false); - - float x1 = -stageSize.x - textSize.x; - float x2 = stageSize.x + textSize.x; - float y1 = -stageSize.y - textSize.y; - float y2 = stageSize.y + textSize.y; - - // Positioning actors outside stage, with no culling, they should still be drawn. - RepositionActorOutside( application, textActor, x1, y1, true ); - RepositionActorOutside( application, textActor, x2, y1, true ); - RepositionActorOutside( application, textActor, x1, y2, true ); - RepositionActorOutside( application, textActor, x2, y2, true ); - - tet_infoline("Setting cull mode to true\n"); - Stage::GetCurrent().GetRenderTaskList().GetTask(0).SetCullMode(true); - - RepositionActorOutside( application, textActor, x1, y1, false ); - RepositionActorOutside( application, textActor, x2, y1, false ); - RepositionActorOutside( application, textActor, x1, y2, false ); - RepositionActorOutside( application, textActor, x2, y2, false ); - - END_TEST; -} diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-Text.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-Text.cpp deleted file mode 100644 index f482755..0000000 --- a/automated-tests/src/dali-internal/utc-Dali-Internal-Text.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -#include - -#include -#include -#include -#include - -// Internal headers are allowed here - -#include - -using namespace Dali; - -void utc_dali_internal_text_startup() -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_internal_text_cleanup() -{ - test_return_value = TET_PASS; -} - -int UtcDaliTextGetImplementation01(void) -{ - TestApplication application; - - Text text( std::string( "Hello world" ) ); - - const Internal::Text& textImpl1 = text.GetImplementation(); - - DALI_TEST_CHECK( NULL != &textImpl1 ); - - Internal::Text& textImpl2 = text.GetImplementation(); - - DALI_TEST_CHECK( NULL != &textImpl2 ); - - END_TEST; -} - -int UtcDaliTextGetImplementation02(void) -{ - TestApplication application; - - Text text; - - bool assert1 = false; - bool assert2 = false; - - try // const GetImpl - { - const Internal::Text& impl = text.GetImplementation(); - (void)impl; // Avoid unused variable warning - } - catch( DaliException& e ) - { - tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "NULL != mImpl && \"Text::GetImplementation: Text is uninitialized\"", TEST_LOCATION ); - - assert1 = true; - } - - try // non const getImp - { - Internal::Text& impl = text.GetImplementation(); - (void)impl; // Avoid unused variable warning - } - catch( DaliException& e ) - { - tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "NULL != mImpl && \"Text::GetImplementation: Text is uninitialized\"", TEST_LOCATION ); - - assert2 = true; - } - - if( assert1 && assert2 ) - { - tet_result( TET_PASS ); - } - else - { - tet_result( TET_FAIL ); - } - END_TEST; -} - -int UtcDaliTextGetTextArray(void) -{ - TestApplication application; - - Text text( std::string( "Hello world" ) ); - - DALI_TEST_EQUALS( text.GetImplementation().GetTextArray().Count(), 11u, TEST_LOCATION ); - - END_TEST; -} diff --git a/automated-tests/src/dali-unmanaged/CMakeLists.txt b/automated-tests/src/dali-unmanaged/CMakeLists.txt index e83d442..008b18c 100644 --- a/automated-tests/src/dali-unmanaged/CMakeLists.txt +++ b/automated-tests/src/dali-unmanaged/CMakeLists.txt @@ -32,7 +32,6 @@ SET(TC_SOURCES utc-Dali-Scripting.cpp utc-Dali-Spline.cpp utc-Dali-TypeRegistry.cpp - utc-Dali-Utf8.cpp utc-Dali-Vector.cpp ) diff --git a/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.cpp b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.cpp index d5f24ab..e149301 100644 --- a/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.cpp +++ b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.cpp @@ -160,148 +160,6 @@ bool TestPlatformAbstraction::IsLoading() } /** - * @copydoc PlatformAbstraction::GetDefaultFontFamily() - */ -const std::string& TestPlatformAbstraction::GetDefaultFontFamily() const -{ - mTrace.PushCall("GetDefaultFontFamily", ""); - return mGetDefaultFontFamilyResult; -} - -/** - * @copydoc PlatformAbstraction::GetDefaultFontSize() - */ -float TestPlatformAbstraction::GetDefaultFontSize() const -{ - mTrace.PushCall("GetDefaultFontSize", ""); - return mGetDefaultFontSizeResult; -} - -PixelSize TestPlatformAbstraction::GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, CapsHeight capsHeight) const -{ - mTrace.PushCall("GetFontLineHeightFromCapsHeight", ""); - // LineHeight will be bigger than CapsHeight, so return capsHeight + 1 - return PixelSize(capsHeight + 1); -} - -/** - * @copydoc PlatformAbstraction::GetGlyphData() - */ - -Integration::GlyphSet* TestPlatformAbstraction::GetGlyphData ( const Integration::TextResourceType& textRequest, - const std::string& fontFamily, - bool getBitmap) const -{ - if( getBitmap ) - { - mTrace.PushCall("GetGlyphData", "getBitmap:true"); - } - else - { - mTrace.PushCall("GetGlyphData", "getBitmap:false"); - } - - // It creates fake metrics for the received characters. - - Integration::GlyphSet* set = new Dali::Integration::GlyphSet(); - Integration::BitmapPtr bitmapData; - - std::set characters; - - for( Integration::TextResourceType::CharacterList::const_iterator it = textRequest.mCharacterList.begin(), endIt = textRequest.mCharacterList.end(); it != endIt; ++it ) - { - if( characters.find( it->character ) == characters.end() ) - { - characters.insert( it->character ); - Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::LOW_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition }; - - if( getBitmap ) - { - bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD); - bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64); - PixelBuffer* pixelBuffer = bitmapData->GetBuffer(); - memset( pixelBuffer, it->character, 64*64 ); - } - - set->AddCharacter(bitmapData, character); - } - } - - set->mLineHeight = 10.0f; - set->mAscender = 9.0f; - set->mUnitsPerEM = 2048.0f/64.0f; - set->SetAtlasResourceId( textRequest.mTextureAtlasId ); - set->mFontHash = textRequest.mFontHash; - - return set; -} - -/** - * @copydoc PlatformAbstraction::GetCachedGlyphData() - */ - -Integration::GlyphSet* TestPlatformAbstraction::GetCachedGlyphData( const Integration::TextResourceType& textRequest, - const std::string& fontFamily ) const -{ - mTrace.PushCall("GetCachedGlyphData", ""); - - // It creates fake metrics and bitmap for received numeric characters '0' through '9'. - Integration::GlyphSet* set = new Dali::Integration::GlyphSet(); - Integration::BitmapPtr bitmapData; - - std::set characters; - - for( Integration::TextResourceType::CharacterList::const_iterator it = textRequest.mCharacterList.begin(), endIt = textRequest.mCharacterList.end(); it != endIt; ++it ) - { - if( it->character >= '0' && it->character <= '9' && characters.find( it->character ) == characters.end() ) - { - characters.insert( it->character ); - Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::HIGH_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition }; - - bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD); - bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64); - PixelBuffer* pixelBuffer = bitmapData->GetBuffer(); - memset( pixelBuffer, it->character, 64*64 ); - set->AddCharacter(bitmapData, character); - } - } - - set->mLineHeight = 10.0f; - set->mAscender = 9.0f; - set->mUnitsPerEM = 2048.0f/64.0f; - set->SetAtlasResourceId( textRequest.mTextureAtlasId ); - set->mFontHash = textRequest.mFontHash; - - return set; -} - - -/** - * @copydoc PlatformAbstraction::GetGlobalMetrics() - */ -void TestPlatformAbstraction::GetGlobalMetrics( const std::string& fontFamily, - const std::string& fontStyle, - Integration::GlobalMetrics& globalMetrics ) const -{ - globalMetrics.lineHeight = 10.0f; - globalMetrics.ascender = 9.0f; - globalMetrics.unitsPerEM = 2048.0f/64.0f; - globalMetrics.underlineThickness = 2.f; - globalMetrics.underlinePosition = 1.f; -} - -/** - * @copydoc PlatformAbstraction::GetFontPath() - */ -std::string TestPlatformAbstraction::GetFontPath(const std::string& family, bool bold, bool italic) const -{ - mTrace.PushCall("GetFontPath", ""); - return mGetFontPathResult; - - // Do nothing with arguments -} - -/** * @copydoc PlatformAbstraction::SetDpi() */ void TestPlatformAbstraction::SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical) @@ -310,42 +168,6 @@ void TestPlatformAbstraction::SetDpi (unsigned int dpiHorizontal, unsigned int d } /** - * @copydoc PlatformAbstraction::GetFontFamilyForChars() - */ -const std::string& TestPlatformAbstraction::GetFontFamilyForChars(const Integration::TextArray& charsRequested) const -{ - mTrace.PushCall("GetFontFamilyForChars", ""); - return mGetDefaultFontFamilyResult; -} - -/** - * @copydoc PlatformAbstraction::AllGlyphsSupported() - */ -bool TestPlatformAbstraction::AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const Integration::TextArray& text) const -{ - mTrace.PushCall("AllGlyphsSupported", ""); - return true; -} - -/** - * @copydoc PlatformAbstraction::ValidateFontFamilyName() - */ -bool TestPlatformAbstraction::ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const -{ - mTrace.PushCall("ValidateFontFamilyName", ""); - return true; -} - -/** - * @copydoc PlatformAbstraction::GetFontList() - */ -void TestPlatformAbstraction::GetFontList( PlatformAbstraction::FontListMode mode, std::vector& fontList ) const -{ - mFontListMode = mode; - mTrace.PushCall("ValidateGetFontList", ""); -} - -/** * @copydoc PlatformAbstraction::LoadFile() */ bool TestPlatformAbstraction::LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const @@ -373,12 +195,6 @@ void TestPlatformAbstraction::JoinLoaderThreads() mTrace.PushCall("JoinLoaderThreads", ""); } -void TestPlatformAbstraction::UpdateDefaultsFromDevice() -{ - mTrace.PushCall("UpdateDefaultsFromDevice", ""); - mGetDefaultFontFamilyResult+=1.0f; -} - Integration::DynamicsFactory* TestPlatformAbstraction::GetDynamicsFactory() { mTrace.PushCall("GetDynamicsFactory", ""); @@ -389,87 +205,15 @@ Integration::DynamicsFactory* TestPlatformAbstraction::GetDynamicsFactory() return mDynamicsFactory; } -bool TestPlatformAbstraction::ReadGlobalMetricsFromCache( const std::string& fontFamily, - const std::string& fontStyle, - Integration::GlobalMetrics& globalMetrics ) -{ - mTrace.PushCall("ReadGlobalMetricsFromCacheFile", ""); - globalMetrics = mReadGlobalMetrics; // Want to copy contents... - return mReadGlobalMetricsResult; // Default false (will be set to true on subsequent write) -} - -void TestPlatformAbstraction::WriteGlobalMetricsToCache( const std::string& fontFamily, - const std::string& fontStyle, - const Integration::GlobalMetrics& globalMetrics ) -{ - // Copy so next read uses written values. TODO: Could add method - // to turn this behaviour off for more extensive testing. - mReadGlobalMetrics = globalMetrics; - mReadGlobalMetricsResult = true; - - mTrace.PushCall("WriteGlobalMetricsToCacheFile", ""); -} - -bool TestPlatformAbstraction::ReadMetricsFromCache( const std::string& fontFamily, - const std::string& fontStyle, - std::vector& glyphMetricsContainer ) -{ - mTrace.PushCall("ReadMetricsFromCacheFile", ""); - glyphMetricsContainer = mReadMetrics; - return mReadMetricsResult; // Default false (will be set to true on subsequent write) -} - -void TestPlatformAbstraction::WriteMetricsToCache( const std::string& fontFamily, - const std::string& fontStyle, - const Integration::GlyphSet& glyphSet ) -{ - // Copy so next read uses written values. TODO: Could add method - // to turn this behaviour off for more extensive testing. - const Integration::GlyphSet::CharacterList& charList = glyphSet.GetCharacterList(); - mReadMetrics.clear(); - for(std::size_t i=0, end=charList.size(); i& fileNames ) -{ - fileNames.push_back( std::string( "u1f004.png" ) ); - fileNames.push_back( std::string( "u1f0cf.png" ) ); - fileNames.push_back( std::string( "u1f170.png" ) ); - fileNames.push_back( std::string( "u1f601.png" ) ); -} - -Integration::BitmapPtr TestPlatformAbstraction::GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const -{ - Integration::BitmapPtr image = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD ); - image->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 1, 1 ); - - mTrace.PushCall("GetGlyphImage", ""); - - return image; -} - /** Call this every test */ void TestPlatformAbstraction::Initialize() { mTrace.Reset(); mTrace.Enable(true); memset(&mResources, 0, sizeof(Resources)); - memset(&mReadGlobalMetrics, 0, sizeof(Integration::GlobalMetrics)); mSeconds=0; mMicroSeconds=0; mIsLoadingResult=false; - mGetDefaultFontFamilyResult = "HelveticaNeue"; - mGetDefaultFontSizeResult=12.0f; - mGetFontPathResult="helvetica-12"; - mReadMetricsResult=false; - mReadGlobalMetricsResult=false; if(mRequest) { @@ -478,7 +222,6 @@ void TestPlatformAbstraction::Initialize() } } - bool TestPlatformAbstraction::WasCalled(TestFuncEnum func) { switch(func) @@ -493,24 +236,9 @@ bool TestPlatformAbstraction::WasCalled(TestFuncEnum func) case CancelLoadFunc: return mTrace.FindMethod("CancelLoad"); case GetResourcesFunc: return mTrace.FindMethod("GetResources"); case IsLoadingFunc: return mTrace.FindMethod("IsLoading"); - case GetDefaultFontFamilyFunc: return mTrace.FindMethod("GetDefaultFontFamily"); - case GetDefaultFontSizeFunc: return mTrace.FindMethod("GetDefaultFontSize"); - case GetFontLineHeightFromCapsHeightFunc: return mTrace.FindMethod("GetFontLineHeightFromCapsHeight"); - case GetGlyphDataFunc: return mTrace.FindMethod("GetGlyphData"); - case GetCachedGlyphDataFunc: return mTrace.FindMethod("GetCachedGlyphData"); - case GetFontPathFunc: return mTrace.FindMethod("GetFontPath"); case SetDpiFunc: return mTrace.FindMethod("SetDpi"); case JoinLoaderThreadsFunc: return mTrace.FindMethod("JoinLoaderThreads"); - case GetFontFamilyForCharsFunc: return mTrace.FindMethod("GetFontFamilyForChars"); - case AllGlyphsSupportedFunc: return mTrace.FindMethod("AllGlyphsSupported"); - case ValidateFontFamilyNameFunc: return mTrace.FindMethod("ValidateFontFamilyName"); - case UpdateDefaultsFromDeviceFunc: return mTrace.FindMethod("UpdateDefaultsFromDevice"); case GetDynamicsFactoryFunc: return mTrace.FindMethod("GetDynamicsFactory"); - case ValidateGetFontListFunc: return mTrace.FindMethod("ValidateGetFontList"); - case ReadGlobalMetricsFromCacheFileFunc: return mTrace.FindMethod("ReadGlobalMetricsFromCacheFile"); - case WriteGlobalMetricsToCacheFileFunc: return mTrace.FindMethod("WriteGlobalMetricsToCacheFile"); - case ReadMetricsFromCacheFileFunc: return mTrace.FindMethod("ReadMetricsFromCacheFile"); - case WriteMetricsToCacheFileFunc: return mTrace.FindMethod("WriteMetricsToCacheFile"); } return false; } @@ -535,21 +263,6 @@ void TestPlatformAbstraction::SetIsLoadingResult(bool result) mIsLoadingResult = result; } -void TestPlatformAbstraction::SetGetDefaultFontFamilyResult(std::string result) -{ - mGetDefaultFontFamilyResult = result; -} - -void TestPlatformAbstraction::SetGetDefaultFontSizeResult(float result) -{ - mGetDefaultFontSizeResult = result; -} - -void TestPlatformAbstraction::SetGetFontPathResult(std::string& result) -{ - mGetFontPathResult = result; -} - void TestPlatformAbstraction::ClearReadyResources() { memset(&mResources, 0, sizeof(Resources)); @@ -619,21 +332,4 @@ void TestPlatformAbstraction::SetSaveFileResult( bool result ) mSaveFileResult = result; } -Integration::PlatformAbstraction::FontListMode TestPlatformAbstraction::GetLastFontListMode( ) -{ - return mFontListMode; -} - -void TestPlatformAbstraction::SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics ) -{ - mReadGlobalMetricsResult = success; - mReadGlobalMetrics = globalMetrics; -} - -void TestPlatformAbstraction::SetReadMetricsResult( bool success, std::vector& glyphMetricsContainer ) -{ - mReadMetricsResult = success; - mReadMetrics = glyphMetricsContainer; // copy -} - } // namespace Dali diff --git a/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.h b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.h index e8614ec..8a9919a 100644 --- a/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.h +++ b/automated-tests/src/dali-unmanaged/dali-test-suite-utils/test-platform-abstraction.h @@ -26,7 +26,6 @@ #include #include -#include #include "test-trace-call-stack.h" #include "test-dynamics.h" @@ -134,72 +133,11 @@ public: virtual bool IsLoading(); /** - * @copydoc PlatformAbstraction::GetDefaultFontFamily() - */ - virtual const std::string& GetDefaultFontFamily() const; - - /** - * @copydoc PlatformAbstraction::GetDefaultFontSize() - */ - virtual float GetDefaultFontSize() const; - - /** - * @copydoc PlatformAbstraction::GetFontLineHeightFromCapsHeight() - */ - virtual PixelSize GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, CapsHeight capsHeight) const; - - /** - * @copydoc PlatformAbstraction::GetGlyphData() - */ - virtual Integration::GlyphSet* GetGlyphData ( const Integration::TextResourceType& textRequest, - const std::string& fontFamily, - bool getBitmap) const; - - /** - * @copydoc PlatformAbstraction::GetCachedGlyphData() - */ - virtual Integration::GlyphSet* GetCachedGlyphData( const Integration::TextResourceType& textRequest, - const std::string& fontFamily ) const; - - - /** - * @copydoc PlatformAbstraction::GetGlobalMetrics() - */ - virtual void GetGlobalMetrics( const std::string& fontFamily, - const std::string& fontStyle, - Integration::GlobalMetrics& globalMetrics ) const; - - /** - * @copydoc PlatformAbstraction::GetFontPath() - */ - virtual std::string GetFontPath(const std::string& family, bool bold, bool italic) const; - - /** * @copydoc PlatformAbstraction::SetDpi() */ virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical); /** - * @copydoc PlatformAbstraction::GetFontFamilyForChars() - */ - virtual const std::string& GetFontFamilyForChars(const Integration::TextArray& charsRequested) const; - - /** - * @copydoc PlatformAbstraction::AllGlyphsSupported() - */ - virtual bool AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const Integration::TextArray& text) const; - - /** - * @copydoc PlatformAbstraction::ValidateFontFamilyName() - */ - virtual bool ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const; - - /** - * @copydoc PlatformAbstraction::GetFontList() - */ - virtual void GetFontList( PlatformAbstraction::FontListMode mode, std::vector& fontList ) const; - - /** * @copydoc PlatformAbstraction::LoadFile() */ virtual bool LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const; @@ -211,30 +149,8 @@ public: virtual void JoinLoaderThreads(); - virtual void UpdateDefaultsFromDevice(); - virtual Integration::DynamicsFactory* GetDynamicsFactory(); - virtual bool ReadGlobalMetricsFromCache( const std::string& fontFamily, - const std::string& fontStyle, - Integration::GlobalMetrics& globalMetrics ); - - virtual void WriteGlobalMetricsToCache( const std::string& fontFamily, - const std::string& fontStyle, - const Integration::GlobalMetrics& globalMetrics ); - - virtual bool ReadMetricsFromCache( const std::string& fontFamily, - const std::string& fontStyle, - std::vector& glyphMetricsContainer ); - virtual void WriteMetricsToCache( const std::string& fontFamily, - const std::string& fontStyle, - const Integration::GlyphSet& glyphSet ); - - virtual void GetFileNamesFromDirectory( const std::string& directoryName, - std::vector& fileNames ); - - virtual Integration::BitmapPtr GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const; - public: // TEST FUNCTIONS // Enumeration of Platform Abstraction methods @@ -250,24 +166,9 @@ public: // TEST FUNCTIONS CancelLoadFunc, GetResourcesFunc, IsLoadingFunc, - GetDefaultFontFamilyFunc, - GetDefaultFontSizeFunc, - GetFontLineHeightFromCapsHeightFunc, - GetGlyphDataFunc, - GetCachedGlyphDataFunc, SetDpiFunc, - GetFontPathFunc, JoinLoaderThreadsFunc, - GetFontFamilyForCharsFunc, - AllGlyphsSupportedFunc, - ValidateFontFamilyNameFunc, - UpdateDefaultsFromDeviceFunc, GetDynamicsFactoryFunc, - ValidateGetFontListFunc, - ReadGlobalMetricsFromCacheFileFunc, - WriteGlobalMetricsToCacheFileFunc, - ReadMetricsFromCacheFileFunc, - WriteMetricsToCacheFileFunc, } TestFuncEnum; /** Call this every test */ @@ -285,12 +186,6 @@ public: // TEST FUNCTIONS void SetIsLoadingResult(bool result); - void SetGetDefaultFontFamilyResult(std::string result); - - void SetGetDefaultFontSizeResult(float result); - - void SetGetFontPathResult(std::string& result); - void ClearReadyResources(); void SetResourceLoaded(Integration::ResourceId loadedId, @@ -316,32 +211,18 @@ public: // TEST FUNCTIONS void SetSaveFileResult( bool result ); - PlatformAbstraction::FontListMode GetLastFontListMode( ); - - void SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics ); - - void SetReadMetricsResult( bool success, std::vector& glyphMetricsContainer ); - private: mutable TraceCallStack mTrace; size_t mSeconds; size_t mMicroSeconds; bool mIsLoadingResult; - std::string mGetDefaultFontFamilyResult; - float mGetDefaultFontSizeResult; - std::string mGetFontPathResult; Resources mResources; Integration::ResourceRequest* mRequest; Vector2 mSize; Vector2 mClosestSize; - bool mReadGlobalMetricsResult; - bool mReadMetricsResult; - Integration::GlobalMetrics mReadGlobalMetrics; - std::vector mReadMetrics; LoadFileResult mLoadFileResult; bool mSaveFileResult; - mutable FontListMode mFontListMode; TestDynamicsFactory* mDynamicsFactory; }; diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-HitTestAlgorithm.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-HitTestAlgorithm.cpp index f6350c7..308fa67 100644 --- a/automated-tests/src/dali-unmanaged/utc-Dali-HitTestAlgorithm.cpp +++ b/automated-tests/src/dali-unmanaged/utc-Dali-HitTestAlgorithm.cpp @@ -387,7 +387,7 @@ int UtcDaliHitTestAlgorithmStencil(void) layer.Add( stencil ); // Create a renderable actor and add that to the layer - Actor layerHitActor = TextActor::New(); + Actor layerHitActor = ImageActor::New(); layerHitActor.SetSize( 100.0f, 100.0f ); layerHitActor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); layerHitActor.SetParentOrigin( ParentOrigin::TOP_LEFT ); diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-ObjectRegistry.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-ObjectRegistry.cpp index d772a3f..64ae73c 100644 --- a/automated-tests/src/dali-unmanaged/utc-Dali-ObjectRegistry.cpp +++ b/automated-tests/src/dali-unmanaged/utc-Dali-ObjectRegistry.cpp @@ -180,24 +180,6 @@ struct TestModelCallback bool& mSignalVerified; }; -struct TestTextActorCallback -{ - TestTextActorCallback(bool& signalReceived) - : mSignalVerified(signalReceived) - { - } - void operator()(BaseHandle object) - { - tet_infoline("Verifying TestTextActorCallback()"); - TextActor actor = TextActor::DownCast(object); - if(actor) - { - mSignalVerified = true; - } - } - bool& mSignalVerified; -}; - struct TestAnimationCallback { TestAnimationCallback(bool& signalReceived) @@ -438,31 +420,6 @@ int UtcDaliObjectRegistrySignalModelCreated(void) END_TEST; } -int UtcDaliObjectRegistrySignalTextActorCreated(void) -{ - TestApplication application; - ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry(); - - bool verified = false; - TestTextActorCallback test(verified); - - Dali::RefObject* objectPointer = NULL; - TestObjectDestroyedCallback test2(verified, objectPointer); - - registry.ObjectCreatedSignal().Connect(&application, test); - registry.ObjectDestroyedSignal().Connect(&application, test2); - - { - TextActor actor = TextActor::New("Hello"); - DALI_TEST_CHECK( test.mSignalVerified ); - - verified = false; - objectPointer = actor.GetObjectPtr(); - } - DALI_TEST_CHECK( test.mSignalVerified ); - END_TEST; -} - int UtcDaliObjectRegistrySignalAnimationCreated(void) { TestApplication application; diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-Scripting.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-Scripting.cpp index 1d3aa68..d39ac28 100644 --- a/automated-tests/src/dali-unmanaged/utc-Dali-Scripting.cpp +++ b/automated-tests/src/dali-unmanaged/utc-Dali-Scripting.cpp @@ -745,12 +745,6 @@ int UtcDaliScriptingNewActorChildren(void) DALI_TEST_EQUALS( child1.GetCurrentPosition(), Vector3::YAXIS, TEST_LOCATION ); DALI_TEST_EQUALS( child1.GetChildCount(), 1u, TEST_LOCATION ); - Actor child2 = handle.GetChildAt(1); - DALI_TEST_CHECK( child2 ); - DALI_TEST_CHECK( TextActor::DownCast( child2 ) ); - DALI_TEST_EQUALS( child2.GetCurrentPosition(), Vector3::ZAXIS, TEST_LOCATION ); - DALI_TEST_EQUALS( child2.GetChildCount(), 0u, TEST_LOCATION ); - Actor grandChild = child1.GetChildAt( 0 ); DALI_TEST_CHECK( grandChild ); DALI_TEST_CHECK( LightActor::DownCast( grandChild ) ); @@ -860,11 +854,9 @@ int UtcDaliScriptingCreatePropertyMapActor(void) { Actor actor = Actor::New(); Actor child = ImageActor::New(); - Actor grandChild = TextActor::New(); - Actor grandChild2 = LightActor::New(); + Actor grandChild = LightActor::New(); actor.Add( child ); child.Add( grandChild ); - child.Add( grandChild2 ); Stage::GetCurrent().Add( actor ); application.SendNotification(); @@ -889,19 +881,13 @@ int UtcDaliScriptingCreatePropertyMapActor(void) DALI_TEST_CHECK( childValue.HasKey( "actors" ) ); Property::Array grandChildren( childValue.GetValue( "actors").Get< Property::Array >() ); - DALI_TEST_CHECK( grandChildren.size() == 2u ); + DALI_TEST_CHECK( grandChildren.size() == 1u ); Property::Map grandChildMap( grandChildren[0].Get< Property::Map >() ); DALI_TEST_CHECK( !grandChildMap.Empty() ); Property::Value grandChildValue( grandChildMap ); DALI_TEST_CHECK( grandChildValue.HasKey( "type" ) ); - DALI_TEST_EQUALS( grandChildValue.GetValue( "type" ).Get< std::string >(), "TextActor", TEST_LOCATION ); - - Property::Map grandChild2Map( grandChildren[1].Get< Property::Map >() ); - DALI_TEST_CHECK( !grandChild2Map.Empty() ); - Property::Value grandChild2Value( grandChild2Map ); - DALI_TEST_CHECK( grandChild2Value.HasKey( "type" ) ); - DALI_TEST_EQUALS( grandChild2Value.GetValue( "type" ).Get< std::string >(), "LightActor", TEST_LOCATION ); + DALI_TEST_EQUALS( grandChildValue.GetValue( "type" ).Get< std::string >(), "LightActor", TEST_LOCATION ); Stage::GetCurrent().Remove( actor ); } diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-TypeRegistry.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-TypeRegistry.cpp index 0ecf8ce..5f2ff27 100644 --- a/automated-tests/src/dali-unmanaged/utc-Dali-TypeRegistry.cpp +++ b/automated-tests/src/dali-unmanaged/utc-Dali-TypeRegistry.cpp @@ -509,13 +509,6 @@ int UtcDaliTypeRegistryCreateDaliObjects(void) Stage::GetCurrent().Add( ia ); application.Render(); - type = registry.GetTypeInfo( "TextActor" ); - DALI_TEST_CHECK( type ); - TextActor ta = TextActor::DownCast(type.CreateInstance()); - DALI_TEST_CHECK( ta ); - Stage::GetCurrent().Add( ta ); - application.Render(); - type = registry.GetTypeInfo( "CameraActor" ); DALI_TEST_CHECK( type ); CameraActor ca = CameraActor::DownCast(type.CreateInstance()); @@ -607,8 +600,8 @@ int UtcDaliTypeRegistryNames(void) // Check named and typeid are equivalent int UtcDaliTypeRegistryNameEquivalence(void) { - TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "TextActor" ); - TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::TextActor) ); + TypeInfo named_type = TypeRegistry::Get().GetTypeInfo( "ImageActor" ); + TypeInfo typeinfo_type = TypeRegistry::Get().GetTypeInfo( typeid(Dali::ImageActor) ); DALI_TEST_CHECK( named_type ); DALI_TEST_CHECK( typeinfo_type ); diff --git a/automated-tests/src/dali-unmanaged/utc-Dali-Utf8.cpp b/automated-tests/src/dali-unmanaged/utc-Dali-Utf8.cpp deleted file mode 100644 index 851d758..0000000 --- a/automated-tests/src/dali-unmanaged/utc-Dali-Utf8.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -#include - -#include -#include -#include - -using namespace Dali; - - -// Positive test case for a method -int UtcDaliUtf8SequenceLength(void) -{ - tet_infoline("UtcDaliUtf8SequenceLength "); - TestApplication application; - - std::string latinText( "amazing" ); - std::string japaneseText( "すごい" ); - std::string accent("é"); - - tet_infoline("utf8 1 byte Test "); - DALI_TEST_EQUALS( Utf8SequenceLength( latinText[0] ), 1u, TEST_LOCATION ); - tet_infoline("utf8 3 byte Test "); - DALI_TEST_EQUALS( Utf8SequenceLength( japaneseText[0] ), 3u, TEST_LOCATION ); - tet_infoline("utf8 2 byte Test "); - DALI_TEST_EQUALS( Utf8SequenceLength( accent[0] ), 2u, TEST_LOCATION ); - END_TEST; -} diff --git a/automated-tests/src/dali/CMakeLists.txt b/automated-tests/src/dali/CMakeLists.txt index b023c1d..532237e 100644 --- a/automated-tests/src/dali/CMakeLists.txt +++ b/automated-tests/src/dali/CMakeLists.txt @@ -16,12 +16,9 @@ SET(TC_SOURCES utc-Dali-BaseHandle.cpp utc-Dali-BitmapImage.cpp utc-Dali-CameraActor.cpp - utc-Dali-Character.cpp utc-Dali-Constraint.cpp utc-Dali-CustomActor.cpp utc-Dali-Degree.cpp - utc-Dali-Font.cpp - utc-Dali-FontParameters.cpp utc-Dali-FrameBufferImage.cpp utc-Dali-Gesture.cpp utc-Dali-GestureDetector.cpp @@ -59,9 +56,6 @@ SET(TC_SOURCES utc-Dali-Stage.cpp utc-Dali-TapGesture.cpp utc-Dali-TapGestureDetector.cpp - utc-Dali-Text.cpp - utc-Dali-TextActor.cpp - utc-Dali-TextStyle.cpp utc-Dali-TouchEventCombiner.cpp utc-Dali-TouchProcessing.cpp utc-Dali-Vector2.cpp diff --git a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h index 375fb90..44be6c4 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h +++ b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.h @@ -296,41 +296,6 @@ void DALI_TEST_EQUALS( const std::string &str1, const char* str2, const char* lo void DALI_TEST_EQUALS( const char* str1, const std::string &str2, const char* location); /** - * Test whether two UTF32 strings are equal. - * @param[in] str1 The first string - * @param[in] str2 The second string - * @param[in] location The TEST_LOCATION macro should be used here - */ -template<> -inline void DALI_TEST_EQUALS( const Integration::TextArray& str1, const Integration::TextArray& str2, const char* location) -{ - if( !std::equal( str1.Begin(), str1.End(), str2.Begin() ) ) - { - fprintf(stderr, "%s, checking '", location); - - for( unsigned int i = 0; i < str1.Count(); ++i ) - { - fprintf(stderr, "%c", str1[i]); - } - - fprintf(stderr, "' == '"); - - for( unsigned int i = 0; i < str2.Count(); ++i ) - { - fprintf(stderr, "%c", str2[i]); - } - - fprintf(stderr, "'\n"); - - tet_result(TET_FAIL); - } - else - { - tet_result(TET_PASS); - } -} - -/** * Test whether one unsigned integer value is greater than another. * Test succeeds if value1 > value2 * @param[in] value1 The first value diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp index 779fd2a..c64af4d 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp @@ -87,16 +87,7 @@ void TestPlatformAbstraction::GetClosestImageSize( Integration::ResourcePointer void TestPlatformAbstraction::LoadResource(const Integration::ResourceRequest& request) { std::ostringstream out; - out << "Type:"; - if( request.GetType()->id == Integration::ResourceText ) - { - out << "Text"; - } - else - { - out << request.GetType()->id; - } - out << ", Path: " << request.GetPath() << std::endl ; + out << "Type:" << request.GetType()->id << ", Path: " << request.GetPath() << std::endl ; mTrace.PushCall("LoadResource", out.str()); if(mRequest != NULL) @@ -170,148 +161,6 @@ bool TestPlatformAbstraction::IsLoading() } /** - * @copydoc PlatformAbstraction::GetDefaultFontFamily() - */ -const std::string& TestPlatformAbstraction::GetDefaultFontFamily() const -{ - mTrace.PushCall("GetDefaultFontFamily", ""); - return mGetDefaultFontFamilyResult; -} - -/** - * @copydoc PlatformAbstraction::GetDefaultFontSize() - */ -float TestPlatformAbstraction::GetDefaultFontSize() const -{ - mTrace.PushCall("GetDefaultFontSize", ""); - return mGetDefaultFontSizeResult; -} - -PixelSize TestPlatformAbstraction::GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, CapsHeight capsHeight) const -{ - mTrace.PushCall("GetFontLineHeightFromCapsHeight", ""); - // LineHeight will be bigger than CapsHeight, so return capsHeight + 1 - return PixelSize(capsHeight + 1); -} - -/** - * @copydoc PlatformAbstraction::GetGlyphData() - */ - -Integration::GlyphSet* TestPlatformAbstraction::GetGlyphData ( const Integration::TextResourceType& textRequest, - const std::string& fontFamily, - bool getBitmap) const -{ - if( getBitmap ) - { - mTrace.PushCall("GetGlyphData", "getBitmap:true"); - } - else - { - mTrace.PushCall("GetGlyphData", "getBitmap:false"); - } - - // It creates fake metrics for the received characters. - - Integration::GlyphSet* set = new Dali::Integration::GlyphSet(); - Integration::BitmapPtr bitmapData; - - std::set characters; - - for( Integration::TextResourceType::CharacterList::const_iterator it = textRequest.mCharacterList.begin(), endIt = textRequest.mCharacterList.end(); it != endIt; ++it ) - { - if( characters.find( it->character ) == characters.end() ) - { - characters.insert( it->character ); - Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::LOW_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition }; - - if( getBitmap ) - { - bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD); - bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64); - PixelBuffer* pixelBuffer = bitmapData->GetBuffer(); - memset( pixelBuffer, it->character, 64*64 ); - } - - set->AddCharacter(bitmapData, character); - } - } - - set->mLineHeight = 10.0f; - set->mAscender = 9.0f; - set->mUnitsPerEM = 2048.0f/64.0f; - set->SetAtlasResourceId( textRequest.mTextureAtlasId ); - set->mFontHash = textRequest.mFontHash; - - return set; -} - -/** - * @copydoc PlatformAbstraction::GetCachedGlyphData() - */ - -Integration::GlyphSet* TestPlatformAbstraction::GetCachedGlyphData( const Integration::TextResourceType& textRequest, - const std::string& fontFamily ) const -{ - mTrace.PushCall("GetCachedGlyphData", ""); - - // It creates fake metrics and bitmap for received numeric characters '0' through '9'. - Integration::GlyphSet* set = new Dali::Integration::GlyphSet(); - Integration::BitmapPtr bitmapData; - - std::set characters; - - for( Integration::TextResourceType::CharacterList::const_iterator it = textRequest.mCharacterList.begin(), endIt = textRequest.mCharacterList.end(); it != endIt; ++it ) - { - if( it->character >= '0' && it->character <= '9' && characters.find( it->character ) == characters.end() ) - { - characters.insert( it->character ); - Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::HIGH_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition }; - - bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD); - bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64); - PixelBuffer* pixelBuffer = bitmapData->GetBuffer(); - memset( pixelBuffer, it->character, 64*64 ); - set->AddCharacter(bitmapData, character); - } - } - - set->mLineHeight = 10.0f; - set->mAscender = 9.0f; - set->mUnitsPerEM = 2048.0f/64.0f; - set->SetAtlasResourceId( textRequest.mTextureAtlasId ); - set->mFontHash = textRequest.mFontHash; - - return set; -} - - -/** - * @copydoc PlatformAbstraction::GetGlobalMetrics() - */ -void TestPlatformAbstraction::GetGlobalMetrics( const std::string& fontFamily, - const std::string& fontStyle, - Integration::GlobalMetrics& globalMetrics ) const -{ - globalMetrics.lineHeight = 10.0f; - globalMetrics.ascender = 9.0f; - globalMetrics.unitsPerEM = 2048.0f/64.0f; - globalMetrics.underlineThickness = 2.f; - globalMetrics.underlinePosition = 1.f; -} - -/** - * @copydoc PlatformAbstraction::GetFontPath() - */ -std::string TestPlatformAbstraction::GetFontPath(const std::string& family, bool bold, bool italic) const -{ - mTrace.PushCall("GetFontPath", ""); - return mGetFontPathResult; - - // Do nothing with arguments -} - -/** * @copydoc PlatformAbstraction::SetDpi() */ void TestPlatformAbstraction::SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical) @@ -320,42 +169,6 @@ void TestPlatformAbstraction::SetDpi (unsigned int dpiHorizontal, unsigned int d } /** - * @copydoc PlatformAbstraction::GetFontFamilyForChars() - */ -const std::string& TestPlatformAbstraction::GetFontFamilyForChars(const Integration::TextArray& charsRequested) const -{ - mTrace.PushCall("GetFontFamilyForChars", ""); - return mGetDefaultFontFamilyResult; -} - -/** - * @copydoc PlatformAbstraction::AllGlyphsSupported() - */ -bool TestPlatformAbstraction::AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const Integration::TextArray& text) const -{ - mTrace.PushCall("AllGlyphsSupported", ""); - return true; -} - -/** - * @copydoc PlatformAbstraction::ValidateFontFamilyName() - */ -bool TestPlatformAbstraction::ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const -{ - mTrace.PushCall("ValidateFontFamilyName", ""); - return true; -} - -/** - * @copydoc PlatformAbstraction::GetFontList() - */ -void TestPlatformAbstraction::GetFontList( PlatformAbstraction::FontListMode mode, std::vector& fonstList ) const -{ - mFontListMode = mode; - mTrace.PushCall("ValidateGetFontList", ""); -} - -/** * @copydoc PlatformAbstraction::LoadFile() */ bool TestPlatformAbstraction::LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const @@ -383,102 +196,21 @@ void TestPlatformAbstraction::JoinLoaderThreads() mTrace.PushCall("JoinLoaderThreads", ""); } -void TestPlatformAbstraction::UpdateDefaultsFromDevice() -{ - mTrace.PushCall("UpdateDefaultsFromDevice", ""); - mGetDefaultFontFamilyResult+=1.0f; -} - Integration::DynamicsFactory* TestPlatformAbstraction::GetDynamicsFactory() { mTrace.PushCall("GetDynamicsFactory", ""); return NULL; } -bool TestPlatformAbstraction::ReadGlobalMetricsFromCache( const std::string& fontFamily, - const std::string& fontStyle, - Integration::GlobalMetrics& globalMetrics ) -{ - mTrace.PushCall("ReadGlobalMetricsFromCacheFile", ""); - globalMetrics = mReadGlobalMetrics; // Want to copy contents... - return mReadGlobalMetricsResult; // Default false (will be set to true on subsequent write) -} - -void TestPlatformAbstraction::WriteGlobalMetricsToCache( const std::string& fontFamily, - const std::string& fontStyle, - const Integration::GlobalMetrics& globalMetrics ) -{ - // Copy so next read uses written values. TODO: Could add method - // to turn this behaviour off for more extensive testing. - mReadGlobalMetrics = globalMetrics; - mReadGlobalMetricsResult = true; - - mTrace.PushCall("WriteGlobalMetricsToCacheFile", ""); -} - -bool TestPlatformAbstraction::ReadMetricsFromCache( const std::string& fontFamily, - const std::string& fontStyle, - std::vector& glyphMetricsContainer ) -{ - mTrace.PushCall("ReadMetricsFromCacheFile", ""); - glyphMetricsContainer = mReadMetrics; - return mReadMetricsResult; // Default false (will be set to true on subsequent write) -} - -void TestPlatformAbstraction::WriteMetricsToCache( const std::string& fontFamily, - const std::string& fontStyle, - const Integration::GlyphSet& glyphSet ) -{ - // Copy so next read uses written values. TODO: Could add method - // to turn this behaviour off for more extensive testing. - const Integration::GlyphSet::CharacterList& charList = glyphSet.GetCharacterList(); - mReadMetrics.clear(); - for(std::size_t i=0, end=charList.size(); i& fileNames ) -{ - fileNames.push_back( std::string( "u1f004.png" ) ); - fileNames.push_back( std::string( "u1f0cf.png" ) ); - fileNames.push_back( std::string( "u1f170.png" ) ); - fileNames.push_back( std::string( "u1f601.png" ) ); -} - - -Integration::BitmapPtr TestPlatformAbstraction::GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const -{ - Integration::BitmapPtr image = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD ); - image->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 1, 1 ); - - mTrace.PushCall("GetGlyphImage", ""); - - return image; -} - - /** Call this every test */ void TestPlatformAbstraction::Initialize() { mTrace.Reset(); mTrace.Enable(true); memset(&mResources, 0, sizeof(Resources)); - memset(&mReadGlobalMetrics, 0, sizeof(Integration::GlobalMetrics)); mSeconds=0; mMicroSeconds=0; mIsLoadingResult=false; - mGetDefaultFontFamilyResult = "HelveticaNeue"; - mGetDefaultFontSizeResult=12.0f; - mGetFontPathResult="helvetica-12"; - mReadMetricsResult=false; - mReadGlobalMetricsResult=false; if(mRequest) { @@ -487,7 +219,6 @@ void TestPlatformAbstraction::Initialize() } } - bool TestPlatformAbstraction::WasCalled(TestFuncEnum func) { switch(func) @@ -502,24 +233,9 @@ bool TestPlatformAbstraction::WasCalled(TestFuncEnum func) case CancelLoadFunc: return mTrace.FindMethod("CancelLoad"); case GetResourcesFunc: return mTrace.FindMethod("GetResources"); case IsLoadingFunc: return mTrace.FindMethod("IsLoading"); - case GetDefaultFontFamilyFunc: return mTrace.FindMethod("GetDefaultFontFamily"); - case GetDefaultFontSizeFunc: return mTrace.FindMethod("GetDefaultFontSize"); - case GetFontLineHeightFromCapsHeightFunc: return mTrace.FindMethod("GetFontLineHeightFromCapsHeight"); - case GetGlyphDataFunc: return mTrace.FindMethod("GetGlyphData"); - case GetCachedGlyphDataFunc: return mTrace.FindMethod("GetCachedGlyphData"); - case GetFontPathFunc: return mTrace.FindMethod("GetFontPath"); case SetDpiFunc: return mTrace.FindMethod("SetDpi"); case JoinLoaderThreadsFunc: return mTrace.FindMethod("JoinLoaderThreads"); - case GetFontFamilyForCharsFunc: return mTrace.FindMethod("GetFontFamilyForChars"); - case AllGlyphsSupportedFunc: return mTrace.FindMethod("AllGlyphsSupported"); - case ValidateFontFamilyNameFunc: return mTrace.FindMethod("ValidateFontFamilyName"); - case UpdateDefaultsFromDeviceFunc: return mTrace.FindMethod("UpdateDefaultsFromDevice"); case GetDynamicsFactoryFunc: return mTrace.FindMethod("GetDynamicsFactory"); - case ValidateGetFontListFunc: return mTrace.FindMethod("ValidateGetFontList"); - case ReadGlobalMetricsFromCacheFileFunc: return mTrace.FindMethod("ReadGlobalMetricsFromCacheFile"); - case WriteGlobalMetricsToCacheFileFunc: return mTrace.FindMethod("WriteGlobalMetricsToCacheFile"); - case ReadMetricsFromCacheFileFunc: return mTrace.FindMethod("ReadMetricsFromCacheFile"); - case WriteMetricsToCacheFileFunc: return mTrace.FindMethod("WriteMetricsToCacheFile"); } return false; } @@ -544,21 +260,6 @@ void TestPlatformAbstraction::SetIsLoadingResult(bool result) mIsLoadingResult = result; } -void TestPlatformAbstraction::SetGetDefaultFontFamilyResult(std::string result) -{ - mGetDefaultFontFamilyResult = result; -} - -void TestPlatformAbstraction::SetGetDefaultFontSizeResult(float result) -{ - mGetDefaultFontSizeResult = result; -} - -void TestPlatformAbstraction::SetGetFontPathResult(std::string& result) -{ - mGetFontPathResult = result; -} - void TestPlatformAbstraction::ClearReadyResources() { memset(&mResources, 0, sizeof(Resources)); @@ -628,22 +329,4 @@ void TestPlatformAbstraction::SetSaveFileResult( bool result ) mSaveFileResult = result; } -Integration::PlatformAbstraction::FontListMode TestPlatformAbstraction::GetLastFontListMode( ) -{ - return mFontListMode; -} - -void TestPlatformAbstraction::SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics ) -{ - mReadGlobalMetricsResult = success; - mReadGlobalMetrics = globalMetrics; -} - -void TestPlatformAbstraction::SetReadMetricsResult( bool success, std::vector& glyphMetricsContainer ) -{ - mReadMetricsResult = success; - mReadMetrics = glyphMetricsContainer; // copy -} - - } // namespace Dali diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h index f3f22ac..d7f1603 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h @@ -26,7 +26,6 @@ #include #include -#include #include "test-trace-call-stack.h" @@ -137,72 +136,11 @@ public: virtual bool IsLoading(); /** - * @copydoc PlatformAbstraction::GetDefaultFontFamily() - */ - virtual const std::string& GetDefaultFontFamily() const; - - /** - * @copydoc PlatformAbstraction::GetDefaultFontSize() - */ - virtual float GetDefaultFontSize() const; - - /** - * @copydoc PlatformAbstraction::GetFontLineHeightFromCapsHeight() - */ - virtual Dali::PixelSize GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, CapsHeight capsHeight) const; - - /** - * @copydoc PlatformAbstraction::GetGlyphData() - */ - virtual Integration::GlyphSet* GetGlyphData ( const Integration::TextResourceType& textRequest, - const std::string& fontFamily, - bool getBitmap) const; - - /** - * @copydoc PlatformAbstraction::GetCachedGlyphData() - */ - virtual Integration::GlyphSet* GetCachedGlyphData( const Integration::TextResourceType& textRequest, - const std::string& fontFamily ) const; - - - /** - * @copydoc PlatformAbstraction::GetGlobalMetrics() - */ - virtual void GetGlobalMetrics( const std::string& fontFamily, - const std::string& fontStyle, - Integration::GlobalMetrics& globalMetrics ) const; - - /** - * @copydoc PlatformAbstraction::GetFontPath() - */ - virtual std::string GetFontPath(const std::string& family, bool bold, bool italic) const; - - /** * @copydoc PlatformAbstraction::SetDpi() */ virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical); /** - * @copydoc PlatformAbstraction::GetFontFamilyForChars() - */ - virtual const std::string& GetFontFamilyForChars(const Integration::TextArray& charsRequested) const; - - /** - * @copydoc PlatformAbstraction::AllGlyphsSupported() - */ - virtual bool AllGlyphsSupported(const std::string& name, const std::string& fontStyle, const Integration::TextArray& text) const; - - /** - * @copydoc PlatformAbstraction::ValidateFontFamilyName() - */ - virtual bool ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestMatch, std::string& closestStyleMatch) const; - - /** - * @copydoc PlatformAbstraction::GetFontList() - */ - virtual void GetFontList( PlatformAbstraction::FontListMode mode, std::vector& fontList ) const; - - /** * @copydoc PlatformAbstraction::LoadFile() */ virtual bool LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const; @@ -214,31 +152,8 @@ public: virtual void JoinLoaderThreads(); - virtual void UpdateDefaultsFromDevice(); - virtual Integration::DynamicsFactory* GetDynamicsFactory(); - virtual bool ReadGlobalMetricsFromCache( const std::string& fontFamily, - const std::string& fontStyle, - Integration::GlobalMetrics& globalMetrics ); - - virtual void WriteGlobalMetricsToCache( const std::string& fontFamily, - const std::string& fontStyle, - const Integration::GlobalMetrics& globalMetrics ); - - virtual bool ReadMetricsFromCache( const std::string& fontFamily, - const std::string& fontStyle, - std::vector& glyphMetricsContainer ); - virtual void WriteMetricsToCache( const std::string& fontFamily, - const std::string& fontStyle, - const Integration::GlyphSet& glyphSet ); - - - virtual void GetFileNamesFromDirectory( const std::string& directoryName, - std::vector& fileNames ); - - virtual Integration::BitmapPtr GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const; - public: // TEST FUNCTIONS // Enumeration of Platform Abstraction methods @@ -254,24 +169,9 @@ public: // TEST FUNCTIONS CancelLoadFunc, GetResourcesFunc, IsLoadingFunc, - GetDefaultFontFamilyFunc, - GetDefaultFontSizeFunc, - GetFontLineHeightFromCapsHeightFunc, - GetGlyphDataFunc, - GetCachedGlyphDataFunc, SetDpiFunc, - GetFontPathFunc, JoinLoaderThreadsFunc, - GetFontFamilyForCharsFunc, - AllGlyphsSupportedFunc, - ValidateFontFamilyNameFunc, - UpdateDefaultsFromDeviceFunc, GetDynamicsFactoryFunc, - ValidateGetFontListFunc, - ReadGlobalMetricsFromCacheFileFunc, - WriteGlobalMetricsToCacheFileFunc, - ReadMetricsFromCacheFileFunc, - WriteMetricsToCacheFileFunc, } TestFuncEnum; /** Call this every test */ @@ -289,12 +189,6 @@ public: // TEST FUNCTIONS void SetIsLoadingResult(bool result); - void SetGetDefaultFontFamilyResult(std::string result); - - void SetGetDefaultFontSizeResult(float result); - - void SetGetFontPathResult(std::string& result); - void ClearReadyResources(); void SetResourceLoaded(Integration::ResourceId loadedId, @@ -320,31 +214,18 @@ public: // TEST FUNCTIONS void SetSaveFileResult( bool result ); - PlatformAbstraction::FontListMode GetLastFontListMode( ); - - void SetReadGlobalMetricsResult( bool success, Integration::GlobalMetrics& globalMetrics ); - - void SetReadMetricsResult( bool success, std::vector& glyphMetricsContainer ); private: mutable TraceCallStack mTrace; size_t mSeconds; size_t mMicroSeconds; bool mIsLoadingResult; - std::string mGetDefaultFontFamilyResult; - float mGetDefaultFontSizeResult; - std::string mGetFontPathResult; Resources mResources; Integration::ResourceRequest* mRequest; Vector2 mSize; Vector2 mClosestSize; - bool mReadGlobalMetricsResult; - bool mReadMetricsResult; - Integration::GlobalMetrics mReadGlobalMetrics; - std::vector mReadMetrics; LoadFileResult mLoadFileResult; bool mSaveFileResult; - mutable FontListMode mFontListMode; }; } // Dali diff --git a/automated-tests/src/dali/utc-Dali-Character.cpp b/automated-tests/src/dali/utc-Dali-Character.cpp deleted file mode 100644 index e7b9523..0000000 --- a/automated-tests/src/dali/utc-Dali-Character.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -#include - -#include -#include -#include - -using namespace Dali; - -void utc_dali_character_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_character_cleanup(void) -{ - test_return_value = TET_PASS; -} - -int UtcDaliCharacterCopyConstructor(void) -{ - tet_infoline("UtcDaliCharacterCopyConstructor "); - TestApplication application; - - Text text( std::string("12") ); - - Character c1 = text[0]; - Character c2 = text[1]; - - Character c3( c1 ); - Character c4 = c2; - - DALI_TEST_CHECK( (c1==c3) && (c2==c4) ); - END_TEST; -} - -int UtcDaliCharacterComparissonOperators(void) -{ - tet_infoline("UtcDaliCharacterComparissonOperators "); - TestApplication application; - - Text text( std::string("12") ); - - Character c1 = text[0]; - Character c2 = text[1]; - - Character c3( c1 ); - Character c4 = c2; - - DALI_TEST_CHECK( (c1==c3) && (c2==c4) && (c1!=c2) && (c1!=c4) ); - END_TEST; -} - -int UtcDaliCharacterAssignmentOperator(void) -{ - tet_infoline("UtcDaliCharacterAssignmentOperator "); - TestApplication application; - - Text text( std::string("12") ); - Character c1 = text[0]; - Character c2 = text[1]; - c1 = c2; //assign - DALI_TEST_CHECK( c1 == c1); - - // this should do nothing - c1 = c1; - DALI_TEST_CHECK( c1 == c2); - - END_TEST; -} - -int UtcDaliCharacterIsLeftToRight(void) -{ - tet_infoline("UtcDaliCharacterIsLeftToRight "); - TestApplication application; - - Text text( std::string("12בא") ); - - Character c1 = text[0]; - Character c2 = text[1]; - Character c3 = text[2]; - Character c4 = text[3]; - - DALI_TEST_CHECK( c1.GetCharacterDirection() != Character::RightToLeft && - c2.GetCharacterDirection() != Character::RightToLeft && - c3.GetCharacterDirection() == Character::RightToLeft && - c4.GetCharacterDirection() == Character::RightToLeft ); - END_TEST; -} - -int UtcDaliGetCharacterDirection(void) -{ - tet_infoline("UtcDaliGetCharacterDirection "); - TestApplication application; - - Text text( std::string("Aבא ") ); - - Character c1 = text[0]; - Character c2 = text[1]; - Character c3 = text[2]; - Character c4 = text[3]; - - DALI_TEST_EQUALS( c1.GetCharacterDirection(), Character::LeftToRight, TEST_LOCATION ); - DALI_TEST_EQUALS( c2.GetCharacterDirection(), Character::RightToLeft, TEST_LOCATION ); - DALI_TEST_EQUALS( c3.GetCharacterDirection(), Character::RightToLeft, TEST_LOCATION ); - DALI_TEST_EQUALS( c4.GetCharacterDirection(), Character::Neutral, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliGetScript(void) -{ - tet_infoline("UtcDaliGetScript "); - TestApplication application; - - Text text( std::string("aᴆₘऄঅਅઅଅஅఅಅഅඅض") ); - - Character c0 = text[0]; - Character c1 = text[1]; - Character c2 = text[2]; - - DALI_TEST_EQUALS( c0.GetScript(), Character::LATIN, TEST_LOCATION ); - DALI_TEST_EQUALS( c1.GetScript(), Character::LATIN, TEST_LOCATION ); - DALI_TEST_EQUALS( c2.GetScript(), Character::LATIN, TEST_LOCATION ); - - - Character c3 = text[3]; - DALI_TEST_EQUALS( c3.GetScript(), Character::DEVANAGARI, TEST_LOCATION ); - - Character c4 = text[4]; - DALI_TEST_EQUALS( c4.GetScript(), Character::BENGALI, TEST_LOCATION ); - - Character c5 = text[5]; - DALI_TEST_EQUALS( c5.GetScript(), Character::GURMUKHI, TEST_LOCATION ); - - Character c6 = text[6]; - DALI_TEST_EQUALS( c6.GetScript(), Character::GUJARATI, TEST_LOCATION ); - - Character c7 = text[7]; - DALI_TEST_EQUALS( c7.GetScript(), Character::ORIYA, TEST_LOCATION ); - - Character c8 = text[8]; - DALI_TEST_EQUALS( c8.GetScript(), Character::TAMIL, TEST_LOCATION ); - - Character c9 = text[9]; - DALI_TEST_EQUALS( c9.GetScript(), Character::TELUGU, TEST_LOCATION ); - - Character c10 = text[10]; - DALI_TEST_EQUALS( c10.GetScript(), Character::KANNADA, TEST_LOCATION ); - - Character c11 = text[11]; - DALI_TEST_EQUALS( c11.GetScript(), Character::MALAYALAM, TEST_LOCATION ); - - Character c12 = text[12]; - DALI_TEST_EQUALS( c12.GetScript(), Character::SINHALA, TEST_LOCATION ); - - Character c13 = text[13]; - DALI_TEST_EQUALS( c13.GetScript(), Character::ARABIC, TEST_LOCATION ); - - // TODO : add more characters to cover all ranges. - END_TEST; -} - -int UtcDaliCharacterIsWhiteSpace(void) -{ - tet_infoline("UtcDaliCharacterIsWhiteSpace "); - TestApplication application; - - Text text( std::string("ab c\n\tdef") ); - - DALI_TEST_CHECK(!text[0].IsWhiteSpace()); // 'a' - DALI_TEST_CHECK(!text[1].IsWhiteSpace()); // 'b' - DALI_TEST_CHECK(text[2].IsWhiteSpace()); // ' ' - DALI_TEST_CHECK(!text[3].IsWhiteSpace()); // 'c' - DALI_TEST_CHECK(text[4].IsWhiteSpace()); // '\n' - DALI_TEST_CHECK(text[5].IsWhiteSpace()); // '\t' - DALI_TEST_CHECK(!text[6].IsWhiteSpace()); // 'd' - DALI_TEST_CHECK(!text[7].IsWhiteSpace()); // 'e' - DALI_TEST_CHECK(!text[8].IsWhiteSpace()); // 'f' - END_TEST; -} - -int UtcDaliCharacterIsNewLine(void) -{ - tet_infoline("UtcDaliCharacterIsWhiteSpace "); - TestApplication application; - - Text text( std::string("ab c\n\tdef") ); - - DALI_TEST_CHECK(!text[0].IsNewLine()); // 'a' - DALI_TEST_CHECK(!text[1].IsNewLine()); // 'b' - DALI_TEST_CHECK(!text[2].IsNewLine()); // ' ' - DALI_TEST_CHECK(!text[3].IsNewLine()); // 'c' - DALI_TEST_CHECK( text[4].IsNewLine()); // '\n' - DALI_TEST_CHECK(!text[5].IsNewLine()); // '\t' - DALI_TEST_CHECK(!text[6].IsNewLine()); // 'd' - DALI_TEST_CHECK(!text[7].IsNewLine()); // 'e' - DALI_TEST_CHECK(!text[8].IsNewLine()); // 'f' - END_TEST; -} diff --git a/automated-tests/src/dali/utc-Dali-Font.cpp b/automated-tests/src/dali/utc-Dali-Font.cpp deleted file mode 100644 index 1d1ea62..0000000 --- a/automated-tests/src/dali/utc-Dali-Font.cpp +++ /dev/null @@ -1,545 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -#include - -#include -#include -#include -#include - -using namespace Dali; - -void utc_dali_font_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_font_cleanup(void) -{ - test_return_value = TET_PASS; -} - -namespace -{ - -const std::string FAMILY_NAME = "Arial"; -const std::string STYLE = "Bold"; -const unsigned int PIXEL_SIZE = 20; -const unsigned int POINT_SIZE = 11.f; - -static Font CreateFont( PointSize size ) -{ - // Don't use a font which could be cached otherwise cached values will be used making measure text test to fail. - return Font::New(FontParameters("TET-FreeSans", "Book", size)); -} - -static Font CreateFont( PixelSize size ) -{ - // Don't use a font which could be cached otherwise cached values will be used making measure text test to fail. - return Font::New(FontParameters("TET-FreeSans", "Book", size)); -} - -static Font CreateFont( CapsHeight size ) -{ - // Don't use a font which could be cached otherwise cached values will be used making measure text test to fail. - return Font::New(FontParameters("TET-FreeSans", "Book", size)); -} - -} //anon namespace - -int UtcDaliFontNew01(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::New() - with specific font family and pixel size"); - - Font font; // invoke default constructor (creates an empty handle) - font = CreateFont(PixelSize(25.0f)); // This does not call platform abstraction until some text is displayed or measured - - DALI_TEST_CHECK(font); - - tet_infoline("Testing Dali::Font::New() - with default font name and pixel size"); - - Font font2 = Font::New(FontParameters("", "", PixelSize(0.0f))); - - DALI_TEST_CHECK(font2); - - Font* ptrFont = new Font; - *ptrFont = Font::New(FontParameters("", "", PixelSize(0.0f))); - delete ptrFont; - END_TEST; -} - -int UtcDaliFontNew02(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::New() - with specific font family and point size"); - - Font font = CreateFont(PointSize(8)); - - DALI_TEST_CHECK(font); - - tet_infoline("Testing Dali::Font::New() - with default font family and point size"); - - Font font2; - font2 = Font::New(FontParameters("", "", PointSize(0))); - - DALI_TEST_CHECK(font2); - END_TEST; -} - -int UtcDaliFontNew03(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::New() - with specific font family and caps-height"); - - Font font = CreateFont(CapsHeight(8)); - - DALI_TEST_CHECK(font); - DALI_TEST_CHECK(font.GetPixelSize() > 8.0f); // Pixel size should be bigger than requested CapsHeight - - tet_infoline("Testing Dali::Font::New() - with default font family and point size"); - - Font font2 = Font::New(FontParameters("", "", CapsHeight(0))); - - DALI_TEST_CHECK(font2); - END_TEST; -} - -int UtcDaliFontNew04(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::New() - with wrong font family or font style"); - - Font font = Font::New(FontParameters("gfagag", "fgafgafga",PointSize(0))); - - DALI_TEST_CHECK(font); - END_TEST; -} - -int UtcDaliFontNew05(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::New() - with pixel size and weight"); - - PixelSize pixelSize(PIXEL_SIZE); - FontParameters fontParams(FAMILY_NAME, "", pixelSize); - Font font = Font::New( fontParams ); - - DALI_TEST_CHECK( font ); - DALI_TEST_CHECK( font.GetName() == FAMILY_NAME ); - DALI_TEST_CHECK( font.GetStyle().empty() ); - END_TEST; -} - -int UtcDaliFontNew06(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::New() - with caps height"); - - CapsHeight capsHeight(10.f); - FontParameters fontParams(FAMILY_NAME, "", capsHeight); - Font font = Font::New( fontParams ); - - DALI_TEST_CHECK( font ); - DALI_TEST_CHECK( font.GetName() == FAMILY_NAME ); - DALI_TEST_CHECK( font.GetStyle().empty() ); - END_TEST; -} - - -int UtcDaliFontDownCast(void) -{ - TestApplication application; - tet_infoline("Testing Dali::Font::DownCast()"); - - Font font = CreateFont(PixelSize(25.0f)); - - BaseHandle object(font); - - Font font2 = Font::DownCast(object); - DALI_TEST_CHECK(font2); - - Font font3 = DownCast< Font >(object); - DALI_TEST_CHECK(font3); - - BaseHandle unInitializedObject; - Font font4 = Font::DownCast(unInitializedObject); - DALI_TEST_CHECK(!font4); - - Font font5 = DownCast< Font >(unInitializedObject); - DALI_TEST_CHECK(!font5); - END_TEST; -} - -int UtcDaliFontGetPixelSize(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::GetPixelSize()"); - - Font font = CreateFont(PixelSize(32)); - - DALI_TEST_CHECK(32 == font.GetPixelSize()); - END_TEST; -} - -int UtcDaliFontGetPointSize(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::GetPointSize)"); - - Font font = CreateFont(PointSize(8.0f)); - - DALI_TEST_EQUALS(8.f, font.GetPointSize(), Math::MACHINE_EPSILON_1000, TEST_LOCATION); - END_TEST; -} - -int UtcDaliFontPointsToPixels(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::PointsToPixels)"); - - unsigned int points= Font::PointsToPixels( 12.0f ); - - DALI_TEST_CHECK( points == 36 ); - END_TEST; -} - -int UtcFontMeasureTextWidth(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::MeasureTextWidth()"); - - TraceCallStack& trace = application.GetPlatform().GetTrace(); - trace.Enable(true); - - Font font = CreateFont(PointSize(8)); - - float width = font.MeasureTextWidth("test me", 24.0f); - - // No cache - - DALI_TEST_CHECK(trace.FindMethod("ReadMetricsFromCacheFile")); - DALI_TEST_CHECK(trace.FindMethod("WriteMetricsToCacheFile")); - DALI_TEST_CHECK(trace.FindMethod("GetGlyphData")); - trace.Reset(); - - DALI_TEST_EQUALS(width, 168.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); - width = font.MeasureTextWidth(Text(std::string("test me")), 24.0f); - - // Should now be cached in memory - DALI_TEST_CHECK( ! trace.FindMethod("ReadMetricsFromCacheFile")); - DALI_TEST_CHECK( ! trace.FindMethod("WriteMetricsToCacheFile")); - DALI_TEST_CHECK( ! trace.FindMethod("GetGlyphData")); - - DALI_TEST_EQUALS(width, 168.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); - - Text text = Text(std::string("t"))[0]; - Character c = text[0]; - width = font.MeasureTextWidth(c, 24.0f); - DALI_TEST_EQUALS(width, 24.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); - - END_TEST; -} - -int UtcFontMeasureTextHeight(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::MeasureTextHeight()"); - - TraceCallStack& trace = application.GetPlatform().GetTrace(); - trace.Enable(true); - - Font font = CreateFont(PointSize(8)); - - float height = font.MeasureTextHeight("test me", 48.0f); - - DALI_TEST_CHECK(trace.FindMethod("ReadMetricsFromCacheFile")); - DALI_TEST_CHECK(trace.FindMethod("WriteMetricsToCacheFile")); - DALI_TEST_CHECK(trace.FindMethod("GetGlyphData")); - trace.Reset(); - - DALI_TEST_EQUALS(height, 6.8571f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); - - height = font.MeasureTextHeight(Text(std::string("test me")), 48.0f); - - DALI_TEST_CHECK( ! trace.FindMethod("ReadMetricsFromCacheFile")); - DALI_TEST_CHECK( ! trace.FindMethod("WriteMetricsToCacheFile")); - DALI_TEST_CHECK( ! trace.FindMethod("GetGlyphData")); - - DALI_TEST_EQUALS(height, 6.8571f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); - - Text text = Text(std::string("t"))[0]; - Character c = text[0]; - height = font.MeasureTextHeight(c, 24.0f); - DALI_TEST_EQUALS(height, 24.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); - - END_TEST; -} - -int UtcFontMeasureText(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::MeasureText()"); - - TraceCallStack& trace = application.GetPlatform().GetTrace(); - trace.Enable(true); - - Font font = CreateFont(PointSize(8)); - - Vector3 size = font.MeasureText("test me"); - - DALI_TEST_CHECK(trace.FindMethod("ReadMetricsFromCacheFile")); - DALI_TEST_CHECK(trace.FindMethod("WriteMetricsToCacheFile")); - DALI_TEST_CHECK(trace.FindMethod("GetGlyphData")); - trace.Reset(); - - DALI_TEST_EQUALS(size.width, 53.1076f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); - DALI_TEST_EQUALS(size.height, 7.5868f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); - - size = font.MeasureText(Text(std::string("test me"))); - - DALI_TEST_CHECK( ! trace.FindMethod("ReadMetricsFromCacheFile")); - DALI_TEST_CHECK( ! trace.FindMethod("WriteMetricsToCacheFile")); - DALI_TEST_CHECK( ! trace.FindMethod("GetGlyphData")); - - DALI_TEST_EQUALS(size.width, 53.1076f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); - DALI_TEST_EQUALS(size.height, 7.5868f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); - - - Character c = Text(std::string("t"))[0]; - size = font.MeasureText(c); - - // character size is square - DALI_TEST_EQUALS(size.width, 7.5868f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); - DALI_TEST_EQUALS(size.height, 7.5868f, Math::MACHINE_EPSILON_1000, TEST_LOCATION); - - END_TEST; -} - -int UtcFontGetFamilyForText(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::GetFamilyForText()"); - - std::string latinFont = Font::GetFamilyForText("Hello world"); - DALI_TEST_CHECK( latinFont.size() != 0 ); - - latinFont = Font::GetFamilyForText( Text(std::string("Hello world")) ); - DALI_TEST_CHECK( latinFont.size() != 0 ); - - std::string asianFont = Font::GetFamilyForText("繁體中文"); - DALI_TEST_CHECK( asianFont.size() != 0 ); - - asianFont = Font::GetFamilyForText(Text(std::string("繁體中文"))); - DALI_TEST_CHECK( asianFont.size() != 0 ); - - Text text = Text(std::string("繁體中文"))[0]; - Character c = text[0]; - - asianFont = Font::GetFamilyForText(c ); - DALI_TEST_CHECK( asianFont.size() != 0 ); - - END_TEST; -} - -int UtcFontGetFontLineHeightFromCapsHeight(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::GetLineHeightFromCapsHeight()"); - - CapsHeight capsHeight(10); - PixelSize pixelSize = Font::GetLineHeightFromCapsHeight("", "", capsHeight); - DALI_TEST_CHECK( capsHeight < pixelSize ); - - pixelSize = Font::GetLineHeightFromCapsHeight(Font::GetFamilyForText("Hello world"), "", capsHeight); - DALI_TEST_CHECK( capsHeight < pixelSize ); - - pixelSize = Font::GetLineHeightFromCapsHeight(Font::GetFamilyForText(Text(std::string("Hello world"))), "", capsHeight); - DALI_TEST_CHECK( capsHeight < pixelSize ); - END_TEST; -} - -int UtcFontAllGlyphsSupported(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::AllGlyphsSupported()"); - - Font font = Font::New(); - - font.AllGlyphsSupported("Hello World\n"); - - DALI_TEST_CHECK(application.GetPlatform().WasCalled(TestPlatformAbstraction::AllGlyphsSupportedFunc)); - application.GetPlatform().ResetTrace(); - - font.AllGlyphsSupported(Text(std::string("Hello World\n"))); - - DALI_TEST_CHECK(application.GetPlatform().WasCalled(TestPlatformAbstraction::AllGlyphsSupportedFunc)); - - application.GetPlatform().ResetTrace(); - - Character c = Text(std::string("t"))[0]; - font.AllGlyphsSupported(c); - - DALI_TEST_CHECK(application.GetPlatform().WasCalled(TestPlatformAbstraction::AllGlyphsSupportedFunc)); - END_TEST; -} - -int UtcFontGetMetrics(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::UtcFontGetMetrics()"); - - Font font = Font::New(); - font.MeasureText(Text(std::string("Hello World"))); // Builds fake metrics in TestPlatformAbstraction. - - float lineHeight = font.GetLineHeight(); - float ascender = font.GetAscender(); - float underlineThickness = font.GetUnderlineThickness(); - float underlinePosition = font.GetUnderlinePosition(); - Font::Metrics metrics = font.GetMetrics( Text("H")[0] ); - - // TODO VCC This TET case fails if there are some metrics cached. - - DALI_TEST_EQUALS( lineHeight, 11.380209f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( ascender, 10.242188f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( underlineThickness, 2.276042f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( underlinePosition, 9.104167f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( metrics.GetAdvance(), 11.380209f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( metrics.GetBearing(), 10.242188f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( metrics.GetWidth(), 11.380209f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - END_TEST; -} - -int UtcFontIsDefault(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::UtcFontIsDefault()"); - - FontParameters fontParams("FreeSans", "", PointSize(10.f)); - Font font1 = Font::New(fontParams); - - DALI_TEST_CHECK( !font1.IsDefaultSystemFont() ); - DALI_TEST_CHECK( !font1.IsDefaultSystemSize() ); - - DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::ValidateFontFamilyNameFunc ) ); - application.GetPlatform().ResetTrace(); - - Font font2 = Font::New(); - - DALI_TEST_CHECK( !font2.IsDefaultSystemFont() ); - DALI_TEST_CHECK( font2.IsDefaultSystemSize() ); - - DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::ValidateFontFamilyNameFunc ) ); - END_TEST; -} - - -int UtcFontGetInstalledFonts(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::Font::GetInstalledFonts()"); - - // the default should only get installed and downloaded fonts - std::vector fontList; - - fontList = Font::GetInstalledFonts(Font::LIST_SYSTEM_FONTS); - DALI_TEST_CHECK( application.GetPlatform().WasCalled( TestPlatformAbstraction::ValidateGetFontListFunc ) ); - DALI_TEST_CHECK( application.GetPlatform().GetLastFontListMode() == Dali::Integration::PlatformAbstraction::LIST_SYSTEM_FONTS ); - - fontList = Font::GetInstalledFonts(Font::LIST_ALL_FONTS); - DALI_TEST_CHECK( application.GetPlatform().GetLastFontListMode() == Dali::Integration::PlatformAbstraction::LIST_ALL_FONTS ); - - fontList = Font::GetInstalledFonts(Font::LIST_APPLICATION_FONTS); - DALI_TEST_CHECK( application.GetPlatform().GetLastFontListMode() == Dali::Integration::PlatformAbstraction::LIST_APPLICATION_FONTS ); - - END_TEST; -} - -int UtcFontMetricsDefaultConstructor(void) -{ - TestApplication application; - - tet_infoline("Testing UtcFontMetricsDefaultConstructor"); - - Font::Metrics metrics; - - DALI_TEST_EQUALS( metrics.GetAdvance() , 0.f , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - DALI_TEST_EQUALS( metrics.GetBearing() , 0.f , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - DALI_TEST_EQUALS( metrics.GetWidth() , 0.f , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - DALI_TEST_EQUALS( metrics.GetHeight() , 0.f , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - - END_TEST; -} - -int UtcFontMetricsCopyConstructor(void) -{ - TestApplication application; - - tet_infoline("Testing UtcFontMetricsCopyConstructor"); - - Font font = Font::New(); - font.MeasureText(Text(std::string("Hello World"))); // Builds fake metrics in TestPlatformAbstraction. - Font::Metrics metrics = font.GetMetrics( Text("H")[0] ); - Font::Metrics metrics2( metrics ); - - DALI_TEST_EQUALS( metrics.GetAdvance() , metrics2.GetAdvance() , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - DALI_TEST_EQUALS( metrics.GetBearing() , metrics2.GetBearing(), Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - DALI_TEST_EQUALS( metrics.GetWidth() , metrics2.GetWidth() , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - DALI_TEST_EQUALS( metrics.GetHeight() , metrics2.GetHeight(), Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - - END_TEST; -} - -int UtcFontMetricsAssignmentOperator(void) -{ - TestApplication application; - - tet_infoline("Testing UtcFontMetricsAssignmentOperator"); - - Font font = Font::New(); - font.MeasureText(Text(std::string("Hello World"))); // Builds fake metrics in TestPlatformAbstraction. - Font::Metrics metrics = font.GetMetrics( Text("H")[0] ); - Font::Metrics metrics2; - - metrics2 = metrics; - - DALI_TEST_EQUALS( metrics.GetAdvance() , metrics2.GetAdvance() , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - DALI_TEST_EQUALS( metrics.GetBearing() , metrics2.GetBearing(), Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - DALI_TEST_EQUALS( metrics.GetWidth() , metrics2.GetWidth() , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - DALI_TEST_EQUALS( metrics.GetHeight() , metrics2.GetHeight(), Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - - END_TEST; -} diff --git a/automated-tests/src/dali/utc-Dali-FontParameters.cpp b/automated-tests/src/dali/utc-Dali-FontParameters.cpp deleted file mode 100644 index fc80f91..0000000 --- a/automated-tests/src/dali/utc-Dali-FontParameters.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -#include - -#include -#include -#include - -#include - -using namespace Dali; - -void utc_dali_font_parameters_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_font_parameters_cleanup(void) -{ - test_return_value = TET_PASS; -} - -namespace -{ - -const std::string FAMILY_NAME = "Arial"; -const std::string STYLE = "Bold"; -const unsigned int PIXEL_SIZE = 20; -const unsigned int POINT_SIZE = 11.f; - -} // anon namespace - - -int UtcDaliFontParamsDefaultConstructor(void) -{ - TestApplication application; - tet_infoline("Testing UtcDaliFontParamsDefaultConstructor"); - FontParameters params; - - DALI_TEST_CHECK(params.GetFamilyName() == "" ); - DALI_TEST_CHECK(params.GetStyle() == "" ); - DALI_TEST_EQUALS( float(params.GetSize()) , 0.f , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliFontParamsPointSizeConstructor(void) -{ - TestApplication application; - tet_infoline("Testing UtcDaliFontParamsPointSizeConstructor"); - - PointSize pointSize( POINT_SIZE ); - FontParameters params( FAMILY_NAME, STYLE, pointSize); - - DALI_TEST_CHECK(params.GetFamilyName() == FAMILY_NAME ); - DALI_TEST_CHECK(params.GetStyle() == STYLE ); - DALI_TEST_EQUALS( float(params.GetSize()), float(pointSize), Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliFontParamsPixelSizeConstructor(void) -{ - TestApplication application; - tet_infoline("Testing UtcDaliFontParamsPixelSizeConstructor"); - - PixelSize pixelSize( PIXEL_SIZE ); - FontParameters params( FAMILY_NAME, STYLE, pixelSize); - - DALI_TEST_CHECK(params.GetFamilyName() == FAMILY_NAME ); - DALI_TEST_CHECK(params.GetStyle() == STYLE ); - DALI_TEST_EQUALS( float(params.GetSize()), Font::PixelsToPoints( PIXEL_SIZE ) , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliFontParamsCopyConstructor(void) -{ - TestApplication application; - tet_infoline("Testing UtcDaliFontParamsCopyConstructor"); - PixelSize pixelSize( PIXEL_SIZE ); - FontParameters params( FAMILY_NAME, STYLE, pixelSize); - - - FontParameters params2( params ); - DALI_TEST_CHECK(params2.GetFamilyName() == FAMILY_NAME ); - DALI_TEST_CHECK(params2.GetStyle() == STYLE ); - DALI_TEST_EQUALS( float(params2.GetSize()), Font::PixelsToPoints( PIXEL_SIZE ) , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliFontParamsAssignmentOperator(void) -{ - TestApplication application; - tet_infoline("Testing UtcDaliFontParamsAssignmentOperator"); - PixelSize pixelSize( PIXEL_SIZE ); - FontParameters params( FAMILY_NAME, STYLE, pixelSize); - - FontParameters params2; - params2 = params; - DALI_TEST_CHECK(params2.GetFamilyName() == FAMILY_NAME ); - DALI_TEST_CHECK(params2.GetStyle() == STYLE ); - DALI_TEST_EQUALS( float(params2.GetSize()) ,Font::PixelsToPoints( PIXEL_SIZE ) , Math::MACHINE_EPSILON_10000, TEST_LOCATION ); - - // for coverage self assignment - params2 = params2; - DALI_TEST_CHECK(params2.GetFamilyName() == FAMILY_NAME ); - - END_TEST; -} - -int UtcDaliFontParamsPointSizeEqualityOperator(void) -{ - TestApplication application; - tet_infoline("Testing UtcDaliFontParamsPixelSizeConstructor"); - PointSize pointSize1(1.f); - PointSize pointSize2(2.f); - DALI_TEST_CHECK( pointSize1 != pointSize2 ); - - END_TEST; -} diff --git a/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp b/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp index efd4e34..cc8bc40 100644 --- a/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp +++ b/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp @@ -1244,7 +1244,7 @@ int UtcDaliHoverStencil(void) TestApplication application; Stage stage = Stage::GetCurrent(); - TextActor actor = TextActor::New(); + Actor actor = ImageActor::New(); actor.SetSize(100.0f, 100.0f); actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); stage.Add(actor); @@ -1282,12 +1282,12 @@ int UtcDaliHoverStencilInActorHierarchy(void) TestApplication application; Stage stage = Stage::GetCurrent(); - TextActor parent = TextActor::New(); + ImageActor parent = ImageActor::New(); parent.SetSize(100.0f, 100.0f); parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); stage.Add(parent); - TextActor child = TextActor::New(); + ImageActor child = ImageActor::New(); child.SetSize(25.0f, 25.0f); child.SetAnchorPoint(AnchorPoint::TOP_LEFT); parent.Add(child); @@ -1368,7 +1368,7 @@ int UtcDaliHoverMultipleStencils(void) TestApplication application; Stage stage = Stage::GetCurrent(); - TextActor actor = TextActor::New(); + ImageActor actor = ImageActor::New(); actor.SetSize(100.0f, 100.0f); actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); stage.Add(actor); diff --git a/automated-tests/src/dali/utc-Dali-ImageActor.cpp b/automated-tests/src/dali/utc-Dali-ImageActor.cpp index 5b7d430..95a4a15 100644 --- a/automated-tests/src/dali/utc-Dali-ImageActor.cpp +++ b/automated-tests/src/dali/utc-Dali-ImageActor.cpp @@ -182,7 +182,7 @@ int UtcDaliImageActorSetSize01(void) BitmapImage img = BitmapImage::New( 1,1 ); ImageActor actor = ImageActor::New( img ); - ShaderEffect effect = ShaderEffect::New( " ", " ", " ", " ", ShaderEffect::HINT_GRID ); + ShaderEffect effect = ShaderEffect::New( " ", " ", GEOMETRY_TYPE_IMAGE, ShaderEffect::HINT_GRID ); actor.SetShaderEffect( effect ); const float INVALID_SIZE = float(1u<<31); diff --git a/automated-tests/src/dali/utc-Dali-Layer.cpp b/automated-tests/src/dali/utc-Dali-Layer.cpp index 82ca140..4fa7fe1 100644 --- a/automated-tests/src/dali/utc-Dali-Layer.cpp +++ b/automated-tests/src/dali/utc-Dali-Layer.cpp @@ -547,8 +547,8 @@ int UtcDaliLayerClippingGLCalls(void) layer.SetClippingBox( testBox ); // Add at least one renderable actor so the GL calls are actually made - Actor textActor = TextActor::New("Hello"); - stage.Add( textActor ); + Actor actor = ImageActor::New(); + stage.Add( actor ); // flush the queue and render once application.SendNotification(); diff --git a/automated-tests/src/dali/utc-Dali-RenderableActor.cpp b/automated-tests/src/dali/utc-Dali-RenderableActor.cpp index 63830e8..6b0441e 100644 --- a/automated-tests/src/dali/utc-Dali-RenderableActor.cpp +++ b/automated-tests/src/dali/utc-Dali-RenderableActor.cpp @@ -38,7 +38,6 @@ void renderable_actor_cleanup(void) namespace { -static const char* TestTextHelloWorld = "Hello World"; static bool gIsActor1SortModifierCorrect; static bool gIsActor2SortModifierCorrect; const float gActor1SortModifierValue = 96.0f; @@ -63,10 +62,10 @@ int UtcDaliRenderableActorDownCast(void) tet_infoline("Testing Dali::RenderableActor::DownCast()"); - TextActor textActor = TextActor::New(TestTextHelloWorld); + ImageActor imageActor = ImageActor::New(); Actor anActor = Actor::New(); - anActor.Add( textActor ); + anActor.Add( imageActor ); Actor child = anActor.GetChildAt(0); RenderableActor renderableActor = RenderableActor::DownCast( child ); @@ -98,7 +97,7 @@ int UtcDaliRenderableActorSetSortModifier(void) float val = -500.0f; - TextActor actor = TextActor::New(TestTextHelloWorld); + ImageActor actor = ImageActor::New(); Stage::GetCurrent().Add(actor); actor.SetSortModifier( val ); @@ -149,7 +148,7 @@ int UtcDaliRenderableActorGetSortModifier(void) tet_infoline("Testing Dali::RenderableActor::GetSortModifier()"); - TextActor actor = TextActor::New(TestTextHelloWorld); + ImageActor actor = ImageActor::New(); Stage::GetCurrent().Add(actor); DALI_TEST_EQUALS(actor.GetSortModifier(), 0.0f, TEST_LOCATION); @@ -164,7 +163,7 @@ int UtcDaliRenderableActorSetGetBlendMode(void) tet_infoline("Testing Dali::RenderableActor::SetBlendMode() / Dali::RenderableActor::GetBlendMode()"); - TextActor actor = TextActor::New(TestTextHelloWorld); + ImageActor actor = ImageActor::New(); actor.SetBlendMode( BlendingMode::OFF ); DALI_TEST_CHECK( BlendingMode::OFF == actor.GetBlendMode() ); @@ -300,10 +299,6 @@ int UtcDaliRenderableActorGetCullFace(void) tet_infoline("Testing Dali::RenderableActor::GetCullFace()"); - TextActor textActor = TextActor::New(TestTextHelloWorld); - - DALI_TEST_CHECK( CullNone == textActor.GetCullFace() ); - ImageActor imageActor = ImageActor::New(); DALI_TEST_CHECK( CullNone == imageActor.GetCullFace() ); @@ -508,7 +503,7 @@ int UtcDaliRenderableActorSetGetFilterModes(void) tet_infoline("Testing Dali::RenderableActor::SetFilterMode() / Dali::RenderableActor::GetFilterMode()"); - TextActor actor = TextActor::New(TestTextHelloWorld); + ImageActor actor = ImageActor::New(); FilterMode::Type minifyFilter = FilterMode::NEAREST; FilterMode::Type magnifyFilter = FilterMode::NEAREST; @@ -776,7 +771,7 @@ int UtcDaliRenderableActorSetShaderEffect(void) int UtcDaliRenderableActorGetShaderEffect(void) { TestApplication application; - TextActor actor = TextActor::New(); + ImageActor actor = ImageActor::New(); ShaderEffect effect = ShaderEffect::New("UtcDaliRenderableActorGetShaderEffect-VertexSource", "UtcDaliRenderableActorGetShaderEffect-FragmentSource" ); actor.SetShaderEffect(effect); @@ -788,7 +783,7 @@ int UtcDaliRenderableActorGetShaderEffect(void) int UtcDaliRenderableActorRemoveShaderEffect01(void) { TestApplication application; - TextActor actor = TextActor::New(); + ImageActor actor = ImageActor::New(); ShaderEffect defaultEffect = actor.GetShaderEffect(); @@ -806,7 +801,7 @@ int UtcDaliRenderableActorRemoveShaderEffect01(void) int UtcDaliRenderableActorRemoveShaderEffect02(void) { TestApplication application; - TextActor actor = TextActor::New(); + ImageActor actor = ImageActor::New(); ShaderEffect defaultEffect = actor.GetShaderEffect(); @@ -823,8 +818,8 @@ int UtcDaliSetShaderEffectRecursively(void) * create a tree * actor1 * actor2 actor4 - * actor3 textactor - * imageactor + * actor3 imageactor1 + * imageactor2 */ BitmapImage img = BitmapImage::New( 1,1 ); ImageActor actor1 = ImageActor::New( img ); @@ -832,10 +827,10 @@ int UtcDaliSetShaderEffectRecursively(void) actor1.Add( actor2 ); Actor actor3 = Actor::New(); actor2.Add( actor3 ); - TextActor textactor = TextActor::New( "Foo" ); - actor2.Add( textactor ); - ImageActor imageactor = ImageActor::New( img ); - actor3.Add( imageactor ); + ImageActor imageactor1 = ImageActor::New( img ); + actor2.Add( imageactor1 ); + ImageActor imageactor2 = ImageActor::New( img ); + actor3.Add( imageactor2 ); Actor actor4 = Actor::New(); actor1.Add( actor4 ); Stage::GetCurrent().Add( actor1 ); @@ -856,12 +851,12 @@ int UtcDaliSetShaderEffectRecursively(void) effect = ShaderEffect::New(vertexShader, fragmentShader ); DALI_TEST_CHECK( effect != actor1.GetShaderEffect() ); - DALI_TEST_CHECK( effect != textactor.GetShaderEffect() ); - DALI_TEST_CHECK( effect != imageactor.GetShaderEffect() ); + DALI_TEST_CHECK( effect != imageactor1.GetShaderEffect() ); + DALI_TEST_CHECK( effect != imageactor2.GetShaderEffect() ); SetShaderEffectRecursively( actor1, effect ); - DALI_TEST_CHECK( effect == textactor.GetShaderEffect() ); - DALI_TEST_CHECK( effect == imageactor.GetShaderEffect() ); + DALI_TEST_CHECK( effect == imageactor1.GetShaderEffect() ); + DALI_TEST_CHECK( effect == imageactor2.GetShaderEffect() ); // flush the queue and render once application.SendNotification(); @@ -882,8 +877,8 @@ int UtcDaliSetShaderEffectRecursively(void) // remove partially RemoveShaderEffectRecursively( actor3 ); - DALI_TEST_CHECK( effect == textactor.GetShaderEffect() ); - DALI_TEST_CHECK( effect != imageactor.GetShaderEffect() ); + DALI_TEST_CHECK( effect == imageactor1.GetShaderEffect() ); + DALI_TEST_CHECK( effect != imageactor2.GetShaderEffect() ); // test with empty actor just to check it does not crash Actor empty; diff --git a/automated-tests/src/dali/utc-Dali-ShaderEffect.cpp b/automated-tests/src/dali/utc-Dali-ShaderEffect.cpp index ba2a30e..d6480dc 100644 --- a/automated-tests/src/dali/utc-Dali-ShaderEffect.cpp +++ b/automated-tests/src/dali/utc-Dali-ShaderEffect.cpp @@ -150,15 +150,6 @@ int UtcDaliShaderEffectMethodNew02(void) END_TEST; } -int UtcDaliShaderEffectMethodNew03(void) -{ - TestApplication application; - - ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource, VertexSource, FragmentSource, ShaderEffect::HINT_NONE ); - DALI_TEST_CHECK(effect); - END_TEST; -} - int UtcDaliShaderEffectMethodNew04(void) { TestApplication application; @@ -233,21 +224,6 @@ int UtcDaliShaderEffectMethodNew05(void) END_TEST; } -int UtcDaliShaderEffectMethodNew06(void) -{ - TestApplication application; - tet_infoline("Testing Dali::ShaderEffect::New() with shader sources for different geometry types"); - - ShaderEffect effect = ShaderEffect::New( "imageVertexShader", "imageFragmentShader", - "textVertexShader", "textFragmentShader", - "texturedMeshVertexShader", "texturedMeshFragmentShader", - "meshVertexShader", "meshFragmentShader", - ShaderEffect::HINT_NONE ); - DALI_TEST_CHECK(effect); - END_TEST; -} - - int UtcDaliShaderEffectMethodDownCast(void) { TestApplication application; diff --git a/automated-tests/src/dali/utc-Dali-Text.cpp b/automated-tests/src/dali/utc-Dali-Text.cpp deleted file mode 100644 index e9ebb97..0000000 --- a/automated-tests/src/dali/utc-Dali-Text.cpp +++ /dev/null @@ -1,503 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -#include - -#include -#include -#include - -using namespace Dali; - -void utc_dali_text_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_text_cleanup(void) -{ - test_return_value = TET_PASS; -} - -int UtcDaliTextConstructor(void) -{ - TestApplication application; - - Text text; - - DALI_TEST_CHECK( text.IsEmpty() ); - - Text someEmptyText1( "" ); - - DALI_TEST_CHECK( someEmptyText1.IsEmpty() ); - - Text someEmptyText2( std::string( "" ) ); - - DALI_TEST_CHECK( someEmptyText2.IsEmpty() ); - - Text someEmptyText3( text ); - - DALI_TEST_CHECK( someEmptyText3.IsEmpty() ); - - Text someText1( "Some text" ); - - DALI_TEST_CHECK( !someText1.IsEmpty() ); - - Text someText2( std::string( "Some text" ) ); - - DALI_TEST_CHECK( !someText2.IsEmpty() ); - - Text someText3( Text( std::string( "Some text" ) ) ); - - DALI_TEST_CHECK( !someText3.IsEmpty() ); - - Character c = someText1[0]; - - Text cText( c ); - - DALI_TEST_CHECK( !cText.IsEmpty() ); - END_TEST; -} - -int UtcDaliTextCopyConstructor(void) -{ - TestApplication application; - - Text someText1( std::string( "Some text1" ) ); - Text someText2( std::string( "Some text2" ) ); - - Text someText3( someText1 ); - Text someText4 = someText2; - - DALI_TEST_CHECK( (someText1.GetText()==someText3.GetText()) && (someText2.GetText()==someText4.GetText()) ); - END_TEST; -} - -int UtcDaliTextAssignmentOperator(void) -{ - TestApplication application; - - // check for assignment when current is NULL - - Text someText1( std::string( "Some text1" ) ); - Text someText2; - someText2 = someText1; - - DALI_TEST_CHECK( (someText1.GetText()==someText2.GetText()) ); - - // check for assignment when current object already has text - Text someText3( std::string( "Some text3" ) ); - someText2 = someText3; - DALI_TEST_CHECK( (someText3.GetText()==someText2.GetText()) ); - - Text someText4; - - // check for assignment of empty text - someText2 = someText4; - DALI_TEST_CHECK( someText2.IsEmpty() ); - - // check for self assignment - someText3 = someText3; - DALI_TEST_CHECK( ! someText3.IsEmpty() ); - - - END_TEST; -} - -int UtcDaliTextSetGetText(void) -{ - TestApplication application; - - const char* someText = "Some text"; - const std::string someText2( "Some text2" ); - - Text text; - text.SetText( someText ); - - DALI_TEST_EQUALS( someText, text.GetText(), TEST_LOCATION ); - - text.SetText( someText2 ); - - DALI_TEST_EQUALS( someText2, text.GetText(), TEST_LOCATION ); - - Character c = text[0]; - text.SetText( c ); - - DALI_TEST_EQUALS( std::string( "S" ), text.GetText(), TEST_LOCATION ); - - Text text2; - text2.SetText( text ); - - DALI_TEST_EQUALS( text2.GetText(), text.GetText(), TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextAccessOperator01(void) -{ - TestApplication application; - - std::string someText; - - Text text; - text.SetText( someText ); - - bool assert1 = false; - bool assert2 = false; - try - { - Character c = text[0]; - } - catch( DaliException& e ) - { - tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "NULL != mImpl && \"Text::operator[]: Text is uninitialized\"", TEST_LOCATION ); - - assert1 = true; - } - - someText = std::string( "some text" ); - text.SetText( someText ); - - try - { - Character c = text[100]; - } - catch( DaliException& e ) - { - tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "position < mString.Count() && \"Text::operator[]: Character position is out of bounds\"", TEST_LOCATION ); - - assert2 = true; - } - - if( assert1 && assert2 ) - { - tet_result( TET_PASS ); - } - else - { - tet_result( TET_FAIL ); - } - END_TEST; -} - -int UtcDaliTextAccessOperator02(void) -{ - TestApplication application; - - const std::string someText( "Some text"); - - Text text; - text.SetText( someText ); - - DALI_TEST_CHECK( someText == text.GetText() ); - - Character c = text[0]; - text.SetText( c ); - - DALI_TEST_CHECK( std::string("S") == text.GetText() ); - END_TEST; -} - -int UtcDaliTextIsEmpty(void) -{ - TestApplication application; - - Text text; - - DALI_TEST_CHECK( text.IsEmpty() ); - - text.SetText( std::string( "Some text") ); - - DALI_TEST_CHECK( !text.IsEmpty() ); - END_TEST; -} - -int UtcDaliTextGetLength(void) -{ - TestApplication application; - - const std::string someText( "Some text"); - - Text text( someText ); - - DALI_TEST_CHECK( someText.size() == text.GetLength() ); - END_TEST; -} - -int UtcDaliTextAppend(void) -{ - TestApplication application; - - Text text( std::string( "Some text") ); - - text.Append( "A" ); - - DALI_TEST_CHECK( std::string( "Some textA" ) == text.GetText() ); - - text.Append( std::string( "B" ) ); - - DALI_TEST_CHECK( std::string( "Some textAB" ) == text.GetText() ); - - Character c = text[0]; - text.Append( c ); - - DALI_TEST_CHECK( std::string( "Some textABS" ) == text.GetText() ); - - Text text2( std::string("C") ); - text.Append( text2 ); - - DALI_TEST_CHECK( std::string( "Some textABSC" ) == text.GetText() ); - - // append to a null text - - Text emptyText; - emptyText.Append( text2 ); - DALI_TEST_CHECK( text2.GetText() == emptyText.GetText() ); - - // append a null text - - Text emptyText2; - emptyText.Append( emptyText2 ); - DALI_TEST_CHECK( text2.GetText() == emptyText.GetText() ); - - END_TEST; -} - -int UtcDaliTextRemove01(void) -{ - TestApplication application; - - Text text( std::string( "Some text") ); - - bool assert1 = false; - bool assert2 = false; - bool assert3 = false; - - try - { - text.Remove( 100, 3 ); - } - catch( DaliException& e ) - { - tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "position < mString.Count() && \"Text::Remove: Character position is out of bounds\"", TEST_LOCATION ); - assert1 = true; - } - - try - { - text.Remove( 1, 300 ); - } - catch( DaliException& e ) - { - tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "position + numberOfCharacters <= mString.Count() && \"Text::Remove: Character position + numberOfCharacters is out of bounds\"", TEST_LOCATION ); - assert2 = true; - } - - try - { - text.SetText( std::string( "" ) ); - text.Remove( 1, 300 ); - } - catch( DaliException& e ) - { - tet_printf( "Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str() ); - DALI_TEST_EQUALS( e.mCondition, "NULL != mImpl && \"Text::Remove: Text is uninitialized\"", TEST_LOCATION ); - assert3 = true; - } - - if( assert1 && assert2 && assert3 ) - { - tet_result( TET_PASS ); - } - else - { - tet_result( TET_FAIL ); - } - END_TEST; -} - -int UtcDaliTextRemove02(void) -{ - TestApplication application; - - Text text01( std::string( "Some text") ); - Text text02( std::string( "Somext") ); - Text text03( std::string( "" ) ); - Text text04( std::string( "Hello world" ) ); - Text text05( std::string( "world" ) ); - - text01.Remove( 3u, 3u ); - - DALI_TEST_EQUALS( text01.GetLength(), text02.GetLength(), TEST_LOCATION ); - DALI_TEST_EQUALS( text01.GetText(), text02.GetText(), TEST_LOCATION ); - - text01.Remove( 0u, 0u ); - - DALI_TEST_EQUALS( text01.GetLength(), text02.GetLength(), TEST_LOCATION ); - DALI_TEST_EQUALS( text01.GetText(), text02.GetText(), TEST_LOCATION ); - - text01.Remove( 0u, 6u ); - - DALI_TEST_EQUALS( text01.GetLength(), text03.GetLength(), TEST_LOCATION ); - DALI_TEST_EQUALS( text01.GetText(), text03.GetText(), TEST_LOCATION ); - - text04.Remove( 0u, 6u ); - - DALI_TEST_EQUALS( text04.GetLength(), text05.GetLength(), TEST_LOCATION ); - DALI_TEST_EQUALS( text04.GetText(), text05.GetText(), TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextFind(void) -{ - TestApplication application; - - Text text; - Character c1 = Text( std::string( "c" ) )[0u]; - Character c2 = Text( std::string( "o" ) )[0u]; - Vector positions; - - // Find in void text. - - positions.Clear(); - text.Find( c1, 0u, 0u, positions ); - DALI_TEST_EQUALS( positions.Count(), 0u, TEST_LOCATION ); - - positions.Clear(); - text.Find( Text::WHITE_SPACE, 0u, 0u, positions ); - DALI_TEST_EQUALS( positions.Count(), 0u, TEST_LOCATION ); - - positions.Clear(); - text.Find( Text::NEW_LINE, 0u, 0u, positions ); - DALI_TEST_EQUALS( positions.Count(), 0u, TEST_LOCATION ); - - // Find in text. - - // Find 'c' and 'o' - text.SetText( std::string( "Hello world" ) ); - - positions.Clear(); - text.Find( c1, 0u, 11u, positions ); - DALI_TEST_EQUALS( positions.Count(), 0u, TEST_LOCATION ); - - positions.Clear(); - text.Find( c2, 0u, 11u, positions ); - DALI_TEST_EQUALS( positions.Count(), 2u, TEST_LOCATION ); - DALI_TEST_EQUALS( positions[0u], 4u, TEST_LOCATION ); - DALI_TEST_EQUALS( positions[1u], 7u, TEST_LOCATION ); - - // Find white space - text.SetText( std::string( " Hello world \n" ) ); - - positions.Clear(); - text.Find( Text::WHITE_SPACE, 0u, 17u, positions ); - DALI_TEST_EQUALS( positions.Count(), 8u, TEST_LOCATION ); - DALI_TEST_EQUALS( positions[0u], 0u, TEST_LOCATION ); - DALI_TEST_EQUALS( positions[1u], 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( positions[2u], 2u, TEST_LOCATION ); - DALI_TEST_EQUALS( positions[3u], 8u, TEST_LOCATION ); - DALI_TEST_EQUALS( positions[4u], 9u, TEST_LOCATION ); - DALI_TEST_EQUALS( positions[5u], 15u, TEST_LOCATION ); - DALI_TEST_EQUALS( positions[6u], 16u, TEST_LOCATION ); - DALI_TEST_EQUALS( positions[7u], 17u, TEST_LOCATION ); - - // Find new line character - text.SetText( std::string( "\n\nHello\nworld\n\n" ) ); - - positions.Clear(); - text.Find( Text::NEW_LINE, 0u, 14u, positions ); - DALI_TEST_EQUALS( positions.Count(), 5u, TEST_LOCATION ); - DALI_TEST_EQUALS( positions[0u], 0u, TEST_LOCATION ); - DALI_TEST_EQUALS( positions[1u], 1u, TEST_LOCATION ); - DALI_TEST_EQUALS( positions[2u], 7u, TEST_LOCATION ); - DALI_TEST_EQUALS( positions[3u], 13u, TEST_LOCATION ); - DALI_TEST_EQUALS( positions[4u], 14u, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextGetSubText(void) -{ - TestApplication application; - - Text text; - Text subText; - - // Get sub-text from a void text. - - subText.SetText( "Hello" ); - text.GetSubText( 0u, 1u, subText ); - DALI_TEST_EQUALS( subText.GetText(), std::string( "Hello" ), TEST_LOCATION ); - - // Get sub-text. - - text.SetText( std::string( "Hello world" ) ); - - // Access out of bounds - subText.SetText( "Hello" ); - text.GetSubText( 30u, 31u, subText ); - DALI_TEST_EQUALS( subText.GetText(), std::string( "Hello" ), TEST_LOCATION ); - text.GetSubText( 0u, 31u, subText ); - DALI_TEST_EQUALS( subText.GetText(), std::string( "Hello" ), TEST_LOCATION ); - text.GetSubText( 30u, 1u, subText ); - DALI_TEST_EQUALS( subText.GetText(), std::string( "Hello" ), TEST_LOCATION ); - - // Check it swaps the indices. - text.GetSubText( 8u, 2u, subText ); - DALI_TEST_EQUALS( subText.GetText(), std::string( "row oll" ), TEST_LOCATION ); - - // Normal access. - subText.SetText( std::string( "" ) ); - text.GetSubText( 4u, 6u, subText ); - DALI_TEST_EQUALS( subText.GetText(), std::string( "o w" ), TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextIsWhiteSpaceNewLine(void) -{ - TestApplication application; - - Text text; - - // Query a void text. - - DALI_TEST_CHECK( !text.IsWhiteSpace( 0u ) ); - DALI_TEST_CHECK( !text.IsNewLine( 0u ) ); - - // Set a text - text.SetText( "Hello world\n" ); - - // Query out of bounds - - DALI_TEST_CHECK( !text.IsWhiteSpace( 30u ) ); - DALI_TEST_CHECK( !text.IsNewLine( 30u ) ); - - // Normal query. - - DALI_TEST_CHECK( !text.IsWhiteSpace( 1u ) ); - DALI_TEST_CHECK( !text.IsNewLine( 1u ) ); - DALI_TEST_CHECK( text.IsWhiteSpace( 5u ) ); - DALI_TEST_CHECK( text.IsNewLine( 11u ) ); - - END_TEST; -} diff --git a/automated-tests/src/dali/utc-Dali-TextActor.cpp b/automated-tests/src/dali/utc-Dali-TextActor.cpp deleted file mode 100644 index a57b2aa..0000000 --- a/automated-tests/src/dali/utc-Dali-TextActor.cpp +++ /dev/null @@ -1,1079 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -#include -#include - -#include -#include - -using namespace Dali; - -void text_actor_test_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void text_actor_test_cleanup(void) -{ - test_return_value = TET_PASS; -} - -namespace -{ -static const char* TestTextHello = "Hello"; -static const char* TestTextHelloWorld = "Hello World"; -static const char* LongTestText = "This is a very long piece of text, and is sure not to fit into any box presented to it"; - -static const std::string DEFAULT_NAME_STYLE( "" ); -static const PointSize DEFAULT_FONT_POINT_SIZE( 0.f ); - -static const std::string FONT_FAMILY( "Arial" ); -static const std::string FONT_STYLE( "Bold" ); -static const PointSize FONT_POINT_SIZE( 12.f ); -static const Vector4 TEXT_COLOR( Color::RED ); - -static const TextStyle::Weight TEXT_WEIGHT( TextStyle::EXTRALIGHT ); -static const float SMOOTH_EDGE( 5.0f ); - -static const bool ITALICS( true ); -static const Degree ITALICS_ANGLE( 10.f ); -static const Radian ITALICS_RADIAN_ANGLE(0.4f); - -static const bool UNDERLINE( true ); -static const float UNDERLINE_THICKNESS( 5.0f ); -static const float UNDERLINE_POSITION( 60.0f ); - -static const bool SHADOW( true ); -static const Vector4 SHADOW_COLOR( Color::BLUE ); -static const Vector2 SHADOW_OFFSET( 2.f, 2.f ); -static const float SHADOW_SIZE( 55.f ); - -static const bool GLOW( true ); -static const Vector4 GLOW_COLOR( Color::BLACK ); -static const float GLOW_INTENSITY( 10.0f ); - -static const bool OUTLINE( true ); -static const Vector4 OUTLINE_COLOR( Color::MAGENTA ); -static const Vector2 OUTLINE_THICKNESS( 15.f, 14.f ); - -static const bool GRADIENT( true ); -static const Vector4 GRADIENT_COLOR( Color::YELLOW ); -static const Vector2 GRADIENT_START_POINT( 1.f, 1.f ); -static const Vector2 GRADIENT_END_POINT( 2.f, 2.f ); -} // anon namespace - -int UtcDaliTextActorConstructorVoid(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor::TextActor()"); - - TextActor actor; - - DALI_TEST_CHECK(!actor); - END_TEST; -} - -int UtcDaliTextActorNew01(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor::New()"); - - TextActor actor = TextActor::New(); - - DALI_TEST_CHECK(actor); - - END_TEST; -} - - -int UtcDaliTextActorNew02(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor::New(const Text& text)"); - - TextActor actor1 = TextActor::New(TestTextHello); - - DALI_TEST_CHECK(actor1); - - TextActor actor2 = TextActor::New(std::string(TestTextHello)); - - DALI_TEST_CHECK(actor2); - - TextActor actor3 = TextActor::New(Text(TestTextHello)); - - DALI_TEST_CHECK(actor3); - - TextActor actor4 = TextActor::New(Text(std::string(TestTextHello))); - - DALI_TEST_CHECK(actor4); - - END_TEST; -} - -int UtcDaliTextActorNew03(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor::New(const Text& text, const TextActorParameters& parameters)"); - - TextActorParameters parameters; - - TextActor actor1 = TextActor::New(TestTextHello, parameters); - - DALI_TEST_CHECK(actor1); - DALI_TEST_CHECK(actor1.IsFontDetectionAutomatic()); - - TextStyle style; - style.SetTextColor( Color::RED ); - - parameters = TextActorParameters( style, TextActorParameters::FONT_DETECTION_OFF ); - - TextActor actor2 = TextActor::New(std::string(TestTextHello), parameters); - - DALI_TEST_CHECK(actor2); - DALI_TEST_CHECK(!actor2.IsFontDetectionAutomatic()); - DALI_TEST_CHECK( style.GetTextColor() == actor2.GetTextStyle().GetTextColor()); - - TextActor actor3 = TextActor::New(Text(TestTextHello), parameters); - - DALI_TEST_CHECK(actor3); - - TextActor actor4 = TextActor::New(Text(std::string(TestTextHello)), parameters); - - DALI_TEST_CHECK(actor4); - - END_TEST; -} - -int UtcDaliTextActorDownCast(void) -{ - TestApplication application; - tet_infoline("Testing Dali::TextActor::DownCast()"); - - TextActor actor1 = TextActor::New("Hello, World!"); - Actor anActor = Actor::New(); - anActor.Add(actor1); - - Actor child = anActor.GetChildAt(0); - TextActor textActor = TextActor::DownCast(child); - - DALI_TEST_CHECK(textActor); - DALI_TEST_CHECK(!textActor.GetText().compare("Hello, World!")); - END_TEST; -} - -int UtcDaliTextActorDownCast2(void) -{ - TestApplication application; - tet_infoline("Testing Dali::TextActor::DownCast()"); - - Actor actor1 = Actor::New(); - Actor anActor = Actor::New(); - anActor.Add(actor1); - - Actor child = anActor.GetChildAt(0); - TextActor textActor = TextActor::DownCast(child); - DALI_TEST_CHECK(!textActor); - - Actor unInitialzedActor; - textActor = DownCast< TextActor >( unInitialzedActor ); - DALI_TEST_CHECK(!textActor); - END_TEST; -} - -int UtcDaliTextActorSetText(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor::SetText()"); - - TextActor actor01 = TextActor::New(TestTextHello); - - actor01.SetText(TestTextHelloWorld); - - std::string text = actor01.GetText(); - - DALI_TEST_EQUALS(text, TestTextHelloWorld, TEST_LOCATION); - - actor01.SetText(Text(std::string(TestTextHelloWorld))); - - text = actor01.GetText(); - - DALI_TEST_EQUALS(text, TestTextHelloWorld, TEST_LOCATION); - - actor01.SetText(""); - - text = actor01.GetText(); - - DALI_TEST_EQUALS(text, "", TEST_LOCATION); - - TextActor actor02 = TextActor::New(""); - - actor02.SetText( std::string() ); - - text = actor02.GetText(); - - DALI_TEST_EQUALS(text, "", TEST_LOCATION); - - actor02.SetText(TestTextHelloWorld); - actor02.SetText( std::string() ); - - text = actor02.GetText(); - - DALI_TEST_EQUALS(text, "", TEST_LOCATION); - - TextActor actor03 = TextActor::New(""); - const Text voidText; - actor03.SetText(voidText); - - text = actor03.GetText(); - - DALI_TEST_EQUALS(text, "", TEST_LOCATION); - - actor03.SetText(TestTextHelloWorld); - actor03.SetText(voidText); - - text = actor03.GetText(); - - DALI_TEST_EQUALS(text, "", TEST_LOCATION); - END_TEST; -} - -int UtcDaliTextActorSetFont(void) -{ - TestApplication application; - - TextActor actor = TextActor::New(TestTextHello); - - Font defaultFont = actor.GetFont(); - DALI_TEST_EQUALS( defaultFont.GetName(), DEFAULT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultFont.GetStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_CHECK( defaultFont.IsDefaultSystemSize() ); - - TextStyle defaultStyle = actor.GetTextStyle(); - DALI_TEST_EQUALS( defaultStyle.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION ); - - FontParameters params( FONT_FAMILY, FONT_STYLE, FONT_POINT_SIZE ); - - Font font = Font::New( params ); - - actor.SetFont( font ); - - Font font2 = actor.GetFont(); - - DALI_TEST_EQUALS( font2.GetName(), FONT_FAMILY, TEST_LOCATION ); - DALI_TEST_EQUALS( font2.GetStyle(), FONT_STYLE, TEST_LOCATION ); - DALI_TEST_CHECK( !font2.IsDefaultSystemSize() ); - DALI_TEST_EQUALS( PointSize( font2.GetPointSize() ), FONT_POINT_SIZE, TEST_LOCATION ); - - TextStyle style = actor.GetTextStyle(); - DALI_TEST_EQUALS( style.GetFontName(), FONT_FAMILY, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetFontStyle(), FONT_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextActorSetFontDetection(void) -{ - TestApplication application; - - TextActor actor = TextActor::New(TestTextHello); - - actor.SetFontDetectionAutomatic( true ); - - DALI_TEST_CHECK( true == actor.IsFontDetectionAutomatic() ); - - END_TEST; -} - -int UtcDaliTextActorSetTextIndividualStyles(void) -{ - TestApplication application; - - TextActor actor = TextActor::New(TestTextHello); - TextStyle defaultStyle = actor.GetTextStyle(); - - DALI_TEST_EQUALS( actor.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION ); - - DALI_TEST_EQUALS( actor.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION ); - - DALI_TEST_EQUALS( defaultStyle.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( !actor.GetItalics() ); - DALI_TEST_EQUALS( actor.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION ); - DALI_TEST_CHECK( defaultStyle.IsItalicsDefault() ); - DALI_TEST_CHECK( !defaultStyle.IsItalicsEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION ); - - DALI_TEST_CHECK( !actor.GetUnderline() ); - DALI_TEST_CHECK( defaultStyle.IsUnderlineDefault() ); - DALI_TEST_CHECK( !defaultStyle.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( defaultStyle.IsShadowDefault() ); - DALI_TEST_CHECK( !defaultStyle.IsShadowEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION ); - - DALI_TEST_CHECK( defaultStyle.IsGlowDefault() ); - DALI_TEST_CHECK( !defaultStyle.IsGlowEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( defaultStyle.IsOutlineDefault() ); - DALI_TEST_CHECK( !defaultStyle.IsOutlineEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION ); - - DALI_TEST_CHECK( defaultStyle.IsGradientDefault() ); - DALI_TEST_CHECK( !defaultStyle.IsGradientEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION ); - - - actor.SetTextColor( TEXT_COLOR ); - - actor.SetWeight( TEXT_WEIGHT ); - actor.SetSmoothEdge( SMOOTH_EDGE ); - - actor.SetItalics( ITALICS, ITALICS_ANGLE ); - actor.SetUnderline( UNDERLINE ); - - actor.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE ); - actor.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY ); - actor.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS ); - actor.SetGradientColor( GRADIENT_COLOR ); - actor.SetGradientStartPoint( GRADIENT_START_POINT ); - actor.SetGradientEndPoint( GRADIENT_END_POINT ); - - - TextStyle style = actor.GetTextStyle(); - - DALI_TEST_EQUALS( actor.GetTextColor(), TEXT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetTextColor(), TEXT_COLOR, TEST_LOCATION ); - - DALI_TEST_EQUALS( actor.GetWeight(), TEXT_WEIGHT, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetWeight(), TEXT_WEIGHT, TEST_LOCATION ); - - DALI_TEST_EQUALS( style.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( actor.GetItalics() ); - DALI_TEST_EQUALS( actor.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION ); - DALI_TEST_CHECK( !style.IsItalicsDefault() ); - DALI_TEST_CHECK( style.IsItalicsEnabled() ); - DALI_TEST_EQUALS( style.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION ); - - DALI_TEST_CHECK( actor.GetUnderline() ); - DALI_TEST_CHECK( !style.IsUnderlineDefault() ); - DALI_TEST_CHECK( style.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( style.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( !style.IsShadowDefault() ); - DALI_TEST_CHECK( style.IsShadowEnabled() ); - DALI_TEST_EQUALS( style.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION ); - - DALI_TEST_CHECK( !style.IsGlowDefault() ); - DALI_TEST_CHECK( style.IsGlowEnabled() ); - DALI_TEST_EQUALS( style.GetGlowColor(), GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( !style.IsOutlineDefault() ); - DALI_TEST_CHECK( style.IsOutlineEnabled() ); - DALI_TEST_EQUALS( style.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION ); - - DALI_TEST_EQUALS( actor.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( actor.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION ); - DALI_TEST_CHECK( !style.IsGradientDefault() ); - DALI_TEST_CHECK( style.IsGradientEnabled() ); - DALI_TEST_EQUALS( style.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION ); - - // Added to increase coverage. - - // Set a different color. - actor.SetTextColor( TEXT_COLOR ); - actor.SetTextColor( Color::GREEN ); - DALI_TEST_EQUALS( actor.GetTextColor(), Color::GREEN, TEST_LOCATION ); - - // Set a different weight - actor.SetWeight( TEXT_WEIGHT ); - actor.SetWeight( TextStyle::BOLD ); - DALI_TEST_EQUALS( actor.GetWeight(), TextStyle::BOLD, TEST_LOCATION ); - - // Set a different smooth edge - actor.SetSmoothEdge( SMOOTH_EDGE ); - actor.SetSmoothEdge( 1.f ); - DALI_TEST_EQUALS( actor.GetTextStyle().GetSmoothEdge(), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - // Set different italic parameters - actor.SetItalics( true, ITALICS_ANGLE ); - actor.SetItalics( false ); - DALI_TEST_CHECK( !actor.GetItalics() ); - actor.SetItalics( true, Degree( 15.f ) ); - DALI_TEST_EQUALS( actor.GetItalicsAngle(), Degree( 15.f ), TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextActorChangingText(void) -{ - TestApplication application; - - TextActor actor = TextActor::New(TestTextHello); - actor.SetSize(Vector3(200, 20, 0.0f)); - actor.SetPosition(20.0f, 400.0f, 40.0f); - Stage::GetCurrent().Add(actor); - - tet_infoline("Testing Dali::TextActor::SetText() & Dali::TextActor::GetText()"); - actor.SetText(LongTestText); - std::string text = actor.GetText(); - DALI_TEST_EQUALS(text, LongTestText, TEST_LOCATION); - - // do a render - application.SendNotification(); - application.Render(); - - // check that the size did not change - DALI_TEST_EQUALS( Vector3(200, 20, 0.0f), actor.GetCurrentSize(), TEST_LOCATION); - END_TEST; -} - -int UtcDaliTextActorGetLoadingState(void) -{ - TestApplication application; - - TextActor actor = TextActor::New(TestTextHello); - - DALI_TEST_CHECK( ResourceLoading == actor.GetLoadingState()); - - application.SendNotification(); - application.Render(); - - DALI_TEST_CHECK( ResourceLoadingSucceeded == actor.GetLoadingState()); - - END_TEST; -} - -int UtcDaliTextActorSetItalics(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor::New()"); - - TextActor actor = TextActor::New(TestTextHello); - - DALI_TEST_CHECK(actor); - - actor.SetItalics( true ); - - DALI_TEST_CHECK( actor.GetItalics() ); - - DALI_TEST_EQUALS( static_cast( Degree( actor.GetItalicsAngle() ) ), static_cast(TextStyle::DEFAULT_ITALICS_ANGLE), 0.0001f, TEST_LOCATION ); - - actor.SetItalics( false ); - - DALI_TEST_CHECK( ! actor.GetItalics() ); - - // TODO: Implement a why on the glAbstraction to check if the geometry was created correctly - END_TEST; -} - -int UtcDaliTextActorSetUnderline(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor::SetUnderline()"); - - TextActor actor = TextActor::New(TestTextHello); - - DALI_TEST_CHECK(actor); - - actor.SetUnderline( true ); - - DALI_TEST_CHECK( actor.GetUnderline() ); - - actor.SetUnderline( false ); - - DALI_TEST_CHECK( ! actor.GetUnderline() ); - - // TODO: Implement a why on the glAbstraction to check if the geometry was created correctly - END_TEST; -} - -int UtcDaliTextActorSetWeight(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor::SetWeight()"); - - TextActor actor = TextActor::New(TestTextHello); - - DALI_TEST_CHECK(actor); - - actor.SetWeight( TextStyle::EXTRABOLD ); - - DALI_TEST_CHECK( TextStyle::EXTRABOLD == actor.GetWeight() ); - - actor.SetWeight( TextStyle::BOLD ); - - DALI_TEST_CHECK( TextStyle::BOLD == actor.GetWeight() ); - END_TEST; -} - -int UtcDaliTextActorSetStyle(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor::SetTextStyle()"); - - TextActor actor = TextActor::New(TestTextHello); - - const TextStyle defaultStyle = actor.GetTextStyle(); - - DALI_TEST_EQUALS( defaultStyle.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION ); - - DALI_TEST_EQUALS( defaultStyle.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( defaultStyle.IsItalicsDefault() ); - DALI_TEST_CHECK( !defaultStyle.IsItalicsEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION ); - - DALI_TEST_CHECK( defaultStyle.IsUnderlineDefault() ); - DALI_TEST_CHECK( !defaultStyle.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( defaultStyle.IsShadowDefault() ); - DALI_TEST_CHECK( !defaultStyle.IsShadowEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION ); - - DALI_TEST_CHECK( defaultStyle.IsGlowDefault() ); - DALI_TEST_CHECK( !defaultStyle.IsGlowEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( defaultStyle.IsOutlineDefault() ); - DALI_TEST_CHECK( !defaultStyle.IsOutlineEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION ); - - DALI_TEST_CHECK( defaultStyle.IsGradientDefault() ); - DALI_TEST_CHECK( !defaultStyle.IsGradientEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION ); - - - // Set a non default style. - - TextStyle style; - style.SetFontName( FONT_FAMILY ); - style.SetFontStyle( FONT_STYLE ); - style.SetFontPointSize( FONT_POINT_SIZE ); - style.SetTextColor( TEXT_COLOR ); - - style.SetWeight( TEXT_WEIGHT ); - style.SetSmoothEdge( SMOOTH_EDGE ); - - style.SetItalics( ITALICS, ITALICS_ANGLE ); - style.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION ); - - style.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE ); - style.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY ); - style.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS ); - style.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - - actor.SetTextStyle( style ); - - // This is necessary since SetColor (via TextStyle) is asynchronous - application.SendNotification(); - application.Render(); - - TextStyle style2 = actor.GetTextStyle(); - - DALI_TEST_CHECK( !style2.IsFontNameDefault() ); - DALI_TEST_CHECK( !style2.IsFontStyleDefault() ); - DALI_TEST_CHECK( !style2.IsFontSizeDefault() ); - DALI_TEST_CHECK( !style2.IsTextColorDefault() ); - DALI_TEST_CHECK( !style2.IsFontWeightDefault() ); - DALI_TEST_CHECK( !style2.IsSmoothEdgeDefault() ); - DALI_TEST_CHECK( !style2.IsItalicsDefault() ); - DALI_TEST_CHECK( !style2.IsUnderlineDefault() ); - DALI_TEST_CHECK( !style2.IsShadowDefault() ); - DALI_TEST_CHECK( !style2.IsGlowDefault() ); - DALI_TEST_CHECK( !style2.IsOutlineDefault() ); - DALI_TEST_CHECK( !style2.IsGradientDefault() ); - - DALI_TEST_EQUALS( style2.GetFontName(), FONT_FAMILY, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetFontStyle(), FONT_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetTextColor(), TEXT_COLOR, TEST_LOCATION ); - - DALI_TEST_EQUALS( style2.GetWeight(), TEXT_WEIGHT, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsItalicsEnabled() ); - DALI_TEST_EQUALS( style2.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( style2.GetUnderlineThickness(), UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetUnderlinePosition(), UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsShadowEnabled() ); - DALI_TEST_EQUALS( style2.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsGlowEnabled() ); - DALI_TEST_EQUALS( style2.GetGlowColor(), GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsOutlineEnabled() ); - DALI_TEST_EQUALS( style2.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsGradientEnabled() ); - DALI_TEST_EQUALS( style2.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION ); - - - // Set a default style - actor.SetTextStyle( defaultStyle ); - - TextStyle style3 = actor.GetTextStyle(); - - DALI_TEST_EQUALS( style3.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( style3.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( style3.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION ); - DALI_TEST_EQUALS( style3.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION ); - - DALI_TEST_EQUALS( style3.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION ); - DALI_TEST_EQUALS( style3.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style3.IsItalicsDefault() ); - DALI_TEST_CHECK( !style3.IsItalicsEnabled() ); - DALI_TEST_EQUALS( style3.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION ); - - DALI_TEST_CHECK( style3.IsUnderlineDefault() ); - DALI_TEST_CHECK( !style3.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( style3.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( style3.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style3.IsShadowDefault() ); - DALI_TEST_CHECK( !style3.IsShadowEnabled() ); - DALI_TEST_EQUALS( style3.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style3.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION ); - - DALI_TEST_CHECK( style3.IsGlowDefault() ); - DALI_TEST_CHECK( !style3.IsGlowEnabled() ); - DALI_TEST_EQUALS( style3.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style3.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style3.IsOutlineDefault() ); - DALI_TEST_CHECK( !style3.IsOutlineEnabled() ); - DALI_TEST_EQUALS( style3.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style3.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION ); - - DALI_TEST_CHECK( style3.IsGradientDefault() ); - DALI_TEST_CHECK( !style3.IsGradientEnabled() ); - DALI_TEST_EQUALS( style3.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style3.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( style3.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION ); - - // Added to increase coverage. - // Reset what is already reset. - - actor.SetTextStyle( style3 ); - - TextStyle style4 = actor.GetTextStyle(); - - DALI_TEST_EQUALS( style4.GetFontName(), DEFAULT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( style4.GetFontStyle(), DEFAULT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( style4.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION ); - DALI_TEST_EQUALS( style4.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION ); - - DALI_TEST_EQUALS( style4.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION ); - DALI_TEST_EQUALS( style4.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style4.IsItalicsDefault() ); - DALI_TEST_CHECK( !style4.IsItalicsEnabled() ); - DALI_TEST_EQUALS( style4.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION ); - - DALI_TEST_CHECK( style4.IsUnderlineDefault() ); - DALI_TEST_CHECK( !style4.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( style4.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( style4.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style4.IsShadowDefault() ); - DALI_TEST_CHECK( !style4.IsShadowEnabled() ); - DALI_TEST_EQUALS( style4.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style4.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION ); - - DALI_TEST_CHECK( style4.IsGlowDefault() ); - DALI_TEST_CHECK( !style4.IsGlowEnabled() ); - DALI_TEST_EQUALS( style4.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style4.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style4.IsOutlineDefault() ); - DALI_TEST_CHECK( !style4.IsOutlineEnabled() ); - DALI_TEST_EQUALS( style4.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style4.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION ); - - DALI_TEST_CHECK( style4.IsGradientDefault() ); - DALI_TEST_CHECK( !style4.IsGradientEnabled() ); - DALI_TEST_EQUALS( style4.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style4.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( style4.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextActorDefaultProperties(void) -{ - TestApplication application; - tet_infoline("Testing Dali::TextActor DefaultProperties"); - - TextActor actor = TextActor::New("@"); - - std::vector indices ; - indices.push_back(TextActor::TEXT ); - indices.push_back(TextActor::FONT ); - indices.push_back(TextActor::FONT_STYLE ); - indices.push_back(TextActor::OUTLINE_ENABLE ); - indices.push_back(TextActor::OUTLINE_COLOR ); - indices.push_back(TextActor::OUTLINE_THICKNESS_WIDTH ); - indices.push_back(TextActor::SMOOTH_EDGE ); - indices.push_back(TextActor::GLOW_ENABLE ); - indices.push_back(TextActor::GLOW_COLOR ); - indices.push_back(TextActor::GLOW_INTENSITY ); - indices.push_back(TextActor::SHADOW_ENABLE ); - indices.push_back(TextActor::SHADOW_COLOR ); - indices.push_back(TextActor::SHADOW_OFFSET ); - indices.push_back(TextActor::ITALICS_ANGLE ); - indices.push_back(TextActor::UNDERLINE ); - indices.push_back(TextActor::WEIGHT ); - indices.push_back(TextActor::FONT_DETECTION_AUTOMATIC ); - indices.push_back(TextActor::GRADIENT_COLOR ); - indices.push_back(TextActor::GRADIENT_START_POINT ); - indices.push_back(TextActor::GRADIENT_END_POINT ); - indices.push_back(TextActor::SHADOW_SIZE ); - indices.push_back(TextActor::TEXT_COLOR ); - - DALI_TEST_CHECK(actor.GetPropertyCount() == ( Actor::New().GetPropertyCount() + indices.size() ) ); - - for(std::vector::iterator iter = indices.begin(); iter != indices.end(); ++iter) - { - DALI_TEST_CHECK( *iter == actor.GetPropertyIndex(actor.GetPropertyName(*iter)) ); - DALI_TEST_CHECK( actor.IsPropertyWritable(*iter) ); - DALI_TEST_CHECK( !actor.IsPropertyAnimatable(*iter) ); - DALI_TEST_CHECK( actor.GetPropertyType(*iter) == actor.GetPropertyType(*iter) ); // just checking call succeeds - } - - // set/get one of them - actor.SetUnderline(false); - DALI_TEST_CHECK(actor.GetUnderline() != true); - - actor.SetProperty(TextActor::UNDERLINE, Property::Value(true)); - Property::Value v = actor.GetProperty(TextActor::UNDERLINE); - DALI_TEST_CHECK(v.GetType() == Property::BOOLEAN); - - DALI_TEST_CHECK(v.Get() == true); - END_TEST; -} - -int UtcDaliTextActorSetGradientColor(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor::SetGradientColor()"); - - TextActor actor = TextActor::New(TestTextHello); - - DALI_TEST_CHECK(actor); - - actor.SetGradientColor( Color::RED ); - DALI_TEST_EQUALS( actor.GetGradientColor(), Color::RED, TEST_LOCATION ); - - actor.SetGradientColor( Color::BLUE ); - DALI_TEST_EQUALS( actor.GetGradientColor(), Color::BLUE, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliTextActorSetGradientStartPoint(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor::SetGradientStartPoint()"); - - TextActor actor = TextActor::New(TestTextHello); - - DALI_TEST_CHECK(actor); - - actor.SetGradientStartPoint( Vector2(0.5f, 0.5f) ); - DALI_TEST_EQUALS( actor.GetGradientStartPoint(), Vector2(0.5f, 0.5f), TEST_LOCATION ); - - actor.SetGradientStartPoint( Vector2(1.0f, 0.0f) ); - DALI_TEST_EQUALS( actor.GetGradientStartPoint(), Vector2(1.0f, 0.0f), TEST_LOCATION ); - END_TEST; -} - -int UtcDaliTextActorSetGradientEndPoint(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor::SetGradientEndPoint()"); - - TextActor actor = TextActor::New(TestTextHello); - - DALI_TEST_CHECK(actor); - - actor.SetGradientEndPoint( Vector2(0.25f, 0.25f) ); - DALI_TEST_EQUALS( actor.GetGradientEndPoint(), Vector2(0.25f, 0.25f), TEST_LOCATION ); - - actor.SetGradientEndPoint( Vector2(0.0f, 1.0f) ); - DALI_TEST_EQUALS( actor.GetGradientEndPoint(), Vector2(0.0f, 1.0f), TEST_LOCATION ); - END_TEST; -} - -int UtcDaliTextActorSynchronousGlyphLoading(void) -{ - TestApplication application; - - tet_infoline( "Testing synchronous loading of glyphs"); - - // All numerals 0 through 9 are 'fake' cached in the test abstraction glyphcache - - // create text actor containg "Hello" - TextActor actor = TextActor::New(TestTextHello); - - // no glyphs will be cached - - // so..GetGlyphData should have been called to gather metrics - DALI_TEST_CHECK( application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:false" ) ); - // ..but not to load glyph bitmap data - DALI_TEST_CHECK( ! application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:true" ) ); - // ..also, cached high quality glyphs will not have been requested yet - DALI_TEST_CHECK( ! application.GetPlatform().WasCalled(TestPlatformAbstraction::GetCachedGlyphDataFunc) ); - - // reset PlatformAbstraction function call traces - application.GetPlatform().ResetTrace(); - - // Invoke Core::ProcessEvent and tick the update/render threads - application.SendNotification(); - application.Render(); - - // An attempt to load high quality glyphs will have been requested and loaded nothing - DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetCachedGlyphDataFunc) ); - // low quality glyphs bitmap data will have now been generated - DALI_TEST_CHECK( application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:true" ) ); - - // request numerals - actor.SetText( "0123456789" ); - - // reset PlatformAbstraction function call traces - application.GetPlatform().ResetTrace(); - - application.SendNotification(); - application.Render(); - - // An attempt to load high quality glyphs will have been requested and loaded all the numerals - DALI_TEST_CHECK( application.GetPlatform().WasCalled(TestPlatformAbstraction::GetCachedGlyphDataFunc) ); - // ..therefore no low quality glyphs bitmap data will have been requested - DALI_TEST_CHECK( !application.GetPlatform().GetTrace().FindMethodAndParams( "GetGlyphData", "getBitmap:true" ) ); - END_TEST; -} - -int UtcDaliTextActorAutomaticSizeSet(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor getting size based on text automatically"); - - // create empty text actor - TextActor actor = TextActor::New(); - Stage::GetCurrent().Add(actor); - - // initial size is zero - DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentSize(), TEST_LOCATION ); - - // set some text - actor.SetText( "a" ); - // render a frame - application.SendNotification(); - application.Render(); - - // dont care about the actual size as that is too hard to figure out, just want to validate that the size was changed to bigger - Vector3 currentSize = actor.GetCurrentSize(); - DALI_TEST_GREATER( currentSize.width, 0.0f, TEST_LOCATION ); - DALI_TEST_GREATER( currentSize.height, 0.0f, TEST_LOCATION ); - - // set some more text - actor.SetText( "abba" ); - // render a frame - application.SendNotification(); - application.Render(); - - Vector3 biggerSize = actor.GetCurrentSize(); - DALI_TEST_GREATER( biggerSize.width, currentSize.width, TEST_LOCATION ); - - // set some shorter text - actor.SetText( "i" ); - // render a frame - application.SendNotification(); - application.Render(); - - // actor has shrunk - DALI_TEST_GREATER( biggerSize.width, actor.GetCurrentSize().width, TEST_LOCATION ); - - // set a size from application side, from this point onwards text actor no longer uses the "natural" size of the text - actor.SetSize( Vector2( 10.0f, 11.0f ) ); - // render a frame - application.SendNotification(); - application.Render(); - // actor has the user set size - DALI_TEST_EQUALS( Vector2( 10.0f, 11.0f ), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION ); - - // set some different text - std::string longText( "jabba dabba duu" ); - actor.SetText( longText ); - // render a frame - application.SendNotification(); - application.Render(); - // actor still has the user set size - DALI_TEST_EQUALS( Vector2( 10.0f, 11.0f ), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION ); - - // set text to its natural size - actor.SetToNaturalSize(); - // render a frame - application.SendNotification(); - application.Render(); - // actor has the natural size - Font defaultFont = Font::New(); - Vector3 naturalSize = defaultFont.MeasureText( longText ); - DALI_TEST_EQUALS( naturalSize.GetVectorXY(), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION ); - END_TEST; -} - -int UtcDaliTextActorAutomaticSizeSetAnimation(void) -{ - TestApplication application; - - tet_infoline("Testing Dali::TextActor getting size based on text automatically with animation"); - - // create empty text actor - TextActor actor = TextActor::New(); - Stage::GetCurrent().Add(actor); - - // initial size is zero - DALI_TEST_EQUALS( Vector3::ZERO, actor.GetCurrentSize(), TEST_LOCATION ); - - // set some text - actor.SetText( "a" ); - // render a frame - application.SendNotification(); - application.Render(); - - // dont care about the actual size as that is too hard to figure out, just want to validate that the size was changed to bigger - Vector3 currentSize = actor.GetCurrentSize(); - DALI_TEST_GREATER( currentSize.width, 0.0f, TEST_LOCATION ); - DALI_TEST_GREATER( currentSize.height, 0.0f, TEST_LOCATION ); - - // animate size, from this point onwards text actor no longer uses the "natural" size of the text - Animation sizeAnim = Animation::New( 0.1f ); // 0.1 seconds - Vector3 animationTargetSize( 20.0f, 30.0f, 0.0f ); - sizeAnim.AnimateTo( Property( actor, Actor::SIZE ), animationTargetSize ); - sizeAnim.Play(); - - // set some more text - actor.SetText( "abba" ); - // render a frame - application.SendNotification(); - application.Render( 1000 ); // 1 second to complete the animation - - DALI_TEST_EQUALS( animationTargetSize, actor.GetCurrentSize(), TEST_LOCATION ); - - // set some more text - std::string moreText( "something else" ); - actor.SetText( moreText ); - // render a frame - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( animationTargetSize, actor.GetCurrentSize(), TEST_LOCATION ); - - // set text to its natural size - actor.SetToNaturalSize(); - // render a frame - application.SendNotification(); - application.Render(); - // actor has the natural size - Font defaultFont = Font::New(); - Vector3 naturalSize = defaultFont.MeasureText( moreText ); - DALI_TEST_EQUALS( naturalSize.GetVectorXY(), actor.GetCurrentSize().GetVectorXY(), TEST_LOCATION ); - END_TEST; -} - - -int UtcDaliTextActorPropertyIndices(void) -{ - TestApplication application; - Actor basicActor = Actor::New(); - TextActor textActor = TextActor::New("Text"); - - Property::IndexContainer indices; - textActor.GetPropertyIndices( indices ); - DALI_TEST_CHECK( indices.size() > basicActor.GetPropertyCount() ); - DALI_TEST_EQUALS( indices.size(), textActor.GetPropertyCount(), TEST_LOCATION ); - END_TEST; -} - -int UtcDaliTextActorGetNaturalSize(void) -{ - TestApplication application; - - TextActor actor = TextActor::New(); - std::string text( "something else" ); - actor.SetText( text ); - - Font defaultFont = Font::New(); - Vector3 naturalSize = defaultFont.MeasureText( text ); - - DALI_TEST_CHECK( actor.GetNaturalSize().GetVectorXY() == naturalSize.GetVectorXY() ); - - END_TEST; -} diff --git a/automated-tests/src/dali/utc-Dali-TextStyle.cpp b/automated-tests/src/dali/utc-Dali-TextStyle.cpp deleted file mode 100644 index 82c750f..0000000 --- a/automated-tests/src/dali/utc-Dali-TextStyle.cpp +++ /dev/null @@ -1,1500 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -#include - -#include -#include -#include - -using namespace Dali; - -void utc_dali_text_style_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_text_style_cleanup(void) -{ - test_return_value = TET_PASS; -} - -namespace -{ -static const std::string DEFAULT_FONT_NAME_STYLE( "" ); -static const PointSize DEFAULT_FONT_POINT_SIZE( 0.f ); - -static const std::string FONT_FAMILY( "Arial" ); -static const std::string FONT_STYLE( "Bold" ); -static const PointSize FONT_POINT_SIZE( 12.f ); -static const Vector4 TEXT_COLOR( Color::RED ); - -static const TextStyle::Weight TEXT_WEIGHT( TextStyle::EXTRALIGHT ); -static const float SMOOTH_EDGE( 5.0f ); - -static const bool ITALICS( true ); -static const Degree ITALICS_ANGLE( 10.f ); - -static const bool UNDERLINE( true ); -static const float UNDERLINE_THICKNESS( 5.0f ); -static const float UNDERLINE_POSITION( 60.0f ); - -static const bool SHADOW( true ); -static const Vector4 SHADOW_COLOR( Color::BLUE ); -static const Vector2 SHADOW_OFFSET( 2.f, 2.f ); -static const float SHADOW_SIZE( 55.f ); - -static const bool GLOW( true ); -static const Vector4 GLOW_COLOR( Color::BLACK ); -static const float GLOW_INTENSITY( 10.0f ); - -static const bool OUTLINE( true ); -static const Vector4 OUTLINE_COLOR( Color::MAGENTA ); -static const Vector2 OUTLINE_THICKNESS( 15.f, 14.f ); - -static const bool GRADIENT( true ); -static const Vector4 GRADIENT_COLOR( Color::YELLOW ); -static const Vector2 GRADIENT_START_POINT( 1.f, 1.f ); -static const Vector2 GRADIENT_END_POINT( 2.f, 2.f ); -} // anon namespace - -int UtcDaliTextStyleDefaultConstructor(void) -{ - tet_infoline(" UtcDaliTextStyleDefaultConstructor "); - - TestApplication application; - - TextStyle defaultStyle; - - DALI_TEST_CHECK( defaultStyle.IsFontNameDefault() ); - DALI_TEST_CHECK( defaultStyle.IsFontStyleDefault() ); - DALI_TEST_CHECK( defaultStyle.IsFontSizeDefault() ); - DALI_TEST_CHECK( defaultStyle.IsTextColorDefault() ); - DALI_TEST_CHECK( defaultStyle.IsFontWeightDefault() ); - DALI_TEST_CHECK( defaultStyle.IsSmoothEdgeDefault() ); - DALI_TEST_CHECK( defaultStyle.IsItalicsDefault() ); - DALI_TEST_CHECK( defaultStyle.IsUnderlineDefault() ); - DALI_TEST_CHECK( defaultStyle.IsShadowDefault() ); - DALI_TEST_CHECK( defaultStyle.IsGlowDefault() ); - DALI_TEST_CHECK( defaultStyle.IsOutlineDefault() ); - DALI_TEST_CHECK( defaultStyle.IsGradientDefault() ); - - DALI_TEST_EQUALS( defaultStyle.GetFontName(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetFontStyle(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION ); - - DALI_TEST_EQUALS( defaultStyle.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( !defaultStyle.IsItalicsEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION ); - - DALI_TEST_CHECK( !defaultStyle.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( !defaultStyle.IsShadowEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION ); - - DALI_TEST_CHECK( !defaultStyle.IsGlowEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( !defaultStyle.IsOutlineEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION ); - - DALI_TEST_CHECK( !defaultStyle.IsGradientEnabled() ); - DALI_TEST_EQUALS( defaultStyle.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( defaultStyle.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextStyleCopyConstructor(void) -{ - tet_infoline(" UtcDaliTextStyleCopyConstructor "); - - TestApplication application; - - TextStyle style; - style.SetFontName( FONT_FAMILY ); - style.SetFontStyle( FONT_STYLE ); - style.SetFontPointSize( FONT_POINT_SIZE ); - style.SetTextColor( TEXT_COLOR ); - - style.SetWeight( TEXT_WEIGHT ); - style.SetSmoothEdge( SMOOTH_EDGE ); - - style.SetItalics( ITALICS, ITALICS_ANGLE ); - style.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION ); - style.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE ); - style.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY ); - style.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS ); - style.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - - TextStyle style1( style ); - TextStyle style2 = style; - - DALI_TEST_CHECK( !style1.IsFontNameDefault() ); - DALI_TEST_CHECK( !style1.IsFontStyleDefault() ); - DALI_TEST_CHECK( !style1.IsFontSizeDefault() ); - DALI_TEST_CHECK( !style1.IsTextColorDefault() ); - DALI_TEST_CHECK( !style1.IsFontWeightDefault() ); - DALI_TEST_CHECK( !style1.IsSmoothEdgeDefault() ); - DALI_TEST_CHECK( !style1.IsItalicsDefault() ); - DALI_TEST_CHECK( !style1.IsUnderlineDefault() ); - DALI_TEST_CHECK( !style1.IsShadowDefault() ); - DALI_TEST_CHECK( !style1.IsGlowDefault() ); - DALI_TEST_CHECK( !style1.IsOutlineDefault() ); - DALI_TEST_CHECK( !style1.IsGradientDefault() ); - - DALI_TEST_EQUALS( style1.GetFontName(), FONT_FAMILY, TEST_LOCATION ); - DALI_TEST_EQUALS( style1.GetFontStyle(), FONT_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( style1.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION ); - DALI_TEST_EQUALS( style1.GetTextColor(), TEXT_COLOR, TEST_LOCATION ); - - DALI_TEST_EQUALS( style1.GetWeight(), TEXT_WEIGHT, TEST_LOCATION ); - DALI_TEST_EQUALS( style1.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style1.IsItalicsEnabled() ); - DALI_TEST_EQUALS( style1.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION ); - - DALI_TEST_CHECK( style1.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( style1.GetUnderlineThickness(), UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( style1.GetUnderlinePosition(), UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style1.IsShadowEnabled() ); - DALI_TEST_EQUALS( style1.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style1.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION ); - - DALI_TEST_CHECK( style1.IsGlowEnabled() ); - DALI_TEST_EQUALS( style1.GetGlowColor(), GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style1.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style1.IsOutlineEnabled() ); - DALI_TEST_EQUALS( style1.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style1.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION ); - - DALI_TEST_CHECK( style1.IsGradientEnabled() ); - DALI_TEST_EQUALS( style1.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style1.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( style1.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsFontNameDefault() ); - DALI_TEST_CHECK( !style2.IsFontStyleDefault() ); - DALI_TEST_CHECK( !style2.IsFontSizeDefault() ); - DALI_TEST_CHECK( !style2.IsTextColorDefault() ); - DALI_TEST_CHECK( !style2.IsFontWeightDefault() ); - DALI_TEST_CHECK( !style2.IsSmoothEdgeDefault() ); - DALI_TEST_CHECK( !style2.IsItalicsDefault() ); - DALI_TEST_CHECK( !style2.IsUnderlineDefault() ); - DALI_TEST_CHECK( !style2.IsShadowDefault() ); - DALI_TEST_CHECK( !style2.IsGlowDefault() ); - DALI_TEST_CHECK( !style2.IsOutlineDefault() ); - DALI_TEST_CHECK( !style2.IsGradientDefault() ); - - DALI_TEST_EQUALS( style2.GetFontName(), FONT_FAMILY, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetFontStyle(), FONT_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetTextColor(), TEXT_COLOR, TEST_LOCATION ); - - DALI_TEST_EQUALS( style2.GetWeight(), TEXT_WEIGHT, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsItalicsEnabled() ); - DALI_TEST_EQUALS( style2.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( style2.GetUnderlineThickness(), UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetUnderlinePosition(), UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsShadowEnabled() ); - DALI_TEST_EQUALS( style2.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsGlowEnabled() ); - DALI_TEST_EQUALS( style2.GetGlowColor(), GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsOutlineEnabled() ); - DALI_TEST_EQUALS( style2.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsGradientEnabled() ); - DALI_TEST_EQUALS( style2.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextStyleAssignmentOperator(void) -{ - tet_infoline(" UtcDaliTextStyleAssignmentOperator "); - - TestApplication application; - - TextStyle style1; - TextStyle style2; - - style1.SetFontName( FONT_FAMILY ); - style1.SetFontStyle( FONT_STYLE ); - style1.SetFontPointSize( FONT_POINT_SIZE ); - style1.SetTextColor( TEXT_COLOR ); - - style1.SetWeight( TEXT_WEIGHT ); - style1.SetSmoothEdge( SMOOTH_EDGE ); - - style1.SetItalics( ITALICS, ITALICS_ANGLE ); - - style1.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION ); - - style1.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE ); - style1.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY ); - style1.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS ); - style1.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - - // Test the copy of all parameters. - style2 = style1; - - DALI_TEST_CHECK( !style2.IsFontNameDefault() ); - DALI_TEST_CHECK( !style2.IsFontStyleDefault() ); - DALI_TEST_CHECK( !style2.IsFontSizeDefault() ); - DALI_TEST_CHECK( !style2.IsTextColorDefault() ); - DALI_TEST_CHECK( !style2.IsFontWeightDefault() ); - DALI_TEST_CHECK( !style2.IsSmoothEdgeDefault() ); - DALI_TEST_CHECK( !style2.IsItalicsDefault() ); - DALI_TEST_CHECK( !style2.IsUnderlineDefault() ); - DALI_TEST_CHECK( !style2.IsShadowDefault() ); - DALI_TEST_CHECK( !style2.IsGlowDefault() ); - DALI_TEST_CHECK( !style2.IsOutlineDefault() ); - DALI_TEST_CHECK( !style2.IsGradientDefault() ); - - DALI_TEST_EQUALS( style2.GetFontName(), FONT_FAMILY, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetFontStyle(), FONT_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetTextColor(), TEXT_COLOR, TEST_LOCATION ); - - DALI_TEST_EQUALS( style2.GetWeight(), TEXT_WEIGHT, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsItalicsEnabled() ); - DALI_TEST_EQUALS( style2.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( style2.GetUnderlineThickness(), UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetUnderlinePosition(), UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsShadowEnabled() ); - DALI_TEST_EQUALS( style2.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsGlowEnabled() ); - DALI_TEST_EQUALS( style2.GetGlowColor(), GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsOutlineEnabled() ); - DALI_TEST_EQUALS( style2.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION ); - - DALI_TEST_CHECK( style2.IsGradientEnabled() ); - DALI_TEST_EQUALS( style2.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION ); - - // Test assignment of the same object. - const TextStyle& style( style2 ); - - style2 = style; - - // Test the assignment of the defaults. - - // Test copy all defaults. - - TextStyle defaultStyle; - style2 = defaultStyle; - - DALI_TEST_CHECK( style2.IsFontNameDefault() ); - DALI_TEST_CHECK( style2.IsFontStyleDefault() ); - DALI_TEST_CHECK( style2.IsFontSizeDefault() ); - DALI_TEST_CHECK( style2.IsTextColorDefault() ); - DALI_TEST_CHECK( style2.IsFontWeightDefault() ); - DALI_TEST_CHECK( style2.IsSmoothEdgeDefault() ); - DALI_TEST_CHECK( style2.IsItalicsDefault() ); - DALI_TEST_CHECK( style2.IsUnderlineDefault() ); - DALI_TEST_CHECK( style2.IsShadowDefault() ); - DALI_TEST_CHECK( style2.IsGlowDefault() ); - DALI_TEST_CHECK( style2.IsOutlineDefault() ); - DALI_TEST_CHECK( style2.IsGradientDefault() ); - - DALI_TEST_EQUALS( style2.GetFontName(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetFontStyle(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION ); - - DALI_TEST_EQUALS( style2.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsItalicsEnabled() ); - DALI_TEST_EQUALS( style2.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( style2.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsShadowEnabled() ); - DALI_TEST_EQUALS( style2.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsGlowEnabled() ); - DALI_TEST_EQUALS( style2.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsOutlineEnabled() ); - DALI_TEST_EQUALS( style2.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsGradientEnabled() ); - DALI_TEST_EQUALS( style2.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION ); - - // Test copy some defaults. - - // set style2 with non defaults. - style2 = style1; - - // create a style with all defaults excepd the font name. - defaultStyle.SetFontName( FONT_FAMILY ); - - // should reset all to defaults except the font name. - style2 = defaultStyle; - - DALI_TEST_CHECK( !style2.IsFontNameDefault() ); - DALI_TEST_CHECK( style2.IsFontStyleDefault() ); - DALI_TEST_CHECK( style2.IsFontSizeDefault() ); - DALI_TEST_CHECK( style2.IsTextColorDefault() ); - DALI_TEST_CHECK( style2.IsFontWeightDefault() ); - DALI_TEST_CHECK( style2.IsSmoothEdgeDefault() ); - DALI_TEST_CHECK( style2.IsItalicsDefault() ); - DALI_TEST_CHECK( style2.IsUnderlineDefault() ); - DALI_TEST_CHECK( style2.IsShadowDefault() ); - DALI_TEST_CHECK( style2.IsGlowDefault() ); - DALI_TEST_CHECK( style2.IsOutlineDefault() ); - DALI_TEST_CHECK( style2.IsGradientDefault() ); - - DALI_TEST_EQUALS( style2.GetFontName(), FONT_FAMILY, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetFontStyle(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION ); - - DALI_TEST_EQUALS( style2.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsItalicsEnabled() ); - DALI_TEST_EQUALS( style2.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( style2.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsShadowEnabled() ); - DALI_TEST_EQUALS( style2.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsGlowEnabled() ); - DALI_TEST_EQUALS( style2.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsOutlineEnabled() ); - DALI_TEST_EQUALS( style2.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsGradientEnabled() ); - DALI_TEST_EQUALS( style2.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION ); - - // reset the text-style to default. - defaultStyle = TextStyle(); - - // test now the default font name. - defaultStyle.SetFontStyle( FONT_STYLE ); - - style2 = defaultStyle; - - DALI_TEST_CHECK( style2.IsFontNameDefault() ); - DALI_TEST_CHECK( !style2.IsFontStyleDefault() ); - DALI_TEST_CHECK( style2.IsFontSizeDefault() ); - DALI_TEST_CHECK( style2.IsTextColorDefault() ); - DALI_TEST_CHECK( style2.IsFontWeightDefault() ); - DALI_TEST_CHECK( style2.IsSmoothEdgeDefault() ); - DALI_TEST_CHECK( style2.IsItalicsDefault() ); - DALI_TEST_CHECK( style2.IsUnderlineDefault() ); - DALI_TEST_CHECK( style2.IsShadowDefault() ); - DALI_TEST_CHECK( style2.IsGlowDefault() ); - DALI_TEST_CHECK( style2.IsOutlineDefault() ); - DALI_TEST_CHECK( style2.IsGradientDefault() ); - - DALI_TEST_EQUALS( style2.GetFontName(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetFontStyle(), FONT_STYLE, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION ); - - DALI_TEST_EQUALS( style2.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsItalicsEnabled() ); - DALI_TEST_EQUALS( style2.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( style2.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsShadowEnabled() ); - DALI_TEST_EQUALS( style2.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsGlowEnabled() ); - DALI_TEST_EQUALS( style2.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsOutlineEnabled() ); - DALI_TEST_EQUALS( style2.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION ); - - DALI_TEST_CHECK( !style2.IsGradientEnabled() ); - DALI_TEST_EQUALS( style2.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextStyleComparisonOperator(void) -{ - tet_infoline(" UtcDaliTextStyleComparisonOperator "); - - TestApplication application; - - TextStyle style1; - TextStyle style2; - - // Compares equality and inequality operators - - // Compare two defaults. - - DALI_TEST_CHECK( style1 == style2 ); - DALI_TEST_CHECK( !( style1 != style2 ) ); - - // Compare with defaults. - - style1.SetFontName( FONT_FAMILY ); - - DALI_TEST_CHECK( !( style1 == style2 ) ); - DALI_TEST_CHECK( style1 != style2 ); - - style1 = TextStyle(); - style2.SetFontName( FONT_FAMILY ); - - DALI_TEST_CHECK( !( style1 == style2 ) ); - DALI_TEST_CHECK( style1 != style2 ); - - // Compare non defaults. - - // Compare different flags - - style1.SetFontName( FONT_FAMILY ); - style2.SetFontStyle( FONT_STYLE ); - style1.SetFontPointSize( FONT_POINT_SIZE ); - style2.SetTextColor( TEXT_COLOR ); - - style1.SetWeight( TEXT_WEIGHT ); - style2.SetSmoothEdge( SMOOTH_EDGE ); - - style1.SetItalics( ITALICS, ITALICS_ANGLE ); - - style2.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION ); - - style1.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE ); - style2.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY ); - style1.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS ); - style2.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - - DALI_TEST_CHECK( !( style1 == style2 ) ); - DALI_TEST_CHECK( style1 != style2 ); - - // Compare same styles - style1 = style2; - - DALI_TEST_CHECK( style1 == style2 ); - DALI_TEST_CHECK( !( style1 != style2 ) ); - - // Compare same flags but different values - style1.SetTextColor( Color::GREEN ); - - DALI_TEST_CHECK( !( style1 == style2 ) ); - DALI_TEST_CHECK( style1 != style2 ); - - END_TEST; -} - -int UtcDaliTextStyleCopy(void) -{ - tet_infoline(" UtcDaliTextStyleCopy "); - - TestApplication application; - - TextStyle style; - - // Set a style different than default. - TextStyle style2; - style2.SetFontName( FONT_FAMILY ); - style2.SetFontStyle( FONT_STYLE ); - style2.SetFontPointSize( FONT_POINT_SIZE ); - style2.SetTextColor( TEXT_COLOR ); - - style2.SetWeight( TEXT_WEIGHT ); - style2.SetSmoothEdge( SMOOTH_EDGE ); - - style2.SetItalics( ITALICS, ITALICS_ANGLE ); - style2.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION ); - style2.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE ); - style2.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY ); - style2.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS ); - style2.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - - // Test not to copy the same object. To increase coverage. - - const TextStyle& same( style2 ); - - style2.Copy( same ); - - DALI_TEST_CHECK( same == style2 ); - - // Test mask. - - // All values are copied. - style.Copy( style2 ); - - DALI_TEST_CHECK( style == style2 ); - - // Copy the default - TextStyle defaultStyle; - - style.Copy( defaultStyle ); - - // Test FONT - style = TextStyle(); - - style.Copy( style2, TextStyle::FONT ); - - DALI_TEST_EQUALS( style.GetFontName(), FONT_FAMILY, TEST_LOCATION ); - - style.Copy( defaultStyle, TextStyle::FONT ); - - DALI_TEST_EQUALS( style.GetFontName(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION ); - - // Test STYLE - style = TextStyle(); - - style.Copy( style2, TextStyle::STYLE ); - - DALI_TEST_EQUALS( style.GetFontStyle(), FONT_STYLE, TEST_LOCATION ); - - style.Copy( defaultStyle, TextStyle::STYLE ); - - DALI_TEST_EQUALS( style.GetFontStyle(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION ); - - // Test SIZE - style = TextStyle(); - - style.Copy( style2, TextStyle::SIZE ); - - DALI_TEST_EQUALS( style.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION ); - - style.Copy( defaultStyle, TextStyle::SIZE ); - - DALI_TEST_EQUALS( style.GetFontPointSize(), PointSize( 0.f ), TEST_LOCATION ); - - // Test COLOR - style = TextStyle(); - - style.Copy( style2, TextStyle::COLOR ); - - DALI_TEST_EQUALS( style.GetTextColor(), TEXT_COLOR, TEST_LOCATION ); - - style.Copy( defaultStyle, TextStyle::COLOR ); - - DALI_TEST_EQUALS( style.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION ); - - // Test WEIGHT - style = TextStyle(); - - style.Copy( style2, TextStyle::WEIGHT ); - - DALI_TEST_EQUALS( style.GetWeight(), TEXT_WEIGHT, TEST_LOCATION ); - - style.Copy( defaultStyle, TextStyle::WEIGHT ); - - DALI_TEST_EQUALS( style.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION ); - - // Test SMOOTH - style = TextStyle(); - - style.Copy( style2, TextStyle::SMOOTH ); - - DALI_TEST_EQUALS( style.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - style.Copy( defaultStyle, TextStyle::SMOOTH ); - - DALI_TEST_EQUALS( style.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - // Test ITALICS - style = TextStyle(); - - style.Copy( style2, TextStyle::ITALICS ); - - DALI_TEST_CHECK( style.IsItalicsEnabled() ); - DALI_TEST_EQUALS( style.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION ); - - style.Copy( defaultStyle, TextStyle::ITALICS ); - - DALI_TEST_CHECK( !style.IsItalicsEnabled() ); - DALI_TEST_EQUALS( style.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION ); - - // Test UNDERLINE - style = TextStyle(); - - style.Copy( style2, TextStyle::UNDERLINE ); - - DALI_TEST_CHECK( style.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( style.GetUnderlineThickness(), UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetUnderlinePosition(), UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - style.Copy( defaultStyle, TextStyle::UNDERLINE ); - - DALI_TEST_CHECK( !style.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( style.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - // Test SHADOW - style = TextStyle(); - - style.Copy( style2, TextStyle::SHADOW ); - - DALI_TEST_CHECK( style.IsShadowEnabled() ); - DALI_TEST_EQUALS( style.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetShadowSize(), SHADOW_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - style.Copy( defaultStyle, TextStyle::SHADOW ); - - DALI_TEST_CHECK( !style.IsShadowEnabled() ); - DALI_TEST_EQUALS( style.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetShadowSize(), TextStyle::DEFAULT_SHADOW_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - // Test GLOW - style = TextStyle(); - - style.Copy( style2, TextStyle::GLOW ); - - DALI_TEST_CHECK( style.IsGlowEnabled() ); - DALI_TEST_EQUALS( style.GetGlowColor(), GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - style.Copy( defaultStyle, TextStyle::GLOW ); - - DALI_TEST_CHECK( !style.IsGlowEnabled() ); - DALI_TEST_EQUALS( style.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - // Test OUTLINE - style = TextStyle(); - - style.Copy( style2, TextStyle::OUTLINE ); - - DALI_TEST_CHECK( style.IsOutlineEnabled() ); - DALI_TEST_EQUALS( style.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION ); - - style.Copy( defaultStyle, TextStyle::OUTLINE ); - - DALI_TEST_CHECK( !style.IsOutlineEnabled() ); - DALI_TEST_EQUALS( style.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION ); - - // Test GRADIENT - style = TextStyle(); - - style.Copy( style2, TextStyle::GRADIENT ); - - DALI_TEST_CHECK( style.IsGradientEnabled() ); - DALI_TEST_EQUALS( style.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION ); - - style.Copy( defaultStyle, TextStyle::GRADIENT ); - - DALI_TEST_CHECK( !style.IsGradientEnabled() ); - DALI_TEST_EQUALS( style.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION ); - - // Copy to a default. - defaultStyle.Copy( style2 ); - DALI_TEST_CHECK( defaultStyle == style2); - - // Copy from default. - defaultStyle = TextStyle(); - - defaultStyle.SetItalics( ITALICS, ITALICS_ANGLE ); - defaultStyle.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION ); - defaultStyle.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE ); - defaultStyle.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY ); - defaultStyle.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS ); - defaultStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - - // Copy the default values - style2.Copy( defaultStyle, static_cast( TextStyle::FONT | - TextStyle::STYLE | - TextStyle::SIZE | - TextStyle::COLOR | - TextStyle::WEIGHT | - TextStyle::SMOOTH ) ); - - defaultStyle = TextStyle(); - - defaultStyle.SetFontName( FONT_FAMILY ); - defaultStyle.SetFontStyle( FONT_STYLE ); - defaultStyle.SetFontPointSize( FONT_POINT_SIZE ); - defaultStyle.SetTextColor( TEXT_COLOR ); - defaultStyle.SetWeight( TEXT_WEIGHT ); - defaultStyle.SetSmoothEdge( SMOOTH_EDGE ); - - // Copy the default values - style2.Copy( defaultStyle, static_cast( TextStyle::ITALICS | - TextStyle::UNDERLINE | - TextStyle::SHADOW | - TextStyle::GLOW | - TextStyle::OUTLINE | - TextStyle::GRADIENT ) ); - - defaultStyle = TextStyle(); - - DALI_TEST_CHECK( defaultStyle == style2 ); - - END_TEST; -} - -int UtcDaliTextStyleMerge(void) -{ - tet_infoline(" UtcDaliTextStyleMerge "); - - TestApplication application; - - TextStyle defaultStyle; - - TextStyle style; - - // Set a style different than default. - TextStyle style2; - style2.SetFontName( FONT_FAMILY ); - style2.SetFontStyle( FONT_STYLE ); - style2.SetFontPointSize( FONT_POINT_SIZE ); - style2.SetTextColor( TEXT_COLOR ); - - style2.SetWeight( TEXT_WEIGHT ); - style2.SetSmoothEdge( SMOOTH_EDGE ); - - style2.SetItalics( ITALICS, ITALICS_ANGLE ); - style2.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION ); - style2.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE ); - style2.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY ); - style2.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS ); - style2.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - - // Test not to merge the same object. To increase coverage. - - const TextStyle& same( style2 ); - - style2.Merge( same ); - - DALI_TEST_CHECK( same == style2 ); - - // Test merge two styles - - style.Merge( style2 ); - - DALI_TEST_CHECK( style == style2 ); - - // Test merge a default style - - style.Merge( defaultStyle ); - - DALI_TEST_CHECK( style == style2 ); - - // Tests to increase branch coverage. - - style = defaultStyle; - style.SetFontName( FONT_FAMILY ); - - TextStyle style3; - style3.Merge( style ); - - DALI_TEST_CHECK( style == style3 ); - - - END_TEST; -} - -int UtcDaliTextStyleReset(void) -{ - tet_infoline(" UtcDaliTextStyleReset "); - - TestApplication application; - - const TextStyle defaultStyle; - - // Reset a default. - TextStyle style; - - style.Reset(); - - DALI_TEST_CHECK( defaultStyle == style ); - - // Reset NONE - style.Reset( TextStyle::NONE ); - - DALI_TEST_CHECK( defaultStyle == style ); - - // Reset ALL - TextStyle style2; - style2.SetFontName( FONT_FAMILY ); - style2.SetFontStyle( FONT_STYLE ); - style2.SetFontPointSize( FONT_POINT_SIZE ); - style2.SetTextColor( TEXT_COLOR ); - - style2.SetWeight( TEXT_WEIGHT ); - style2.SetSmoothEdge( SMOOTH_EDGE ); - - style2.SetItalics( ITALICS, ITALICS_ANGLE ); - style2.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION ); - style2.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE ); - style2.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY ); - style2.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS ); - style2.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - - style2.Reset( TextStyle::ALL ); - - DALI_TEST_CHECK( defaultStyle == style2 ); - - // Set all parameters - style2.SetFontName( FONT_FAMILY ); - style2.SetFontStyle( FONT_STYLE ); - style2.SetFontPointSize( FONT_POINT_SIZE ); - style2.SetTextColor( TEXT_COLOR ); - - style2.SetWeight( TEXT_WEIGHT ); - style2.SetSmoothEdge( SMOOTH_EDGE ); - - style2.SetItalics( ITALICS, ITALICS_ANGLE ); - style2.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION ); - style2.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE ); - style2.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY ); - style2.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS ); - style2.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - - // Reset FONT - style2.Reset( TextStyle::FONT ); - - DALI_TEST_CHECK( style2.IsFontNameDefault() ); - DALI_TEST_EQUALS( style2.GetFontName(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION ); - - // Reset STYLE - style2.Reset( TextStyle::STYLE ); - - DALI_TEST_CHECK( style2.IsFontStyleDefault() ); - DALI_TEST_EQUALS( style2.GetFontStyle(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION ); - - // Reset SIZE - style2.Reset( TextStyle::SIZE ); - - DALI_TEST_CHECK( style2.IsFontSizeDefault() ); - DALI_TEST_EQUALS( style2.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION ); - - // Reset COLOR - style2.Reset( TextStyle::COLOR ); - - DALI_TEST_CHECK( style2.IsTextColorDefault() ); - DALI_TEST_EQUALS( style2.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION ); - - // Reset WEIGHT - style2.Reset( TextStyle::WEIGHT ); - - DALI_TEST_CHECK( style2.IsFontWeightDefault() ); - DALI_TEST_EQUALS( style2.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION ); - - // Reset SMOOTH - style2.Reset( TextStyle::SMOOTH ); - - DALI_TEST_CHECK( style2.IsSmoothEdgeDefault() ); - DALI_TEST_EQUALS( style2.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - // Reset ITALICS - style2.Reset( TextStyle::ITALICS ); - - DALI_TEST_CHECK( style2.IsItalicsDefault() ); - DALI_TEST_CHECK( !style2.IsItalicsEnabled() ); - DALI_TEST_EQUALS( style2.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION ); - - // Reset UNDERLINE - style2.Reset( TextStyle::UNDERLINE ); - - DALI_TEST_CHECK( style2.IsUnderlineDefault() ); - DALI_TEST_CHECK( !style2.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( style2.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - // Reset SHADOW - style2.Reset( TextStyle::SHADOW ); - - DALI_TEST_CHECK( style2.IsShadowDefault() ); - DALI_TEST_CHECK( !style2.IsShadowEnabled() ); - DALI_TEST_EQUALS( style2.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetShadowSize(), TextStyle::DEFAULT_SHADOW_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - // Reset GLOW - style2.Reset( TextStyle::GLOW ); - - DALI_TEST_CHECK( style2.IsGlowDefault() ); - DALI_TEST_CHECK( !style2.IsGlowEnabled() ); - DALI_TEST_EQUALS( style2.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - // Reset OUTLINE - style2.Reset( TextStyle::OUTLINE ); - - DALI_TEST_CHECK( style2.IsOutlineDefault() ); - DALI_TEST_CHECK( !style2.IsOutlineEnabled() ); - DALI_TEST_EQUALS( style2.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION ); - - // Reset GRADIENT - style2.Reset( TextStyle::GRADIENT ); - - DALI_TEST_CHECK( style2.IsGradientDefault() ); - DALI_TEST_CHECK( !style2.IsGradientEnabled() ); - DALI_TEST_EQUALS( style2.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( style2.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION ); - - - // Added to increase coverage. - - { - // Reset the font name when there is another parameter of a different struct. - // Test when the struct storing the font name is in the last position of the vector and when is not. - - TextStyle nameStyle; - - nameStyle.SetFontName( FONT_FAMILY ); - nameStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - nameStyle.Reset( TextStyle::FONT ); - - DALI_TEST_EQUALS( nameStyle.GetFontName(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION ); - - nameStyle.SetFontName( FONT_FAMILY ); - nameStyle.Reset( TextStyle::FONT ); - - DALI_TEST_EQUALS( nameStyle.GetFontName(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION ); - } - - { - // Reset the font style when there is another parameter of a different struct. - // Test when the struct storing the font style is in the last position of the vector and when is not. - - TextStyle styleStyle; - - styleStyle.SetFontStyle( FONT_STYLE ); - styleStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - styleStyle.Reset( TextStyle::STYLE ); - - DALI_TEST_EQUALS( styleStyle.GetFontStyle(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION ); - - styleStyle.SetFontStyle( FONT_STYLE ); - styleStyle.Reset( TextStyle::STYLE ); - - DALI_TEST_EQUALS( styleStyle.GetFontStyle(), DEFAULT_FONT_NAME_STYLE, TEST_LOCATION ); - } - - { - // Reset the font size when there is another parameter of a different struct. - // Test when the struct storing the font size is in the last position of the vector and when is not. - - TextStyle sizeStyle; - - sizeStyle.SetFontPointSize( FONT_POINT_SIZE ); - sizeStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - sizeStyle.Reset( TextStyle::SIZE ); - - DALI_TEST_EQUALS( sizeStyle.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION ); - - sizeStyle.SetFontPointSize( FONT_POINT_SIZE ); - sizeStyle.Reset( TextStyle::SIZE ); - - DALI_TEST_EQUALS( sizeStyle.GetFontPointSize(), DEFAULT_FONT_POINT_SIZE, TEST_LOCATION ); - } - - { - // Reset the text color when there is another parameter of a different struct. - // Test when the struct storing the text color is in the last position of the vector and when is not. - - TextStyle colorStyle; - - colorStyle.SetTextColor( TEXT_COLOR ); - colorStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - colorStyle.Reset( TextStyle::COLOR ); - - DALI_TEST_EQUALS( colorStyle.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION ); - - colorStyle.SetTextColor( TEXT_COLOR ); - colorStyle.Reset( TextStyle::COLOR ); - - DALI_TEST_EQUALS( colorStyle.GetTextColor(), TextStyle::DEFAULT_TEXT_COLOR, TEST_LOCATION ); - } - - { - // Reset the text weight when there is another parameter of a different struct. - // Test when the struct storing the text weight is in the last position of the vector and when is not. - - TextStyle weightStyle; - - weightStyle.SetWeight( TEXT_WEIGHT ); - weightStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - weightStyle.Reset( TextStyle::WEIGHT ); - - DALI_TEST_EQUALS( weightStyle.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION ); - - weightStyle.SetWeight( TEXT_WEIGHT ); - weightStyle.Reset( TextStyle::WEIGHT ); - - DALI_TEST_EQUALS( weightStyle.GetWeight(), TextStyle::DEFAULT_FONT_WEIGHT, TEST_LOCATION ); - } - - { - // Reset the smooth edge when there is another parameter of a different struct. - // Test when the struct storing the smooth edge is in the last position of the vector and when is not. - - TextStyle smoothStyle; - - smoothStyle.SetSmoothEdge( SMOOTH_EDGE ); - smoothStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - smoothStyle.Reset( TextStyle::SMOOTH ); - - DALI_TEST_EQUALS( smoothStyle.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - smoothStyle.SetSmoothEdge( SMOOTH_EDGE ); - smoothStyle.Reset( TextStyle::SMOOTH ); - - DALI_TEST_EQUALS( smoothStyle.GetSmoothEdge(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - } - - { - // Reset the italics when there is another parameter of a different struct. - // Test when the struct storing the italics is in the last position of the vector and when is not. - - TextStyle italicsStyle; - - italicsStyle.SetItalics( ITALICS, ITALICS_ANGLE ); - italicsStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - italicsStyle.Reset( TextStyle::ITALICS ); - - DALI_TEST_EQUALS( italicsStyle.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION ); - - italicsStyle.SetItalics( ITALICS, ITALICS_ANGLE ); - italicsStyle.Reset( TextStyle::ITALICS ); - - DALI_TEST_EQUALS( italicsStyle.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION ); - } - - { - // Reset the underline when there is another parameter of a different struct. - // Test when the struct storing the underline is in the last position of the vector and when is not. - - TextStyle underlineStyle; - - underlineStyle.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION ); - underlineStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - underlineStyle.Reset( TextStyle::UNDERLINE ); - - DALI_TEST_EQUALS( underlineStyle.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( underlineStyle.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - underlineStyle.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION ); - underlineStyle.Reset( TextStyle::UNDERLINE ); - - DALI_TEST_EQUALS( underlineStyle.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( underlineStyle.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - } - - - - - - { - // Reset the shadow when there is another parameter of a different struct. - // Test when the struct storing the shadow is in the last position of the vector and when is not. - - TextStyle shadowStyle; - - shadowStyle.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE ); - shadowStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - shadowStyle.Reset( TextStyle::SHADOW ); - - DALI_TEST_CHECK( shadowStyle.IsShadowDefault() ); - - shadowStyle.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE ); - shadowStyle.Reset( TextStyle::SHADOW ); - - DALI_TEST_CHECK( shadowStyle.IsShadowDefault() ); -} - - { - // Reset the glow when there is another parameter of a different struct. - // Test when the struct storing the glow is in the last position of the vector and when is not. - - TextStyle glowStyle; - - glowStyle.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY ); - glowStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - glowStyle.Reset( TextStyle::GLOW ); - - DALI_TEST_CHECK( glowStyle.IsGlowDefault() ); - - glowStyle.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY ); - glowStyle.Reset( TextStyle::GLOW ); - - DALI_TEST_CHECK( glowStyle.IsGlowDefault() ); - } - - { - // Reset the outline when there is another parameter of a different struct. - // Test when the struct storing the outline is in the last position of the vector and when is not. - - TextStyle outlineStyle; - - outlineStyle.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS ); - outlineStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - outlineStyle.Reset( TextStyle::OUTLINE ); - - DALI_TEST_CHECK( outlineStyle.IsOutlineDefault() ); - - outlineStyle.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS ); - outlineStyle.Reset( TextStyle::OUTLINE ); - - DALI_TEST_CHECK( outlineStyle.IsOutlineDefault() ); - } - - { - // Reset the gradient when there is another parameter of a different struct. - // Test when the struct storing the gradient is in the last position of the vector and when is not. - - TextStyle gradientStyle; - - gradientStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - gradientStyle.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS ); - gradientStyle.Reset( TextStyle::GRADIENT ); - - DALI_TEST_CHECK( gradientStyle.IsGradientDefault() ); - - gradientStyle.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - gradientStyle.Reset( TextStyle::GRADIENT ); - - DALI_TEST_CHECK( gradientStyle.IsGradientDefault() ); - } - - END_TEST; -} - -int UtcDaliTextStyleSetGetFontName(void) -{ - tet_infoline(" UtcDaliTextStyleSetGetFontName "); - - TestApplication application; - - TextStyle style; - - style.SetFontName( FONT_FAMILY ); - - DALI_TEST_EQUALS( style.GetFontName(), FONT_FAMILY, TEST_LOCATION ); - - // Added to increase coverage - style.SetFontStyle( FONT_STYLE ); - DALI_TEST_EQUALS( style.GetFontStyle(), FONT_STYLE, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextStyleSetGetFontStyle(void) -{ - tet_infoline(" UtcDaliTextStyleSetGetFontStyle "); - - TestApplication application; - - TextStyle style; - - style.SetFontStyle( FONT_STYLE ); - - DALI_TEST_EQUALS( style.GetFontStyle(), FONT_STYLE, TEST_LOCATION ); - - // Added to increase coverage - style.SetFontName( FONT_FAMILY ); - DALI_TEST_EQUALS( style.GetFontName(), FONT_FAMILY, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextStyleSetGetFontPointSize(void) -{ - tet_infoline(" UtcDaliTextStyleSetGetFontPointSize "); - - TestApplication application; - - TextStyle style; - - style.SetFontPointSize( FONT_POINT_SIZE ); - - DALI_TEST_EQUALS( style.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION ); - - // Added to increase coverage - style.SetTextColor( TEXT_COLOR ); - DALI_TEST_EQUALS( style.GetTextColor(), TEXT_COLOR, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextStyleSetGetTextColor(void) -{ - tet_infoline(" UtcDaliTextStyleSetGetTextColor "); - - TestApplication application; - - TextStyle style; - - style.SetTextColor( TEXT_COLOR ); - - DALI_TEST_EQUALS( style.GetTextColor(), TEXT_COLOR, TEST_LOCATION ); - - // Added to increase coverage - style.SetFontPointSize( FONT_POINT_SIZE ); - DALI_TEST_EQUALS( style.GetFontPointSize(), FONT_POINT_SIZE, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextStyleSetGetWeight(void) -{ - tet_infoline(" UtcDaliTextStyleSetGetWeight "); - - TestApplication application; - - TextStyle style; - - style.SetWeight( TEXT_WEIGHT ); - - DALI_TEST_EQUALS( style.GetWeight(), TEXT_WEIGHT, TEST_LOCATION ); - - // Added to increase coverage - style.SetSmoothEdge( SMOOTH_EDGE ); - DALI_TEST_EQUALS( style.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextStyleSetGetSmoothEdge(void) -{ - tet_infoline(" UtcDaliTextStyleSetGetGlow "); - - TestApplication application; - - TextStyle style; - - style.SetSmoothEdge( SMOOTH_EDGE ); - - DALI_TEST_EQUALS( style.GetSmoothEdge(), SMOOTH_EDGE, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - // Added to increase coverage - style.SetWeight( TEXT_WEIGHT ); - DALI_TEST_EQUALS( style.GetWeight(), TEXT_WEIGHT, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextStyleSetGetItalics(void) -{ - tet_infoline(" UtcDaliTextStyleSetGetItalics "); - - TestApplication application; - - TextStyle style; - - DALI_TEST_EQUALS( style.GetItalicsAngle(), TextStyle::DEFAULT_ITALICS_ANGLE, TEST_LOCATION ); - - style.SetItalics( ITALICS, ITALICS_ANGLE ); - - DALI_TEST_CHECK( style.IsItalicsEnabled() ); - DALI_TEST_EQUALS( style.GetItalicsAngle(), ITALICS_ANGLE, TEST_LOCATION ); - - style.SetItalics( !ITALICS, TextStyle::DEFAULT_ITALICS_ANGLE ); - - DALI_TEST_CHECK( !style.IsItalicsEnabled() ); - - END_TEST; -} - -int UtcDaliTextStyleSetGetUnderline(void) -{ - tet_infoline(" UtcDaliTextStyleSetGetUnderline "); - - TestApplication application; - - TextStyle style; - - style.SetUnderline( UNDERLINE, UNDERLINE_THICKNESS, UNDERLINE_POSITION ); - - DALI_TEST_CHECK( style.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( style.GetUnderlineThickness(), UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetUnderlinePosition(), UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - style.SetUnderline( !UNDERLINE, TextStyle::DEFAULT_UNDERLINE_THICKNESS, TextStyle::DEFAULT_UNDERLINE_POSITION ); - - DALI_TEST_CHECK( !style.IsUnderlineEnabled() ); - DALI_TEST_EQUALS( style.GetUnderlineThickness(), TextStyle::DEFAULT_UNDERLINE_THICKNESS, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetUnderlinePosition(), TextStyle::DEFAULT_UNDERLINE_POSITION, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextStyleSetGetShadow(void) -{ - tet_infoline(" UtcDaliTextStyleSetGetShadow "); - - TestApplication application; - - TextStyle style; - - DALI_TEST_CHECK( !style.IsShadowEnabled() ); - - style.SetShadow( SHADOW, SHADOW_COLOR, SHADOW_OFFSET, SHADOW_SIZE ); - - DALI_TEST_CHECK( style.IsShadowEnabled() ); - DALI_TEST_EQUALS( style.GetShadowColor(), SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetShadowOffset(), SHADOW_OFFSET, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetShadowSize(), SHADOW_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - style.SetShadow( !SHADOW, TextStyle::DEFAULT_SHADOW_COLOR, TextStyle::DEFAULT_SHADOW_OFFSET, TextStyle::DEFAULT_SHADOW_SIZE ); - DALI_TEST_CHECK( !style.IsShadowEnabled() ); - DALI_TEST_EQUALS( style.GetShadowColor(), TextStyle::DEFAULT_SHADOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetShadowOffset(), TextStyle::DEFAULT_SHADOW_OFFSET, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetShadowSize(), TextStyle::DEFAULT_SHADOW_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextStyleSetGetGlow(void) -{ - tet_infoline(" UtcDaliTextStyleSetGetGlow "); - - TestApplication application; - - TextStyle style; - - DALI_TEST_CHECK( !style.IsGlowEnabled() ); - - style.SetGlow( GLOW, GLOW_COLOR, GLOW_INTENSITY ); - - DALI_TEST_CHECK( style.IsGlowEnabled() ); - DALI_TEST_EQUALS( style.GetGlowColor(), GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetGlowIntensity(), GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - style.SetGlow( !GLOW, TextStyle::DEFAULT_GLOW_COLOR, TextStyle::DEFAULT_GLOW_INTENSITY ); - - DALI_TEST_CHECK( !style.IsGlowEnabled() ); - DALI_TEST_EQUALS( style.GetGlowColor(), TextStyle::DEFAULT_GLOW_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetGlowIntensity(), TextStyle::DEFAULT_GLOW_INTENSITY, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextStyleSetGetOutline(void) -{ - tet_infoline(" UtcDaliTextStyleSetGetOutline "); - - TestApplication application; - - TextStyle style; - - DALI_TEST_CHECK( !style.IsOutlineEnabled() ); - - style.SetOutline( OUTLINE, OUTLINE_COLOR, OUTLINE_THICKNESS ); - - DALI_TEST_CHECK( style.IsOutlineEnabled() ); - DALI_TEST_EQUALS( style.GetOutlineColor(), OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetOutlineThickness(), OUTLINE_THICKNESS, TEST_LOCATION ); - - style.SetOutline( !OUTLINE, TextStyle::DEFAULT_OUTLINE_COLOR, TextStyle::DEFAULT_OUTLINE_THICKNESS ); - - DALI_TEST_CHECK( !style.IsOutlineEnabled() ); - DALI_TEST_EQUALS( style.GetOutlineColor(), TextStyle::DEFAULT_OUTLINE_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetOutlineThickness(), TextStyle::DEFAULT_OUTLINE_THICKNESS, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliTextStyleSetGetGradient(void) -{ - tet_infoline(" UtcDaliTextStyleSetGetGradient "); - - TestApplication application; - - TextStyle style; - - DALI_TEST_CHECK( !style.IsGradientEnabled() ); - - style.SetGradient( GRADIENT, GRADIENT_COLOR, GRADIENT_START_POINT, GRADIENT_END_POINT ); - - DALI_TEST_CHECK( style.IsGradientEnabled() ); - DALI_TEST_EQUALS( style.GetGradientColor(), GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetGradientStartPoint(), GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetGradientEndPoint(), GRADIENT_END_POINT, TEST_LOCATION ); - - style.SetGradient( !GRADIENT, TextStyle::DEFAULT_GRADIENT_COLOR, TextStyle::DEFAULT_GRADIENT_START_POINT, TextStyle::DEFAULT_GRADIENT_END_POINT ); - - DALI_TEST_CHECK( !style.IsGradientEnabled() ); - DALI_TEST_EQUALS( style.GetGradientColor(), TextStyle::DEFAULT_GRADIENT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetGradientStartPoint(), TextStyle::DEFAULT_GRADIENT_START_POINT, TEST_LOCATION ); - DALI_TEST_EQUALS( style.GetGradientEndPoint(), TextStyle::DEFAULT_GRADIENT_END_POINT, TEST_LOCATION ); - - END_TEST; -} diff --git a/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp b/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp index 19327d6..49130c3 100644 --- a/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp +++ b/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp @@ -1295,7 +1295,7 @@ int UtcDaliTouchStencil(void) TestApplication application; Stage stage = Stage::GetCurrent(); - TextActor actor = TextActor::New(); + ImageActor actor = ImageActor::New(); actor.SetSize(100.0f, 100.0f); actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); stage.Add(actor); @@ -1333,12 +1333,12 @@ int UtcDaliTouchStencilInActorHierarchy(void) TestApplication application; Stage stage = Stage::GetCurrent(); - TextActor parent = TextActor::New(); + ImageActor parent = ImageActor::New(); parent.SetSize(100.0f, 100.0f); parent.SetAnchorPoint(AnchorPoint::TOP_LEFT); stage.Add(parent); - TextActor child = TextActor::New(); + ImageActor child = ImageActor::New(); child.SetSize(25.0f, 25.0f); child.SetAnchorPoint(AnchorPoint::TOP_LEFT); parent.Add(child); @@ -1419,7 +1419,7 @@ int UtcDaliTouchMultipleStencils(void) TestApplication application; Stage stage = Stage::GetCurrent(); - TextActor actor = TextActor::New(); + ImageActor actor = ImageActor::New(); actor.SetSize(100.0f, 100.0f); actor.SetAnchorPoint(AnchorPoint::TOP_LEFT); stage.Add(actor); diff --git a/dali/integration-api/file.list b/dali/integration-api/file.list index 30dee19..d6b7779 100644 --- a/dali/integration-api/file.list +++ b/dali/integration-api/file.list @@ -3,7 +3,6 @@ platform_abstraction_src_files = \ $(platform_abstraction_src_dir)/bitmap.cpp \ $(platform_abstraction_src_dir)/core.cpp \ - $(platform_abstraction_src_dir)/glyph-set.cpp \ $(platform_abstraction_src_dir)/image-data.cpp \ $(platform_abstraction_src_dir)/debug.cpp \ $(platform_abstraction_src_dir)/profiling.cpp \ @@ -26,7 +25,6 @@ platform_abstraction_src_files = \ platform_abstraction_header_files = \ $(platform_abstraction_src_dir)/core.h \ $(platform_abstraction_src_dir)/context-notifier.h \ - $(platform_abstraction_src_dir)/glyph-set.h \ $(platform_abstraction_src_dir)/debug.h \ $(platform_abstraction_src_dir)/profiling.h \ $(platform_abstraction_src_dir)/input-options.h \ @@ -45,8 +43,7 @@ platform_abstraction_header_files = \ $(platform_abstraction_src_dir)/platform-abstraction.h \ $(platform_abstraction_src_dir)/shader-data.h \ $(platform_abstraction_src_dir)/system-overlay.h \ - $(platform_abstraction_src_dir)/common/lockless-buffer.h \ - $(platform_abstraction_src_dir)/text-array.h + $(platform_abstraction_src_dir)/common/lockless-buffer.h platform_abstraction_dynamics_header_files = \ $(platform_abstraction_src_dir)/dynamics/dynamics-body-intf.h \ diff --git a/dali/integration-api/glyph-set.cpp b/dali/integration-api/glyph-set.cpp deleted file mode 100644 index 33d3e47..0000000 --- a/dali/integration-api/glyph-set.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -namespace Dali -{ - -namespace Integration -{ - -GlyphSet::GlyphSet() -: mFontHash(0), - mLineHeight(0.0f), - mAscender(0.0f), - mUnitsPerEM(0.0f), - mUnderlinePosition(0.0f), - mUnderlineThickness(0.0f), - mPadAdjust(0.0f), - mAtlasId( 0 ) -{ -} - -GlyphSet::~GlyphSet() -{ - mCharacterList.clear(); -} - -void GlyphSet::AddCharacter(BitmapPtr bitmapData, const GlyphMetrics& glyphMetrics) -{ - mCharacterList.push_back(Character(bitmapData, glyphMetrics)); -} - -void GlyphSet::AddCharacter(const Character& character) -{ - mCharacterList.push_back(character); -} - -const GlyphSet::CharacterList& GlyphSet::GetCharacterList() const -{ - return mCharacterList; -} - -bool GlyphSet::HasCharacter(const uint32_t charCode) const -{ - for (CharacterConstIter iter = mCharacterList.begin(), endIter = mCharacterList.end(); iter != endIter; ++iter) - { - if (iter->second.code == charCode) - { - return true; - } - } - return false; -} - -bool GlyphSet::HasCharacter(const Character& character) const -{ - return HasCharacter(character.second.code); -} - -ResourceId GlyphSet::GetAtlasResourceId() const -{ - return mAtlasId; -} - -void GlyphSet::SetAtlasResourceId(ResourceId resourceId) -{ - mAtlasId = resourceId; -} - -} //namespace Integration - -} //namespace Dali diff --git a/dali/integration-api/glyph-set.h b/dali/integration-api/glyph-set.h deleted file mode 100644 index 9474711..0000000 --- a/dali/integration-api/glyph-set.h +++ /dev/null @@ -1,186 +0,0 @@ -#ifndef __DALI_INTEGRATION_PLATFORM_FONT_H__ -#define __DALI_INTEGRATION_PLATFORM_FONT_H__ - -/* - * Copyright (c) 2014 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 - -// INTERNAL INCLUDES -#include -#include -#include -#include - -namespace Dali -{ - -namespace Integration -{ -class GlyphSet; -typedef IntrusivePtr GlyphSetPointer; - -/** - * A Glyph holds information for a single character. - */ -struct GlyphMetrics -{ - enum GlyphQuality - { - LOW_QUALITY = 0x0, - HIGH_QUALITY = 0x1 - }; - - uint32_t code:21; ///< character code (UTF-32), max value of 0x10ffff (21 bits) - uint32_t quality:1; ///< 0 = low quality, 1 = high quality - float width; ///< glyph width in pixels - float height; ///< glyph height in pixels - float top; ///< distance between glyph's tallest pixel and baseline - float left; ///< where to place the glyph horizontally in relation to current 'pen' position - float xAdvance; ///< distance in pixels to move the 'pen' after displaying the character - unsigned int xPosition; ///< x position in target atlas texture - unsigned int yPosition; ///< y position in target atlas texture -}; - -/** - * Stores font global metrics. - */ -struct GlobalMetrics -{ - GlobalMetrics() - : lineHeight( 0.f ), - ascender( 0.f ), - unitsPerEM( 0.f ), - underlinePosition( 0.f ), - underlineThickness( 0.f ), - padAdjustX( 0.f ), - padAdjustY( 0.f ), - maxWidth( 0.f ), - maxHeight( 0.f ) - {} - - GlobalMetrics( float lh, float asc, float upem, float up, float ut, float pax, float pay, float mw, float mh ) - : lineHeight( lh ), - ascender( asc ), - unitsPerEM( upem ), - underlinePosition( up ), - underlineThickness( ut ), - padAdjustX( pax ), - padAdjustY( pay ), - maxWidth( mw ), - maxHeight ( mh ) - {} - - float lineHeight; ///< Distance between baselines - float ascender; ///< Distance from baseline to top of cell - float unitsPerEM; ///< font units/EM - float underlinePosition; ///< Underline distance from baseline - float underlineThickness; ///< Underline thickness - float padAdjustX; ///< X adjustment value for padding around distance field - float padAdjustY; ///< Y adjustment value for padding around distance field - float maxWidth; ///< Width of widest glyph - float maxHeight; ///< Height of tallest glyph -}; - -/** - * - * Platform font class. - * A container for font data; consisting of some metrics and a list of bitmaps - */ -class DALI_IMPORT_API GlyphSet : public Dali::RefObject -{ -public: - typedef std::pair Character; - typedef IntrusivePtr CharacterPtr; - typedef std::vector CharacterList; - typedef CharacterList::iterator CharacterIter; - typedef CharacterList::const_iterator CharacterConstIter; - - /** - * Constructor. - */ - GlyphSet(); - - /** - * Destructor. - */ - ~GlyphSet(); - - /** - * Add a character to the platform font - * @param [in] bitmapData A bitmap of the rendered character - * @param [in] glyphMetrics Metrics for the character, including its character code - */ - void AddCharacter(BitmapPtr bitmapData, const GlyphMetrics& glyphMetrics); - - /** - * Add a character to the platform font - * @param [in] character The Character object - */ - void AddCharacter(const Character& character); - - /** - * Get the list of characters in the font - * @return The list of characters - */ - const CharacterList& GetCharacterList() const; - - /** - * Checks if the character is contained in the GlyphSet - * @param [in] charCode The character to search for. - * @return true if the character is contained in the GlyphSet - */ - bool HasCharacter(const uint32_t charCode) const; - - /** - * Checks if the character is contained in the GlyphSet - * @param [in] character The character to search for. - * @return true if the character is contained in the GlyphSet - */ - bool HasCharacter(const Character& character) const; - - /** - * Returns the resource ID of the texture atlas these bitmaps will be written to - * @return the resource id - */ - ResourceId GetAtlasResourceId() const; - - /** - * Sets the resource ID of the texture atlas these bitmaps will be written to - * @param[in] resourceId the resource identifier of the texture atlas. - */ - void SetAtlasResourceId(ResourceId resourceId); - - size_t mFontHash; ///< hash of the fontname the glyphs were loaded for - float mLineHeight; ///< Distance between baselines - float mAscender; ///< Distance from baseline to top of cell - float mUnitsPerEM; ///< font units/EM - float mUnderlinePosition; ///< Underline distance from baseline - float mUnderlineThickness; ///< Underline thickness - float mPadAdjust; ///< Adjustment value for padding around distance field - -private: - CharacterList mCharacterList; - ResourceId mAtlasId; ///< Resource ID of target texture -}; - -} // namespace Integration - -} // namespace Dali - -#endif // __DALI_INTEGRATION_PLATFORM_FONT_H__ diff --git a/dali/integration-api/platform-abstraction.h b/dali/integration-api/platform-abstraction.h index 77fa8fe..5f7601e 100644 --- a/dali/integration-api/platform-abstraction.h +++ b/dali/integration-api/platform-abstraction.h @@ -19,9 +19,8 @@ */ // INTERNAL INCLUDES -#include +#include #include -#include namespace Dali { @@ -162,79 +161,6 @@ public: */ virtual void JoinLoaderThreads() = 0; - // Font Queries - - /** - * Called by Dali to retrieve the default font family for the platform. - * Multi-threading note: this method will be called from the main thread only i.e. not - * from within the Core::Render() method. - * @return The default font family. - */ - virtual const std::string& GetDefaultFontFamily() const = 0; - - /** - * Called by Dali to retrieve the default font size for the platform in points. - * Multi-threading note: this method will be called from the main thread only i.e. not - * from within the Core::Render() method. - * @return The default font size. - */ - virtual float GetDefaultFontSize() const = 0; - - /** - * Gets a font line height to match a given caps-height - * - * @note fontFamily and fontStyle must have been validated previously. - * @see ValidateFontFamilyName(). - * - * @param[in] fontFamily The name of the font's family - * @param[in] fontStyle The style of the font - * @param[in] capsHeight The caps-height in pixels - */ - virtual PixelSize GetFontLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, CapsHeight capsHeight) const = 0; - - /** - * Called by Font objects to synchronously query glyph data. - * - * @note fontFamily and font style, included in the resource request, must have been validated previously. - * @see ValidateFontFamilyName(). - * - * @note Font's style goes inside the textRequest parameter - * @param[in] textRequest Resource request. Includes font's style. - * @param[in] fontFamily The name of the font's family - * @param[in] getBitmap Whether to load bitmaps for the symbols as well - * @return A GlyphSet pointer with a list of the requested glyph metrics. - */ - virtual Integration::GlyphSet* GetGlyphData ( const Integration::TextResourceType& textRequest, - const std::string& fontFamily, - bool getBitmap) const = 0; - - /** - * Called by GlyphResourceManager to synchronously load glyph data. - * - * @note fontFamily and font style, included in the resource request, must have been validated previously. - * @see ValidateFontFamilyName(). - * - * @param[in] textRequest resource request - * @param[in] fontFamily name of the font's family - * @return A GlyphSet pointer containing the requested glyph bitmaps. - */ - virtual Integration::GlyphSet* GetCachedGlyphData( const TextResourceType& textRequest, - const std::string& fontFamily ) const = 0; - - /** - * Called by Font objects to synchronously query global font metrics. - * - * @note fontFamily and fontStyle, must have been validated previously. - * @see ValidateFontFamilyName(). - * - * @param[in] fontFamily The name of the font's family - * @param[in] fontStyle The style of the font - * @param[out] globalMetrics font requested global metrics. - */ - virtual void GetGlobalMetrics( const std::string& fontFamily, - const std::string& fontStyle, - Integration::GlobalMetrics& globalMetrics ) const = 0; - /** * Sets horizontal and vertical pixels per inch value that is used by the display * @param[in] dpiHorizontal horizontal dpi value @@ -243,56 +169,6 @@ public: virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical) = 0; /** - * Returns the name of the font's family for displayed text. - * If possible, the returned font name should be able to display all characters in text. - * Otherwise returns closest match. - * @param[in] charsRequested displayed text - */ - virtual const std::string& GetFontFamilyForChars(const TextArray& charsRequested) const = 0; - - /** - * Checks whether all characters of text could be displayed with specified font family. - * - * @note fontFamily and fontStyle must have been validated previously. - * @see ValidateFontFamilyName(). - * - * @param[in] fontFamily The name of the font's family - * @param[in] fontStyle The style of the font - * @param[in] text displayed text - */ - virtual bool AllGlyphsSupported(const std::string& fontFamily, const std::string& fontStyle, const TextArray& text) const = 0; - - /** - * Checks whether fontName is a valid font family name and fontStyle is a valid font style. - * closestFontFamilyMatch and closestFontStyleMatch are always set to the best matching font - * or the system default font if no near match is detected. - * @param[in] fontFamily The name of the font's family - * @param[in] fontStyle The style of the font - * @param[out] isDefaultSystemFont Whether this font has been created with a default system font. - * @param[out] closestFontFamilyMatch Name of the font's family found based on the user input family's name - * @param[out] closestFontStyleMatch Name of the font's style found based on the user input font's style - * @return Whether a valid match has been found. - */ - virtual bool ValidateFontFamilyName(const std::string& fontFamily, const std::string& fontStyle, bool& isDefaultSystemFont, std::string& closestFontFamilyMatch, std::string& closestFontStyleMatch) const = 0; - - /** - * The mode for GetFontList() - */ - enum FontListMode - { - LIST_SYSTEM_FONTS, - LIST_APPLICATION_FONTS, - LIST_ALL_FONTS - }; - - /** - * Gets a list of fonts installed on the system. - * @param[in] mode which fonts to include in the list. - * @param[out] fontList The list of font family names. - */ - virtual void GetFontList( FontListMode mode, std::vector& fontList ) const = 0; - - /** * Load a file into a buffer * @param[in] filename The filename to load * @param[out] buffer A buffer to receive the file. @@ -310,95 +186,10 @@ public: virtual bool SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const = 0; /** - * This method re-loads the device defaults that Dali uses. Adaptor will call this - * when devices settings change. - */ - virtual void UpdateDefaultsFromDevice() = 0; - - /** * Get a pointer to the DynamicsFactory. */ virtual DynamicsFactory* GetDynamicsFactory() = 0; - /** - * Read from the metrics cache into the global metrics parameter - * - * @note fontFamily and fontStyle must have been validated previously. - * @see ValidateFontFamilyName(). - * - * @param[in] fontFamily The name of the font family - * @param[in] fontStyle The name of the font style - * @param[out] globalMetrics The data store to write into - * @return \e true if the operation succeeded - */ - virtual bool ReadGlobalMetricsFromCache( const std::string& fontFamily, - const std::string& fontStyle, - Integration::GlobalMetrics& globalMetrics ) = 0; - - /** - * - * @note fontFamily and fontStyle must have been validated previously. - * @see ValidateFontFamilyName(). - * - * Write the global metrics parameter to the metrics cache - * @param[in] fontFamily The name of the font family - * @param[in] fontStyle The name of the font style - * @param[out] globalMetrics The data store to write - */ - virtual void WriteGlobalMetricsToCache( const std::string& fontFamily, - const std::string& fontStyle, - const Integration::GlobalMetrics& globalMetrics ) = 0; - - /** - * Read the metrics from the cache into the supplied vector - * - * @note fontFamily and fontStyle must have been validated previously. - * @see ValidateFontFamilyName(). - * - * @param[in] fontFamily The name of the font family - * @param[in] fontStyle The name of the font style - * @param[out] glyphMetricsContainer The vector of metrics to write - * @return true if the operation succeeded - */ - virtual bool ReadMetricsFromCache( const std::string& fontFamily, - const std::string& fontStyle, - std::vector& glyphMetricsContainer ) = 0; - - /** - * Write the metrics to the cache - * - * @note fontFamily and fontStyle must have been validated previously. - * @see ValidateFontFamilyName(). - * - * @param[in] fontFamily The name of the font family - * @param[in] fontStyle The name of the font style - * @param[in] glyphSet The set of metrics to write - */ - virtual void WriteMetricsToCache( const std::string& fontFamily, - const std::string& fontStyle, - const Integration::GlyphSet& glyphSet ) = 0; - - /** - * Retrieves file names from the given directory. - * - * @param[in] directoryName The directory name. - * @param[out] fileNames The file names in the given directory. - */ - virtual void GetFileNamesFromDirectory( const std::string& directoryName, - std::vector& fileNames ) = 0; - - /** - * Retrieves the glyph image which represents the character. - * - * @param[in] fontFamily The font's family name. - * @param[in] fontStyle The font's style. - * @param[in] fontSize The font's size (in points). - * @param[in] character The given character. - * - * @return A bitmap representing the character. - */ - virtual Integration::BitmapPtr GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const = 0; - }; // class PlatformAbstraction } // namespace Integration diff --git a/dali/integration-api/profiling.cpp b/dali/integration-api/profiling.cpp index 4343fe5..bd3e6f2 100644 --- a/dali/integration-api/profiling.cpp +++ b/dali/integration-api/profiling.cpp @@ -26,14 +26,12 @@ #include #include -#include #include #include #include #include #include -#include #include #include @@ -48,7 +46,6 @@ #include #include -#include #include #include @@ -66,7 +63,6 @@ #include #include #include -#include #include @@ -74,7 +70,6 @@ #include #include -#include #include using Dali::Internal::GestureEventProcessor; @@ -126,13 +121,6 @@ const int CAMERA_ACTOR_MEMORY_SIZE( sizeof( Internal::CameraAttachment ) + sizeof( Internal::SceneGraph::Node ) + sizeof( Internal::SceneGraph::CameraAttachment ) ); -const int TEXT_ACTOR_MEMORY_SIZE( - sizeof( Internal::TextActor ) + - sizeof( Internal::TextAttachment ) + - sizeof( Internal::SceneGraph::Node ) + - sizeof( Internal::SceneGraph::TextAttachment ) + - sizeof( Internal::TextParameters ) + - sizeof( Internal::SceneGraph::TextRenderer ) ); const int MESH_ACTOR_MEMORY_SIZE( sizeof( Internal::MeshActor ) + sizeof( Internal::MeshAttachment ) + diff --git a/dali/integration-api/resource-cache.h b/dali/integration-api/resource-cache.h index f094033..e5fa3d6 100644 --- a/dali/integration-api/resource-cache.h +++ b/dali/integration-api/resource-cache.h @@ -21,7 +21,6 @@ // INTERNAL INCLUDES #include #include -#include namespace Dali { diff --git a/dali/integration-api/resource-types.h b/dali/integration-api/resource-types.h index 4174b0e..1811a3d 100644 --- a/dali/integration-api/resource-types.h +++ b/dali/integration-api/resource-types.h @@ -45,8 +45,7 @@ enum ResourceTypeId ResourceTargetImage, ResourceShader, ResourceModel, - ResourceMesh, - ResourceText + ResourceMesh }; /** @@ -266,145 +265,6 @@ private: }; /** - * TextResourceType describes a font resource, which can be requested. - * from PlatformAbstraction::LoadResource() No font atlas is created. - */ -struct TextResourceType : public ResourceType -{ - /** - * Text quality enum - */ - enum TextQuality - { - TextQualityLow, ///< Request lower quality text - TextQualityHigh ///< Request higher quality text - }; - - /** - * Structure for requesting character to be loaded from file with atlas position - * for automatic texture upload - */ - struct GlyphPosition - { - GlyphPosition(unsigned int chr, unsigned int xPos, unsigned int yPos) - : character(chr), - quality(0), - loaded(0), - xPosition(xPos), - yPosition(yPos) - { - } - - /** \addtogroup GlyphPositionPackedWord - * We have 32 bits available for this data because of the alignment restrictions - * on the 32 bit words that follow so rather than using the minimum number of - * bits for each, we give "loaded" a whole 8 bits and push it to a byte-aligned - * address to make access possible via a plain byte load instead of a load, - * mask, shift sequence. The naive bitwidths before this modification are as follows: - * character:21; - * quality:1; - * loaded:1; - * @{ - */ - uint32_t character:21; ///< character code (UTF-32), max value of 0x10ffff (21 bits) - uint32_t quality:3; ///< Loaded quality 0 = low quality, 1 = high quality - uint32_t loaded:8; ///< true if Loaded - /** @}*/ - - uint32_t xPosition; ///< X Position in atlas - uint32_t yPosition; ///< Y Position in atlas - - /** - * Used by ResourceTypeCompare - */ - friend bool operator==(const GlyphPosition& lhs, const GlyphPosition& rhs); - }; - - typedef std::vector< GlyphPosition > CharacterList; ///< List of glyphs requested - - enum GlyphCacheMode - { - GLYPH_CACHE_READ, ///< Doesn't cache glyphs. - GLYPH_CACHE_WRITE, ///< Caches glyphs. - }; - - /** - * Text resource type constructor - * @param [in] hash The resourceHash for the FontAtlas and FontMetrics - * @param [in] style The font style - * @param [in] characterList The requested text as a vector or UTF-32 codes - * @param [in] textureAtlasId The resource ID of the texture atlas - * @param [in] quality A boolean, set to true to request high quality glyph bitmaps. - * @param [in] maxGlyphSize The size of the largest glyph in the font. - * @param [in] cache Whether text glyph should be cached or not. - */ - TextResourceType( const size_t hash, - const std::string& style, - const CharacterList& characterList, - ResourceId textureAtlasId, - TextQuality quality = TextQualityLow, - Vector2 maxGlyphSize = Vector2::ONE, - GlyphCacheMode cache = GLYPH_CACHE_READ ) - : ResourceType(ResourceText), - mFontHash(hash), - mStyle(style), - mCharacterList(characterList), - mTextureAtlasId(textureAtlasId), - mQuality(quality), - mMaxGlyphSize(maxGlyphSize), - mCache( cache ) - { - } - - /** - * virtual destructor - */ - virtual ~TextResourceType() - { - } - - /** - * @copydoc ResourceType::Clone - */ - virtual ResourceType* Clone() const - { - return new TextResourceType(mFontHash, mStyle, mCharacterList, mTextureAtlasId, mQuality, mMaxGlyphSize, mCache); - } - - /** - * Font resource hash. - */ - const size_t mFontHash; - - /** - * Font style. - */ - const std::string mStyle; - - /** - * Displayed text (UTF-32 codes) - */ - - CharacterList mCharacterList; ///< List of characters - - ResourceId mTextureAtlasId; ///< Resource ID of the texture atlas this request is for - - TextQuality mQuality; ///< Text quality setting - - Vector2 mMaxGlyphSize; ///< Max glyph size for font - - GlyphCacheMode mCache; ///< Whether text glyphs should be cached. - -private: - - // Undefined copy constructor. - TextResourceType(const TextResourceType& typePath); - - // Undefined copy constructor. - TextResourceType& operator=(const TextResourceType& rhs); -}; - -/** * ModelResourceType describes a model resource, which can be requested * from PlatformAbstraction::LoadResource() */ @@ -477,11 +337,6 @@ private: MeshResourceType& operator=(const MeshResourceType& rhs); }; -inline bool operator==(const TextResourceType::GlyphPosition& lhs, const TextResourceType::GlyphPosition& rhs) -{ - return lhs.character == rhs.character && lhs.xPosition == rhs.xPosition && lhs.yPosition == rhs.yPosition && lhs.quality == rhs.quality; -} - } // namespace Integration } // namespace Dali diff --git a/dali/integration-api/text-array.h b/dali/integration-api/text-array.h deleted file mode 100644 index 70d78ef..0000000 --- a/dali/integration-api/text-array.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef __DALI_INTERNAL_TEXT_ARRAY_H__ -#define __DALI_INTERNAL_TEXT_ARRAY_H__ - -/* - * Copyright (c) 2014 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 - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Integration -{ - -/** - * array of UTF-32 codes. - */ -typedef Vector TextArray; - -} // namespace Integration - -} // namespace Dali - -#endif // __DALI_INTERNAL_TEXT_ARRAY_H__ diff --git a/dali/internal/common/bitmap-upload.h b/dali/internal/common/bitmap-upload.h index d6419c1..700785f 100644 --- a/dali/internal/common/bitmap-upload.h +++ b/dali/internal/common/bitmap-upload.h @@ -80,7 +80,7 @@ typedef std::vector BitmapUploadArray; ///< typedef for a array of /** - * Structure is used for clearing areas of the atlas prior to loading glyphs + * Structure is used for clearing areas of the bitmap */ typedef std::vector BitmapClearArray; diff --git a/dali/internal/common/core-impl.cpp b/dali/internal/common/core-impl.cpp index 97787c7..8f788ed 100644 --- a/dali/internal/common/core-impl.cpp +++ b/dali/internal/common/core-impl.cpp @@ -39,9 +39,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -95,11 +93,9 @@ Core::Core( RenderController& renderController, PlatformAbstraction& platform, mDiscardQueue(NULL), mResourcePostProcessQueue(), mNotificationManager(NULL), - mFontFactory(NULL), mImageFactory(NULL), mModelFactory(NULL), mShaderFactory(NULL), - mEmojiFactory(NULL), mIsActive(true), mProcessingEvent(false) { @@ -163,12 +159,10 @@ Core::Core( RenderController& renderController, PlatformAbstraction& platform, mGestureEventProcessor = new GestureEventProcessor(*mStage, gestureManager, mRenderController); mEventProcessor = new EventProcessor(*mStage, *mNotificationManager, *mGestureEventProcessor); - mFontFactory = new FontFactory(*mResourceClient); mImageFactory = new ImageFactory( *mResourceClient ); mModelFactory = new ModelFactory(*mResourceClient); mShaderFactory = new ShaderFactory(*mResourceClient); mShaderFactory->LoadDefaultShaders(); - mEmojiFactory = new EmojiFactory(); GetImplementation(Dali::TypeRegistry::Get()).CallInitFunctions(); } @@ -199,7 +193,6 @@ Core::~Core() delete mEventProcessor; delete mGestureEventProcessor; delete mNotificationManager; - delete mFontFactory; delete mImageFactory; delete mModelFactory; delete mShaderFactory; @@ -207,7 +200,6 @@ Core::~Core() delete mResourceManager; delete mUpdateManager; delete mTouchResampler; - delete mEmojiFactory; delete mRenderManager; delete mDiscardQueue; delete mResourcePostProcessQueue; @@ -223,7 +215,6 @@ void Core::RecoverFromContextLoss() DALI_LOG_INFO(gCoreFilter, Debug::Verbose, "Core::RecoverFromContextLoss()\n"); mImageFactory->RecoverFromContextLoss(); // Reload images from files - mFontFactory->RecoverFromContextLoss(); // Reload glyphs from cache into new atlas mStage->GetRenderTaskList().RecoverFromContextLoss(); // Re-trigger render-tasks } @@ -245,7 +236,6 @@ void Core::SurfaceResized(unsigned int width, unsigned int height) void Core::SetDpi(unsigned int dpiHorizontal, unsigned int dpiVertical) { mPlatform.SetDpi( dpiHorizontal, dpiVertical ); - mFontFactory->SetDpi( dpiHorizontal, dpiVertical); mStage->SetDpi( Vector2( dpiHorizontal , dpiVertical) ); } @@ -333,9 +323,6 @@ void Core::ProcessEvents() // Flush discard queue for image factory mImageFactory->FlushReleaseQueue(); - // send text requests if required - mFontFactory->SendTextRequests(); - // Flush any queued messages for the update-thread const bool messagesToProcess = eventToUpdate.FlushQueue(); @@ -424,11 +411,6 @@ ResourceClient& Core::GetResourceClient() return *(mResourceClient); } -FontFactory& Core::GetFontFactory() -{ - return *(mFontFactory); -} - ImageFactory& Core::GetImageFactory() { return *(mImageFactory); @@ -449,11 +431,6 @@ GestureEventProcessor& Core::GetGestureEventProcessor() return *(mGestureEventProcessor); } -EmojiFactory& Core::GetEmojiFactory() -{ - return *mEmojiFactory; -} - void Core::CreateThreadLocalStorage() { // a pointer to the ThreadLocalStorage object will be stored in TLS diff --git a/dali/internal/common/core-impl.h b/dali/internal/common/core-impl.h index b456e82..aa0ce23 100644 --- a/dali/internal/common/core-impl.h +++ b/dali/internal/common/core-impl.h @@ -56,12 +56,10 @@ class EventProcessor; class GestureEventProcessor; class ResourceClient; class ResourceManager; -class FontFactory; class ImageFactory; class ModelFactory; class ShaderFactory; class TouchResampler; -class EmojiFactory; namespace SceneGraph { @@ -239,12 +237,6 @@ private: // for use by ThreadLocalStorage ResourceClient& GetResourceClient(); /** - * Returns the Font factory - * @return A reference to the Font factory. - */ - FontFactory& GetFontFactory(); - - /** * Returns the Image factory * @return A reference to the Image factory. */ @@ -268,12 +260,6 @@ private: // for use by ThreadLocalStorage */ GestureEventProcessor& GetGestureEventProcessor(); - /** - * Returns the Emoji factory. - * @return a reference to the Emoji factory. - */ - EmojiFactory& GetEmojiFactory(); - private: /** @@ -302,14 +288,12 @@ private: NotificationManager* mNotificationManager; ///< Notification manager AnimationPlaylistOwner mAnimationPlaylist; ///< For 'Fire and forget' animation support OwnerPointer mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications - FontFactory* mFontFactory; ///< font resource factory ImageFactory* mImageFactory; ///< Image resource factory ModelFactory* mModelFactory; ///< Model resource factory ShaderFactory* mShaderFactory; ///< Shader resource factory ResourceClient* mResourceClient; ///< Asynchronous Resource Loading ResourceManager* mResourceManager; ///< Asynchronous Resource Loading TouchResampler* mTouchResampler; ///< Resamples touches to correct frame rate. - EmojiFactory* mEmojiFactory; ///< Emoji resource factory. bool mIsActive : 1; ///< Whether Core is active or suspended bool mProcessingEvent : 1; ///< True during ProcessEvents() diff --git a/dali/internal/common/text-parameters.cpp b/dali/internal/common/text-parameters.cpp deleted file mode 100644 index 7edcae2..0000000 --- a/dali/internal/common/text-parameters.cpp +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -TextParameters::TextParameters() -: mFlags( 0 ) -{ -} - -TextParameters::~TextParameters() -{ - // destroy all containers. - if ( mFlags & OUTLINE_EXISTS ) - { - OutlineAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( mFlags & TEXT_PARAMETER_MASK ) ) ); - delete attrPtr; - } - if ( mFlags & GLOW_EXISTS ) - { - GlowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) ); - delete attrPtr; - } - if ( mFlags & DROP_SHADOW_EXISTS ) - { - DropShadowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) ); - delete attrPtr; - } - if ( mFlags & GRADIENT_EXISTS ) - { - GradientAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) ); - delete attrPtr; - } -} - -void TextParameters::SetOutline( bool enable, const Vector4& color, const Vector2& thickness ) -{ - if ( mFlags & OUTLINE_EXISTS ) - { - OutlineAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( mFlags & TEXT_PARAMETER_MASK ) ) ); - attrPtr->mOutlineColor = color; - attrPtr->mOutlineThickness = thickness; - } - else - { - OutlineAttributes* attr = new OutlineAttributes(); - attr->mOutlineColor = color; - attr->mOutlineThickness = thickness; - mFlags |= ( ( mFlags & ~OUTLINE_INDEX ) | ( mParameters.Size() & TEXT_PARAMETER_MASK ) | OUTLINE_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } - - if( enable ) - { - mFlags |= OUTLINE_ENABLED; - } - else - { - mFlags &= ~OUTLINE_ENABLED; - } -} - -void TextParameters::SetGlow( bool enable, const Vector4& color, float intensity ) -{ - if ( mFlags & GLOW_EXISTS ) - { - GlowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) ); - attrPtr->mGlowColor = color; - attrPtr->mGlowIntensity = intensity; - } - else - { - GlowAttributes* attr = new GlowAttributes(); - attr->mGlowColor = color; - attr->mGlowIntensity = intensity; - mFlags |= ( ( mFlags & ~GLOW_INDEX ) | ( ( mParameters.Size() & TEXT_PARAMETER_MASK ) << GLOW_INDEX_SHIFT ) | GLOW_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } - - if( enable ) - { - mFlags |= GLOW_ENABLED; - } - else - { - mFlags &= ~GLOW_ENABLED; - } -} - -void TextParameters::SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size ) -{ - if ( mFlags & DROP_SHADOW_EXISTS ) - { - DropShadowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) ); - attrPtr->mDropShadowColor = color; - attrPtr->mDropShadowOffset = offset; - attrPtr->mDropShadowSize = size; - } - else - { - DropShadowAttributes* attr = new DropShadowAttributes(); - attr->mDropShadowColor = color; - attr->mDropShadowOffset = offset; - attr->mDropShadowSize = size; - mFlags |= ( ( mFlags & ~DROP_SHADOW_INDEX ) | ( ( mParameters.Size() & TEXT_PARAMETER_MASK ) << DROP_SHADOW_INDEX_SHIFT ) | DROP_SHADOW_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } - - if( enable ) - { - mFlags |= DROP_SHADOW_ENABLED; - } - else - { - mFlags &= ~DROP_SHADOW_ENABLED; - } -} - -void TextParameters::SetGradient( const Vector4& color, const Vector2& start, const Vector2& end ) -{ - if ( mFlags & GRADIENT_EXISTS ) - { - GradientAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) ); - attrPtr->mGradientColor = color; - attrPtr->mGradientStartPoint = start; - attrPtr->mGradientEndPoint = end; - } - else - { - GradientAttributes* attr = new GradientAttributes(); - attr->mGradientColor = color; - attr->mGradientStartPoint = start; - attr->mGradientEndPoint = end; - mFlags |= ( ( mFlags & ~GRADIENT_INDEX ) | ( ( mParameters.Size() & TEXT_PARAMETER_MASK ) << GRADIENT_INDEX_SHIFT ) | GRADIENT_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } - - if ( end != start ) - { - mFlags |= GRADIENT_ENABLED; - } - else - { - mFlags &=~GRADIENT_ENABLED; - } -} - -const Vector4& TextParameters::GetOutlineColor() const -{ - if ( mFlags & OUTLINE_ENABLED ) - { - const OutlineAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( mFlags & TEXT_PARAMETER_MASK ) ) ); - return attrPtr->mOutlineColor; - } - else - { - return TextStyle::DEFAULT_OUTLINE_COLOR; - } -} - -const Vector2& TextParameters::GetOutlineThickness() const -{ - if ( mFlags & OUTLINE_EXISTS ) - { - const OutlineAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( mFlags & TEXT_PARAMETER_MASK ) ) ); - return attrPtr->mOutlineThickness; - } - else - { - return TextStyle::DEFAULT_OUTLINE_THICKNESS; - } -} - -const Vector4& TextParameters::GetGlowColor() const -{ - if ( mFlags & GLOW_EXISTS ) - { - const GlowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) ); - return attrPtr->mGlowColor; - } - else - { - return TextStyle::DEFAULT_GLOW_COLOR; - } -} - -float TextParameters::GetGlowIntensity() const -{ - if ( mFlags & GLOW_EXISTS ) - { - const GlowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) ); - return attrPtr->mGlowIntensity; - } - else - { - return TextStyle::DEFAULT_GLOW_INTENSITY; - } -} - -const Vector4& TextParameters::GetDropShadowColor() const -{ - if ( mFlags & DROP_SHADOW_EXISTS ) - { - const DropShadowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) ); - return attrPtr->mDropShadowColor; - } - else - { - return TextStyle::DEFAULT_SHADOW_COLOR; - } -} - -const Vector2& TextParameters::GetDropShadowOffset() const -{ - if ( mFlags & DROP_SHADOW_EXISTS ) - { - - const DropShadowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) ); - return attrPtr->mDropShadowOffset; - } - else - { - return TextStyle::DEFAULT_SHADOW_OFFSET; - } -} - -float TextParameters::GetDropShadowSize() const -{ - if ( mFlags & DROP_SHADOW_EXISTS ) - { - const DropShadowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) ); - return attrPtr->mDropShadowSize; - } - else - { - return TextStyle::DEFAULT_SHADOW_SIZE; - } -} - -const Vector4& TextParameters::GetGradientColor() const -{ - if ( mFlags & GRADIENT_EXISTS ) - { - const GradientAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) ); - return attrPtr->mGradientColor; - } - else - { - return TextStyle::DEFAULT_GRADIENT_COLOR; - } -} - -const Vector2& TextParameters::GetGradientStartPoint() const -{ - if ( mFlags & GRADIENT_EXISTS ) - { - const GradientAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) ); - return attrPtr->mGradientStartPoint; - } - else - { - return TextStyle::DEFAULT_GRADIENT_START_POINT; - } -} - -const Vector2& TextParameters::GetGradientEndPoint() const -{ - if ( mFlags & GRADIENT_EXISTS ) - { - const GradientAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & TEXT_PARAMETER_MASK ) ) ); - return attrPtr->mGradientEndPoint; - } - else - { - return TextStyle::DEFAULT_GRADIENT_END_POINT; - } -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/common/text-parameters.h b/dali/internal/common/text-parameters.h deleted file mode 100644 index 8252523..0000000 --- a/dali/internal/common/text-parameters.h +++ /dev/null @@ -1,264 +0,0 @@ -#ifndef __INTERNAL_TEXT_PARAMETERS_H__ -#define __INTERNAL_TEXT_PARAMETERS_H__ - -/* - * Copyright (c) 2014 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 -#include -#include - -namespace Dali -{ - -namespace Internal -{ - - - // Number of bits for an index mask - increase if more attributes are added... - const unsigned int TEXT_PARAMETER_BITS = 2u; - - // Set mask for this number of bits - const unsigned int TEXT_PARAMETER_MASK = ~( -1 << TEXT_PARAMETER_BITS ); - - // Shift values for attribute indices - const unsigned int OUTLINE_INDEX_SHIFT = 0u; - const unsigned int GLOW_INDEX_SHIFT = OUTLINE_INDEX_SHIFT + TEXT_PARAMETER_BITS; - const unsigned int DROP_SHADOW_INDEX_SHIFT = GLOW_INDEX_SHIFT + TEXT_PARAMETER_BITS; - const unsigned int GRADIENT_INDEX_SHIFT = DROP_SHADOW_INDEX_SHIFT + TEXT_PARAMETER_BITS; - const unsigned int TEXT_PARAMETER_FLAGS = GRADIENT_INDEX_SHIFT + TEXT_PARAMETER_BITS; - - // Position in flags for attribute index - const unsigned int OUTLINE_INDEX = 0u; // bits 0,1 - const unsigned int GLOW_INDEX = TEXT_PARAMETER_MASK << GLOW_INDEX_SHIFT; // bits 2,3 - const unsigned int DROP_SHADOW_INDEX = TEXT_PARAMETER_MASK << DROP_SHADOW_INDEX_SHIFT; // bits 4,5 - const unsigned int GRADIENT_INDEX = TEXT_PARAMETER_MASK << GRADIENT_INDEX_SHIFT; // bits 6,7 - - // Flag positions for attributes ( gradient has two as parameters can be set independently ) - const unsigned int OUTLINE_EXISTS = 1u << TEXT_PARAMETER_FLAGS; // bit 8 - const unsigned int OUTLINE_ENABLED = 1u << ( TEXT_PARAMETER_FLAGS + 1u ); // bit 9 - const unsigned int GLOW_EXISTS = 1u << ( TEXT_PARAMETER_FLAGS + 2u ); // bit 10 - const unsigned int GLOW_ENABLED = 1u << ( TEXT_PARAMETER_FLAGS + 3u ); // bit 11 - const unsigned int DROP_SHADOW_EXISTS = 1u << ( TEXT_PARAMETER_FLAGS + 4u ); // bit 12 - const unsigned int DROP_SHADOW_ENABLED = 1u << ( TEXT_PARAMETER_FLAGS + 5u ); // bit 13 - const unsigned int GRADIENT_EXISTS = 1u << ( TEXT_PARAMETER_FLAGS + 6u ); // bit 14 - const unsigned int GRADIENT_ENABLED = 1u << ( TEXT_PARAMETER_FLAGS + 7u ); // bit 15 - const unsigned int ATTRIBUTE_END = GRADIENT_ENABLED; - -/** - * class TextParameters internal class to encapsulate (and allow on demand allocation) of - * text effect parameters like, outline, glow and shadow - */ -class TextParameters -{ -public: - - /** - * @brief Outline attributes - */ - struct OutlineAttributes - { - Vector4 mOutlineColor; - Vector2 mOutlineThickness; - }; - - /** - * @brief Glow attributes - */ - struct GlowAttributes - { - Vector4 mGlowColor; - float mGlowIntensity; - }; - - /** - * @brief Drop Shadow attributes - */ - struct DropShadowAttributes - { - Vector4 mDropShadowColor; - Vector2 mDropShadowOffset; - float mDropShadowSize; - }; - - /** - * @brief Gradient attributes - */ - struct GradientAttributes - { - Vector4 mGradientColor; - Vector2 mGradientStartPoint; - Vector2 mGradientEndPoint; - }; - - /** - * Constructor - */ - TextParameters(); - - /** - * Destructor - */ - ~TextParameters(); - - /// @copydoc Dali::TextActor::SetOutline - void SetOutline( bool enable, const Vector4& color, const Vector2& thickness ); - - /// @copydoc Dali::TextActor::SetGlow - void SetGlow( bool enable, const Vector4& color, float intensity ); - - /// @copydoc Dali::TextActor::SetShadow - void SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size ); - - /** - * @brief Set Gradient parameters. - * @param[in] color The gradient color (end-point color) - * @param[in] start The relative position of the gradient start point. - * @param[in] end The relative position of the gradient end point. - */ - void SetGradient( const Vector4& color, const Vector2& start, const Vector2& end ); - - /** - * @brief Get the Gradient Color - * - * @return Gradient Color - */ - const Vector4& GetOutlineColor() const; - - /** - * @brief Get Outline Thickness - * - * @return Outline Thickness - */ - const Vector2& GetOutlineThickness() const; - - /** - * @brief Get Glow Color - * - * @return Glow Color - */ - const Vector4& GetGlowColor() const; - - /** - * @brief Get Glow Intensity - * - * @return Glow Intensity - */ - float GetGlowIntensity() const; - - /** - * @brief Get Drop Shadow Color - * - * @return Drop Shadow Color - */ - const Vector4& GetDropShadowColor() const; - - /** - * @brief Get Drop Shadow Offset - * - * @return Drop Shadow Offset - */ - const Vector2& GetDropShadowOffset() const; - - /** - * @brief Get Drop Shadow Size - * - * @return Drop Shadow Size - */ - float GetDropShadowSize() const; - - /** - * @brief Get Gradient Color - * - * @return Gradient Color - */ - const Vector4& GetGradientColor() const; - - /** - * @brief Get Gradient Start Point - * - * @return Position of Gradient Start Point - */ - const Vector2& GetGradientStartPoint() const; - - /** - * @brief Get Gradient End Point - * - * @return Position of Gradient End Point - */ - const Vector2& GetGradientEndPoint() const; - - /** - * @brief Get if Outline is enabled - * - * @return true if enabled, false if not - */ - bool IsOutlineEnabled() const - { - return ( ( mFlags & OUTLINE_ENABLED ) != 0 ); - } - - /** - * @brief Get if Glow is enabled - * - * @return true if enabled, false if not - */ - bool IsGlowEnabled() const - { - return ( ( mFlags & GLOW_ENABLED ) != 0 ); - } - - /** - * @brief Get if Drop Shadow is enabled - * - * @return true if enabled, false if not - */ - bool IsDropShadowEnabled() const - { - return ( ( mFlags & DROP_SHADOW_ENABLED ) != 0 ); - } - - /** - * @brief Get if Gradient is enabled - * - * @return true if enabled, false if not - */ - bool IsGradientEnabled() const - { - return ( ( mFlags & GRADIENT_ENABLED ) != 0 ); - } - -private: // unimplemented copy constructor and assignment operator - TextParameters( const TextParameters& copy ); - TextParameters& operator=(const TextParameters& rhs); - - Vector mParameters; // container for any used attributes - -#if ( ATTRIBUTE_END > 0x8000 ) - unsigned int mFlags; // flags for used attributes, packed with position in container -#else - unsigned short mFlags; // might be rendered irrelevant by alignment / packing -#endif - -}; // class TextParameters - -} // namespace Internal - -} // namespace Dali - -#endif // __INTERNAL_TEXT_PARAMETERS_H__ diff --git a/dali/internal/common/text-vertex-buffer.h b/dali/internal/common/text-vertex-buffer.h deleted file mode 100644 index 1459ace..0000000 --- a/dali/internal/common/text-vertex-buffer.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef __DALI_INTERNAL_TEXT_VERTEX_BUFFER_H__ -#define __DALI_INTERNAL_TEXT_VERTEX_BUFFER_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -/* - * Vertex data for display text. - * No indices are stored because, text is an array of quads. - * each character quad is made up for 2 triangles (4 points). - */ -struct TextVertexBuffer -{ - std::vector mVertices; ///< List of vertices (coordinates and texture coordinates) - unsigned int mTextureId; ///< Texture id - Vector2 mVertexMax; ///< Calculated unskewed geometry size - Vector2 mGeometryExtent; ///< Actual extents of geometry -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_TEXT_VERTEX_BUFFER_H__ diff --git a/dali/internal/event/actor-attachments/actor-attachment-declarations.h b/dali/internal/event/actor-attachments/actor-attachment-declarations.h index 3759f37..36744ea 100644 --- a/dali/internal/event/actor-attachments/actor-attachment-declarations.h +++ b/dali/internal/event/actor-attachments/actor-attachment-declarations.h @@ -32,7 +32,6 @@ class ActorAttachment; class CameraAttachment; class ImageAttachment; class LightAttachment; -class TextAttachment; class MeshAttachment; typedef IntrusivePtr ActorAttachmentPtr; @@ -40,7 +39,6 @@ typedef IntrusivePtr CameraAttachmentPtr; typedef IntrusivePtr ImageAttachmentPtr; typedef IntrusivePtr LightAttachmentPtr; typedef IntrusivePtr MeshAttachmentPtr; -typedef IntrusivePtr TextAttachmentPtr; } // namespace Internal diff --git a/dali/internal/event/actor-attachments/text-attachment-impl.cpp b/dali/internal/event/actor-attachments/text-attachment-impl.cpp deleted file mode 100644 index 97ee7ad..0000000 --- a/dali/internal/event/actor-attachments/text-attachment-impl.cpp +++ /dev/null @@ -1,631 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER - -#include - -// INTERNAL INCLUDES - -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -TextAttachmentPtr TextAttachment::New( const SceneGraph::Node& parentNode, const Integration::TextArray& text, FontPointer font ) -{ - StagePtr stage = Stage::GetCurrent(); - - TextAttachmentPtr attachment( new TextAttachment( *stage ) ); - - // Second-phase construction - - attachment->mFont = font; - attachment->mText = text; - - // Transfer object ownership of scene-object to message - SceneGraph::TextAttachment* sceneObject = SceneGraph::TextAttachment::New(); - - AttachToNodeMessage( stage->GetUpdateManager(), parentNode, sceneObject ); - - // Keep raw pointer for message passing - attachment->mSceneObject = sceneObject; - - attachment->CalculateWeightedSmoothing( TextStyle::DEFAULT_FONT_WEIGHT, TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD ); // adjust smoothedge for font weight - - return attachment; -} - -TextAttachment::TextAttachment( Stage& stage ) -: RenderableAttachment( stage ), - mSceneObject( NULL ), - mTextRequestHelper( *this ), - mTextColor( NULL ), - mTextChanged( true ), - mFontChanged( true ), - mUnderlineChanged( true ), - mItalicsChanged( true ), - mTextureIdSet( false ), - mTextureId(0), - mTextSize( Vector3::ZERO ) -{ -} - -TextAttachment::~TextAttachment() -{ - delete mTextColor; -} - -void TextAttachment::SetText( const Integration::TextArray& text ) -{ - // return if the text hasn't changed - if( ( text.Count() == mText.Count() ) && - std::equal( mText.Begin(), mText.End(), text.Begin () ) ) - { - return; - } - - // Cache for public getters - mText = text; - mTextChanged = true; -} - -void TextAttachment::SetFont(Font& font) -{ - if( font == *mFont ) - { - return; - } - // References the font - mFont = &font; - mFontChanged = true; -} - -void TextAttachment::SetTextColor( const Vector4& color ) -{ - bool sendMessage( false ); - - Vector4 clampedColor = Clamp( color, 0.f, 1.f ); - - if( NULL == mTextColor ) - { - // A color (different from default) has been set, so allocate storage for the text color - mTextColor = new Vector4( clampedColor ); - sendMessage = true; - } - else - { - if( *mTextColor != clampedColor ) - { - // text color has changed - *mTextColor = clampedColor; - sendMessage = true; - } - } - - if( sendMessage ) - { - SetTextColorMessage( mStage->GetUpdateInterface(), *mSceneObject, clampedColor ); - } -} - -Vector4 TextAttachment::GetTextColor() const -{ - Vector4 color; - - if( NULL != mTextColor ) - { - color = *mTextColor; - } - else - { - color = TextStyle::DEFAULT_TEXT_COLOR; - } - - return color; -} - -void TextAttachment::ResetTextColor() -{ - if( NULL != mTextColor ) - { - delete mTextColor; - mTextColor = NULL; - - SetTextColorMessage( mStage->GetUpdateInterface(), *mSceneObject, TextStyle::DEFAULT_TEXT_COLOR ); - } -} - -void TextAttachment::SetWeight( TextStyle::Weight weight ) -{ - if( mStyle.IsFontWeightDefault() || - ( mStyle.GetWeight() != weight ) ) - { - mStyle.SetWeight( weight ); - - CalculateWeightedSmoothing( weight, mStyle.GetSmoothEdge() ); - } -} - -TextStyle::Weight TextAttachment::GetWeight() const -{ - return mStyle.GetWeight(); -} - -void TextAttachment::ResetWeight() -{ - if( !mStyle.IsFontWeightDefault() ) - { - mStyle.Reset( TextStyle::WEIGHT ); - - CalculateWeightedSmoothing( TextStyle::DEFAULT_FONT_WEIGHT, mStyle.GetSmoothEdge() ); - } -} - -void TextAttachment::SetSmoothEdge( float smoothEdge ) -{ - if( mStyle.IsSmoothEdgeDefault() || - ( fabsf( smoothEdge - mStyle.GetSmoothEdge() ) > Math::MACHINE_EPSILON_1000 ) ) - { - mStyle.SetSmoothEdge( smoothEdge ); - CalculateWeightedSmoothing( mStyle.GetWeight(), smoothEdge ); - } -} - -float TextAttachment::GetSmoothEdge() const -{ - return mStyle.GetSmoothEdge(); -} - -void TextAttachment::ResetSmoothEdge() -{ - if( !mStyle.IsSmoothEdgeDefault() ) - { - mStyle.Reset( TextStyle::SMOOTH ); - - CalculateWeightedSmoothing( mStyle.GetWeight(), TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD ); - } -} - -void TextAttachment::SetItalics( Radian angle ) -{ - if( mStyle.IsItalicsDefault() || - ( Radian( mStyle.GetItalicsAngle() ) != angle ) ) - { - mItalicsChanged = true; - - const Radian radian0( 0.0f ); - mStyle.SetItalics( ( radian0 != angle ), Degree( angle ) ); - } -} - -bool TextAttachment::GetItalics() const -{ - return mStyle.IsItalicsEnabled(); -} - -Radian TextAttachment::GetItalicsAngle() const -{ - return Radian( mStyle.GetItalicsAngle() ); -} - -void TextAttachment::ResetItalics() -{ - if( !mStyle.IsItalicsDefault() ) - { - mStyle.Reset( TextStyle::ITALICS ); - - mItalicsChanged = true; - } -} - -void TextAttachment::SetUnderline( bool enable, float thickness, float position ) -{ - if( mStyle.IsUnderlineDefault() || - ( mStyle.IsUnderlineEnabled() != enable ) || - ( fabsf( mStyle.GetUnderlineThickness() - thickness ) > Math::MACHINE_EPSILON_1000 ) || - ( fabsf( mStyle.GetUnderlinePosition() - position ) > Math::MACHINE_EPSILON_1000 ) ) - { - mUnderlineChanged = true; - - mStyle.SetUnderline( enable, thickness, position ); - } -} - -bool TextAttachment::GetUnderline() const -{ - return mStyle.IsUnderlineEnabled(); -} - -float TextAttachment::GetUnderlineThickness() const -{ - return mStyle.GetUnderlineThickness(); -} - -float TextAttachment::GetUnderlinePosition() const -{ - return mStyle.GetUnderlinePosition(); -} - -void TextAttachment::ResetUnderline() -{ - if( !mStyle.IsUnderlineDefault() ) - { - mStyle.Reset( TextStyle::UNDERLINE ); - - mUnderlineChanged = true; - } -} - -void TextAttachment::SetOutline( bool enable, const Vector4& color, const Vector2& thickness ) -{ - if( mStyle.IsOutlineDefault() || - ( mStyle.IsOutlineEnabled() != enable ) || - ( mStyle.GetOutlineColor() != color ) || - ( mStyle.GetOutlineThickness() != thickness ) ) - { - mStyle.SetOutline( enable, color, thickness ); - - SetOutlineMessage( mStage->GetUpdateInterface(), *mSceneObject, enable, color, thickness ); - } -} - -bool TextAttachment::GetOutline() const -{ - return mStyle.IsOutlineEnabled(); -} - -void TextAttachment::GetOutlineParams( Vector4& color, Vector2& thickness ) const -{ - color = mStyle.GetOutlineColor(); - thickness = mStyle.GetOutlineThickness(); -} - -void TextAttachment::ResetOutline() -{ - if( !mStyle.IsOutlineDefault() ) - { - mStyle.Reset( TextStyle::OUTLINE ); - - SetOutlineMessage( mStage->GetUpdateInterface(), *mSceneObject, false, TextStyle::DEFAULT_OUTLINE_COLOR, TextStyle::DEFAULT_OUTLINE_THICKNESS ); - } -} - -void TextAttachment::SetGlow( bool enable, const Vector4& color, float intensity ) -{ - if( mStyle.IsGlowDefault() || - ( mStyle.IsGlowEnabled() != enable ) || - ( mStyle.GetGlowColor() != color ) || - ( fabsf( mStyle.GetGlowIntensity() - intensity ) > Math::MACHINE_EPSILON_1000 ) ) - { - mStyle.SetGlow( enable, color, intensity ); - - SetGlowMessage( mStage->GetUpdateInterface(), *mSceneObject, enable, color, intensity ); - } -} - -bool TextAttachment::GetGlow() const -{ - return mStyle.IsGlowEnabled(); -} - -void TextAttachment::GetGlowParams( Vector4& color, float& intensity) const -{ - color = mStyle.GetGlowColor(); - intensity = mStyle.GetGlowIntensity(); -} - -void TextAttachment::ResetGlow() -{ - if( !mStyle.IsGlowDefault() ) - { - mStyle.Reset( TextStyle::GLOW ); - - SetGlowMessage( mStage->GetUpdateInterface(), *mSceneObject, false, TextStyle::DEFAULT_GLOW_COLOR, TextStyle::DEFAULT_GLOW_INTENSITY ); - } -} - -void TextAttachment::SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size ) -{ - if( mStyle.IsShadowDefault() || - ( mStyle.IsShadowEnabled() != enable ) || - ( mStyle.GetShadowColor() != color ) || - ( mStyle.GetShadowOffset() != offset ) || - ( fabsf( mStyle.GetShadowSize() - size ) > Math::MACHINE_EPSILON_1000 ) ) - { - mStyle.SetShadow( enable, color, offset, size ); - - const float unitPointSize( 64.0f ); - const float unitsToPixels( mFont->GetUnitsToPixels()); - const float fontPointSize( mFont->GetPointSize() ); - - float shadowSize( (size * 0.25f) / unitsToPixels ); - - Vector2 shadowOffset( offset ); - Vector2 maxOffset( fontPointSize / 4.5f, fontPointSize / 4.5f ); - shadowOffset = Min( shadowOffset, maxOffset ); - shadowOffset = Max( shadowOffset, -maxOffset ); - shadowOffset *= unitPointSize / fontPointSize; - SetDropShadowMessage( mStage->GetUpdateInterface(), *mSceneObject, enable, color, shadowOffset, shadowSize ); - } -} - -bool TextAttachment::GetShadow() const -{ - return mStyle.IsShadowEnabled(); -} - -void TextAttachment::GetShadowParams( Vector4& color, Vector2& offset, float& size ) const -{ - color = mStyle.GetShadowColor(); - offset = mStyle.GetShadowOffset(); - size = mStyle.GetShadowSize(); -} - -void TextAttachment::ResetShadow() -{ - if( !mStyle.IsShadowDefault() ) - { - mStyle.Reset( TextStyle::SHADOW ); - - const float unitPointSize( 64.0f ); - const float unitsToPixels( mFont->GetUnitsToPixels()); - const float fontPointSize( mFont->GetPointSize() ); - - float shadowSize( ( TextStyle::DEFAULT_SHADOW_SIZE * 0.25f ) / unitsToPixels ); - - Vector2 shadowOffset( TextStyle::DEFAULT_SHADOW_OFFSET ); - Vector2 maxOffset( fontPointSize / 4.5f, fontPointSize / 4.5f ); - shadowOffset = Min( shadowOffset, maxOffset ); - shadowOffset = Max( shadowOffset, -maxOffset ); - shadowOffset *= unitPointSize / fontPointSize; - SetDropShadowMessage( mStage->GetUpdateInterface(), *mSceneObject, false, TextStyle::DEFAULT_SHADOW_COLOR, shadowOffset, shadowSize ); - } -} - -void TextAttachment::SetGradient( const Vector4& color, const Vector2& startPoint, const Vector2& endPoint ) -{ - if( mStyle.IsGradientDefault() || - ( mStyle.GetGradientColor() != color ) || - ( mStyle.GetGradientStartPoint() != startPoint ) || - ( mStyle.GetGradientEndPoint() != endPoint ) ) - { - mStyle.SetGradient( true, color, startPoint, endPoint ); - SetGradientMessage( mStage->GetUpdateInterface(), *mSceneObject, color, startPoint, endPoint ); - } -} - -const Vector4& TextAttachment::GetGradientColor() const -{ - return mStyle.GetGradientColor(); -} - -const Vector2& TextAttachment::GetGradientStartPoint() const -{ - return mStyle.GetGradientStartPoint(); -} - -const Vector2& TextAttachment::GetGradientEndPoint() const -{ - return mStyle.GetGradientEndPoint(); -} - -void TextAttachment::ResetGradient() -{ - if( !mStyle.IsGradientDefault() ) - { - mStyle.Reset( TextStyle::GRADIENT ); - - SetGradientMessage( mStage->GetUpdateInterface(), *mSceneObject, TextStyle::DEFAULT_GRADIENT_COLOR, TextStyle::DEFAULT_GRADIENT_START_POINT, TextStyle::DEFAULT_GRADIENT_END_POINT ); - } -} - -void TextAttachment::GetTextStyle( TextStyle& style ) const -{ - style.Copy( mStyle ); - - // Font name, font style, font point size and color are not store inside the mStyle, so they need to be copied after. - - if( NULL != mTextColor ) - { - style.SetTextColor( *mTextColor ); - } - - if( !mFont->IsDefaultSystemFont() ) - { - style.SetFontName( mFont->GetName() ); - style.SetFontStyle( mFont->GetStyle() ); - } - - if( !mFont->IsDefaultSystemSize() ) - { - style.SetFontPointSize( PointSize( mFont->GetPointSize() ) ); - } -} - -Vector3 TextAttachment::MeasureText() const -{ - return mFont->MeasureText( mText ); -} - -void TextAttachment::TextChanged() -{ - DALI_LOG_INFO(Debug::Filter::gResource, Debug::Verbose, "TextAttachment::TextChanged() TextModified:%s TextEmpty:%s\n", IsTextModified()?"Y":"N", ( 0u == mText.Count() )?"Y":"N"); - - if( !IsTextModified() ) - { - return; - } - - // if the underline or italics have changed we trigger a text request - if( mUnderlineChanged || mItalicsChanged ) - { - mTextChanged = true; - } - - TextFormat format( mStyle.IsUnderlineEnabled(), - mStyle.IsItalicsEnabled(), - Radian( mStyle.GetItalicsAngle() ), - mFont->GetPointSize(), - mStyle.GetUnderlineThickness(), - mStyle.GetUnderlinePosition() ); - - if ( mTextChanged && mFontChanged ) - { - mVertexBuffer = mTextRequestHelper.SetTextAndFont( mText, mFont, format ); - } - else if( mTextChanged ) - { - mVertexBuffer = mTextRequestHelper.SetText( mText, format ); - } - else if ( mFontChanged ) - { - mVertexBuffer = mTextRequestHelper.SetFont( mFont, format ); - } - - // sceneObject is being used in a separate thread; queue a message to set - SetTextChanges(); - - mTextChanged = false; - mFontChanged = false; - mUnderlineChanged = false; - mItalicsChanged = false; -} - -bool TextAttachment::IsTextLoaded() -{ - bool loaded = mTextRequestHelper.IsTextLoaded(); - if( loaded && !mTextureIdSet ) - { - mTextureIdSet = true; - } - - return loaded; -} - -void TextAttachment::CalculateWeightedSmoothing( TextStyle::Weight weight, float smoothEdge ) -{ - float weightedSmoothing = smoothEdge; - - // Adjust edge smoothing for font weight - const float BOLDER = 0.20f; - const float LIGHTER = 1.65f; - const float offset = 1.0f - ( ( 1.0f / Dali::TextStyle::EXTRABLACK ) * weight ); - weightedSmoothing *= BOLDER + ( ( LIGHTER - BOLDER ) * offset ); - weightedSmoothing = std::max( 0.0f, weightedSmoothing ); - weightedSmoothing = std::min( 1.0f, weightedSmoothing ); - - SetSmoothEdgeMessage( mStage->GetUpdateInterface(), *mSceneObject, weightedSmoothing ); -} - -void TextAttachment::TextureResized( const TextureIdList& oldTextureIds, unsigned int newTextureId ) -{ - bool matched( false ); - - // check if resized texture is the one we are using - for( std::size_t i = 0, count = oldTextureIds.size(); i < count; ++i ) - { - if( oldTextureIds[i] == mTextureId ) - { - matched = true; - break; - } - } - - DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "TextAttachment::TextureResized() Current texture: %d New texture: %d\n", mTextureId, newTextureId); - - if( newTextureId == mTextureId ) - { - // nothing has changed, we are using the new texture already - return; - } - - // the texture we're using has been replaced - // re-request the text vertex information and update the texture id on the scene graph text attachment - if( matched ) - { - mTextRequestHelper.TextureChanged( mTextureId, newTextureId ); - mTextureId = newTextureId; - mTextChanged = true; - TextChanged(); - return; - } -} - -void TextAttachment::TextureSplit( FontId fontId, const TextureIdList& oldTextureIds, unsigned int newTextureId ) -{ - // currently not supported. - // the implementation will be if( fontId == mFont->GetId() ) TextureResized(..); -} - -bool TextAttachment::IsTextModified() -{ - return ( mTextChanged || mFontChanged || mUnderlineChanged || mItalicsChanged ); -} - -void TextAttachment::OnStageConnection2() -{ - // do nothing -} - -void TextAttachment::OnStageDisconnection2() -{ - // do nothing -} - -const SceneGraph::RenderableAttachment& TextAttachment::GetSceneObject() const -{ - DALI_ASSERT_DEBUG( mSceneObject != NULL ); - return *mSceneObject; -} - -void TextAttachment::SetTextChanges() -{ - if( mVertexBuffer ) - { - // record the natural size of the text - mTextSize = mVertexBuffer->mVertexMax; - - // remember the texture id, so we can detect atlas resizes / splits - mTextureId = mVertexBuffer->mTextureId; - - EventToUpdate& eventToUpdate( mStage->GetUpdateInterface() ); - const SceneGraph::TextAttachment& attachment( *mSceneObject ); - - if( mTextChanged || mFontChanged ) - { - DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "TextAttachment::SetTextChanges() Sending VertexBuffer to attachment:%p textureId:%d\n", &attachment, mVertexBuffer->mTextureId); - - // release the vertex buffer to pass ownership to the scene-graph-text-attachment - SetTextVertexBufferMessage( eventToUpdate, attachment, *mVertexBuffer.Release() ); - - if( mFontChanged ) - { - SetTextFontSizeMessage( eventToUpdate, attachment, mFont->GetPixelSize() ); - } - } - } -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/actor-attachments/text-attachment-impl.h b/dali/internal/event/actor-attachments/text-attachment-impl.h deleted file mode 100644 index de16ee8..0000000 --- a/dali/internal/event/actor-attachments/text-attachment-impl.h +++ /dev/null @@ -1,409 +0,0 @@ -#ifndef __DALI_INTERNAL_TEXT_ATTACHMENT_H__ -#define __DALI_INTERNAL_TEXT_ATTACHMENT_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -class TextParameters; - -namespace SceneGraph -{ -class TextAttachment; -class Node; -} - -/** - * An attachment for rendering text from a font atlas. - */ -class TextAttachment : public RenderableAttachment, public GlyphTextureObserver -{ -public: - - /** - * Create a new TextAttachment. - * @param[in] parentNode The node to attach a scene-object to. - * @param [in] text The text which will be displayed. - * @param [in] font The font which will be used for the text. - * @return A smart-pointer to the newly allocated TextAttachment. - */ - static TextAttachmentPtr New( const SceneGraph::Node& parentNode, const Integration::TextArray& text, FontPointer font ); - - /** - * Set the text label displayed by the attachment - * @param [in] text The new text label - */ - void SetText(const Integration::TextArray& text); - - /** - * Get the text label displayed by the attachment - * @return The text label - */ - const Integration::TextArray& GetText() const - { - // This is not animatable; the cached value is up-to-date. - return mText; - } - - /** - * Get the natural text size - * @return the natural size of the text. - */ - const Vector2& GetNaturalTextSize() const - { - // This is not animatable; the cached value is up-to-date. - return mTextSize; - } - - /** - * Set the font used to display the text label displayed by the attachment - * @param [in] font The new font - */ - void SetFont(Font& font); - - /** - * Get the font used to display the text label displayed by the attachment - * @return The font currently in use - */ - Font& GetFont() - { - return *mFont; - } - - /** - * Set the text color - * @param[in] color The text color - */ - void SetTextColor(const Vector4& color); - - /** - * Get the text color - * @return The text color - */ - Vector4 GetTextColor() const; - - /** - * Resets to default the text color. - */ - void ResetTextColor(); - - /** - * @copydoc Dali::TextActor::SetWeight() - */ - void SetWeight( TextStyle::Weight weight ); - - /** - * @copydoc Dali::TextActor::GetWeight() - */ - TextStyle::Weight GetWeight() const; - - /** - * Resets to default the text weight. - */ - void ResetWeight(); - - /** - * @copydoc Dali::TextActor::SetSmoothEdge(const float) - */ - void SetSmoothEdge( float smoothEdge ); - - /** - * Retrieve the smooth edge value. - * @return the smooth edge value. - */ - float GetSmoothEdge() const; - - /** - * Resets to default the smooth edge. - */ - void ResetSmoothEdge(); - - /** - * Enable italics on the text actor, the text will be sheared by the given angle. - * @param[in] angle Italics angle in radians. - */ - void SetItalics( Radian angle ); - - /** - * @copydoc Dali::TextActor::GetItalics() - */ - bool GetItalics() const; - - /** - * @copydoc Dali::TextActor::GetItalicsAngle() - */ - Radian GetItalicsAngle() const; - - /** - * Resets to default the italics. - */ - void ResetItalics(); - - /** - * @copydoc Dali::TextActor::SetUnderline() - */ - void SetUnderline( bool enable, float thickness, float position ); - - /** - * @copydoc Dali::TextActor::GetUnderline() - */ - bool GetUnderline() const; - - /** - * @copydoc Internal::TextActor::GetUnderlineThickness() - */ - float GetUnderlineThickness() const; - - /** - * @copydoc Internal::TextActor::GetUnderlinePosition() - */ - float GetUnderlinePosition() const; - - /** - * Resets to default the text underline. - */ - void ResetUnderline(); - - /** - * @copydoc Dali::TextActor::SetOutline(const bool,const Vector4&,const Vector2&) - */ - void SetOutline( bool enable, const Vector4& color, const Vector2& thickness ); - - /** - * Get outline state. - * @return \e true if outline is enabled, otherwise \e false. - */ - bool GetOutline() const; - - /** - * Retrieve outline parameters. - * @param[out] color The outline color. - * @param[out] thickness The outline parameters. - */ - void GetOutlineParams( Vector4& color, Vector2& thickness ) const; - - /** - * Resets to default the text outline. - */ - void ResetOutline(); - - /** - * @copydoc Dali::TextActor::SetGlow(const bool,const Vector4&,const float) - */ - void SetGlow( bool enable, const Vector4& color, float intensity ); - - /** - * Get glow state. - * @return \e true if glow is enabled, otherwise \e false. - */ - bool GetGlow() const; - - /** - * Retrieve glow parameters. - * @param[out] color The glow color. - * @param[out] intensity The glow intensity. - */ - void GetGlowParams( Vector4& color, float& intensity ) const; - - /** - * Resets to default the text glow. - */ - void ResetGlow(); - - /** - * @copydoc Dali::TextActor::SetShadow(const bool,const Vector4&,const Vector2&,const float) - */ - void SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size ); - - /** - * Retrieve the shadow state. - * @return \e true if shadow is enabled, otherwise \e false. - */ - bool GetShadow() const; - - /** - * Retrieve shadow parameters. - * @param[out] color The shadow color. - * @param[out] offset The shadow offset. - * @param[out] size The shadow size. - */ - void GetShadowParams( Vector4& color, Vector2& offset, float& size ) const; - - /** - * Resets to default the text shadow. - */ - void ResetShadow(); - - /** - * @see Dali::TextActor::SetGradientColor() - * @see Dali::TextActor::SetGradientStartPoint() - * @see Dali::TextActor::SetGradientEndPoint() - */ - void SetGradient( const Vector4& color, const Vector2& startPoint, const Vector2& endPoint ); - - /** - * @copydoc Dali::TextActor::GetGradientColor() - */ - const Vector4& GetGradientColor() const; - - /** - * @copydoc Dali::TextActor::GetGradientStartPoint() - */ - const Vector2& GetGradientStartPoint() const; - - /** - * @copydoc Dali::TextActor::GetGradientEndPoint() - */ - const Vector2& GetGradientEndPoint() const; - - /** - * Resets to default the text gradient. - */ - void ResetGradient(); - - /** - * Retrieves the text style. - * - * @param[out] style The text style. - */ - void GetTextStyle( TextStyle& style ) const; - - /** - * Measure the natural size of a text string, as displayed in this font. - * @return The natural size of the text. - */ - Vector3 MeasureText() const; - - /** - * Inform the text attachment the text / font it is using has changed. - * The TextChanged() and TextNotRequired() functions are used to avoid duplicate - * requests for text. For example if the text is changed, and the font is changed - * then we want to avoid requesting the new text with the old font, then the new - * text with the new font. - */ - void TextChanged(); - - /** - * @return true if all text has been loaded and is ready to display - */ - bool IsTextLoaded(); - - /** - * Calculates the weighted smoothing value. - */ - void CalculateWeightedSmoothing( TextStyle::Weight weight, float smoothEdge ); - -public: // glyph texture observer - - /** - * @copydoc Dali::Internal::GlyphTextureObserver::TextureResized() - */ - virtual void TextureResized( const TextureIdList& oldTextureIds, unsigned int newTextureId ); - - /** - * @copydoc Dali::Internal::GlyphTextureObserver::TextureSplit() - */ - virtual void TextureSplit( FontId fontId, const TextureIdList& oldTextureIds, unsigned int newTextureId ); - -private: - - /** - * Check if the text has been modified - * @return true if the text or it's formating has been modified - */ - bool IsTextModified(); - - /** - * First stage construction of a TextAttachment. - * @param[in] stage Used to send messages to scene-graph. - */ - TextAttachment( Stage& stage ); - - /** - * @copydoc Dali::Internal::RenderableAttachment::OnStageConnection2() - */ - virtual void OnStageConnection2(); - - /** - * @copydoc Dali::Internal::RenderableAttachment::OnStageDisconnection2() - */ - virtual void OnStageDisconnection2(); - - /** - * @copydoc Dali::Internal::RenderableAttachment::GetSceneObject() - */ - virtual const SceneGraph::RenderableAttachment& GetSceneObject() const; - - /** - * Update any text & font changes to the on stage scene graph text attachment - */ - void SetTextChanges(); - -protected: - - /** - * A reference counted object may only be deleted by calling Unreference() - */ - virtual ~TextAttachment(); - -private: - - const SceneGraph::TextAttachment* mSceneObject; ///< Not owned - - TextRequestHelper mTextRequestHelper; ///< Text request helper - FontPointer mFont; ///< The font resource - Vector4* mTextColor; ///< on demand storage for text color - TextStyle mStyle; ///< on demand storage for text effects parameters ( do not store font parameters and color ) - ///< Font parameters are stored in the FontPointer member. Inside the TextStyle, font parameters and color are allocated in the same struct, - ///< so store the text color in the style will allocate space for the font parameters as well, wasting space. - // Cached values for public getters - Integration::TextArray mText; - - bool mTextChanged:1; ///< whether the text has changed - bool mFontChanged:1; ///< whether the font has changed - bool mUnderlineChanged:1; ///< whether the underline has changed - bool mItalicsChanged:1; ///< whether the italics has changed - bool mTextureIdSet:1; ///< flag to signify if the texture id has been set on the scene-graph text-attachment - unsigned int mTextureId; ///< the texture id of the glyph atlas being used - Vector2 mTextSize; ///< text natural size - - OwnerPointer< TextVertexBuffer > mVertexBuffer; ///< vertex data to display the text -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_TEXT_ATTACHMENT_H__ diff --git a/dali/internal/event/actors/actor-declarations.h b/dali/internal/event/actors/actor-declarations.h index a6f8feb..2d2df75 100644 --- a/dali/internal/event/actors/actor-declarations.h +++ b/dali/internal/event/actors/actor-declarations.h @@ -34,7 +34,6 @@ class ImageActor; class Layer; class LightActor; class MeshActor; -class TextActor; typedef IntrusivePtr ActorPtr; typedef IntrusivePtr CameraActorPtr; @@ -43,7 +42,6 @@ typedef IntrusivePtr ImageActorPtr; typedef IntrusivePtr LayerPtr; typedef IntrusivePtr LightActorPtr; typedef IntrusivePtr MeshActorPtr; -typedef IntrusivePtr TextActorPtr; } // namespace Internal diff --git a/dali/internal/event/actors/text-actor-impl.cpp b/dali/internal/event/actors/text-actor-impl.cpp deleted file mode 100644 index e631516..0000000 --- a/dali/internal/event/actors/text-actor-impl.cpp +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -const Property::Index TextActor::TEXT = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT; -const Property::Index TextActor::FONT = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 1; -const Property::Index TextActor::FONT_STYLE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 2; -const Property::Index TextActor::OUTLINE_ENABLE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 3; -const Property::Index TextActor::OUTLINE_COLOR = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 4; -const Property::Index TextActor::OUTLINE_THICKNESS_WIDTH = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 5; -const Property::Index TextActor::SMOOTH_EDGE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 6; -const Property::Index TextActor::GLOW_ENABLE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 7; -const Property::Index TextActor::GLOW_COLOR = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 8; -const Property::Index TextActor::GLOW_INTENSITY = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 9; -const Property::Index TextActor::SHADOW_ENABLE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 10; -const Property::Index TextActor::SHADOW_COLOR = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 11; -const Property::Index TextActor::SHADOW_OFFSET = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 12; -const Property::Index TextActor::ITALICS_ANGLE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 13; -const Property::Index TextActor::UNDERLINE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 14; -const Property::Index TextActor::WEIGHT = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 15; -const Property::Index TextActor::FONT_DETECTION_AUTOMATIC = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 16; -const Property::Index TextActor::GRADIENT_COLOR = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 17; -const Property::Index TextActor::GRADIENT_START_POINT = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 18; -const Property::Index TextActor::GRADIENT_END_POINT = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 19; -const Property::Index TextActor::SHADOW_SIZE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 20; -const Property::Index TextActor::TEXT_COLOR = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 21; - -namespace -{ - -const char* DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[] = -{ - "text", - "font", - "font-style", - "outline-enable", - "outline-color", - "outline-thickness-width", - "smooth-edge", - "glow-enable", - "glow-color", - "glow-intensity", - "shadow-enable", - "shadow-color", - "shadow-offset", - "italics-angle", - "underline", - "weight", - "font-detection-automatic", - "gradient-color", - "gradient-start-point", - "gradient-end-point", - "shadow-size", - "text-color" -}; -const int DEFAULT_TEXT_ACTOR_PROPERTY_COUNT = sizeof( DEFAULT_TEXT_ACTOR_PROPERTY_NAMES ) / sizeof( DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[0] ); - -const Property::Type DEFAULT_TEXT_ACTOR_PROPERTY_TYPES[DEFAULT_TEXT_ACTOR_PROPERTY_COUNT] = -{ - Property::STRING, // "text" - Property::STRING, // "font" - Property::STRING, // "font-style" - Property::BOOLEAN, // "outline-enable" - Property::VECTOR4, // "outline-color" - Property::VECTOR2, // "outline-thickness-width" - Property::FLOAT, // "smooth-edge" - Property::BOOLEAN, // "glow-enable" - Property::VECTOR4, // "glow-color" - Property::FLOAT, // "glow-intensity" - Property::BOOLEAN, // "shadow-enable" - Property::VECTOR4, // "shadow-color" - Property::VECTOR2, // "shadow-offset" - Property::FLOAT, // "italics-angle" - Property::BOOLEAN, // "underline" - Property::INTEGER, // "weight" - Property::BOOLEAN, // "font-detection-automatic" - Property::VECTOR4, // "gradient-color", - Property::VECTOR2, // "gradient-start-point", - Property::VECTOR2, // "gradient-end-point" - Property::FLOAT, // "shadow-size" - Property::VECTOR4, // "text-color", -}; - -} - -namespace Internal -{ - -namespace -{ - -BaseHandle Create() -{ - return Dali::TextActor::New(); -} - -TypeRegistration mType( typeid(Dali::TextActor), typeid(Dali::RenderableActor), Create ); - -SignalConnectorType s1( mType, Dali::TextActor::SIGNAL_TEXT_LOADING_FINISHED, &TextActor::DoConnectSignal ); - -} - -TextActorPtr TextActor::New( const Integration::TextArray& utfCodes, const TextActorParameters& parameters ) -{ - // first stage construction - TextActorPtr actor ( new TextActor( parameters.IsAutomaticFontDetectionEnabled() ) ); - - const TextStyle& style = parameters.GetTextStyle(); - - FontPointer fontPtr( Font::New(style.GetFontName(), style.GetFontStyle(), style.GetFontPointSize() ) ); - - // Second-phase construction - actor->Initialize(); - - //create the attachment - actor->mTextAttachment = TextAttachment::New( *actor->mNode, Integration::TextArray(), fontPtr ); - actor->Attach(*actor->mTextAttachment); - - // Note: SetTextStyle() MUST be called before SetText(), to ensure - // that a single ResourceRequest for the glyphs is made. Calling - // them in the wrong order will issue two requests. - actor->SetTextStyle( style, DONT_REQUEST_NEW_TEXT ); - - actor->SetText( utfCodes ); - - return actor; -} - -TextActor::TextActor(bool fontDetection) -: RenderableActor(), - mLoadingState(Dali::ResourceLoading), - mUsingNaturalSize(true), - mInternalSetSize(false), - mFontDetection(fontDetection), - mObserving(false) -{ -} - -void TextActor::OnInitialize() -{ -} - -TextActor::~TextActor() -{ - StopObservingTextLoads(); -} - -const std::string TextActor::GetText() const -{ - const Integration::TextArray& utfCodes = mTextAttachment->GetText(); - - std::string text; - - const std::size_t length = utfCodes.Count(); - // minimize allocations for ascii strings - text.reserve( length ); - - for (unsigned int i = 0; i < length; ++i) - { - unsigned char utf8Data[4]; - unsigned int utf8Length; - - utf8Length = UTF8Write(utfCodes[i], utf8Data); - - text.append(reinterpret_cast(utf8Data), utf8Length); - } - - return text; -} - -Font* TextActor::GetFont() const -{ - return &mTextAttachment->GetFont(); -} - -void TextActor::SetToNaturalSize() -{ - // ignore size set by application - mUsingNaturalSize = true; - TextChanged(); // this will calculate natural size -} - -void TextActor::StopObservingTextLoads() -{ - if( mObserving ) - { - mTextAttachment->GetFont().RemoveObserver( *this ); - mObserving = false; - } -} - -void TextActor::StartObservingTextLoads() -{ - if( !mObserving ) - { - mTextAttachment->GetFont().AddObserver( *this ); - mObserving = true; - } -} - -void TextActor::SetText(const Integration::TextArray& utfCodes) -{ - StopObservingTextLoads(); - - // assign the new text - mTextAttachment->SetText(utfCodes); - - if( mFontDetection ) - { - // first check if the provided font supports the text - // - if( !mTextAttachment->GetFont().AllGlyphsSupported(utfCodes) ) - { - // auto-detect font - // @todo GetFamilyForText should return font name and style - const std::string fontName = Font::GetFamilyForText(utfCodes); - - // use previous formatting - Internal::Font& font = mTextAttachment->GetFont(); - - Dali::Font fontNew = Dali::Font::New( Dali::FontParameters( fontName, font.GetStyle(), PointSize(font.GetPointSize() ) ) ); - - SetFont( GetImplementation(fontNew), DONT_REQUEST_NEW_TEXT ); - } - } - - TextChanged(); -} - -void TextActor::SetFont(Font& font, TextRequestMode mode ) -{ - StopObservingTextLoads(); - - if( mode == REQUEST_NEW_TEXT ) - { - // set the new font - mTextAttachment->SetFont( font ); - - // request text for new font - TextChanged(); - } - else - { - // just set the font - mTextAttachment->SetFont( font ); - } -} - -Vector3 TextActor::GetNaturalSize() const -{ - Vector2 naturalSize( mTextAttachment->GetNaturalTextSize() ); - return Vector3( naturalSize.width, naturalSize.height, CalculateSizeZ( naturalSize ) ); -} - -void TextActor::OnSizeSet(const Vector3& targetSize) -{ - if( !mInternalSetSize ) - { - // after size is once set by application we no longer use the natural size - mUsingNaturalSize = false; - } -} - -void TextActor::OnSizeAnimation(Animation& animation, const Vector3& targetSize) -{ - // after size has been animated by application we no longer use the natural size - mUsingNaturalSize = false; -} - -RenderableAttachment& TextActor::GetRenderableAttachment() const -{ - DALI_ASSERT_DEBUG( mTextAttachment ); - return *mTextAttachment; -} - -void TextActor::SetGradientColor( const Vector4& color ) -{ - mTextAttachment->SetGradient( color, mTextAttachment->GetGradientStartPoint(), mTextAttachment->GetGradientEndPoint() ); -} - -const Vector4& TextActor::GetGradientColor() const -{ - return mTextAttachment->GetGradientColor(); -} - -void TextActor::SetGradientStartPoint( const Vector2& position ) -{ - mTextAttachment->SetGradient( mTextAttachment->GetGradientColor(), position, mTextAttachment->GetGradientEndPoint() ); -} - -const Vector2& TextActor::GetGradientStartPoint() const -{ - return mTextAttachment->GetGradientStartPoint(); -} - -void TextActor::SetGradientEndPoint( const Vector2& position ) -{ - mTextAttachment->SetGradient( mTextAttachment->GetGradientColor(), mTextAttachment->GetGradientStartPoint(), position ); -} - -const Vector2& TextActor::GetGradientEndPoint() const -{ - return mTextAttachment->GetGradientEndPoint(); -} - -void TextActor::SetGradient( const Vector4& color, const Vector2& startPoint, const Vector2& endPoint ) -{ - mTextAttachment->SetGradient( color, startPoint, endPoint ); -} - -void TextActor::SetTextStyle( const TextStyle& style, TextRequestMode mode ) -{ - // Set font. - const Font& font = mTextAttachment->GetFont(); - - // Determine the font name/style/size that Font would create. - // Then compare this to the existing font (which has been validated by Font). - - std::string resolvedFontName = style.GetFontName(); - std::string resolvedFontStyle = style.GetFontStyle(); - float resolvedFontPointSize = style.GetFontPointSize(); - bool resolvedFontFamilyDefault(false); - bool resolvedFontPointSizeDefault(false); - - Font::ValidateFontRequest( resolvedFontName, - resolvedFontStyle, - resolvedFontPointSize, - resolvedFontFamilyDefault, - resolvedFontPointSizeDefault ); - - // Now compare to existing font used to see if a font change is necessary. - if( ( font.GetName() != resolvedFontName ) || - ( font.GetStyle() != resolvedFontStyle ) || - ( fabsf(font.GetPointSize() - resolvedFontPointSize) >= GetRangedEpsilon(font.GetPointSize(), resolvedFontPointSize) ) ) - { - // Create font with original request (so font can determine if family and/or point size is default) - SetFont( *(Font::New( style.GetFontName(), style.GetFontStyle(), style.GetFontPointSize() ) ), mode ); - } - - // Set color. - if( !style.IsTextColorDefault() ) - { - SetTextColor( style.GetTextColor() ); - } - else - { - mTextAttachment->ResetTextColor(); - } - - // Italics - if( !style.IsItalicsDefault() ) - { - SetItalics( style.IsItalicsEnabled() ? Radian( style.GetItalicsAngle() ) : Radian( 0.0f ) ); - } - else - { - mTextAttachment->ResetItalics(); - } - - // Underline - if( !style.IsUnderlineDefault() ) - { - SetUnderline( style.IsUnderlineEnabled(), style.GetUnderlineThickness(), style.GetUnderlinePosition() ); - } - else - { - mTextAttachment->ResetUnderline(); - } - - // Shadow - if( !style.IsShadowDefault() ) - { - SetShadow( style.IsShadowEnabled(), style.GetShadowColor(), style.GetShadowOffset(), style.GetShadowSize() ); - } - else - { - mTextAttachment->ResetShadow(); - } - - // Glow - if( !style.IsGlowDefault() ) - { - SetGlow( style.IsGlowEnabled(), style.GetGlowColor(), style.GetGlowIntensity() ); - } - else - { - mTextAttachment->ResetGlow(); - } - - // Soft Smooth edge. - if( !style.IsSmoothEdgeDefault() ) - { - SetSmoothEdge( style.GetSmoothEdge() ); - } - else - { - mTextAttachment->ResetSmoothEdge(); - } - - // Outline - if( !style.IsOutlineDefault() ) - { - SetOutline( style.IsOutlineEnabled(), style.GetOutlineColor(), style.GetOutlineThickness() ); - } - else - { - mTextAttachment->ResetOutline(); - } - - // Weight - if( !style.IsFontWeightDefault() ) - { - SetWeight( style.GetWeight() ); - } - else - { - mTextAttachment->ResetWeight(); - } - - //Gradient - if( !style.IsGradientDefault() ) - { - if( style.IsGradientEnabled() ) - { - SetGradient( style.GetGradientColor(), style.GetGradientStartPoint(), style.GetGradientEndPoint() ); - } - else - { - SetGradient( TextStyle::DEFAULT_GRADIENT_COLOR, TextStyle::DEFAULT_GRADIENT_START_POINT, TextStyle::DEFAULT_GRADIENT_END_POINT ); - } - } - else - { - mTextAttachment->ResetGradient(); - } - TextChanged(); -} - -TextStyle TextActor::GetTextStyle() const -{ - TextStyle textStyle; - mTextAttachment->GetTextStyle( textStyle ); - - return textStyle; -} - -void TextActor::SetTextColor(const Vector4& color) -{ - mTextAttachment->SetTextColor( color ); -} - -Vector4 TextActor::GetTextColor() const -{ - return mTextAttachment->GetTextColor(); -} - -void TextActor::SetSmoothEdge( float smoothEdge ) -{ - mTextAttachment->SetSmoothEdge(smoothEdge); -} - -void TextActor::SetOutline( bool enable, const Vector4& color, const Vector2& offset ) -{ - mTextAttachment->SetOutline(enable, color, offset); -} - -void TextActor::SetGlow( bool enable, const Vector4& color, float intensity ) -{ - mTextAttachment->SetGlow(enable, color, intensity); -} - -void TextActor::SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size ) -{ - mTextAttachment->SetShadow(enable, color, offset, size); -} - -void TextActor::SetItalics( Radian angle ) -{ - mTextAttachment->SetItalics( angle ); - - TextChanged(); -} - -bool TextActor::GetItalics() const -{ - return mTextAttachment->GetItalics(); -} - -Radian TextActor::GetItalicsAngle() const -{ - return mTextAttachment->GetItalicsAngle(); -} - -void TextActor::SetUnderline( bool enable, float thickness, float position ) -{ - mTextAttachment->SetUnderline( enable, thickness, position ); - - TextChanged(); -} - -bool TextActor::GetUnderline() const -{ - return mTextAttachment->GetUnderline(); -} - -float TextActor::GetUnderlineThickness() const -{ - return mTextAttachment->GetUnderlineThickness(); -} - -float TextActor::GetUnderlinePosition() const -{ - return mTextAttachment->GetUnderlinePosition(); -} - -void TextActor::SetWeight( TextStyle::Weight weight ) -{ - mTextAttachment->SetWeight( weight ); -} - -TextStyle::Weight TextActor::GetWeight() const -{ - return mTextAttachment->GetWeight(); -} - -void TextActor::SetFontDetectionAutomatic(bool value) -{ - mFontDetection = value; -} - -bool TextActor::IsFontDetectionAutomatic() const -{ - return mFontDetection; -} - -bool TextActor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) -{ - bool connected( true ); - TextActor* textActor = dynamic_cast(object); - - if( Dali::TextActor::SIGNAL_TEXT_LOADING_FINISHED == signalName ) - { - textActor->TextAvailableSignal().Connect( tracker, functor ); - } - else - { - // signalName does not match any signal - connected = false; - } - - return connected; -} - -void TextActor::TextLoaded() -{ - // if the text is loaded, trigger the loaded finished signal - CheckTextLoadState(); -} - -void TextActor::TextChanged() -{ - // this will tell the text attachment to act on any text or font changes - mTextAttachment->TextChanged(); - - // check the loading state - bool loaded = CheckTextLoadState(); - if( ! loaded) - { - mLoadingState = Dali::ResourceLoading; - - StartObservingTextLoads(); - } - // the text natural size is calculated synchronously above, when TextChanged() is called - if (mUsingNaturalSize) - { - mInternalSetSize = true; // to know we're internally setting size - SetSize( mTextAttachment->GetNaturalTextSize() ); - mInternalSetSize = false; - } -} - -bool TextActor::CheckTextLoadState() -{ - if( mTextAttachment->IsTextLoaded() ) - { - mLoadingState = Dali::ResourceLoadingSucceeded; - - StopObservingTextLoads(); - - // emit text available signal - - mLoadingFinishedV2.Emit( Dali::TextActor( this ) ); - - return true; - } - - // text not loaded - return false; -} - -unsigned int TextActor::GetDefaultPropertyCount() const -{ - return RenderableActor::GetDefaultPropertyCount() + DEFAULT_TEXT_ACTOR_PROPERTY_COUNT; -} - -void TextActor::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const -{ - RenderableActor::GetDefaultPropertyIndices( indices ); // RenderableActor class properties - - indices.reserve( indices.size() + DEFAULT_TEXT_ACTOR_PROPERTY_COUNT ); - - int index = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT; - for ( int i = 0; i < DEFAULT_TEXT_ACTOR_PROPERTY_COUNT; ++i, ++index ) - { - indices.push_back( index ); - } -} - -const char* TextActor::GetDefaultPropertyName( Property::Index index ) const -{ - if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT) - { - return RenderableActor::GetDefaultPropertyName(index) ; - } - else - { - index -= DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT; - - if ( ( index >= 0 ) && ( index < DEFAULT_TEXT_ACTOR_PROPERTY_COUNT ) ) - { - return DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[index]; - } - else - { - return NULL; - } - } -} - -Property::Index TextActor::GetDefaultPropertyIndex(const std::string& name) const -{ - Property::Index index = Property::INVALID_INDEX; - - // Look for name in default properties - for( int i = 0; i < DEFAULT_TEXT_ACTOR_PROPERTY_COUNT; ++i ) - { - if( 0 == strcmp( name.c_str(), DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[ i ] ) ) // dont want to convert rhs to string - { - index = i + DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT; - break; - } - } - - // If not found, check in base class - if( Property::INVALID_INDEX == index ) - { - index = RenderableActor::GetDefaultPropertyIndex( name ); - } - - return index; -} - -bool TextActor::IsDefaultPropertyWritable( Property::Index index ) const -{ - if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT) - { - return RenderableActor::IsDefaultPropertyWritable(index) ; - } - else - { - return true; - } -} - -bool TextActor::IsDefaultPropertyAnimatable( Property::Index index ) const -{ - if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT) - { - return RenderableActor::IsDefaultPropertyAnimatable(index) ; - } - else - { - return false; - } -} - -bool TextActor::IsDefaultPropertyAConstraintInput( Property::Index index ) const -{ - if( index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT ) - { - return RenderableActor::IsDefaultPropertyAConstraintInput(index); - } - return true; // Our properties can be used as input to constraints. -} - -Property::Type TextActor::GetDefaultPropertyType( Property::Index index ) const -{ - if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT) - { - return RenderableActor::GetDefaultPropertyType(index) ; - } - else - { - index -= DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT; - - if ( ( index >= 0 ) && ( index < DEFAULT_TEXT_ACTOR_PROPERTY_COUNT ) ) - { - return DEFAULT_TEXT_ACTOR_PROPERTY_TYPES[index]; - } - else - { - // index out-of-bounds - return Property::NONE; - } - } -} - -void TextActor::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) -{ - if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT) - { - RenderableActor::SetDefaultProperty(index, propertyValue) ; - } - else - { - switch(index) - { - case Dali::TextActor::TEXT: - { - SetText( GetTextArray( Dali::Text( propertyValue.Get() ) ) ); - break; - } - case Dali::TextActor::FONT: - { - SetFont(*Font::New(propertyValue.Get(), - mTextAttachment->GetFont().GetStyle(), - PointSize(mTextAttachment->GetFont().GetPointSize()))); - break; - } - case Dali::TextActor::FONT_STYLE: - { - SetFont(*Font::New(mTextAttachment->GetFont().GetName(), - propertyValue.Get(), - PointSize(mTextAttachment->GetFont().GetPointSize()))); - break; - } - case Dali::TextActor::OUTLINE_ENABLE: - { - Vector4 color; - Vector2 thickness; - mTextAttachment->GetOutlineParams( color, thickness ); - mTextAttachment->SetOutline(propertyValue.Get(), color, thickness); - break; - } - case Dali::TextActor::OUTLINE_COLOR: - { - Vector4 color; - Vector2 thickness; - mTextAttachment->GetOutlineParams( color, thickness ); - mTextAttachment->SetOutline(mTextAttachment->GetOutline(), propertyValue.Get(), thickness); - break; - } - case Dali::TextActor::OUTLINE_THICKNESS_WIDTH: - { - Vector4 color; - Vector2 thickness; - mTextAttachment->GetOutlineParams( color, thickness ); - mTextAttachment->SetOutline(mTextAttachment->GetOutline(), color, propertyValue.Get()); - break; - } - case Dali::TextActor::SMOOTH_EDGE: - { - mTextAttachment->SetSmoothEdge( propertyValue.Get()); - break; - } - case Dali::TextActor::GLOW_ENABLE: - { - Vector4 color; - float intensity; - mTextAttachment->GetGlowParams( color, intensity ); - mTextAttachment->SetGlow(propertyValue.Get(), color, intensity); - break; - } - case Dali::TextActor::GLOW_COLOR: - { - Vector4 color; - float intensity; - mTextAttachment->GetGlowParams( color, intensity ); - mTextAttachment->SetGlow(mTextAttachment->GetGlow(), propertyValue.Get(), intensity); - break; - } - case Dali::TextActor::GLOW_INTENSITY: - { - Vector4 color; - float intensity; - mTextAttachment->GetGlowParams( color, intensity ); - mTextAttachment->SetGlow(mTextAttachment->GetGlow(), color, propertyValue.Get()); - break; - } - case Dali::TextActor::SHADOW_ENABLE: - { - Vector4 color; - Vector2 offset; - float size; - mTextAttachment->GetShadowParams( color, offset, size ); - mTextAttachment->SetShadow(propertyValue.Get(), color, offset, size ); - break; - } - case Dali::TextActor::SHADOW_COLOR: - { - Vector4 color; - Vector2 offset; - float size; - mTextAttachment->GetShadowParams( color, offset, size ); - mTextAttachment->SetShadow(mTextAttachment->GetShadow(), propertyValue.Get(), offset, size); - break; - } - case Dali::TextActor::SHADOW_OFFSET: - { - Vector4 color; - Vector2 offset; - float size; - mTextAttachment->GetShadowParams( color, offset, size ); - mTextAttachment->SetShadow(mTextAttachment->GetShadow(), color, propertyValue.Get(), size ); - break; - } - case Dali::TextActor::SHADOW_SIZE: - { - Vector4 color; - Vector2 offset; - float size; - mTextAttachment->GetShadowParams( color, offset, size ); - mTextAttachment->SetShadow(mTextAttachment->GetShadow(), color, offset, propertyValue.Get()); - break; - } - case Dali::TextActor::ITALICS_ANGLE: - { - SetItalics(Radian(propertyValue.Get())) ; - break; - } - case Dali::TextActor::UNDERLINE: - { - SetUnderline(propertyValue.Get(), 0.f, 0.f ) ; - break; - } - case Dali::TextActor::WEIGHT: - { - mTextAttachment->SetWeight(static_cast(propertyValue.Get())) ; - break; - } - case Dali::TextActor::FONT_DETECTION_AUTOMATIC: - { - mFontDetection = propertyValue.Get() ; - break; - } - case Dali::TextActor::GRADIENT_COLOR: - { - mTextAttachment->SetGradient( propertyValue.Get(), mTextAttachment->GetGradientStartPoint(), mTextAttachment->GetGradientEndPoint() ); - break; - } - case Dali::TextActor::GRADIENT_START_POINT: - { - mTextAttachment->SetGradient( mTextAttachment->GetGradientColor(), propertyValue.Get(), mTextAttachment->GetGradientEndPoint() ); - break; - } - case Dali::TextActor::GRADIENT_END_POINT: - { - mTextAttachment->SetGradient( mTextAttachment->GetGradientColor(), mTextAttachment->GetGradientStartPoint(), propertyValue.Get() ); - break; - } - case Dali::TextActor::TEXT_COLOR: - { - mTextAttachment->SetTextColor( propertyValue.Get() ); - break; - } - default: - { - DALI_LOG_WARNING("Unknown text set property (%d)\n", index); - break; - } - } // switch(index) - - } // else -} - -Property::Value TextActor::GetDefaultProperty( Property::Index index ) const -{ - Property::Value ret ; - if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT) - { - ret = RenderableActor::GetDefaultProperty(index) ; - } - else - { - switch(index) - { - case Dali::TextActor::TEXT: - { - ret = GetText(); - break; - } - case Dali::TextActor::FONT: - { - ret = mTextAttachment->GetFont().GetName(); - break; - } - case Dali::TextActor::FONT_STYLE: - { - ret = mTextAttachment->GetFont().GetStyle(); - break; - } - case Dali::TextActor::OUTLINE_ENABLE: - { - ret = mTextAttachment->GetOutline(); - break; - } - case Dali::TextActor::OUTLINE_COLOR: - { - Vector4 color; - Vector2 thickness; - mTextAttachment->GetOutlineParams( color, thickness ); - ret = color; - break; - } - case Dali::TextActor::OUTLINE_THICKNESS_WIDTH: - { - Vector4 color; - Vector2 thickness; - mTextAttachment->GetOutlineParams( color, thickness ); - ret = thickness; - break; - } - case Dali::TextActor::SMOOTH_EDGE: - { - ret = mTextAttachment->GetSmoothEdge(); - break; - } - case Dali::TextActor::GLOW_ENABLE: - { - ret = mTextAttachment->GetGlow(); - break; - } - case Dali::TextActor::GLOW_COLOR: - { - Vector4 color; - float intensity(0.0f); - mTextAttachment->GetGlowParams( color, intensity ); - ret = color; - break; - } - case Dali::TextActor::GLOW_INTENSITY: - { - Vector4 color; - float intensity(0.0f); - mTextAttachment->GetGlowParams( color, intensity ); - ret = intensity; - break; - } - case Dali::TextActor::SHADOW_ENABLE: - { - ret = mTextAttachment->GetShadow(); - break; - } - case Dali::TextActor::SHADOW_COLOR: - { - Vector4 color; - Vector2 offset; - float size; - mTextAttachment->GetShadowParams( color, offset, size ); - ret = color; - break; - } - case Dali::TextActor::SHADOW_OFFSET: - { - Vector4 color; - Vector2 offset; - float size; - mTextAttachment->GetShadowParams( color, offset, size ); - ret = offset; - break; - } - case Dali::TextActor::SHADOW_SIZE: - { - Vector4 color; - Vector2 offset; - float size; - mTextAttachment->GetShadowParams( color, offset, size ); - ret = size; - break; - } - case Dali::TextActor::ITALICS_ANGLE: - { - ret = static_cast(mTextAttachment->GetItalics()) ; - break; - } - case Dali::TextActor::UNDERLINE: - { - ret = mTextAttachment->GetUnderline() ; - break; - } - case Dali::TextActor::WEIGHT: - { - ret = static_cast(mTextAttachment->GetWeight()); - break; - } - case Dali::TextActor::FONT_DETECTION_AUTOMATIC: - { - ret = mFontDetection; - break; - } - case Dali::TextActor::GRADIENT_COLOR: - { - ret = mTextAttachment->GetGradientColor(); - break; - } - case Dali::TextActor::GRADIENT_START_POINT: - { - ret = mTextAttachment->GetGradientStartPoint(); - break; - } - case Dali::TextActor::GRADIENT_END_POINT: - { - ret = mTextAttachment->GetGradientEndPoint(); - break; - } - case Dali::TextActor::TEXT_COLOR: - { - ret = mTextAttachment->GetTextColor(); - break; - } - default: - { - DALI_LOG_WARNING("Unknown text set property (%d)\n", index); - break; - } - } // switch(index) - } // if from base class - - return ret ; -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/actors/text-actor-impl.h b/dali/internal/event/actors/text-actor-impl.h deleted file mode 100644 index a226e13..0000000 --- a/dali/internal/event/actors/text-actor-impl.h +++ /dev/null @@ -1,416 +0,0 @@ -#ifndef __DALI_INTERNAL_TEXT_ACTOR_H__ -#define __DALI_INTERNAL_TEXT_ACTOR_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include -#include -#include -#include -#include - - -namespace Dali -{ - -namespace Internal -{ - -class Font; - -/** - * TextActor implementation. - * A text actor is an actor with a TextAttachment. - * If no size is given to the actor, then after the font has loaded - * the actor will be set to the size of the text displayed. - * - */ -class TextActor : public RenderableActor, public TextObserver -{ -public: - - enum TextRequestMode - { - REQUEST_NEW_TEXT, ///< When changing font, request new text - DONT_REQUEST_NEW_TEXT ///< When changing font, don't request new text - }; - - /** - * @see Dali::TextActor::New( const Text& text, const TextActorParameters& parameters ) - * @return A pointer to a new TextActor. - */ - static TextActorPtr New( const Integration::TextArray& utfCodes, const TextActorParameters& parameters ); - - /** - * @copydoc Dali::Internal::Actor::OnInitialize - */ - void OnInitialize(); - - /** - * @copydoc Dali::TextActor::GetText() - */ - const std::string GetText() const; - - /** - * @copybrief Dali::TextActor::SetText(const std::string&) - * @param[in] utfCodes An std::vector containing the UTF-32 codes - */ - void SetText(const Integration::TextArray& utfCodes); - - /** - * @copydoc Dali::TextActor::SetToNaturalSize() - */ - void SetToNaturalSize(); - - /** - * @copydoc Dali::TextActor::GetFont() - */ - Font* GetFont() const; - - /** - * @copydoc Dali::TextActor::SetFont() - * @param TextRequestMode whether new text should be requested - */ - void SetFont(Font& font, TextRequestMode mode = REQUEST_NEW_TEXT ); - - /** - * @copydoc Dali::TextActor::SetGradientColor() - */ - void SetGradientColor( const Vector4& color ); - - /** - * @copydoc Dali::TextActor::GetGradientColor() - */ - const Vector4& GetGradientColor() const; - - /** - * @copydoc Dali::TextActor::SetGradientStartPoint() - */ - void SetGradientStartPoint( const Vector2& position ); - - /** - * @copydoc Dali::TextActor::SetGradientStartPoint() - */ - const Vector2& GetGradientStartPoint() const; - - /** - * @copydoc Dali::TextActor::SetGradientEndPoint() - */ - void SetGradientEndPoint( const Vector2& position ); - - /** - * @copydoc Dali::TextActor::GetGradientEndPoint() - */ - const Vector2& GetGradientEndPoint() const; - - /** - * @see Dali::TextActor::SetGradientColor() - * @see Dali::TextActor::SetGradientStartPoint() - * @see Dali::TextActor::SetGradientEndPoint() - */ - void SetGradient( const Vector4& color, const Vector2& startPoint, const Vector2& endPoint ); - - /** - * @copydoc Dali::TextActor::SetTextStyle( const TextStyle& style ) - * @param mode whether new text should be requested - */ - void SetTextStyle( const TextStyle& style, TextRequestMode mode = REQUEST_NEW_TEXT ); - - /** - * @copydoc Dali::TextActor::GetTextStyle() - */ - TextStyle GetTextStyle() const; - - /** - * @copydoc Dali::TextActor::SetTextColor(const Vector4&) - */ - void SetTextColor(const Vector4& color); - - /** - * @copydoc Dali::TextActor::GetTextColor() - */ - Vector4 GetTextColor() const; - - /** - * @copydoc Dali::TextActor::SetSmoothEdge(const float) - */ - void SetSmoothEdge( float smoothEdge ); - - /** - * @copydoc Dali::TextActor::SetOutline( bool,const Vector4&,const Vector2&) - */ - void SetOutline( bool enable, const Vector4& color, const Vector2& thickness ); - - /** - * @copydoc Dali::TextActor::SetGlow(const bool,const Vector4&,const float) - */ - void SetGlow( bool enable, const Vector4& color, float intensity ); - - /** - * @copydoc Dali::TextActor::SetShadow(const bool,const Vector4&,const Vector2&,const float) - */ - void SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size ); - - /** - * Enable italics on the text actor, the text will be sheared by the given angle. - * @param[in] angle Italics angle in radians. - */ - void SetItalics( Radian angle ); - - /** - * @copydoc Dali::TextActor::GetItalics() - */ - bool GetItalics() const; - - /** - * @copydoc Dali::TextActor::GetItalicsAngle() - */ - Radian GetItalicsAngle() const; - - /** - * @copydoc Dali::TextActor::SetUnderline() - */ - void SetUnderline( bool enable, float thickness, float position ); - - /** - * @copydoc Dali::TextActor::GetUnderline() - */ - bool GetUnderline() const; - - /** - * @return The underline's thickness. - */ - float GetUnderlineThickness() const; - - /** - * @return The underline's position. - */ - float GetUnderlinePosition() const; - - /** - * @copydoc Dali::TextActor::SetWeight() - */ - void SetWeight( TextStyle::Weight weight ); - - /** - * @copydoc Dali::TextActor::GetWeight() - */ - TextStyle::Weight GetWeight() const; - - /** - * @copydoc Dali::TextActor::SetFontDetectionAutomatic() - */ - void SetFontDetectionAutomatic(bool value); - - /** - * @copydoc Dali::TextActor::IsFontDetectionAutomatic() - */ - bool IsFontDetectionAutomatic() const; - -public: // From Actor - - /** - * @copydoc Dali::Actor::GetNaturalSize() - */ - virtual Vector3 GetNaturalSize() const; - -private: // from Actor - - /** - * @copydoc Actor::OnSizeSet - */ - virtual void OnSizeSet(const Vector3& targetSize); - - /** - * @copydoc Actor::OnSizeAnimation( Animation& animation, const Vector3& targetSize ) - */ - virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize); - -private: // From RenderableActor - - /** - * @copydoc RenderableActor::GetRenderableAttachment - */ - virtual RenderableAttachment& GetRenderableAttachment() const; - -protected: - - /** - * Protected constructor; see also TextActor::New() - */ - TextActor(bool fontDetection); - - /** - * A reference counted object may only be deleted by calling Unreference() - */ - virtual ~TextActor(); - -public: - - /** - * @copydoc Dali::Image::GetLoadingState() - */ - Dali::LoadingState GetLoadingState() const { return mLoadingState; } - - /** - * @copydoc Dali::TextActor::TextAvailableSignal() - */ - Dali::TextActor::TextSignalV2& TextAvailableSignal() { return mLoadingFinishedV2; } - - /** - * Connects a callback function with the text actors signals. - * @param[in] object The object providing the signal. - * @param[in] tracker Used to disconnect the signal. - * @param[in] signalName The signal to connect to. - * @param[in] functor A newly allocated FunctorDelegate. - * @return True if the signal was connected. - * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor. - */ - static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ); - -public: // From TextObserver - - /** - * @copydoc Dali::Internal::TextObserver::TextLoaded() - */ - virtual void TextLoaded(); - -private: - - /** - * Text has been changed observe ticket or - * emit text available signal - */ - void TextChanged(); - - /** - * Checks whether the text is loaded or not - * @return true if text is loaded - */ - bool CheckTextLoadState(); - - /** - * Stop observing text loads on the current font. - */ - void StopObservingTextLoads(); - - /** - * Start observing text loads on the current font. - */ - void StartObservingTextLoads(); - - // Undefined - TextActor(const TextActor&); - - // Undefined - TextActor& operator=(const TextActor& rhs); - -private: // ProxyObject default non-animatable properties - /** - * copydoc Dali::Internal::ProxyObject - */ - virtual unsigned int GetDefaultPropertyCount() const ; - - /** - * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices() - */ - virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const; - - /** - * copydoc Dali::Internal::ProxyObject - */ - virtual const char* GetDefaultPropertyName( Property::Index index ) const ; - - /** - * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() - */ - virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const; - - /** - * copydoc Dali::Internal::ProxyObject - */ - virtual bool IsDefaultPropertyWritable( Property::Index index ) const ; - - /** - * copydoc Dali::Internal::ProxyObject - */ - virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const ; - - /** - * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput() - */ - virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const; - - /** - * copydoc Dali::Internal::ProxyObject - */ - virtual Property::Type GetDefaultPropertyType( Property::Index index ) const ; - - /** - * copydoc Dali::Internal::ProxyObject - */ - virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) ; - - /** - * copydoc Dali::Internal::ProxyObject - */ - virtual Property::Value GetDefaultProperty( Property::Index index ) const ; - -protected: - - TextAttachmentPtr mTextAttachment; ///< Used to display the text - - Dali::LoadingState mLoadingState; - -private: - - Dali::TextActor::TextSignalV2 mLoadingFinishedV2; - bool mUsingNaturalSize:1; ///< whether the actor is using natural size - bool mInternalSetSize:1; ///< to determine when we are internally setting size - bool mFontDetection:1; ///< tells whether TextActor should query platform abstraction after SetText - bool mObserving:1; ///< Whether the text actor is waiting for text to load -}; - -} // namespace Internal - -// Helpers for public-api forwarding methods - -inline Internal::TextActor& GetImplementation(Dali::TextActor& actor) -{ - DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" ); - - BaseObject& handle = actor.GetBaseObject(); - - return static_cast(handle); -} - -inline const Internal::TextActor& GetImplementation(const Dali::TextActor& actor) -{ - DALI_ASSERT_ALWAYS( actor && "Actor handle is empty" ); - - const BaseObject& handle = actor.GetBaseObject(); - - return static_cast(handle); -} - -} // namespace Dali - -#endif // __DALI_INTERNAL_TEXT_ACTOR_H__ diff --git a/dali/internal/event/common/thread-local-storage.cpp b/dali/internal/event/common/thread-local-storage.cpp index f1f69cf..c553417 100644 --- a/dali/internal/event/common/thread-local-storage.cpp +++ b/dali/internal/event/common/thread-local-storage.cpp @@ -114,11 +114,6 @@ ModelFactory& ThreadLocalStorage::GetModelFactory() return mCore->GetModelFactory(); } -FontFactory& ThreadLocalStorage::GetFontFactory() -{ - return mCore->GetFontFactory(); -} - ShaderFactory& ThreadLocalStorage::GetShaderFactory() { return mCore->GetShaderFactory(); @@ -139,11 +134,6 @@ GestureEventProcessor& ThreadLocalStorage::GetGestureEventProcessor() return mCore->GetGestureEventProcessor(); } -EmojiFactory& ThreadLocalStorage::GetEmojiFactory() -{ - return mCore->GetEmojiFactory(); -} - } // namespace Internal } // namespace Dali diff --git a/dali/internal/event/common/thread-local-storage.h b/dali/internal/event/common/thread-local-storage.h index f0dff0c..fe1403c 100644 --- a/dali/internal/event/common/thread-local-storage.h +++ b/dali/internal/event/common/thread-local-storage.h @@ -40,11 +40,9 @@ class ResourceClient; class ResourceManager; class ImageFactory; class ModelFactory; -class FontFactory; class ShaderFactory; class EventToUpdate; class GestureEventProcessor; -class EmojiFactory; namespace SceneGraph { @@ -132,12 +130,6 @@ public: ModelFactory& GetModelFactory(); /** - * Returns the Font Factory - * @return reference to the Font Factory - */ - FontFactory& GetFontFactory(); - - /** * Returns the Shader Factory * @return reference to the Shader Factory */ @@ -161,12 +153,6 @@ public: */ GestureEventProcessor& GetGestureEventProcessor(); - /** - * Returns the Emoji factory. - * @return a reference to the Emoji factory. - */ - EmojiFactory& GetEmojiFactory(); - private: Core* mCore; ///< reference to core diff --git a/dali/internal/event/effects/shader-declarations.h b/dali/internal/event/effects/shader-declarations.h index e224d99..7dbca62 100644 --- a/dali/internal/event/effects/shader-declarations.h +++ b/dali/internal/event/effects/shader-declarations.h @@ -42,15 +42,7 @@ enum ShaderSubTypes SHADER_VERTEX_COLOR, ///< Use only vertex color TOTAL_MESH_SHADERS, - // for text shader - SHADER_GRADIENT = 1, ///< Shader Supports: GRADIENT - SHADER_GRADIENT_GLOW, ///< Shader Supports: GRADIENT + GLOW - SHADER_GRADIENT_SHADOW, ///< Shader Supports: GRADIENT + SHADOW - SHADER_GRADIENT_OUTLINE, ///< Shader Supports: GRADIENT + OUTLINE - SHADER_GRADIENT_OUTLINE_GLOW, ///< Shader Supports: GRADIENT + OUTLINE + GLOW - TOTAL_TEXT_SHADERS, - - SHADER_SUBTYPE_LAST = ( ( TOTAL_MESH_SHADERS > TOTAL_TEXT_SHADERS ) ? TOTAL_MESH_SHADERS : TOTAL_TEXT_SHADERS), + SHADER_SUBTYPE_LAST = TOTAL_MESH_SHADERS, SHADER_SUBTYPE_ALL = 0xFF, }; diff --git a/dali/internal/event/effects/shader-effect-impl.cpp b/dali/internal/event/effects/shader-effect-impl.cpp index ab85eb8..bf77f68 100644 --- a/dali/internal/event/effects/shader-effect-impl.cpp +++ b/dali/internal/event/effects/shader-effect-impl.cpp @@ -95,10 +95,6 @@ WrapperStrings customShaderWrappers [] = CustomImagePostfixVertex, CustomImagePostfixFragment }, { - CustomTextDistanceFieldPrefixVertex, CustomTextDistanceFieldPrefixFragment, - CustomTextDistanceFieldPostfixVertex, CustomTextDistanceFieldPostfixFragment - }, - { CustomUntexturedMeshPrefixVertex, CustomUntexturedMeshPrefixFragment, CustomUntexturedMeshPostfixVertex, CustomUntexturedMeshPostfixFragment }, @@ -144,19 +140,14 @@ void WrapAndSetProgram( Internal::ShaderEffect& effect, index = 0; break; } - case GEOMETRY_TYPE_TEXT: - { - index = 1; - break; - } case GEOMETRY_TYPE_UNTEXTURED_MESH: { - index = 2; + index = 1; break; } case GEOMETRY_TYPE_TEXTURED_MESH: { - index = 3; + index = 2; break; } case GEOMETRY_TYPE_LAST: @@ -346,7 +337,6 @@ void ShaderEffect::SetPrograms( GeometryType geometryType, } WrapAndSetProgram( *this, geometryType, GEOMETRY_TYPE_IMAGE, vertexPrefix, fragmentPrefix, vertexSource, fragmentSource, modifiesGeometry ); - WrapAndSetProgram( *this, geometryType, GEOMETRY_TYPE_TEXT, vertexPrefix, fragmentPrefix, vertexSource, fragmentSource, modifiesGeometry ); WrapAndSetProgram( *this, geometryType, GEOMETRY_TYPE_TEXTURED_MESH, vertexPrefix, fragmentPrefix, vertexSource, fragmentSource, modifiesGeometry ); WrapAndSetProgram( *this, geometryType, GEOMETRY_TYPE_UNTEXTURED_MESH, vertexPrefix, fragmentPrefix, vertexSource, fragmentSource, modifiesGeometry ); } @@ -515,10 +505,6 @@ void ShaderEffect::SetDefaultProperty( Property::Index index, const Property::Va { geometryType = GEOMETRY_TYPE_IMAGE; } - else if (s == "GEOMETRY_TYPE_TEXT") - { - geometryType = GEOMETRY_TYPE_TEXT; - } else if( s == "GEOMETRY_TYPE_UNTEXTURED_MESH") { geometryType = GEOMETRY_TYPE_UNTEXTURED_MESH; diff --git a/dali/internal/event/effects/shader-factory.cpp b/dali/internal/event/effects/shader-factory.cpp index 0dec5d4..e4000dd 100644 --- a/dali/internal/event/effects/shader-factory.cpp +++ b/dali/internal/event/effects/shader-factory.cpp @@ -114,21 +114,6 @@ void ShaderFactory::LoadDefaultShaders() mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_IMAGE, SHADER_DEFAULT, ImageVertex, ImageFragment, false ); - mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_TEXT, SHADER_DEFAULT, TextDistanceFieldVertex, TextDistanceFieldFragment, false ); - - mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT, - std::string( SHADER_DEF_USE_GRADIENT ) + TextDistanceFieldVertex, - std::string( SHADER_DEF_USE_GRADIENT ) + TextDistanceFieldFragment, - false ); - - mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_GLOW, TextDistanceFieldGlowVertex, TextDistanceFieldGlowFragment, false ); - - mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_SHADOW, TextDistanceFieldShadowVertex, TextDistanceFieldShadowFragment, false ); - - mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_OUTLINE, TextDistanceFieldOutlineVertex, TextDistanceFieldOutlineFragment, false ); - - mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_TEXT, SHADER_GRADIENT_OUTLINE_GLOW, TextDistanceFieldOutlineGlowVertex, TextDistanceFieldOutlineGlowFragment, false ); - // Untextured meshes mDefaultShader->SendProgramMessage( GEOMETRY_TYPE_UNTEXTURED_MESH, SHADER_DEFAULT, UntexturedMeshVertex, diff --git a/dali/internal/event/images/emoji-factory.cpp b/dali/internal/event/images/emoji-factory.cpp deleted file mode 100644 index 5efa943..0000000 --- a/dali/internal/event/images/emoji-factory.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// EXTERNAL INCLUDES -#include -#include - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace -{ -const std::string U( "u" ); ///< -const std::string PNG( ".png" ); ///< Used to build the emoji file name. -const std::size_t PNG_SIZE( 4u ); ///< -} // namespace - -EmojiFactory::EmojiFactory() -: mColorGlyphs(), - mMinEmoji( std::numeric_limits::max() ) -{ - Internal::ThreadLocalStorage& tls = Internal::ThreadLocalStorage::Get(); - - // Get the color glyphs from the directory. - Integration::PlatformAbstraction& platform = tls.GetPlatformAbstraction(); - - std::vector fileNames; - platform.GetFileNamesFromDirectory( DALI_EMOTICON_DIR, fileNames ); - - for( std::vector::const_iterator it = fileNames.begin(), endIt = fileNames.end(); it != endIt; ++it ) - { - const std::string& fileName( *it ); - const std::size_t fileNameSize = fileName.size(); - - if( ( fileNameSize < PNG_SIZE + 1u ) || - ( U != fileName.substr( 0u, 1u ) ) || - ( PNG != fileName.substr( fileNameSize - PNG_SIZE, PNG_SIZE ) ) ) - { - // Invalid emoji file name. - break; - } - - uint32_t character = 0u; - - std::istringstream( fileName.substr( 1u, fileNameSize - PNG_SIZE - 1u ) ) >> std::hex >> character; - - if( 0u != character ) - { - if( character < mMinEmoji ) - { - mMinEmoji = character; - } - - mColorGlyphs[character] = fileName; - } - } -} - -EmojiFactory::~EmojiFactory() -{ -} - -bool EmojiFactory::IsEmoji( const uint32_t character ) const -{ - return ( character >= mMinEmoji ) && - ( mColorGlyphs.find( character ) != mColorGlyphs.end() ); -} - -std::string EmojiFactory::GetEmojiFileNameFromCharacter( const uint32_t character ) const -{ - std::string fileName; - - std::map::const_iterator it = mColorGlyphs.find( character ); - - if( it != mColorGlyphs.end() ) - { - fileName = it->second; - } - - return fileName; -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/images/emoji-factory.h b/dali/internal/event/images/emoji-factory.h deleted file mode 100644 index fb293a7..0000000 --- a/dali/internal/event/images/emoji-factory.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef __DALI_INTERNAL_EMOJI_FACTORY_H__ -#define __DALI_INTERNAL_EMOJI_FACTORY_H__ - -/* - * Copyright (c) 2014 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 -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * EmojiFactory is an object that store emoji file names indexing them by its unicode value. - */ -class EmojiFactory -{ -public: - - /** - * Default constructor. - */ - EmojiFactory(); - - /** - * Default destructor. - */ - virtual ~EmojiFactory(); - - /** - * Retrieves whether the character is an emoji. - * - * @param[in] character The character to be checked. - * - * @return \e true if the emoji has been inserted. Otherwise it return \e false. - */ - bool IsEmoji( uint32_t character ) const; - - /** - * Retrieves the emoji file name for the given character. - * - * @param[in] character The given character. - * - * @return A string with the emoji file name or a void string if the character is not an emoji. - */ - std::string GetEmojiFileNameFromCharacter( uint32_t character ) const; - -private: - - // Undefined - EmojiFactory( const EmojiFactory& rhs ); - - // Undefined - EmojiFactory& operator=( const EmojiFactory& rhs ); - -private: - std::map mColorGlyphs; ///< Emoji map with the file names indexed by the unicode. - uint32_t mMinEmoji; ///< The minimum emoji code. -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_EMOJI_FACTORY_H__ diff --git a/dali/internal/event/resources/resource-client.cpp b/dali/internal/event/resources/resource-client.cpp index b8dd6cf..bf68566 100644 --- a/dali/internal/event/resources/resource-client.cpp +++ b/dali/internal/event/resources/resource-client.cpp @@ -19,12 +19,10 @@ #include #include -#include #include #include #include -#include #include #include #include @@ -48,7 +46,6 @@ struct ResourceClient::Impl { Impl(ResourcePolicy::DataRetention dataRetentionPolicy) : mNextId(0), - mGlyphLoadObserver(NULL), mDataRetentionPolicy( dataRetentionPolicy ) { } @@ -56,7 +53,6 @@ struct ResourceClient::Impl ResourceId mNextId; TicketContainer mTickets; BitmapCache mBitmaps; - GlyphLoadObserver* mGlyphLoadObserver; ResourcePolicy::DataRetention mDataRetentionPolicy; }; @@ -126,7 +122,6 @@ ResourceTicketPtr ResourceClient::RequestResource( case ResourceTargetImage: case ResourceShader: case ResourceMesh: - case ResourceText: { newTicket = new ResourceTicket(*this, newId, typePath); break; @@ -175,7 +170,6 @@ ResourceTicketPtr ResourceClient::DecodeResource( case ResourceTargetImage: case ResourceShader: case ResourceMesh: - case ResourceText: { DALI_LOG_ERROR( "Unsupported resource type passed for decoding from a memory buffer." ); } @@ -468,16 +462,6 @@ Bitmap* ResourceClient::GetBitmap(ResourceTicketPtr ticket) return bitmap; } -void ResourceClient::SetGlyphLoadObserver( GlyphLoadObserver* glyphLoadedInterface ) -{ - mImpl->mGlyphLoadObserver = glyphLoadedInterface; -} - -void ResourceClient::UpdateAtlasStatus( ResourceId id, ResourceId atlasId, Integration::LoadStatus loadStatus ) -{ - RequestAtlasUpdateMessage( mUpdateManager.GetEventToUpdate(), mResourceManager, id, atlasId, loadStatus ); -} - /******************************************************************************** ******************** ResourceTicketLifetimeObserver methods **************** ********************************************************************************/ @@ -588,20 +572,6 @@ void ResourceClient::NotifySavingFailed( ResourceId id ) } } -void ResourceClient::NotifyGlyphSetLoaded( ResourceId id, const GlyphSet& glyphSet, LoadStatus loadStatus ) -{ - if( mImpl->mGlyphLoadObserver == NULL) - { - // should not happen. - DALI_ASSERT_DEBUG( !"GlyphLoadObserver == NULL "); - return; - } - - DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceClient: NotifyGlyphSetLoaded(hash:%u)\n", glyphSet.mFontHash); - - mImpl->mGlyphLoadObserver->GlyphsLoaded( id, glyphSet, loadStatus ); -} - void ResourceClient::UpdateImageTicket( ResourceId id, const Dali::ImageAttributes& imageAttributes ) ///!< Issue #AHC01 { DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceClient: UpdateImageTicket(id:%u)\n", id); diff --git a/dali/internal/event/resources/resource-client.h b/dali/internal/event/resources/resource-client.h index 923e73f..4f98e99 100644 --- a/dali/internal/event/resources/resource-client.h +++ b/dali/internal/event/resources/resource-client.h @@ -24,7 +24,6 @@ // INTERNAL INCLUDES #include #include -#include #include #include #include @@ -40,14 +39,12 @@ class NativeImage; namespace Integration { class Bitmap; -class GlyphSet; } namespace Internal { class ResourceManager; class NotificationManager; -class GlyphLoadObserver; namespace SceneGraph { @@ -228,7 +225,6 @@ public: /** * Update a texture with an array of bitmaps. - * Typically used to upload multiple glyph bitmaps to a texture. * @param[in] id texture resource id * @param[in] uploadArray the upload array */ @@ -264,20 +260,6 @@ public: */ Integration::Bitmap* GetBitmap(ResourceTicketPtr ticket); - /** - * Set the glyph load observer - * @param glyphLoadedInterface pointer to an object which supports the glyphLoadedInterface - */ - void SetGlyphLoadObserver( GlyphLoadObserver* glyphLoadedInterface ); - - /** - * Update atlas status - * @param id The ticket resource Id - * @param atlasId The atlas texture Id - * @param loadStatus The status update - */ - void UpdateAtlasStatus( ResourceId id, ResourceId atlasId, Integration::LoadStatus loadStatus ); - public: // From ResourceTicketLifetimeObserver. /** @@ -331,14 +313,6 @@ public: // Message methods void NotifySavingFailed( ResourceId id ); /** - * Notify associated glyph loader observer that a glyph set is loading - * @param[in] id The resource id of the loaded id - * @param[in] glyphSet The loading glyph set - * @param[in] loadStatus The current load status - */ - void NotifyGlyphSetLoaded( ResourceId id, const Integration::GlyphSet& glyphSet, Integration::LoadStatus loadStatus ); - - /** * Finds ImageTicket which belongs to resource identified by id and updates the cached size and pixelformat * with the data from texture. * !!! NOTE, this will replace the whole ImageAttributes member of the ticket, not just the three properties mentioned !!! @@ -397,11 +371,6 @@ inline MessageBase* SavingFailedMessage( ResourceClient& client, ResourceId id ) return new MessageValue1< ResourceClient, ResourceId >( &client, &ResourceClient::NotifySavingFailed, id ); } -inline MessageBase* LoadingGlyphSetSucceededMessage( ResourceClient& client, ResourceId id, const Integration::GlyphSetPointer& glyphSet, Integration::LoadStatus loadStatus ) -{ - return new MessageValue3< ResourceClient, ResourceId, Integration::GlyphSet, Integration::LoadStatus >( &client, &ResourceClient::NotifyGlyphSetLoaded, id, *glyphSet, loadStatus ); -} - } // namespace Internal } // namespace Dali diff --git a/dali/internal/event/resources/resource-type-path.cpp b/dali/internal/event/resources/resource-type-path.cpp index 7ebd63d..04a5cf8 100644 --- a/dali/internal/event/resources/resource-type-path.cpp +++ b/dali/internal/event/resources/resource-type-path.cpp @@ -111,42 +111,6 @@ int ResourceTypeCompare(const ResourceType& lhs, const ResourceType& rhs) break; // result = 0 } - case ResourceText: - { - // compare text requests - const TextResourceType& lhsText = static_cast(lhs); - const TextResourceType& rhsText = static_cast(rhs); - - if( lhsText.mStyle != rhsText.mStyle ) - { - result = lhsText.mStyle < rhsText.mStyle ? -1 : 1; - } - else if (lhsText.mCharacterList.size() != rhsText.mCharacterList.size()) - { - result = lhsText.mCharacterList.size() < rhsText.mCharacterList.size() ? -1 : 1; - } - else if (!std::equal(lhsText.mCharacterList.begin(), lhsText.mCharacterList.end(), rhsText.mCharacterList.begin())) - { - for (unsigned int i = 0; i < lhsText.mCharacterList.size(); ++i) - { - if (lhsText.mCharacterList[i].character != rhsText.mCharacterList[i].character) - { - result = lhsText.mCharacterList[i].character <= rhsText.mCharacterList[i].character ? -1 : 1; - break; - } - } - } - else if (lhsText.mFontHash != rhsText.mFontHash) - { - result = lhsText.mFontHash < rhsText.mFontHash ? -1 : 1; - } - else if (lhsText.mQuality != rhsText.mQuality) - { - result = lhsText.mQuality < rhsText.mQuality ? -1 : 1; - } - break; - } - case ResourceMesh: { break; // result = 0 diff --git a/dali/internal/event/text/atlas/atlas-rank-generator.cpp b/dali/internal/event/text/atlas/atlas-rank-generator.cpp deleted file mode 100644 index 90e5241..0000000 --- a/dali/internal/event/text/atlas/atlas-rank-generator.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2014 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 INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace // un-named namespace -{ - -/** - * Given a text string, and the number of characters matched, return the match status - * @param textSize, size of the text - * @param charMissing number of characters that don't exist in the Atlas - * @return the character match status - */ -AtlasRanking::CharacterMatch GetTextMatchStatus( std::size_t textSize, std::size_t charsMissing ) -{ - if( charsMissing == 0 ) - { - return AtlasRanking::ALL_CHARACTERS_MATCHED; - } - else if ( charsMissing == textSize ) - { - return AtlasRanking::NO_CHARACTERS_MATCHED; - } - else - { - return AtlasRanking::SOME_CHARACTERS_MATCHED; - } -} - -/** - * Returns the space status of the atlas based on whether the text will - * fit in it and if it can be resized - * @param canFit whether the text can fit in the atlas - * @param atlasResizable whether the atlas is resizable. - * @return the space status - */ -AtlasRanking::SpaceStatus GetAtlasSpaceStatus( bool canFit, bool atlasResizable) -{ - if( canFit ) - { - return AtlasRanking::HAS_SPACE; - } - else if( atlasResizable ) - { - return AtlasRanking::FULL_CAN_BE_RESIZED; - } - else - { - return AtlasRanking::FULL_CANNOT_BE_RESIZED; - } -} - -} // un-named namespace - -AtlasRanking GetAtlasRanking( const Integration::TextArray& text, - FontId fontId, - const GlyphStatusContainer& container, - bool atlasResizable) -{ - bool canFit(false); - unsigned int charsNotLoaded(0); - - // find if the text will fit or not, and how many characters are missing - container.GetTextStatus( text, fontId, charsNotLoaded, canFit); - - AtlasRanking::CharacterMatch charMatchStatus = GetTextMatchStatus( text.Count(), charsNotLoaded ); - - AtlasRanking::SpaceStatus spaceStatus = GetAtlasSpaceStatus( canFit, atlasResizable); - - AtlasRanking ranking( charMatchStatus, - AtlasRanking::FONT_MATCHED, // @todo hard coded for now, until atlas splitting supported - spaceStatus, - charsNotLoaded ); - return ranking; -} - -} // namespace Internal -} // namespace Dali diff --git a/dali/internal/event/text/atlas/atlas-rank-generator.h b/dali/internal/event/text/atlas/atlas-rank-generator.h deleted file mode 100644 index a59a97a..0000000 --- a/dali/internal/event/text/atlas/atlas-rank-generator.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef __DALI_INTERNAL_ATLAS_RANK_GENERATOR_H__ -#define __DALI_INTERNAL_ATLAS_RANK_GENERATOR_H__ - -/* - * Copyright (c) 2014 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 INCLUDES - -#include -#include - - -namespace Dali -{ - -namespace Internal -{ - - /** - * Helper to generate the ranking for an atlas. - * @param[in] text the text to match against - * @param[in] fontId font id - * @param[in] container glyph status container - * @param[in] atlasResizable whether the atlas is resizable - * @return atlas ranking - */ - AtlasRanking GetAtlasRanking( const Integration::TextArray& text, - FontId fontId, - const GlyphStatusContainer& container, - bool atlasResizable); - - - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_ATLAS_RANK_GENERATOR_H__ diff --git a/dali/internal/event/text/atlas/atlas-ranking.cpp b/dali/internal/event/text/atlas/atlas-ranking.cpp deleted file mode 100644 index 6268f20..0000000 --- a/dali/internal/event/text/atlas/atlas-ranking.cpp +++ /dev/null @@ -1,118 +0,0 @@ - -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -namespace Dali -{ - -namespace Internal -{ - -AtlasRanking::AtlasRanking( unsigned int unMatchedCharacters ) -: mUnMatchedCharacters( unMatchedCharacters ), - mChararacterMatch( NO_CHARACTERS_MATCHED ), - mFontMatch( NO_FONT_MATCHED ), - mSpaceStatus( FULL_CANNOT_BE_RESIZED ) -{ -} - -AtlasRanking::AtlasRanking( CharacterMatch characterMatch, - FontMatch fontMatch, - SpaceStatus spaceStatus, - unsigned int unMatchedCharacters ) -: mUnMatchedCharacters( unMatchedCharacters ), - mChararacterMatch( characterMatch ), - mFontMatch( fontMatch ), - mSpaceStatus( spaceStatus ) -{ - -} - -AtlasRanking::~AtlasRanking() -{ - -} - -AtlasRanking::AtlasRanking( const AtlasRanking& rhs) -: mUnMatchedCharacters( rhs.mUnMatchedCharacters ), - mChararacterMatch( rhs.mChararacterMatch ), - mFontMatch( rhs.mFontMatch ), - mSpaceStatus( rhs.mSpaceStatus ) -{ - -} - -AtlasRanking& AtlasRanking::operator=( const AtlasRanking& rhs) -{ - mUnMatchedCharacters = rhs.mUnMatchedCharacters; - mChararacterMatch = rhs.mChararacterMatch; - mFontMatch = rhs.mFontMatch; - mSpaceStatus = rhs.mSpaceStatus; - return *this; -} - -bool AtlasRanking::HigherRanked(const AtlasRanking &atlasRank) const -{ - int ret = Compare( *this , atlasRank ); - return (ret == 1); -} - -bool AtlasRanking::TextFits() const -{ - return ( mSpaceStatus == HAS_SPACE ) || (mChararacterMatch == ALL_CHARACTERS_MATCHED); -} - -bool AtlasRanking::AllCharactersMatched() const -{ - return ( mChararacterMatch == ALL_CHARACTERS_MATCHED ); -} - -AtlasRanking::SpaceStatus AtlasRanking::GetSpaceStatus() const -{ - return mSpaceStatus; -} - -int AtlasRanking::Compare( const AtlasRanking &a, const AtlasRanking &b) const -{ - if( a.mChararacterMatch != b.mChararacterMatch ) - { - return a.mChararacterMatch > b.mChararacterMatch ? 1 : -1; - } - - if( a.mFontMatch != b.mFontMatch ) - { - return a.mFontMatch > b.mFontMatch ? 1 : -1; - } - - if( a.mSpaceStatus != b.mSpaceStatus ) - { - return a.mSpaceStatus > b.mSpaceStatus ? 1 : -1; - } - - if( a.mUnMatchedCharacters != b.mUnMatchedCharacters ) - { - return a.mUnMatchedCharacters < b.mUnMatchedCharacters ? 1: -1; - } - return 0; -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/atlas/atlas-ranking.h b/dali/internal/event/text/atlas/atlas-ranking.h deleted file mode 100644 index 849dbca..0000000 --- a/dali/internal/event/text/atlas/atlas-ranking.h +++ /dev/null @@ -1,157 +0,0 @@ -#ifndef __DALI_INTERNAL_ATLAS_RANKING_H__ -#define __DALI_INTERNAL_ATLAS_RANKING_H__ - -/* - * Copyright (c) 2014 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. - * - */ - - -namespace Dali -{ - -namespace Internal -{ - -/** - * Small class used to store and compare how suitable an atlas is - * for storing a string of text. - * - * The search ranking allows us to chose the best Atlas / tweak behaviour. - * - * The ranking algorithm is based on various factors, such as: - * - Whether all or some of the characters are in the atlas already - * - Whether the atlas contains other characters of the same font - * - Whether the atlas is full but can be split up (if it has more than one font) - * - Whether the atlas is full, but can be enlarged. - * - * Contains POD - */ -class AtlasRanking -{ - -public: - - /** - * Character match status - */ - enum CharacterMatch - { - NO_CHARACTERS_MATCHED = 0x0, ///< Atlas contains no matching characters - SOME_CHARACTERS_MATCHED = 0x1, ///< Some characters are in the Atlas - ALL_CHARACTERS_MATCHED = 0x2 ///< All characters are in the atlas - }; - - /** - * Font match status - */ - enum FontMatch - { - NO_FONT_MATCHED = 0x0, ///< Atlas has no characters using the the same font - FONT_MATCHED = 0x1 ///< Atlas characters using the same font - }; - - /** - * Space status - */ - enum SpaceStatus - { - FULL_CANNOT_BE_RESIZED = 0x0, ///< Atlas can't be resized ( recached max texture size) - FULL_CAN_BE_SPLIT = 0x1, ///< Atlas is full and contains more than one font, so can be split up - FULL_CAN_BE_RESIZED = 0x2, ///< Atlas is full and can be resized - HAS_SPACE = 0x4 ///< Atlas has free space - }; - - /** - * Constructor. - * @param[in] unMatchedCharacters number of un-matched characters - */ - AtlasRanking( unsigned int unMatchedCharacters ); - - /** - * Constructor - * @param[in] characterMatch character match status - * @param[in] fontMatch font match status - * @param[in] spaceStatus space status - * @param[in] unMatchedCharacters number of un-matched characters - */ - AtlasRanking( CharacterMatch characterMatch, - FontMatch fontMatch, - SpaceStatus spaceStatus, - unsigned int unMatchedCharacters); - - - /** - * non virtual destructor, not intended as a base class. - */ - ~AtlasRanking(); - - /** - * Copy constructor - * @param[in] rhs atlas to copy - */ - AtlasRanking( const AtlasRanking& rhs); - - /** - * Assignment operator. - * @param[in] rhs atlas to assign - * @return reference to this - */ - AtlasRanking& operator=( const AtlasRanking& rhs ); - - /** - * Returns if this atlas ranking is higher than the - * parameter passed in, - * @param atlasRank the rank to compare against - * @return true if it is higher ranked - */ - bool HigherRanked(const AtlasRanking &atlasRank) const; - - /** - * @return true if the text fits in the atlas - */ - bool TextFits() const; - - /** - * @return true if the atlas already contains all the characters in the text - */ - bool AllCharactersMatched() const; - - /** - * @return the atlas space status - */ - SpaceStatus GetSpaceStatus() const; - -private: - - /** - * Compare two atlas rankings - * @param a atlas a ranking - * @param b atlas b ranking - * @return -1 if a b - */ - int Compare( const AtlasRanking &a, const AtlasRanking &b) const; - - unsigned int mUnMatchedCharacters:10; ///< number of un-matched characters - CharacterMatch mChararacterMatch:2; ///< character match status - FontMatch mFontMatch:1; ///< font match status - SpaceStatus mSpaceStatus:3; ///< space tatus -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_ATLAS_RANKING_H__ diff --git a/dali/internal/event/text/atlas/atlas-size.cpp b/dali/internal/event/text/atlas/atlas-size.cpp deleted file mode 100644 index 0223c73..0000000 --- a/dali/internal/event/text/atlas/atlas-size.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// HEADER -#include - -// EXTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace -{ -const unsigned int DISTANCE_FIELD_BLOCK_SIZE( 64 ); ///< @todo add to platform abstraction - -/** - * Lookup table used to determine how an atlas should grow - * in size, as more characters are added - */ -const unsigned int ATLAS_SIZES[] = -{ - // - // Each character has a pixel size of 64x64 @ 1 byte per pixel = 4096 bytes ( 4KB) - // An atlas with 16 characters has an OpenGL Texture size of 16 * 4096 bytes = 64 KB. - // Atlas are square. - // - // Atlas width ( pixels) // Number of characters | Texture Memory | Texture Size | Power of 2 | - // // | | | - 4 * DISTANCE_FIELD_BLOCK_SIZE, // 16 (4*4) | 64 KB | 256 x 256 | Yes - 8 * DISTANCE_FIELD_BLOCK_SIZE, // 64 (8*8) | 256 KB | 512 x 512 | Yes - 12 * DISTANCE_FIELD_BLOCK_SIZE, // 144 | 576 KB | 768 x 768 | --- - 16 * DISTANCE_FIELD_BLOCK_SIZE, // 256 | 1 MB | 1024 x 1024 | Yes - 20 * DISTANCE_FIELD_BLOCK_SIZE, // 400 | 1.56 MB | 1280 x 1280 | --- - 24 * DISTANCE_FIELD_BLOCK_SIZE, // 576 | 2.25 MB | 1536 x 1536 | --- - 28 * DISTANCE_FIELD_BLOCK_SIZE, // 784 | 3.06 MB | 1792 x 1792 | --- - 32 * DISTANCE_FIELD_BLOCK_SIZE, // 1024 | 4 MB | 2048 x 2048 | Yes - 48 * DISTANCE_FIELD_BLOCK_SIZE, // 2304 | 9 MB | 3072 x 3072 | --- - 64 * DISTANCE_FIELD_BLOCK_SIZE, // 4096 | 16 MB | 4096 x 4096 | Yes -}; - - -const std::size_t ATLAS_SIZE_COUNT = (sizeof( ATLAS_SIZES))/ (sizeof(unsigned int)) ; - -} // un-named name space - -unsigned int GlyphAtlasSize::GetAtlasCharacterCount( unsigned int size ) -{ - // if atlas size = 256. - // Then character count is ( 256 / block )= 4. Squared = 4 * 4 = 16 characters - unsigned int oneSide= (size / DISTANCE_FIELD_BLOCK_SIZE ); - return oneSide * oneSide; -} - -unsigned int GlyphAtlasSize::GetInitialSize( unsigned int initialiCharacterCount) -{ - for( std::size_t i = 0; i < ATLAS_SIZE_COUNT; ++i) - { - unsigned int atlasCharCount = GetAtlasCharacterCount( ATLAS_SIZES[i] ); - - if( initialiCharacterCount <= atlasCharCount ) - { - return ATLAS_SIZES[i]; - } - } - return GetMaxSize(); -} - -unsigned int GlyphAtlasSize::GetNextSize( unsigned int currentSize ) -{ - for( std::size_t i = 0; i < ATLAS_SIZE_COUNT; ++i) - { - if( currentSize < ATLAS_SIZES[i] ) - { - return ATLAS_SIZES[i]; - } - } - return GetMaxSize(); -} - -unsigned int GlyphAtlasSize::GetMaxSize() -{ - return ATLAS_SIZES[ ATLAS_SIZE_COUNT -1]; -} - -unsigned int GlyphAtlasSize::GetBlockSize() -{ - return DISTANCE_FIELD_BLOCK_SIZE; -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/atlas/atlas-size.h b/dali/internal/event/text/atlas/atlas-size.h deleted file mode 100644 index f7b3323..0000000 --- a/dali/internal/event/text/atlas/atlas-size.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef __DALI_INTERNAL_ATLAS_SIZES_H__ -#define __DALI_INTERNAL_ATLAS_SIZES_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -namespace Dali -{ - -namespace Internal -{ - -namespace GlyphAtlasSize -{ - -/** - * Given an atlas size, return the maximum amount of characters it can hold - * @return maximum of number of characters - */ -unsigned int GetAtlasCharacterCount( unsigned int size ); - -/** - * Get the initial size of an atlas, which will at least fit - * character count passed in. - * @return initial size of the atlas - */ -unsigned int GetInitialSize( unsigned int initialiCharacterCount); - -/** - * Gets the next biggest atlas size - * @return the next atlas size - */ -unsigned int GetNextSize( unsigned int currentSize); - -/** - * This returns the maximum atlas size. - * @return the maximum atlas size - */ -unsigned int GetMaxSize(); - -/** - * Return the atlas block size. - * @return block size - */ -unsigned int GetBlockSize(); - -} // namespace GlyphAtlasSize - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_ATLAS_SIZES_H__ diff --git a/dali/internal/event/text/atlas/atlas-uv-interface.h b/dali/internal/event/text/atlas/atlas-uv-interface.h deleted file mode 100644 index 157a052..0000000 --- a/dali/internal/event/text/atlas/atlas-uv-interface.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef __DALI_INTERNAL_ATLAS_UV_INTERFACE_H__ -#define __DALI_INTERNAL_ATLAS_UV_INTERFACE_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * Abstract interface for requesting the UV co-ordinates of an item held in an Atlas. - * - */ -class AtlasUvInterface -{ - -public: - - /** - * Get the uv-coordinates of an item in the atlas. - * @param itemIndex unique index of an item in the atlas. E.g. a character code - * @return uv co-ordinates of the item. - */ - virtual UvRect GetUvCoordinates( unsigned int itemIndex ) const = 0; - - -protected: - - /** - * Constructor - */ - AtlasUvInterface() - { - } - - /** - * Virtual destructor. - */ - virtual ~AtlasUvInterface() - { - } - -private: - - // Undefined copy constructor. - AtlasUvInterface( const AtlasUvInterface& ); - - // Undefined assignment operator. - AtlasUvInterface& operator=( const AtlasUvInterface& ); - -}; - - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_ATLAS_UV_INTERFACE_H__ diff --git a/dali/internal/event/text/atlas/atlas.cpp b/dali/internal/event/text/atlas/atlas.cpp deleted file mode 100644 index 03f3574..0000000 --- a/dali/internal/event/text/atlas/atlas.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include -#include -#include - -// EXTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace // un-named namespace -{ - -void GetByteAndBitPosition( unsigned int blockNum, unsigned int& bytePos, unsigned int& bitPos ) -{ - // divide by 8 to calculate the byte this block is in - // 1 byte holds bitmask for 8 blocks - // Example: If block = 10, then block is in byte 1. - // - // byte 0 byte 1 byte 3 - // [ 0000,0000 ], [ 00 X ..... ] , [.........] - // 0123 4567 89 ^10th bit set - // blockNum / 8 = byte number - // - - bytePos = blockNum >> 3; // >>3 = divide by 8 - - // calculate the bit, within the byte which the block uses - // the lower 3 bits define it's position with the block - // if block = 10, in binary this is 1010. Lower 3 bits = 010. - // So bit position = 2 ( zero based) - - bitPos = blockNum & 7; // AND With binary 111 to lower 3 bits -} - -} // un-named namespace - - -Atlas::Atlas(const unsigned int atlasSize, - const unsigned int blockSize) -: mSize(atlasSize), - mBlockSize(blockSize) -{ - DALI_ASSERT_DEBUG(mBlockSize > 0 && atlasSize >= blockSize); - - // Atlases are square - unsigned int totalBlocks = GetBlocksPerRow() * GetBlocksPerRow(); - - DALI_ASSERT_DEBUG( (totalBlocks % 8) == 0 && "Atlas num blocks must be factor of 8" ); - - // block allocation is using a bitmask in a 1D array. - // e.g. 256 blocks require 256 bits to say whether a block is allocated - // 256 / 8 = 32 bytes (or >> 3 to divide by 8 ). - unsigned int bitMaskBytes = totalBlocks >> 3; - - mFreeBlocks.resize( bitMaskBytes ); // contents auto-initialised to zero -} - -Atlas::~Atlas() -{ - -} - -void Atlas::CloneContents( Atlas* clone ) -{ - // Internally atlas allocation is done using a 1 dimensional array. - // A single bit set in the array represents an allocation. - // - // So an atlas of size 8 x 8 blocks is 64 bits long. - // - // When cloning we keep the allocated blocks in the same 2D space. - // - // - // Original (4 x 4) --> New Atlas ( 8 x 8) - // - // 1110 1110 0000 - // 0010 ----------> 0010 0000 - // 0000 0000 0000 - // 1001 1001 0000 - // - // 0000 0000 - // 0000 0000 - // 0000 0000 - // 0000 0000 - // - // If we want the X,Y position of character 'X' in original atlas, it will be identical in the new atlas. - // This allows the glyph bitmap to be uploaded to an identical place in the gl texture - // to the old texture. - // Original aim of this approach was to avoid re-calcualating uv co-ordinates. - // However as the texture width / height has changed, the uv values also need adjusting (scaling) - - DALI_ASSERT_DEBUG( clone->mSize <= mSize); - - // go through each allocated block in the cloned atlas, and add to the this atlas. - - BlockLookup::const_iterator endIter = clone->mBlockLookup.end(); - for( BlockLookup::const_iterator iter = clone->mBlockLookup.begin(); iter != endIter; ++iter ) - { - unsigned int key = (*iter).first; - unsigned int block = (*iter).second; - unsigned int row,column; - - clone->GetPositionOfBlock( block, row, column ); - - unsigned int newBlockId = AllocateBlock( row, column ); - - mBlockLookup[ key ] = newBlockId; - } - -#ifdef DEBUG_ATLAS - DebugPrintAtlasWithIds( clone->mFreeBlocks, clone->mBlockLookup, clone->GetBlocksPerRow()); - DebugPrintAtlasWithIds( mFreeBlocks,mBlockLookup, GetBlocksPerRow() ); -#endif -} - -bool Atlas::Insert( unsigned int id) -{ - unsigned int blockNum(0); - - bool ok = AllocateBlock( blockNum ); - - if (!ok) - { - DALI_ASSERT_DEBUG( 0 && "Atlas full "); - // Atlas full - return false; - } - - DALI_ASSERT_ALWAYS( mBlockLookup.find(id) == mBlockLookup.end() && "Inserted duplicate id into the atlas" ); - - // store the link between block number and unique id - mBlockLookup[id] = blockNum; - -#ifdef DEBUG_ATLAS - DebugPrintAtlas( mFreeBlocks, GetBlocksPerRow() ); -#endif - - return true; -} - -void Atlas::Remove(unsigned int id) -{ - BlockLookup::const_iterator iter = mBlockLookup.find( id ); - - DALI_ASSERT_ALWAYS( iter != mBlockLookup.end() && "Failed to find id in atlas\n"); - - DeAllocateBlock( (*iter).second ); - - // remove the id from the lookup - mBlockLookup.erase( id ); -} - -unsigned int Atlas::GetSize() const -{ - return mSize; -} - -void Atlas::GetXYPosition( unsigned int id, unsigned int& xPos, unsigned int& yPos ) const -{ - AtlasItem item; - - unsigned int blockNum( GetBlockNumber( id ) ); - FillAtlasItem( blockNum, item, DONT_CALCULATE_UV ); - - xPos = item.xPos; - yPos = item.yPos; -} - -UvRect Atlas::GetUvCoordinates( unsigned int id ) const -{ - AtlasItem item; - - unsigned int blockNum( GetBlockNumber( id ) ); - FillAtlasItem( blockNum, item, CALCULATE_UV ); - - return item.uv; -} - -Atlas::Atlas() -:mSize( 0 ), - mBlockSize( 0 ) -{ - -} - -bool Atlas::AllocateBlock( unsigned int& blockNum ) -{ - // scan the bitmask for a free block - // each byte is a bitmask for 8 blocks, so 0000 0011, means blocks 1 and 2 are allocated - for( size_t i = 0, end = mFreeBlocks.size(); i < end; ++i ) - { - // check if a free bit is available - unsigned char mask = mFreeBlocks[i]; - if( 0xFF != mask) - { - for( int n = 0; n < 8 ; n++) - { - // check if a bit is not set. - if( ! (mask & (1 << n) ) ) - { - // we have found a free bit, set it to 1. - mask|= (1 << n); - blockNum = i * 8 + n; - mFreeBlocks[i] = mask; - - return true; - } - } - } - } - blockNum = 0; - return false; -} - -void Atlas::DeAllocateBlock( unsigned int blockNum ) -{ - unsigned int bytePos,bitPos; - - GetByteAndBitPosition( blockNum, bytePos, bitPos ); - - unsigned char mask = mFreeBlocks[ bytePos ]; - - // check the block was allocated - DALI_ASSERT_DEBUG( ((mask & (1<< bitPos))) && "DeAllocated a block, that was never allocated" ); - - // clear the bit - mask &= ~(1 << bitPos); - - mFreeBlocks[ bytePos ] = mask; - -} - -void Atlas::FillAtlasItem( unsigned int blockNum, AtlasItem& atlasItem, UvMode mode ) const -{ - UvRect& uv(atlasItem.uv); - - unsigned int block1dPos = blockNum * mBlockSize; - - unsigned int blockX = block1dPos % mSize; - unsigned int blockY = mBlockSize * floor( block1dPos / mSize ); - - atlasItem.xPos = blockX; - atlasItem.yPos = blockY; - - if( mode == DONT_CALCULATE_UV ) - { - return; - } - const float ratio = 1.0f / mSize; - - uv.u0 = ratio * (blockX); - uv.v0 = ratio * (blockY); - uv.u2 = ratio * (blockX + mBlockSize); - uv.v2 = ratio * (blockY + mBlockSize); - -} - -unsigned int Atlas::GetBlockNumber( unsigned int id) const -{ - BlockLookup::const_iterator iter = mBlockLookup.find( id ); - - DALI_ASSERT_ALWAYS( iter != mBlockLookup.end() ); - - return (*iter).second; -} - -unsigned int Atlas::GetBlocksPerRow() const -{ - return mSize / mBlockSize; -} - -void Atlas::GetPositionOfBlock( unsigned int block1dPos, unsigned int& row, unsigned int& column ) -{ - column = 0; - if( block1dPos > 0) - { - column = block1dPos % GetBlocksPerRow(); - } - row = floor( block1dPos / GetBlocksPerRow() ); - - unsigned int bytePos, bitPos; - - GetByteAndBitPosition( block1dPos, bytePos, bitPos ); -} - -unsigned int Atlas::AllocateBlock( unsigned int row, unsigned int column ) -{ - unsigned int blockNum = (row * GetBlocksPerRow()) + column; - - unsigned int bytePos, bitPos; - - GetByteAndBitPosition( blockNum, bytePos, bitPos ); - - unsigned char& mask = mFreeBlocks.at( bytePos); - - mask |= 1<< bitPos; // set the bit to mark as allocated - - return blockNum; -} - - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/atlas/atlas.h b/dali/internal/event/text/atlas/atlas.h deleted file mode 100644 index dd2bc2d..0000000 --- a/dali/internal/event/text/atlas/atlas.h +++ /dev/null @@ -1,253 +0,0 @@ -#ifndef __DALI_INTERNAL_ATLAS_H__ -#define __DALI_INTERNAL_ATLAS_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * The atlas class contains the logic for working out where a fixed size - * block (a bitmap) should be placed in to a texture atlas. - * - * Note: There is no physical storage done, the class just maps out where - * blocks should be placed in the texture. - * - * The class uses a bitmask to represent which blocks are used. - * E.g if we have a simple 8 x 8 block Atlas. It would be represent like: - * - * 0000 0000 ( one byte) - * 0000 0000 - * 0000 0000 - * 0000 0000. - * - * If a block is marked as allocated, it's bit is set to 1. - * E.g. - * 1110 0001 - * 0000 0100 - * .... .... - * Means blocks 0,1,2,7 and 13 are allocated. - * - * Internally instead of having a 2D array, the bitmask is just a 1D array. - * - * The class also provides an API to access the position and texture coordinates of each block. - * - * To debug the class, enable DEBUG_ATLAS in atlas-debug.h - * - */ -class Atlas : public AtlasUvInterface -{ - -public: - - /** - * Constructor - * @param[in] atlasSize The width / height of the atlas (only square atlases are supported) - * @param[in] blockSize The width / height of each block in the atlas - */ - Atlas( const unsigned int atlasSize, const unsigned int blockSize ); - - /** - * Destructor - */ - virtual ~Atlas(); - - /** - * Clone the contents of the atlas passed as a parameter into this atlas - * @param clone the atlas to clone - */ - void CloneContents( Atlas* clone ); - - /** - * Inserts a block in to the atlas. - * - * @param[in] id, a user defined unique id, which can be used to delete the block in the future - * @return true on success, false if there is no space in the atlas - */ - bool Insert( unsigned int id ); - - /** - * Remove a block from the atlas - * @param[in] id, a unique id of the block to be deleted - */ - void Remove( unsigned int id ); - - /** - * Get the atlas size in pixels. As it is square, the size = width = height. - * @return the size of the atlas - */ - unsigned int GetSize() const; - - /** - * Get the x,y position of an allocated block within the atlas. - * Used to determine the x,y position to upload the block to in a texture - * @param[in] id, a user defined unique id of the item to get - * @param[out] xPos x position of the block - * @param[out] yPos y position of the block - */ - void GetXYPosition( unsigned int id, unsigned int &xPos, unsigned int &yPos ) const; - -private: // AtlasUvInterface - - /** - * @copydoc AtlasUvInterface::GetUvCoordinates - */ - UvRect GetUvCoordinates( unsigned int id ) const; - -private: - - /** - * Default constructor - */ - Atlas(); - - // Undefined copy constructor. - Atlas( const Atlas& ); - - // Undefined assignment operator. - Atlas& operator=( const Atlas& ); - - /** - * Allocate a block in the atlas - * @param[out] blockNum assigned a free block number - */ - bool AllocateBlock( unsigned int& blockNum ); - - - /** - * De-allocate a block in the atlas - * @param[in] blockNum the block number to mark as free - */ - void DeAllocateBlock( unsigned int blockNum ); - - /** - * Used to control whether the uv-coordinates are generated - * when getting an atlas item. - */ - enum UvMode - { - CALCULATE_UV, - DONT_CALCULATE_UV - }; - - /** - * Holds the UV co-ordinates and x,y position of - * an item in the atlas. - */ - struct AtlasItem - { - AtlasItem() - : xPos(0), - yPos(0) - { - } - - ~AtlasItem() - { - } - // Undefined copy constructor. - AtlasItem( const AtlasItem& ); - - // Undefined assignment operator. - AtlasItem& operator=( const AtlasItem& ); - - UvRect uv; ///< Texture uv co-ordinates - unsigned int xPos; ///< x-pixel position - unsigned int yPos; ///< y-pixel position - }; - - /** - * Allocate a block in the atlas - * @param[in] blockNum the block number - * @param[out] atlasItem filled with information about the block - * @param[in] mode whether to generate uv-coordinates or not - */ - void FillAtlasItem( unsigned int blockNum, AtlasItem& atlasItem, UvMode mode) const; - - /** - * Given a unique ID, returns the block number - * @param[in] id unique user defined id - * @return block number - */ - unsigned int GetBlockNumber( unsigned int id) const; - - /** - * Gets the blocks per row. E.g. a 4 x 4 Atlas will return 4. - * @return the number of blocks per row. - */ - unsigned int GetBlocksPerRow( ) const; - - /** - * Returns if a block is allocated or not, along with the unique id of the block - * @param[in] row block row - * @param[in] column block column - * @param[out] id unique id - * @return true if block is allocated - */ - bool IsBlockAllocated( unsigned int row, unsigned int column, unsigned int& id ); - - /** - * Gets a position of the block within the atlas. - * E.g. In a 8 x 8 Atlas, block 8 (zero based) with have row = 1, col = 0. - * - * @param[in] block1dPos block id - * @param[out] row atlas row - * @param[out] column atlas column - */ - void GetPositionOfBlock( unsigned int block1dPos, unsigned int& row, unsigned int& column ); - - /** - * Mark a block as a allocated - * @param[in] row atlas row - * @param[in] column atlas column - * @return the id of the block that was allocated - */ - unsigned int AllocateBlock( unsigned int row, unsigned int column ); - - /** - * Lookup between a user defined unique id, and a block number - */ - typedef std::map< unsigned int /* user defined id */, unsigned int /* block num */ > BlockLookup; - - /** - * Bitmask, each bit set represents an allocated block - */ - typedef std::vector FreeBlocks; - - unsigned int mSize; ///< The size of the atlas - unsigned int mBlockSize; ///< The block size - FreeBlocks mFreeBlocks; ///< Bitmask of free blocks - BlockLookup mBlockLookup; ///< lookup between block number and unique id given by user - - -}; // class Atlas - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_ATLAS_H__ diff --git a/dali/internal/event/text/atlas/debug/atlas-debug.cpp b/dali/internal/event/text/atlas/debug/atlas-debug.cpp deleted file mode 100644 index 2994e2a..0000000 --- a/dali/internal/event/text/atlas/debug/atlas-debug.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// HEADER -#include - -namespace Dali -{ -namespace Internal -{ -#if defined(DEBUG_ENABLED) -Debug::Filter* gTextAtlasLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_TEXT_ATLAS"); -#endif -} -} - -#ifdef DEBUG_ATLAS - -// INTERNAL INCLUDES -#include - -// EXTERNAL INCLUDES -#include -#include // for setw - -namespace Dali -{ - -namespace Internal -{ - -namespace -{ - -unsigned int GetBlockId( unsigned int blockIndex, const BlockLookup* blockLookup) -{ - // this is a reverse lookup between the block number and the character code - BlockLookup::const_iterator endIter = blockLookup->end(); - for(BlockLookup::const_iterator iter = blockLookup->begin(); iter != endIter; ++iter ) - { - - if( blockIndex == (*iter).second ) - { - unsigned int charCode; - FontId fontId; - - // the value stored in the lookup is encoded to CharacterCode | Font Id - GlyphStatus::GetDecodedValue( (*iter).first , charCode, fontId); - - return charCode; - } - } - return -1; -} - -void PrintByte( unsigned int byteIndex, unsigned char block, const BlockLookup* blockLookup, unsigned int blocksPerRows ) -{ - for( unsigned int n = 0; n < 8; ++n) - { - unsigned int blockNum = (byteIndex * 8) + n; // 8 blocks per byte - - if(( blockNum > 0) && ( blockNum % blocksPerRows) == 0 ) - { - std::cout << std::endl; - } - - bool bitset= block& (1< - -namespace Dali -{ -namespace Internal -{ -#if defined(DEBUG_ENABLED) -extern Debug::Filter* gTextAtlasLogFilter; -#endif -} -} - -#ifdef DEBUG_ATLAS - -#include -#include - -namespace Dali -{ -namespace Internal -{ - -// typedefs below are only defined if DEBUG_ATLAS is defined - -/** - * lookup typedef between a block and a character code. - */ -typedef std::map< unsigned int /* used defined id */, unsigned int /* block num */ > BlockLookup; - -/** - * array of bytes. Each bit represents an allocation block - */ -typedef std::vector FreeBlocks; - -/** - * Print the atlas. E.g. for a 4x4 atlas print - * 1 1 1 1 - * 1 1 _ _ - * _ _ _ _ - * _ _ _ _ - * - * The 1's represent an allocated block - * @param blocks Array of bytes, each bit set represents an allocated block - * @param blocksPerRow how blocks per row. E.g. for a 4x4 atlas, it is 4 blocks per row - */ -void DebugPrintAtlas( const FreeBlocks& blocks, - unsigned int blocksPerRow); - -/** - * Print the atlas with the character id next to each allocated block - * E.g. - * 1 (34) 1(65) 1(13) _ - * _ _ _ _ - * @param blocks Array of bytes, each bit set represents an allocated block - * @param blockLookup lookup that maps a block id, to a character id - * @param blocksPerRow how blocks per row. E.g. for a 4x4 atlas, it is 4 blocks per row - */ -void DebugPrintAtlasWithIds( const FreeBlocks& blocks, - const BlockLookup& blockLookup, - unsigned int blocksPerRow); - - -} // namespace Internal - -} // namespace Dali - -#endif //DEBUG_ATLAS - -#endif // __DALI_INTERNAL_ATLAS_DEBUG_H__ diff --git a/dali/internal/event/text/atlas/glyph-atlas-manager-interface.h b/dali/internal/event/text/atlas/glyph-atlas-manager-interface.h deleted file mode 100644 index 8e09597..0000000 --- a/dali/internal/event/text/atlas/glyph-atlas-manager-interface.h +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef __DALI_INTERNAL_GLYPH_ATLAS_MANAGER_INTERFACE_H__ -#define __DALI_INTERNAL_GLYPH_ATLAS_MANAGER_INTERFACE_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * Abstract interface for Glyph AtlasManager - * - */ -class GlyphAtlasManagerInterface -{ - -public: - - /** - * Get the vertex buffer to draw the text. - * The caller takes ownership of the buffer and is responsible for - * deleting it. - * @param[in] text the text to generate the vertex data from - * @param[in] format text format - * @param[in] metric interface to get metric information for the text - * @return text vertex buffer - */ - virtual TextVertexBuffer* TextRequired( const Integration::TextArray& text, - const TextFormat& format, - FontMetricsInterface& metrics ) = 0; - - - /** - * Called when text is no longer required - * @param[in] text array - * @param[in] format text format - * @param[in] fontId font id - * @param[in] textureId texture id (each atlas has a single texture) - */ - virtual void TextNotRequired( const Integration::TextArray& text, - const TextFormat& format, - FontId fontId, - unsigned int textureId ) = 0; - - /** - * Check if the characters are loaded into a texture (atlas). - * @param[in] text array - * @param[in] format text format - * @param[in] fontId font id - * @param[in] textureId texture id (each atlas has a single texture) - * @return true if all characters are available, false if not - */ - virtual bool IsTextLoaded( const Integration::TextArray& text, - const TextFormat& format, - FontId fontId, - unsigned int textureId) const = 0; - - - /** - * Adds a text observer. - * The text observer will get a call back whenever new text is loaded. - * The observer is responsible for calling RemoveObserver() when - * all it's text is loaded or before destruction - * @param[in] observer The observer to add. - */ - virtual void AddTextObserver( TextObserver& observer ) = 0; - - /** - * Removes a text observer - * @param[in] observer The observer to remove. - */ - virtual void RemoveTextObserver( TextObserver& observer ) = 0 ; - - /** - * Adds a texture observer, to detect atlas resize / split changes - * @param[in] observer The observer to add. - */ - virtual void AddTextureObserver( GlyphTextureObserver& observer ) = 0; - - /** - * Removes a texture observer - * @param[in] observer The texture observer to remove. - */ - virtual void RemoveTextureObserver( GlyphTextureObserver& observer ) = 0 ; - -protected: - - /** - * Constructor - */ - GlyphAtlasManagerInterface() - { - } - /** - * Destructor. - */ - virtual ~GlyphAtlasManagerInterface() - { - } - -private: - - // Undefined copy constructor. - GlyphAtlasManagerInterface( const GlyphAtlasManagerInterface& ); - - // Undefined assignment operator. - GlyphAtlasManagerInterface& operator=( const GlyphAtlasManagerInterface& ); - -}; - - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_GLYPH_ATLAS_MANAGER_INTERFACE_H__ diff --git a/dali/internal/event/text/atlas/glyph-atlas-manager.cpp b/dali/internal/event/text/atlas/glyph-atlas-manager.cpp deleted file mode 100644 index 18b6245..0000000 --- a/dali/internal/event/text/atlas/glyph-atlas-manager.cpp +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - - -GlyphAtlasManager::GlyphAtlasManager( const FontLookupInterface& fontLookup ) -: mGlyphResourceManager( fontLookup ), - mAtlasesChanged(false) -{ -} - -GlyphAtlasManager::~GlyphAtlasManager() -{ - // Atlases automatically get destroyed. -} - -TextVertexBuffer* GlyphAtlasManager::TextRequired( const Integration::TextArray& text , - const TextFormat& format, - FontMetricsInterface& metrics ) -{ - // get the font id - FontId fontId = metrics.GetFontId(); - - AtlasRanking bestRank( text.Count() ); - - // find the atlas which is best suited to displaying the text string - GlyphAtlas* atlas = FindAtlas( text, format, fontId, bestRank); - - DALI_ASSERT_DEBUG( atlas && "Find atlas should always return a valid atlas." ); - if( atlas ) - { - // if the atlas is full, create a new larger one - if( bestRank.GetSpaceStatus() == AtlasRanking::FULL_CAN_BE_RESIZED ) - { - atlas = CreateLargerAtlas( atlas ); - } - - // assign the text to it - return atlas->AssignText( text, format, fontId, metrics ); - } - else - { - return NULL; - } -} - -void GlyphAtlasManager::TextNotRequired( const Integration::TextArray& text, - const TextFormat& format, - FontId fontId, - unsigned int textureId ) -{ - GlyphAtlas& atlas = GetAtlas( textureId ); - - atlas.TextNoLongerUsed( text, format, fontId ); -} - - -bool GlyphAtlasManager::IsTextLoaded( const Integration::TextArray& text, - const TextFormat& format, - FontId fontId, - unsigned int textureId ) const -{ - - GlyphAtlas& atlas = GetAtlas( textureId ); - - return atlas.IsTextLoaded( text, format, fontId ); -} - -void GlyphAtlasManager::AddTextObserver( TextObserver& observer) -{ - mGlyphResourceManager.AddTextObserver( observer ); -} - -void GlyphAtlasManager::RemoveTextObserver( TextObserver& observer) -{ - mGlyphResourceManager.RemoveTextObserver( observer ); -} - -void GlyphAtlasManager::AddTextureObserver( GlyphTextureObserver& observer) -{ - DALI_ASSERT_DEBUG( std::find(mTextureObservers.Begin(), mTextureObservers.End(), &observer) == mTextureObservers.End() && "Observer already exists" ); - mTextureObservers.PushBack(&observer); -} - -void GlyphAtlasManager::RemoveTextureObserver( GlyphTextureObserver& observer) -{ - TextureObserverList::Iterator iter = std::find(mTextureObservers.Begin(), mTextureObservers.End(), &observer); - - DALI_ASSERT_DEBUG( iter != mTextureObservers.End() && "Observer missing" ); - mTextureObservers.Erase(iter); -} - -void GlyphAtlasManager::SendTextRequests() -{ - if( mAtlasesChanged ) - { - NotifyAtlasObservers(); - mAtlasesChanged = false; - } - - // this is called at the end of an event cycle. - // Each atlas builds up a list of text load requests - // We grab the requests here and pass them on to glyph-resource-manager - for( std::size_t i = 0, atlasCount = mAtlasList.Size() ; i < atlasCount ; ++i ) - { - GlyphAtlas& atlas( *mAtlasList[i] ); - - if( atlas.HasPendingRequests() ) - { - const GlyphRequestList& requestList( atlas.GetRequestList() ); - - mGlyphResourceManager.AddRequests( requestList, atlas, atlas.GetTextureId() ); - - atlas.ClearRequestLists(); - } - } -} - -GlyphLoadObserver& GlyphAtlasManager::GetLoadObserver() -{ - return mGlyphResourceManager; -} - -void GlyphAtlasManager::ReloadAtlases() -{ - std::vector newAtlasList; - - // Copy all atlases to a new list - for( AtlasList::Iterator it = mAtlasList.Begin(), end = mAtlasList.End() ; - it != end ; ++it ) - { - // Create a new atlas the same size as the previous atlas. - GlyphAtlas* oldAtlas = *it; - - GlyphAtlas* newAtlas = GlyphAtlas::New(oldAtlas->GetSize()); - newAtlas->CloneContents( oldAtlas ); - - // Add it to temporary list - newAtlasList.push_back(newAtlas); - - mGlyphResourceManager.RemoveObserver( *oldAtlas ); - } - // destroy old atlases - mAtlasList.Clear(); - - // Add new atlases to proper list - for( std::vector::iterator it = newAtlasList.begin(); it != newAtlasList.end(); ++it ) - { - AddAtlas( *it ); - } - - mAtlasesChanged = true; -} - -GlyphAtlas* GlyphAtlasManager::CreateAtlas( unsigned int size ) -{ - GlyphAtlas* atlas = GlyphAtlas::New( size ); - - AddAtlas( atlas ); - - return atlas; -} - -GlyphAtlas* GlyphAtlasManager::FindAtlas( const Integration::TextArray& text, - const TextFormat& format, - FontId fontId, - AtlasRanking &bestRank ) -{ - // if the text is underlined, add the underline character to the text string - Integration::TextArray searchText( text ); - if( format.IsUnderLined() ) - { - searchText.PushBack( format.GetUnderLineCharacter() ); - } - - if( mAtlasList.Count() == 0 ) - { - // make sure the initial atlas size holds the requested text. - unsigned int size = GlyphAtlasSize::GetInitialSize( searchText.Count() ); - - return CreateAtlas( size ); - } - - // go through each atlas finding the best match - GlyphAtlas* bestMatch( NULL ); - - for( std::size_t i = 0, atlasCount = mAtlasList.Size() ; i < atlasCount ; ++i ) - { - GlyphAtlas& atlas( *mAtlasList[i] ); - - AtlasRanking rank = atlas.GetRanking( searchText , fontId ); - - if( bestRank.HigherRanked( rank ) == false) - { - bestMatch = &atlas; - bestRank = rank; - } - - if( rank.AllCharactersMatched() ) - { - // break if an atlas is found which has all the glyphs loaded - break; - } - } - return bestMatch; -} - -void GlyphAtlasManager::AddAtlas( GlyphAtlas* atlas) -{ - // create a texture for the atlas. - unsigned int textureID = mGlyphResourceManager.CreateTexture( atlas->GetSize() ); - - // assign the texture id - atlas->SetTextureId( textureID ); - - mAtlasList.PushBack( atlas ); - - // resource manager will inform the atlas when glyphs are loaded or uploaded to a texture - mGlyphResourceManager.AddObserver( *atlas ); -} - -void GlyphAtlasManager::RemoveAtlas( GlyphAtlas* atlas ) -{ - for( std::size_t i = 0; i< mAtlasList.Size(); ++i ) - { - if( mAtlasList[i] == atlas) - { - // remove it from the resource manager observer list - mGlyphResourceManager.RemoveObserver( *atlas ); - - // remove the item from the list & delete it - mAtlasList.Erase( mAtlasList.Begin()+i ); - return; - } - } - DALI_ASSERT_DEBUG( 0 && "atlas not found"); -} - -GlyphAtlas& GlyphAtlasManager::GetAtlas( unsigned int textureId ) const -{ - for( std::size_t i = 0, atlasCount = mAtlasList.Size() ; i < atlasCount ; ++i ) - { - GlyphAtlas& atlas( *mAtlasList[i] ); - - if( atlas.GetTextureId() == textureId ) - { - return atlas; - } - - // check if the texture id is for an old atlas that has been replaced by this atlas - if( atlas.HasReplacedTexture( textureId ) ) - { - return atlas; - } - } - DALI_ASSERT_ALWAYS( 0 && "Atlas not found"); -} - -GlyphAtlas* GlyphAtlasManager::CreateLargerAtlas( GlyphAtlas* atlas ) -{ - if( atlas->GetSize() == GlyphAtlasSize::GetMaxSize() ) - { - // @todo implement atlas splitting - DALI_ASSERT_ALWAYS(0 && "Atlas reached max size"); - } - - // Create a new bigger atlas - unsigned int biggerSize = GlyphAtlasSize::GetNextSize( atlas->GetSize() ); - - GlyphAtlas* newAtlas = GlyphAtlas::New( biggerSize ); - - // clone the contents of the old atlas - newAtlas->CloneContents( atlas ); - - // remove the old atlas - RemoveAtlas( atlas ); - - // add the new atlas - AddAtlas( newAtlas ); - - mAtlasesChanged = true; - - return newAtlas; -} - -void GlyphAtlasManager::NotifyAtlasObservers() -{ - DALI_LOG_INFO(gTextAtlasLogFilter, Debug::General, "GlyphAtlasManager::NotifyAtlasObservers()\n"); - - for( std::size_t i = 0, atlasCount = mAtlasList.Size() ; i < atlasCount ; ++i ) - { - GlyphAtlas& atlas( *mAtlasList[i] ); - - Integration::ResourceId newTexture; - TextureIdList oldTextures; - atlas.GetNewTextureId( oldTextures, newTexture ); - - // copy this list so, the observers can remove themselves during the call back - TextureObserverList observerList( mTextureObservers ); - - TextureObserverList::Iterator iter( observerList.Begin() ); - TextureObserverList::ConstIterator endIter( observerList.End() ); - for( ; iter != endIter; ++iter ) - { - GlyphTextureObserver* observer((*iter)); - observer->TextureResized( oldTextures, newTexture ); - } - } -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/atlas/glyph-atlas-manager.h b/dali/internal/event/text/atlas/glyph-atlas-manager.h deleted file mode 100644 index 2663f92..0000000 --- a/dali/internal/event/text/atlas/glyph-atlas-manager.h +++ /dev/null @@ -1,202 +0,0 @@ -#ifndef __DALI_INTERNAL_GLYPH_ATLAS_MANAGER_H__ -#define __DALI_INTERNAL_GLYPH_ATLAS_MANAGER_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * - * Glyph atlas manager does the following: - * - Creates Atlases - * - Resizes Atlases - * - Finds the best atlas given a string of text - * - * GlyphAtlasManagerInterface provides: - * - * - Text Vertex creation from a string of text - * - Allows observers to watch for text load events - * - Allows observers to watch for texture resize events. - */ -class GlyphAtlasManager: public GlyphAtlasManagerInterface -{ -public: - - /** - * constructor - * @param[in] fontLookup font lookup interface - */ - GlyphAtlasManager( const FontLookupInterface& fontLookup ); - - /** - * destructor - */ - virtual ~GlyphAtlasManager(); - - -public: // for GlyphAtlasManagerInterface - - /** - * @copydoc GlyphAtlasManagerInterface::TextRequired() - */ - virtual TextVertexBuffer* TextRequired( const Integration::TextArray& text, - const TextFormat& format, - FontMetricsInterface& metrics ); - - /** - * @copydoc GlyphAtlasManagerInterface::TextNotRequired() - */ - virtual void TextNotRequired( const Integration::TextArray& text, - const TextFormat& format, - FontId font, - unsigned int textureId ); - - /** - * @copydoc GlyphAtlasManagerInterface::IsTextLoaded() - */ - virtual bool IsTextLoaded( const Integration::TextArray& text, - const TextFormat& format, - FontId fontId, - unsigned int textureId) const; - - /** - * @copydoc GlyphAtlasManagerInterface::AddTextObserver() - */ - virtual void AddTextObserver( TextObserver& observer ); - - /** - * @copydoc GlyphAtlasManagerInterface::RemoveTextObserver() - */ - virtual void RemoveTextObserver( TextObserver& observer ); - - /** - * @copydoc GlyphAtlasManagerInterface::AddObserver() - */ - virtual void AddTextureObserver( GlyphTextureObserver& observer); - - /** - * @copydoc GlyphAtlasManagerInterface::RemoveObserver() - */ - virtual void RemoveTextureObserver( GlyphTextureObserver& observer); - -public: - - /** - * Send any pending glyph load requests held in each atlas to the resource manager. - */ - void SendTextRequests(); - - /** - * @return glyph load observer interface - */ - GlyphLoadObserver& GetLoadObserver(); - - /** - * Reload glyphs into atlas, should be used after GL context has been regained - * (i.e. the GL texture backing the atlas has been lost) - */ - void ReloadAtlases(); - -private: - - // Undefined copy constructor. - GlyphAtlasManager( const GlyphAtlasManager& ); - - // Undefined assignment operator. - GlyphAtlasManager& operator=( const GlyphAtlasManager& ); - - /** - * Creates a new atlas - * @param[in] size the atlas size in pixels (size = width = height) - * @return atlas - */ - GlyphAtlas* CreateAtlas( unsigned int size ); - - /** - * Find the most suitable atlas for a string of text - * @param[in] text text array - * @param[in] format text format - * @param[in] font id - * @param[in,out] the ranking for the atlas that is found - * @return atlas - */ - GlyphAtlas* FindAtlas( const Integration::TextArray& text , - const TextFormat& format, - FontId fontId, - AtlasRanking& bestRank); - - /** - * Add an atlas - * @param[in] atlas to add - */ - void AddAtlas( GlyphAtlas* atlas); - - /** - * Remove an atlas - * @param[in] atlas the atlas to remove - */ - void RemoveAtlas( GlyphAtlas* atlas ); - - /** - * Get an atlas given a texture id - * @param[in] textureId - * @return atlas - */ - GlyphAtlas& GetAtlas( unsigned int textureId ) const; - - /** - * Takes an atlas and returns a bigger version. - * The old atlas is deleted. - * @param atlas the atlas to make bigger - * @returns a bigger atlas - */ - GlyphAtlas* CreateLargerAtlas( GlyphAtlas* atlas ); - - /** - * Notify atlas observers that the texture has changed. Note, this no longer means - * that the glyphs are present. - */ - void NotifyAtlasObservers(); - - - typedef OwnerContainer< GlyphAtlas* > AtlasList; ///< atlas list typedef - typedef Dali::Vector< GlyphTextureObserver* > TextureObserverList; ///< list of observers that get informed when an atlas is resized / split - - AtlasList mAtlasList; ///< List of atlases - GlyphResourceManager mGlyphResourceManager; ///< glyph resource manager - TextureObserverList mTextureObservers; ///< unique set of observers that watch texture resize / split changes - bool mAtlasesChanged; ///< Set to true if any atlas is resized, used to notify observers at end of event cycle -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_GLYPH_ATLAS_MANAGER_H__ diff --git a/dali/internal/event/text/atlas/glyph-atlas.cpp b/dali/internal/event/text/atlas/glyph-atlas.cpp deleted file mode 100644 index cf00962..0000000 --- a/dali/internal/event/text/atlas/glyph-atlas.cpp +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -GlyphAtlas* GlyphAtlas::New( unsigned int size ) -{ - return new GlyphAtlas( size ) ; -} - -GlyphAtlas::~GlyphAtlas() -{ -} - -TextVertexBuffer* GlyphAtlas::AssignText( const Integration::TextArray& text, - const TextFormat &format, - FontId fontId, - FontMetricsInterface& metrics ) -{ - // go through each character increasing it's reference count - // if it doesn't exist, then it will be marked to be loaded at the end of the event cycle - ReferenceText( text, format, fontId ); - - // generate the vertex information - TextVertexBuffer* textBuffer = TextVertexGenerator::Generate( text, format, metrics, mAtlas, fontId ); - - // assign the texture id - textBuffer->mTextureId = mTextureId; - - return textBuffer; -} - -void GlyphAtlas::TextNoLongerUsed( const Integration::TextArray& text, const TextFormat &format, FontId fontId ) -{ - // go through each character un-referencing it - for( Integration::TextArray::ConstIterator it = text.Begin(), endIt = text.End(); it != endIt; ++it ) - { - mGlyphContainer.DecreaseRefCount( *it, fontId ); - } - - if( format.IsUnderLined() ) - { - mGlyphContainer.DecreaseRefCount( format.GetUnderLineCharacter(), fontId ); - } -} - -AtlasRanking GlyphAtlas::GetRanking( const Integration::TextArray& text , FontId fontId ) const -{ - return GetAtlasRanking( text, fontId, mGlyphContainer, Resizable() ); -} - -unsigned int GlyphAtlas::GetSize() const -{ - return mAtlas.GetSize(); -} - -void GlyphAtlas::SetTextureId( unsigned int textureId ) -{ - mTextureId = textureId; -} - -bool GlyphAtlas::HasPendingRequests() const -{ - return (!mRequestList.empty()); -} - -const GlyphRequestList& GlyphAtlas::GetRequestList() const -{ - return mRequestList; -} - -void GlyphAtlas::ClearRequestLists() -{ - mRequestList.clear(); -} - -bool GlyphAtlas::IsTextLoaded( const Integration::TextArray& text, const TextFormat &format, FontId fontId) const -{ - // check the underline character is needed / loaded first - if( format.IsUnderLined() ) - { - Integration::TextArray tempText; - tempText.PushBack( format.GetUnderLineCharacter() ); - bool loaded = mGlyphContainer.IsTextLoaded( tempText, fontId ); - - if( !loaded ) - { - return false; - } - } - // check the text is loaded - return mGlyphContainer.IsTextLoaded( text, fontId ); -} - -void GlyphAtlas::CloneContents( GlyphAtlas* oldAtlas) -{ - // ensure this atlas is empty - DALI_ASSERT_DEBUG( mGlyphContainer.Empty() ); - - // Clear out any dead characters which have a ref count of zero from the old atlas - // we don't want to re-request these, as they may not be used again - oldAtlas->ClearDeadCharacters(); - - // clone the atlas - mAtlas.CloneContents( &oldAtlas->mAtlas ); - - // clone the glyph container - mGlyphContainer.CloneContents( oldAtlas->mGlyphContainer ); - - // if we get more than one atlas resize event per event cycle we need to store - // a list of the atlas texture id's that have been resized. - mTextureIdOfReplacedAtlases = oldAtlas->GetTextureIdOfReplacedAtlas(); - mTextureIdOfReplacedAtlases.push_back( oldAtlas->GetTextureId() ); - - // clear the old atlas - oldAtlas->Clear(); - - // do a load request for all characters - - GlyphStatusContainer::StatusSet::iterator endIter = mGlyphContainer.GetStatusSet().end(); - for( GlyphStatusContainer::StatusSet::iterator iter = mGlyphContainer.GetStatusSet().begin(); iter != endIter; ++iter) - { - const GlyphStatus& status = (*iter); - uint32_t charCode = status.GetCharacterCode(); - FontId fontId = status.GetFontId(); - unsigned int xPos=0, yPos=0; - GetGlyphTexturePosition( charCode, fontId, xPos, yPos ); - - RequestToLoadCharacter( charCode, xPos, yPos, fontId, GlyphResourceRequest::LOW_QUALITY ); - status.SetLoadStatus( GlyphStatus::GLYPH_LOAD_REQUESTED ); - } - -} - -void GlyphAtlas::ClearDeadCharacters() -{ - // Dead characters are characters which are in the GL Texture - // but have a reference count of zero. - // go through each dead character, marking them as de-allocated in the atlas - - Integration::TextArray deadCharacters; - mGlyphContainer.GetDeadCharacters( deadCharacters ); - - for( Integration::TextArray::ConstIterator it = deadCharacters.Begin(), endIt = deadCharacters.End(); it != endIt; ++it ) - { - mAtlas.Remove( *it ); - } - - // clear the dead characters from the glyph container - mGlyphContainer.ClearDeadCharacters(); -} - -void GlyphAtlas::Clear() -{ - mGlyphContainer.ClearContents(); -} - -bool GlyphAtlas::HasReplacedTexture( unsigned int textureId ) -{ - for( std::size_t i = 0, count = mTextureIdOfReplacedAtlases.size(); i < count; ++i ) - { - if( mTextureIdOfReplacedAtlases[i] == textureId ) - { - return true; - } - } - return false; -} - -void GlyphAtlas::GlyphUpLoadedToTexture( uint32_t charCode, FontId fontId ) -{ - const GlyphStatus* status = mGlyphContainer.FindGlyphStatus( charCode, fontId ); - if( !status ) - { - // the character is no longer used - return; - } - status->SetTextureStatus( GlyphStatus::GLYPH_UPLOADED_TO_TEXTURE ); -} - -void GlyphAtlas::GlyphLoadedFromFile( uint32_t charCode, FontId fontId, Quality loadStatus ) -{ - unsigned int xPos, yPos; - - // Get texture position - bool inUse = GetGlyphTexturePosition( charCode, fontId, xPos, yPos ); - - // check the glyph is still used. - // it is possible in between a load request, and load complete that character is no longer required. - const GlyphStatus* status = mGlyphContainer.FindGlyphStatus( charCode, fontId ); - if( !status || !inUse ) - { - // the character is no longer used - return; - } - - DALI_ASSERT_DEBUG( status->IsLoadRequested() ); - - if( loadStatus == HIGH_QUALITY_LOADED ) - { - status->SetLoadStatus( GlyphStatus::GLYPH_HIGH_QUALITY_LOADED ); - } - else - { - // low quality loaded, high quality in progress - status->SetLoadStatus( GlyphStatus::GLYPH_LOW_QUALITY_LOADED_HIGH_REQUESTED ); - } -} - -bool GlyphAtlas::GetGlyphTexturePosition( uint32_t charCode, FontId fontId, unsigned int &xPos, unsigned int &yPos) const -{ - // check if the character is still in use - const GlyphStatus* status = mGlyphContainer.FindGlyphStatus( charCode, fontId ); - if( status == NULL ) - { - return false; - } - // atlas stores a unique id which is a combination of character charCode and font id. - unsigned int uniqueId = GlyphStatus::GetEncodedValue( charCode, fontId ); - - mAtlas.GetXYPosition( uniqueId, xPos, yPos); - - return true; -} - -unsigned int GlyphAtlas::GetTextureId() const -{ - return mTextureId; -} - -GlyphResourceObserver::TextureState GlyphAtlas::GetTextureState() -{ - if( mTextureIdOfReplacedAtlases.empty() ) - { - return GlyphResourceObserver::NO_CHANGE; - } - else - { - return GlyphResourceObserver::TEXTURE_RESIZED; - } -} - -void GlyphAtlas::GetNewTextureId( std::vector& oldTextureIds , unsigned int& newTextureId ) -{ - oldTextureIds = mTextureIdOfReplacedAtlases; - newTextureId = mTextureId; - - mTextureIdOfReplacedAtlases.clear(); -} - -void GlyphAtlas::ReferenceText( const Integration::TextArray& text, - const TextFormat &format, - FontId fontId) -{ - - // go through each character, if it exists increase it's ref count. - for( Integration::TextArray::ConstIterator it = text.Begin(), endIt = text.End(); it != endIt; ++it ) - { - // this will automatically load the character if it doesn't exist - IncreaseGlyphRefCount( *it, fontId ); - } - - if( format.IsUnderLined() ) - { - IncreaseGlyphRefCount( format.GetUnderLineCharacter(), fontId ); - } -} - -void GlyphAtlas::IncreaseGlyphRefCount( uint32_t charCode, FontId fontId) -{ - if( charCode < SpecialCharacters::FIRST_VISIBLE_CHAR ) - { - return; - } - - const GlyphStatus* status = mGlyphContainer.FindGlyphStatus( charCode, fontId ); - if( status == NULL ) - { - // insert the character in to the glyph container / atlas - InsertNewCharacter( charCode , fontId ); - - unsigned int xPos=0, yPos=0; - GetGlyphTexturePosition( charCode, fontId, xPos, yPos ); - - // queue a request for a low quality version of the character - // if the distance field is cached for this character then a high - // quality version will be returned - RequestToLoadCharacter( charCode, xPos, yPos, fontId, GlyphResourceRequest::LOW_QUALITY ); - } - else - { - // character is already in-use, so increase its reference count - mGlyphContainer.IncreaseRefCount( charCode, fontId ); - } -} - -void GlyphAtlas::InsertNewCharacter( uint32_t charCode , FontId fontId ) -{ - // The AtlasManager will never allow more characters to fit in the - // atlas than is available. - // - // However in order to fit new characters in the Atlas, - // 'dead' characters with a ref-count of zero may need replacing. - - // atlas stores a unique id which is a combination of character code and font id. - unsigned int uniqueId = GlyphStatus::GetEncodedValue( charCode, fontId ); - unsigned int deadUniqueId(0); - - // insert the character into the container and see if it's replacing a dead character - GlyphStatusContainer::InsertResult insertResult; - - insertResult = mGlyphContainer.InsertNewCharacter( charCode, fontId, deadUniqueId ); - - if( insertResult == GlyphStatusContainer::INSERTED_OK ) - { - // insert in to the layout atlas - mAtlas.Insert( uniqueId ); - } - else // insertResult == REPLACE_DEAD_CHARACTER - { - // remove the dead character from the atlas - mAtlas.Remove( deadUniqueId ); - - // insert the new character into the atlas - mAtlas.Insert( uniqueId ); - } -} - -void GlyphAtlas::RequestToLoadCharacter(uint32_t charCode, unsigned int xPos, unsigned int yPos, FontId fontId, GlyphResourceRequest::GlyphQuality quality ) -{ - // find the request list with matching font id - // if it's not found it will be created - GlyphResourceRequest& resourceRequest( GetResourceRequest( fontId, quality )); - - // add the character to the request list - if it's not already present - resourceRequest.InsertCharacter( charCode, xPos, yPos ); -} - -GlyphResourceRequest& GlyphAtlas::GetResourceRequest( FontId fontId, GlyphResourceRequest::GlyphQuality quality ) -{ - // search for the resource request, using font id, and quality - - for( std::size_t i = 0, count = mRequestList.size(); i < count; ++i) - { - GlyphResourceRequest& resourceRequest( mRequestList[ i ] ); - - if( (resourceRequest.GetFontId() == fontId ) && - (resourceRequest.GetQuality() == quality ) ) - { - return resourceRequest; - } - } - // doesn't exist, so create a new one - mRequestList.push_back( GlyphResourceRequest(fontId, quality)); - - return mRequestList[ mRequestList.size()-1 ]; -} - -bool GlyphAtlas::Resizable() const -{ - return (GetSize() < GlyphAtlasSize::GetMaxSize() ); -} - -TextureIdList GlyphAtlas::GetTextureIdOfReplacedAtlas() -{ - return mTextureIdOfReplacedAtlases; -} - -GlyphAtlas::GlyphAtlas( unsigned int size) -:mGlyphContainer( GlyphAtlasSize::GetAtlasCharacterCount( size ) ), - mAtlas( size, GlyphAtlasSize::GetBlockSize() ), - mTextureId(0) -{ - -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/atlas/glyph-atlas.h b/dali/internal/event/text/atlas/glyph-atlas.h deleted file mode 100644 index f804d7a..0000000 --- a/dali/internal/event/text/atlas/glyph-atlas.h +++ /dev/null @@ -1,286 +0,0 @@ -#ifndef __DALI_INTERNAL_GLYPH_ATLAS_H__ -#define __DALI_INTERNAL_GLYPH_ATLAS_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -struct TextVertexBuffer; -struct TextFormat; - -/** - * - * Glyph Atlas class. - * - * Internally does the following: - * - Uses an Atlas object to manage where glyphs are allocated / positioned in the texture - * - Uses a Glyph Status Container, to reference count glyphs - * - * When text is added to the atlas, it returns a TextVertexBuffer which holds everything - * required to display the text. - * - * Provides a GlyphResourceObserver interface, so it can be notified by the glyph-resource-manager - * when glyphs are loaded from disk. - * - * It operates as follows: - * - Event Cycle Start - * -- - * -- Text Actors have text assigned to them - * -- Atlas->AssignText() is called, which returns a vertex buffer to display the text. - * -- Any text that is not loaded, is added to mRequestList - * -- - * - Event Cycle Finish - * -- mRequestList is processed by Glyph Resource Manager, and sends request to resource-loader - * - * While waiting for text to load, text-actors use the TextObserver interface, which is triggered - * whenever text is loaded. - */ -class GlyphAtlas : public GlyphResourceObserver -{ - -public: - - /** - * Create a FontAtlas - * @param[in] atlas size in pixels (e.g. 256, for a 256x256 atlas) - */ - static GlyphAtlas* New( unsigned int size ); - - /** - * Destructor - */ - virtual ~GlyphAtlas(); - - /** - * Assign text to the atlas. - * @param[in] text the text to assign to the atlas - * @param[in] format the text format - * @param[in] fontId the font id - * @param[in] metrics font metrics interface - */ - TextVertexBuffer* AssignText( const Integration::TextArray& text, const TextFormat &format, FontId fontId, FontMetricsInterface& metrics ); - - /** - * Inform the atlas that text is no longer used - * @param[in] text the text to assign to the atlas - * @param[in] format the text format - * @param[in] fontId the font id - */ - void TextNoLongerUsed( const Integration::TextArray& text, const TextFormat &format, FontId fontId ); - - /** - * Given a text string, returns an atlas ranking. - * An atlas ranking describes how suitable it is to store the text - * @param[in] text the text - * @param[in] fontId the font id - * @return atlas ranking - */ - AtlasRanking GetRanking( const Integration::TextArray& text , FontId fontId ) const; - - /** - * Get the atlas size - * @return the atlas size - */ - unsigned int GetSize() const; - - /** - * Set the texture id - * @param[in] textureId texture id (resource id) - */ - void SetTextureId( unsigned int textureId ); - - /** - * @return true if the atlas has any glyph load requests it wants passing to the resource-loader - */ - bool HasPendingRequests() const; - - /** - * Get the glyph request list. - * The request list is an array of characters/font pairs that need loading. - * @return glyph load requests - */ - const GlyphRequestList& GetRequestList() const; - - /** - * Clear the glyph request list. - */ - void ClearRequestLists(); - - /** - * Find out if all the characters in the text string are loaded - * @param[in] text the text to check for - * @param[in] format the text format - * @param[in] fontId the font id - * @return true if the text is loaded - */ - bool IsTextLoaded( const Integration::TextArray& text, const TextFormat &format, FontId fontId) const; - - /** - * Clone the contents of the atlas into this atlas - * @param clone the atlas to clone - */ - void CloneContents( GlyphAtlas* clone); - - /** - * Remove characters with a ref count of zero from the atlas - */ - void ClearDeadCharacters(); - - /** - * Clear the contents of the atlas - */ - void Clear(); - - /** - * Checks if this atlas has replaced a previous atlas with - * a certain texture id. - * @param[in] textureId texture id - * @return true if it has replaced an atlas using the texture id specified - */ - bool HasReplacedTexture( unsigned int textureId ); - -public: // for glyph resource observer - - /** - * @copydoc GlyphResourceObserver::GlyphUpLoadedToTexture() - */ - virtual void GlyphUpLoadedToTexture( uint32_t charCode, FontId fontId); - - /** - * @copydoc GlyphResourceObserver::GlyphLoadedFromFile() - */ - virtual void GlyphLoadedFromFile( uint32_t charCode, FontId fontId, Quality status ); - - /** - * @copydoc GlyphResourceObserver::GetGlyphTexturePosition() - */ - virtual bool GetGlyphTexturePosition( uint32_t charCode, FontId fontId, unsigned int &xPos, unsigned int &yPos) const; - - /** - * @copydoc GlyphResourceObserver::GetTextureId() - */ - virtual unsigned int GetTextureId() const; - - /** - * @copydoc GlyphResourceObserver::GetTextureState() - */ - virtual TextureState GetTextureState(); - - /** - * @copydoc GlyphResourceObserver::GetTextureState() - */ - virtual void GetNewTextureId( TextureIdList& oldTextureIds, unsigned int& newTextureId ); - -private: - - /** - * Increase the reference count of every character help in the text array - * @param[in] text the text to reference - * @param[in] format the text format - * @param[in] fontId font id - */ - void ReferenceText( const Integration::TextArray& text, - const TextFormat &format, - FontId fontId); - - /** - * Increase glyph reference count. - * If the character doesn't exist, then add it, and mark it to be loaded - * @param[in] charCode character code - * @param[in] fontId the font id - */ - void IncreaseGlyphRefCount( uint32_t charCode, FontId fontId); - - /** - * Insert a new character in to the atlas - * @param[in] charCode character code - * @param[in] fontId the font id - */ - void InsertNewCharacter( uint32_t charCode, FontId fontId ); - - /** - * Add a character to a resource request. - * At the end of an event cycle, glyph-atlas-manager calls GetRequestList() - * to retrieve the request list. - * @param[in] charCode character code - * @param[in] xPos The X coordinate in the texture - * @param[in] yPos The Y coordinate in the texture - * @param[in] fontId the font id - * @param[in] quality glyph - */ - void RequestToLoadCharacter(uint32_t charCode, unsigned int xPos, unsigned int yPos, FontId fontId, GlyphResourceRequest::GlyphQuality quality ); - - /** - * Get a resource request. - * Each resource request is a list of characters + font id and a quality setting. - * @param[in] fontId the font id - * @param[in] quality glyph - * @return glyph resource request object - */ - GlyphResourceRequest& GetResourceRequest( FontId fontId, GlyphResourceRequest::GlyphQuality quality ); - - /** - * @return true if the atlas is resizable - */ - bool Resizable() const; - - /** - * Get a list of texture id's of Atlases this Atlas has replaced. - * It is possible an atlas can be resized multiple times in a single event cycle. - * So atlas 5, can be replaced by atlas 6, which is then replaced by atlas 7. - * Any text-attachments using atlas 5 & 6, need to know they should use atlas 7 now. - * @return texture id list - */ - TextureIdList GetTextureIdOfReplacedAtlas(); - - /** - * Private constructor, use GlyphAtlas::New() - * @param[in] size used to define the width / height of the atlas - */ - GlyphAtlas( unsigned int size); - -private: - - GlyphRequestList mRequestList; ///< list of GlyphResourceRequest objects - GlyphStatusContainer mGlyphContainer; ///< Glyph status container - Atlas mAtlas; ///< has block allocation algorithm - unsigned int mTextureId; ///< texture id - TextureIdList mTextureIdOfReplacedAtlases; ///< list of previously replaced atlases - -}; - - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_GLYPH_ATLAS_H__ diff --git a/dali/internal/event/text/character-impl.cpp b/dali/internal/event/text/character-impl.cpp deleted file mode 100644 index 9b7df7f..0000000 --- a/dali/internal/event/text/character-impl.cpp +++ /dev/null @@ -1,517 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// HEADER CLASS -#include - -namespace -{ - -const unsigned char CHAR_WHITE_SPACE(32); ///< Unsigned characters 0-32 (' ') are white space, 33-127 are standard ASCII, 128+ are UTF-8. -const unsigned char CHAR_NEW_LINE( 0x0A ); ///< New Line character (LF) - -bool IsCharBidirectional(uint32_t i) -{ - //TODO: Cover the entire table. - /* - http://www.ietf.org/rfc/rfc3454.txt - D. Bidirectional tables - D.1 Characters with bidirectional property "R" or "AL" - D.2 Characters with bidirectional property "L" - - bidirectional characters are those characters which are neither R (D.1) or L (D.2) - */ - if( i < 0x0041 ) - { - return true; - } - if( i > 0x005a && i < 0x0061 ) - { - return true; - } - if( i > 0x007a && i < 0x00aa ) - { - return true; - } - - return false; -} - -bool IsCharLeftToRight(uint32_t i) -{ - //TODO: This method could be optimized. Performance notes: 1400us for 64k calls (80us for first if statement, 40us for each subsequent if statement) - //TODO: This table could be parsed from internet (http://www.unicode.org/Public/6.0.0/ucd/UnicodeData.txt) or a config file. - /* - http://www.ietf.org/rfc/rfc3454.txt - D. Bidirectional tables - D.1 Characters with bidirectional property "R" or "AL" - - ----- Start Table D.1 ----- - 05BE - 05C0 - 05C3 - 05D0-05EA - 05F0-05F4 - 061B - 061F - 0621-063A - 0640-064A - 066D-066F - 0671-06D5 - 06DD - 06E5-06E6 - 06FA-06FE - 0700-070D - 0710 - 0712-072C - 0780-07A5 - 07B1 - 200F - FB1D - FB1F-FB28 - FB2A-FB36 - FB38-FB3C - FB3E - FB40-FB41 - FB43-FB44 - FB46-FBB1 - FBD3-FD3D - FD50-FD8F - FD92-FDC7 - FDF0-FDFC - FE70-FE74 - FE76-FEFC - ----- End Table D.1 ----- - */ - - if( 0x05BE == i ) - { - return false; - } - if( 0x05C0 == i ) - { - return false; - } - if( 0x05C3 == i ) - { - return false; - } - if( ( 0x05D0 <= i ) && ( 0x05EA >= i ) ) - { - return false; - } - if( ( 0x05F0 <= i ) && ( 0x05F4 >= i ) ) - { - return false; - } - if( 0x061B == i ) - { - return false; - } - if( 0x061F == i ) - { - return false; - } - if( ( 0x0621 <= i ) && ( 0x063A >= i ) ) - { - return false; - } - if( ( 0x0640 <= i ) && ( 0x064A >= i ) ) - { - return false; - } - if( ( 0x066D <= i ) && ( 0x066F >= i ) ) - { - return false; - } - if( ( 0x0671 <= i ) && ( 0x06D5 >= i ) ) - { - return false; - } - if( 0x06DD == i ) - { - return false; - } - if( ( 0x06E5 <= i ) && ( 0x06E6 >= i ) ) - { - return false; - } - if( ( 0x06FA <= i ) && ( 0x06FE >= i ) ) - { - return false; - } - if( ( 0x0700 <= i ) && ( 0x070D >= i ) ) - { - return false; - } - if( 0x0710 == i ) - { - return false; - } - if( ( 0x0712 <= i ) && ( 0x072C >= i ) ) - { - return false; - } - if( ( 0x0780 <= i ) && ( 0x07A5 >= i ) ) - { - return false; - } - if( 0x07B1 == i ) - { - return false; - } - if( 0x200F == i ) - { - return false; - } - if( 0xFB1D == i ) - { - return false; - } - if( ( 0xFB1F <= i ) && ( 0xFB28 >= i ) ) - { - return false; - } - if( ( 0xFB2A <= i ) && ( 0xFB36 >= i ) ) - { - return false; - } - if( ( 0xFB38 <= i ) && ( 0xFB3C >= i ) ) - { - return false; - } - if( 0xFB3E == i ) - { - return false; - } - if( ( 0xFB40 <= i ) && ( 0xFB41 >= i ) ) - { - return false; - } - if( ( 0xFB43 <= i ) && ( 0xFB44 >= i ) ) - { - return false; - } - if( ( 0xFB46 <= i ) && ( 0xFBB1 >= i ) ) - { - return false; - } - if( ( 0xFBD3 <= i ) && ( 0xFD3D >= i ) ) - { - return false; - } - if( ( 0xFD50 <= i ) && ( 0xFD8F >= i ) ) - { - return false; - } - if( ( 0xFD92 <= i ) && ( 0xFDC7 >= i ) ) - { - return false; - } - if( ( 0xFDF0 <= i ) && ( 0xFDFC >= i ) ) - { - return false; - } - if( ( 0xFE70 <= i ) && ( 0xFE74 >= i ) ) - { - return false; - } - if( ( 0xFE76 <= i ) && ( 0xFEFC >= i ) ) - { - return false; - } - - return true; -} - -Dali::Character::Script GetCharacterScript( uint32_t character ) -{ - // Latin script: - // 0x0000 - 0x007f C0 Controls and Basic Latin - // 0x0080 - 0x00ff C1 Controls and Latin-1 Supplement - // 0x0100 - 0x017f Latin Extended-A - // 0x0180 - 0x024f Latin Extended-B - // 0x0250 - 0x02af IPA Extensions - // 0x02b0 - 0x02ff Spacing Modifier Letters - // 0x1d00 - 0x1d7f Phonetic Extensions - // 0x1d80 - 0x1dbf Phonetic Extensions Supplement - // 0x1e00 - 0x1eff Latin Extended Additional - // 0x2070 - 0x209f Superscripts and Subscripts - // 0x2100 - 0x214f Letterlike symbols - // 0x2150 - 0x218f Number Forms - // 0x2c60 - 0x2c7f Latin Extended-C - // 0xa720 - 0xa7ff Latin Extended-D - // 0xab30 - 0xab6f Latin Extended-E - // 0xfb00 - 0xfb4f Alphabetic Presentation Forms - // 0xff00 - 0xffef Halfwidth and Fullwidth Forms - - // Brahmic scripts: - // 0x0900 - 0x097f Devanagari - // 0x0980 - 0x09ff Bengali - // 0x0a00 - 0x0a7f Gurmukhi - // 0x0a80 - 0x0aff Gujarati - // 0x0b00 - 0x0b7f Oriya - // 0x0b80 - 0x0bff Tamil - // 0x0c00 - 0x0c7f Telugu - // 0x0c80 - 0x0cff Kannada - // 0x0d00 - 0x0d7f Malayalam - - // Sinhala script. - // 0x0d80 - 0x0dff Sinhala - - // Arabic script. - // 0x0600 - 0x06ff - // 0x0750 - 0x077f - // 0x08A0 - 0x08ff - // 0xfb50 - 0xfdff - // 0xfe70 - 0xfeff - // 0x1ee00 - 0x1eeff - - - if( character <= 0x0cff ) - { - if( character <= 0x09ff ) - { - if( character <= 0x077f ) - { - if( character <= 0x02ff ) - { - return Dali::Character::LATIN; - } - if( ( 0x0600 <= character ) && ( character <= 0x06ff ) ) - { - return Dali::Character::ARABIC; - } - if( ( 0x0750 <= character ) && ( character <= 0x077f ) ) - { - return Dali::Character::ARABIC; - } - } - else - { - if( ( 0x08A0 <= character ) && ( character <= 0x08ff ) ) - { - return Dali::Character::ARABIC; - } - if( ( 0x0900 <= character ) && ( character <= 0x097f ) ) - { - return Dali::Character::DEVANAGARI; - } - if( ( 0x0980 <= character ) && ( character <= 0x09ff ) ) - { - return Dali::Character::BENGALI; - } - } - } - else - { - if( character <= 0x0b7f ) - { - if( ( 0x0a00 <= character ) && ( character <= 0x0a7f ) ) - { - return Dali::Character::GURMUKHI; - } - if( ( 0x0a80 <= character ) && ( character <= 0x0aff ) ) - { - return Dali::Character::GUJARATI; - } - if( ( 0x0b00 <= character ) && ( character <= 0x0b7f ) ) - { - return Dali::Character::ORIYA; - } - } - else - { - if( ( 0x0b80 <= character ) && ( character <= 0x0bff ) ) - { - return Dali::Character::TAMIL; - } - if( ( 0x0c00 <= character ) && ( character <= 0x0c7f ) ) - { - return Dali::Character::TELUGU; - } - if( ( 0x0c80 <= character ) && ( character <= 0x0cff ) ) - { - return Dali::Character::KANNADA; - } - } - } - } - else - { - if( character <= 0x2c7f ) - { - if( character <= 0x1eff ) - { - if( ( 0x0d00 <= character ) && ( character <= 0x0d7f ) ) - { - return Dali::Character::MALAYALAM; - } - if( ( 0x0d80 <= character ) && ( character <= 0x0dff ) ) - { - return Dali::Character::SINHALA; - } - if( ( 0x1d00 <= character ) && ( character <= 0x1eff ) ) - { - return Dali::Character::LATIN; - } - } - else - { - if( ( 0x2070 <= character ) && ( character <= 0x209f ) ) - { - return Dali::Character::LATIN; - } - if( ( 0x2100 <= character ) && ( character <= 0x218f ) ) - { - return Dali::Character::LATIN; - } - if( ( 0x2c60 <= character ) && ( character <= 0x2c7f ) ) - { - return Dali::Character::LATIN; - } - } - } - else - { - if( character <= 0xfdff ) - { - if( ( 0xa720 <= character ) && ( character <= 0xa7ff ) ) - { - return Dali::Character::LATIN; - } - if( ( 0xab30 <= character ) && ( character <= 0xab6f ) ) - { - return Dali::Character::LATIN; - } - if( ( 0xfb00 <= character ) && ( character <= 0xfb4f ) ) - { - return Dali::Character::LATIN; - } - if( ( 0xfb50 <= character ) && ( character <= 0xfdff ) ) - { - return Dali::Character::ARABIC; - } - } - else - { - if( ( 0xfe70 <= character ) && ( character <= 0xfeff ) ) - { - return Dali::Character::ARABIC; - } - if( ( 0xff00 <= character ) && ( character <= 0xffef ) ) - { - return Dali::Character::LATIN; - } - if( ( 0x1ee00 <= character ) && ( character <= 0x1eeff ) ) - { - return Dali::Character::ARABIC; - } - } - } - } - - return Dali::Character::UNKNOWN; -} - -} // unnamed namespace - -namespace Dali -{ - -namespace Internal -{ - -Character::Character( uint32_t character ) -: mCharacter( character ) -{ -} - -Character::~Character() -{ -} - -Character::CharacterDirection Character::GetCharacterDirection(uint32_t character) -{ - //TODO: This method could be optimized, and should cover all 5 types of characters. - if( IsCharBidirectional(character) ) - { - return Dali::Character::Neutral; - } - - if( IsCharLeftToRight(character) ) - { - return Dali::Character::LeftToRight; - } - - return Dali::Character::RightToLeft; -} - -Character::CharacterDirection Character::GetCharacterDirection() const -{ - return GetCharacterDirection( mCharacter ); -} - -Dali::Character::Script Character::GetScript( uint32_t character ) -{ - return GetCharacterScript( character ); -} - -Dali::Character::Script Character::GetScript() const -{ - return GetCharacterScript( mCharacter ); -} - -bool Character::IsLeftToRight() const -{ - return GetCharacterDirection() != Dali::Character::RightToLeft; -} - -bool Character::IsWhiteSpace() const -{ - return Character::IsWhiteSpace( mCharacter ); -} - -bool Character::IsNewLine() const -{ - return Character::IsNewLine( mCharacter ); -} - -uint32_t Character::GetCharacter() const -{ - return mCharacter; -} - -void Character::SetCharacter( uint32_t character ) -{ - mCharacter = character; -} - -bool Character::IsWhiteSpace( uint32_t character ) -{ - // TODO: It should cover unicode characters: http://en.wikipedia.org/wiki/Whitespace_character - return character <= CHAR_WHITE_SPACE; -} - -bool Character::IsNewLine( uint32_t character ) -{ - return character == CHAR_NEW_LINE; -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/character-impl.h b/dali/internal/event/text/character-impl.h deleted file mode 100644 index 5fb2478..0000000 --- a/dali/internal/event/text/character-impl.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef __DALI_INTERNAL_CHARACTER_H__ -#define __DALI_INTERNAL_CHARACTER_H__ - -/* - * Copyright (c) 2014 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 - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * Implementation class for Dali::Character. - * @see Dali::Character. - */ -class Character -{ -public: - - typedef Dali::Character::CharacterDirection CharacterDirection; - -public: - - /** - * Constructor. - * Creates a Character with the given UTF-32 encoded character. - * @param character A UTF-32 encoded character. - */ - Character( uint32_t character ); - - /** - * Non virtual destructor. - */ - ~Character(); - - /** - * Returns character direction - * @param[in] character The unicode character to determine direction of. - * @return The character's direction is returned. - */ - static CharacterDirection GetCharacterDirection(uint32_t character); - - /** - * @copydoc Dali::Character::GetCharacterDirection() - */ - CharacterDirection GetCharacterDirection() const; - - /** - * Returns the character's script. - * - * @param[in] character The unicode value of the character. - * - * @return The script of the character. - */ - static Dali::Character::Script GetScript( uint32_t character ); - - /** - * @copydoc Dali::Character::GetScript() - */ - Dali::Character::Script GetScript() const; - - /** - * @copydoc Dali::Character::IsLeftToRight() - */ - bool IsLeftToRight() const; - - /** - * @copydoc Dali::Character::IsWhiteSpace() - */ - bool IsWhiteSpace() const; - - /** - * @copydoc Dali::Character::IsNewLine() - */ - bool IsNewLine() const; - - /** - * Retrieves the encapsulated UTF-32 encoded character. - * @return A UTF-32 encoded character. - */ - uint32_t GetCharacter() const; - - /** - * Sets a encapsulated UTF-32 encoded character. - * @param character A UTF-32 encoded character. - */ - void SetCharacter( uint32_t character ); - - /** - * Whether the given character is a white space. - * - * @param[in] character The character. - * - * @return \e true the given character is a white space. - */ - static bool IsWhiteSpace( uint32_t character ); - - /** - * Whether the given character is a new line character. - * - * @param[in] character The character. - * - * @return \e true the given character is a new line character. - */ - static bool IsNewLine( uint32_t character ); - -private: - - // Undefined constructor. - Character(); - - // Undefined copy constructor. - Character( const Character& character ); - - // Undefined assignment operator - Character& operator=( const Character& character ); - - private: //data - - uint32_t mCharacter; ///< Stores the unicode of the character. -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_CHARACTER_H__ diff --git a/dali/internal/event/text/font-declarations.h b/dali/internal/event/text/font-declarations.h deleted file mode 100644 index bd21860..0000000 --- a/dali/internal/event/text/font-declarations.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __DALI_INTERNAL_FONT_DECLARATIONS_H__ -#define __DALI_INTERNAL_FONT_DECLARATIONS_H__ - -/* - * Copyright (c) 2014 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. - * - */ - -namespace Dali -{ - -namespace Internal -{ - -class Font; -typedef IntrusivePtr FontPointer; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_FONT_DECLARATIONS_H__ - diff --git a/dali/internal/event/text/font-factory.cpp b/dali/internal/event/text/font-factory.cpp deleted file mode 100644 index 3062a3c..0000000 --- a/dali/internal/event/text/font-factory.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL HEADERS -#include -#include -#include -#include -#include - - -using namespace Dali::Integration; - -namespace Dali -{ - -namespace Internal -{ - -FontFactory::FontFactory(ResourceClient& resourceClient) -: mResourceClient(resourceClient), - mFontCount( 0 ), - mHorizontalDpi( 0.f ), - mVerticalDpi( 0.f ) -{ - mAtlasManager = new GlyphAtlasManager( *this ); - - mResourceClient.SetGlyphLoadObserver( &mAtlasManager->GetLoadObserver() ); -} - -FontFactory::~FontFactory() -{ - mResourceClient.SetGlyphLoadObserver( NULL ); - - delete mAtlasManager; -} - -FontMetricsIntrusivePtr FontFactory::GetFontMetrics( const std::string& fontFamily, const std::string& fontStyle ) -{ - - std::size_t hashValue = CalculateHash(fontFamily,fontStyle); - FontMetricsIntrusivePtr metrics; - - FontMetricsIter iter = mMetricsCache.find( hashValue ); - if ( iter == mMetricsCache.end() ) - { - metrics = FontMetrics::New( Vector2(mHorizontalDpi, mVerticalDpi), hashValue, mFontCount, fontFamily, fontStyle ); - mFontCount++; - - // load the global metrics - metrics->LoadGlobalMetrics(); - - // insert into a lookup table. - mMetricsCache.insert( FontMetricsPair( hashValue, metrics ) ); - - } - else - { - metrics = iter->second; - } - // increase the number of fonts using this metrics - metrics->IncreaseFontCount(); - - return metrics; -} - -void FontFactory::RemoveFontMetrics(const std::string& fontFamily, - const std::string& fontStyle) -{ - std::size_t hashValue = CalculateHash(fontFamily, fontStyle); - FontMetricsIntrusivePtr metrics; - - FontMetricsIter iter = mMetricsCache.find( hashValue ); - if ( iter != mMetricsCache.end() ) - { - (*iter).second->DecreaseFontCount(); - } - // for now we keep metrics in memory even if ref count = 0 - // @todo implement a scheme to delete metrics that haven't been used for - // a certain amount of time -} - - -void FontFactory::GetFontInformation( FontId fontId, - std::string& family, - std::string& style, - float& maxGlyphWidth, - float& maxGlyphHeight) const -{ - // typically we only have around 4 fonts in the cache, - // and GetFontInformation is only called a couple of times on startup - // so just iterate over the map, manually searching for the font id - FontMetricsMap::const_iterator endIter = mMetricsCache.end(); - - for( FontMetricsMap::const_iterator iter = mMetricsCache.begin(); iter != endIter; ++iter) - { - const FontMetrics* metric( (*iter).second.Get() ); - - if( metric->GetFontId() == fontId) - { - family = metric->GetFontFamilyName(); - style = metric->GetFontStyleName(); - metric->GetMaximumGylphSize( maxGlyphWidth, maxGlyphHeight ); - return; - } - } - DALI_ASSERT_ALWAYS( 0 && "Font id not found"); -} - -void FontFactory::SendTextRequests() -{ - mAtlasManager->SendTextRequests(); -} - -GlyphAtlasManagerInterface& FontFactory::GetAtlasManagerInterface() -{ - return *mAtlasManager; -} - -void FontFactory::SetDpi( float horizontalDpi, float verticalDpi ) -{ - mHorizontalDpi = horizontalDpi; - mVerticalDpi = verticalDpi; -} - -void FontFactory::RecoverFromContextLoss() -{ - mAtlasManager->ReloadAtlases(); -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/font-factory.h b/dali/internal/event/text/font-factory.h deleted file mode 100644 index cdd530f..0000000 --- a/dali/internal/event/text/font-factory.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef __DALI_INTERNAL_FONT_FACTORY_H__ -#define __DALI_INTERNAL_FONT_FACTORY_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -class ResourceClient; -class GlyphAtlasManager; - -/** - * FontFactory is used to do the following: - * - create FontMetric objects - * - Allocate Atlas Manager - * - provide a FontLookupInterface - * - * @todo class needs renaming, possibly splitting as it's - * doing more than one thing. - */ -class FontFactory : public FontLookupInterface -{ -public: - - /** - * default constructor - * @param resource client - */ - FontFactory( ResourceClient& resourceClient ); - - /** - * Default destructor - */ - virtual ~FontFactory(); - - /** - * Gets a pre-existing font metrics object, or creates a new one if not found. - * @param[in] fontFamily The name of the font's family used to generate a hash for fast lookup - * @param[in] fontStyle The font's style used to generate a hash for fast lookup - * @return a pointer to a ref counted object - */ - FontMetricsIntrusivePtr GetFontMetrics( const std::string& fontFamily, const std::string& fontStyle ); - - /** - * Removes the font metrics associated with a font, from the font factory cache. - * - * @param[in] fontFamily The name of the font's family used to generate a hash for fast lookup - * @param[in] fontStyle The font's style used to generate a hash for fast lookup - */ - void RemoveFontMetrics(const std::string& fontFamily, - const std::string& fontStyle); - - /** - * Send a single resource request for any text which is required, but is not loaded. - * Should be called at the end of each event cycle. - */ - void SendTextRequests(); - - /** - * Get the glyph atlas manager interface - * @return atlas manager interface - */ - GlyphAtlasManagerInterface& GetAtlasManagerInterface(); - - /** - * set the dpi - * @param[in] horizontalDpi horizontal dpi - * @param[in] verticalDpi vertical dpi - */ - void SetDpi( float horizontalDpi, float verticalDpi ); - - /** - * Called when context has been regained after a loss. The text subsystem will - * reload the glyphs into a new atlas and inform their observers. - */ - void RecoverFromContextLoss(); - -public: // FontLookupInterface - - /** - * @copydoc FontLookupInterface::GetFontInformation() - */ - virtual void GetFontInformation( FontId fontId, - std::string& family, - std::string& style, - float& maxGlyphWidth, - float& maxGlyphHeight ) const; - -private: - - // Undefined - FontFactory( const FontFactory& ); - - // Undefined - FontFactory& operator=( const FontFactory& rhs ); - -private: - - GlyphAtlasManager* mAtlasManager; ///< Font atlas manager - ResourceClient& mResourceClient; ///< resource client - FontMetricsMap mMetricsCache; ///< Cache of font metrics - unsigned int mFontCount; ///< font count - float mHorizontalDpi; ///< horizontal dpi - float mVerticalDpi; ///< vertical dpi - -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_FONT_FACTORY_H__ diff --git a/dali/internal/event/text/font-impl.cpp b/dali/internal/event/text/font-impl.cpp deleted file mode 100644 index f9f9c83..0000000 --- a/dali/internal/event/text/font-impl.cpp +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL HEADERS -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using Dali::Integration::PlatformAbstraction; - -namespace Dali -{ - -namespace Internal -{ - -namespace // unnamed namespace -{ -#if defined(DEBUG_ENABLED) -Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_FONT"); -#endif - -const float INCH_TO_POINTS( 72.f ); -const float POINT_TO_INCHES( 1.f / INCH_TO_POINTS ); - -const char * const DALI_DEFAULT_FONT_CACHE_PATH( DALI_GLYPH_CACHE_DIR ); - -const float MINIMUM_TEXT_SIZE = 1.0f; // Text will not be drawn if it's less than this size in pixels - -} // unnamed namespace - -const float Font::MIN_FONT_POINT_SIZE( 4.0f ); -const float Font::MAX_FONT_POINT_SIZE( 128.0f ); - -Font* Font::New(const std::string& fontFamily, const std::string& fontStyle, float size) -{ - ThreadLocalStorage& tls = ThreadLocalStorage::Get(); - - FontFactory& fontFactory( tls.GetFontFactory() ); - - return new Font(fontFamily, - fontStyle, - size, - tls.GetPlatformAbstraction(), - tls.GetResourceClient(), - fontFactory, - fontFactory.GetAtlasManagerInterface()); - -} - -bool Font::operator==( const Font& font ) const -{ - return ( font.GetResourceId() == GetResourceId() ) && ( fabsf( font.GetPointSize() - GetPointSize() ) < Math::MACHINE_EPSILON_1000 ); -} - -const std::string Font::GetFamilyForText(const Integration::TextArray& text) -{ - Integration::PlatformAbstraction& platform = ThreadLocalStorage::Get().GetPlatformAbstraction(); - // this is a synchronous request - return platform.GetFontFamilyForChars( text ); -} - -PixelSize Font::GetLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, const CapsHeight& capsHeight) -{ - std::string name,style; - bool isDefault( false ); - - Integration::PlatformAbstraction& platform = Internal::ThreadLocalStorage::Get().GetPlatformAbstraction(); - if (!platform.ValidateFontFamilyName(fontFamily, fontStyle, isDefault, name, style)) - { - DALI_LOG_INFO( gLogFilter, Debug::General, "%s: requested font <%s:%s> not found. Using <%s:%s> for measurements\n", - __PRETTY_FUNCTION__, fontFamily.c_str(), fontStyle.c_str(), name.c_str(), style.c_str()); - } - - return platform.GetFontLineHeightFromCapsHeight(name, style, capsHeight); -} - -void Font::GetInstalledFonts( Dali::Font::FontListMode mode, std::vector& fontList ) -{ - Integration::PlatformAbstraction& platform = Internal::ThreadLocalStorage::Get().GetPlatformAbstraction(); - - Integration::PlatformAbstraction::FontListMode listMode ; - switch( mode ) - { - case Dali::Font::LIST_SYSTEM_FONTS: - { - listMode = Integration::PlatformAbstraction::LIST_SYSTEM_FONTS; - break; - } - case Dali::Font::LIST_APPLICATION_FONTS: - { - listMode = Integration::PlatformAbstraction::LIST_APPLICATION_FONTS; - break; - } - case Dali::Font::LIST_ALL_FONTS: - { - listMode = Integration::PlatformAbstraction::LIST_ALL_FONTS; - break; - } - default: - { - listMode = Integration::PlatformAbstraction::LIST_ALL_FONTS; - break; - } - } - - platform.GetFontList( listMode, fontList ); -} - -bool Font::AllGlyphsSupported(const Integration::TextArray& text) const -{ - // this is a synchronous request - return mPlatform.AllGlyphsSupported(mName, mStyle, text); -} - -unsigned int Font::GetResourceId() const -{ - return mMetrics->GetFontId(); -} - -float Font::MeasureTextWidth(const Integration::TextArray& text, float textHeightPx) const -{ - Vector3 size = MeasureText(text); - - if( ( size.x < MINIMUM_TEXT_SIZE ) || ( size.y < MINIMUM_TEXT_SIZE ) || ( textHeightPx < MINIMUM_TEXT_SIZE ) ) - { - return 0.0f; - } - - float scale = textHeightPx / size.y; - float width = size.x * scale; - - return width; -} - -float Font::MeasureTextHeight(const Integration::TextArray& text, float textWidthPx) const -{ - Vector3 size = MeasureText(text); - - if (size.x < MINIMUM_TEXT_SIZE || size.y < MINIMUM_TEXT_SIZE || textWidthPx < MINIMUM_TEXT_SIZE) - { - return 0.0f; - } - - float scale = textWidthPx / size.x; - float height = size.y * scale; - - return height; -} - -Vector3 Font::MeasureText(const Integration::TextArray& text) const -{ - if (mMetrics) - { - return mMetrics->MeasureText(text ) * GetUnitsToPixels(); - } - else - { - DALI_LOG_WARNING("Font not initialized!\n"); - return Vector3::ZERO; - } -} - -bool Font::IsDefaultSystemFont() const -{ - return mIsDefault; -} - -bool Font::IsDefaultSystemSize() const -{ - return mIsDefaultSize; -} - -const std::string& Font::GetName() const -{ - return mName; -} - -const std::string& Font::GetStyle() const -{ - return mStyle; -} - -float Font::GetPointSize() const -{ - return mPointSize; -} - -unsigned int Font::GetPixelSize() const -{ - return PointsToPixels( mPointSize ); -} - -float Font::GetLineHeight() const -{ - return (mMetrics) ? mMetrics->GetLineHeight() : 0.0f; -} - -float Font::GetAscender() const -{ - return (mMetrics) ? mMetrics->GetAscender() : 0.0f; -} - -float Font::GetUnderlineThickness() const -{ - // It adds the vertical pad adjust used to fit some effects like glow or shadow. - return (mMetrics) ? mMetrics->GetUnderlineThickness() + 2.f * mMetrics->GetPadAdjustY(): 0.f; -} - -float Font::GetUnderlinePosition() const -{ - // It adds the vertical pad adjust used to fit some effects like glow or shadow. - return (mMetrics) ? mMetrics->GetAscender() - mMetrics->GetUnderlinePosition() + mMetrics->GetPadAdjustY() : 0.f; -} - -float Font::GetUnitsToPixels() const -{ - return mMetrics->GetUnitsToPixels(mPointSize); -} - -void Font::GetMetrics(const Dali::Character& character, Dali::Font::Metrics::Impl& metricsImpl) const -{ - Integration::TextArray text; - text.PushBack( character.GetImplementation().GetCharacter() ); - - mMetrics->GetMetrics( character, metricsImpl ); - - const float unitsToPixel( GetUnitsToPixels() ); - - metricsImpl.advance *= unitsToPixel; - metricsImpl.bearing *= unitsToPixel; - metricsImpl.width *= unitsToPixel; - metricsImpl.height *= unitsToPixel; -} - -unsigned int Font::PointsToPixels(float pointSize) -{ - const Vector2& dpi = Dali::Stage::GetCurrent().GetDpi(); - const float meanDpi = (dpi.height + dpi.width) / 2.0f; - - return static_cast((pointSize * meanDpi) * POINT_TO_INCHES + 0.5f); -} - -float Font::PixelsToPoints(int pixelSize) -{ - const Vector2& dpi = Dali::Stage::GetCurrent().GetDpi(); - const float meanDpi = (dpi.height + dpi.width) / 2.0f; - - return (pixelSize * INCH_TO_POINTS) / meanDpi; -} - -void Font::ValidateFontRequest(std::string& fontFamily, std::string& fontStyle, float& fontPointSize, bool& fontFamilyDefault, bool& fontPointSizeDefault ) -{ - Internal::ThreadLocalStorage& tls = Internal::ThreadLocalStorage::Get(); - Integration::PlatformAbstraction& platform = tls.GetPlatformAbstraction(); - - std::string requestedFamily = fontFamily; - std::string requestedStyle = fontStyle; - - fontFamilyDefault = false; - - if ( !platform.ValidateFontFamilyName( requestedFamily, requestedStyle, fontFamilyDefault, fontFamily, fontStyle ) ) - { - DALI_LOG_INFO( gLogFilter, Debug::General, "%s: requested font <%s:%s> not found. Using <%s:%s>\n", - __PRETTY_FUNCTION__, requestedFamily.c_str(), requestedStyle.c_str(), fontFamily.c_str(), fontStyle.c_str()); - } - - // check for zero size, and calculate the pixel size from point size and vice-versa - if( fontPointSize < GetRangedEpsilon( fontPointSize, 0.0f ) ) - { - fontPointSize = platform.GetDefaultFontSize(); - fontPointSizeDefault = true; - } - else - { - fontPointSizeDefault = false; - } - - if( fontPointSize < MIN_FONT_POINT_SIZE ) - { - DALI_LOG_ERROR("pointSize %.2f is less than min of %.2f\n", fontPointSize, MIN_FONT_POINT_SIZE); - fontPointSize = MIN_FONT_POINT_SIZE; - } - else if( fontPointSize > MAX_FONT_POINT_SIZE ) - { - DALI_LOG_ERROR("pointSize %.2f is greater than max of %.2f\n", fontPointSize, MAX_FONT_POINT_SIZE); - fontPointSize = MAX_FONT_POINT_SIZE; - } -} - -void Font::AddObserver(TextObserver& observer) -{ - mAtlasManager.AddTextObserver(observer); -} - -void Font::RemoveObserver(TextObserver& observer) -{ - mAtlasManager.RemoveTextObserver(observer); -} - -TextVertexBuffer* Font::TextRequired( const Integration::TextArray& text, const TextFormat& format) -{ - // make sure the metrics are loaded for the text string, along with underline character if required - if( format.IsUnderLined() ) - { - Integration::TextArray underline; - underline.PushBack( SpecialCharacters::UNDERLINE_CHARACTER ); - - mMetrics->LoadMetricsSynchronously( underline ); - } - - mMetrics->LoadMetricsSynchronously( text ); - - return mAtlasManager.TextRequired(text, format, *(mMetrics.Get())); -} - -void Font::TextNotRequired( const Integration::TextArray& text, const TextFormat& format, unsigned int mTextureId ) -{ - // let the atlas manager we no longer need the text - mAtlasManager.TextNotRequired( text, format, mMetrics->GetFontId(), mTextureId ); -}; - -void Font::AddTextureObserver(GlyphTextureObserver& observer ) -{ - mAtlasManager.AddTextureObserver( observer ); -} - -void Font::RemoveTextureObserver(GlyphTextureObserver& observer ) -{ - mAtlasManager.RemoveTextureObserver( observer ); -} - -bool Font::IsTextLoaded( const Integration::TextArray& text, const TextFormat& format, unsigned int textureId ) const -{ - return mAtlasManager.IsTextLoaded( text, format, mMetrics->GetFontId(), textureId ); -} - -Font::Font(const std::string& fontFamily, - const std::string& fontStyle, - float size, - Integration::PlatformAbstraction& platform, - ResourceClient& resourceClient, - FontFactory& fontfactory, - GlyphAtlasManagerInterface& atlasInterface) -: mIsDefault(false), - mIsDefaultSize(false), - mName(fontFamily), - mStyle(fontStyle), - mMetrics(NULL), - mPointSize(size), - mUnitsToPixels(1.0f), - mPlatform(platform), - mResourceClient(resourceClient), - mFontFactory(fontfactory), - mAtlasManager( atlasInterface ) -{ - // Validates the font name, style, and point size (determines if point size is default i.e 0.0pt) - ValidateFontRequest(mName, mStyle, mPointSize, mIsDefault, mIsDefaultSize); - - // get font metrics (cached global metrics will be available instantly) - mMetrics = mFontFactory.GetFontMetrics(mName, mStyle); -} - -Font::~Font() -{ - // Guard to allow handle destruction after Core has been destroyed - if ( Stage::IsInstalled() ) - { - mFontFactory.RemoveFontMetrics(mName,mStyle); - } -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/font-impl.h b/dali/internal/event/text/font-impl.h deleted file mode 100644 index 7645f8a..0000000 --- a/dali/internal/event/text/font-impl.h +++ /dev/null @@ -1,320 +0,0 @@ -#ifndef __DALI_INTERNAL_FONT_H__ -#define __DALI_INTERNAL_FONT_H__ - -/* - * Copyright (c) 2014 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 - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace Integration -{ -class PlatformAbstraction; -} - -namespace Internal -{ - -// Forward declarations. - -struct TextFormat; -class ResourceClient; -class FontFactory; - -/** - * Responsible for loading and rendering fonts using the Freetype library. - */ -class Font : public BaseObject -{ -public: - static const float MIN_FONT_POINT_SIZE; ///< Minimum font point size supported. - static const float MAX_FONT_POINT_SIZE; ///< Maximum font point size supported. - - /** - * Create a new font object using a font name and size - * @param [in] fontFamily The family's name of the font requested - * @param [in] fontStyle The style of the font requested - * @param [in] size size of the font in points. - * @return A newly allocated Font - */ - static Font* New(const std::string& fontFamily, const std::string& fontStyle, float size); - - /** - * Equality operator. - * - * Two fonts are considered equal if they are created with the same family, style and size. - * - * @param[in] font The font to be compared. - * - * @return \e true if the given font is equal to current one, otherwise it returns \e false. - */ - bool operator==( const Font& font ) const; - - /** - * @copydoc Dali::Font::GetFamilyForText() - */ - static const std::string GetFamilyForText(const Integration::TextArray& text); - - /** - * @copydoc Dali::Font::GetLineHeightFromCapsHeight() - */ - static PixelSize GetLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, const CapsHeight& capsHeight); - - /** - * @copydoc Dali::Font::GetInstalledFonts() - */ - static void GetInstalledFonts( Dali::Font::FontListMode mode, std::vector& fontList ); - - /** - * @copydoc Dali::Font::AllGlyphsSupported() - */ - bool AllGlyphsSupported(const Integration::TextArray& text) const; - - /** - * returns the Id used for lookups - * @return the unique ID of the font. This is actually also the same as FontMetrics and FontAtlas Id. - */ - unsigned int GetResourceId() const; - - /** - * @copydoc Dali::Font::MeasureTextWidth() - */ - float MeasureTextWidth(const Integration::TextArray& text, float textHeightPx) const; - - /** - * @copydoc Dali::Font::MeasureTextHeight() - */ - float MeasureTextHeight(const Integration::TextArray& text, float textWidthPx) const; - - /** - * @copydoc Dali::Font::MeasureText(const Text& text) const - */ - Vector3 MeasureText(const Integration::TextArray& text) const; - - /** - * @copydoc Dali::Font::IsDefaultSystemFont() - */ - bool IsDefaultSystemFont() const; - - /** - * @copydoc Dali::Font::IsDefaultSystemSize() - */ - bool IsDefaultSystemSize() const; - - /** - * @copydoc Dali::Font::GetName() - */ - const std::string& GetName() const; - - /** - * @copydoc Dali::Font::GetStyle() - */ - const std::string& GetStyle() const; - - /** - * @copydoc Dali::Font::GetPointSize() - */ - float GetPointSize() const; - - /** - * @copydoc Dali::Font::GetPixelSize() - */ - unsigned int GetPixelSize() const; - - /** - * The line height is the vertical distance between the top of the highest character - * to the bottom of the lowest character - * @return the line height of the font in pixels - */ - float GetLineHeight() const; - - /** - * The ascender is the vertical distance from the - * baseline to the highest character coordinate in a font face. - * @return the ascender in pixels - */ - float GetAscender() const; - - /** - * @copydoc Dali::Font::GetUnderlineThickness() - */ - float GetUnderlineThickness() const; - - /** - * @copydoc Dali::Font::GetUnderlinePosition() - */ - float GetUnderlinePosition() const; - - /** - * Returns the scale factor to convert font units to pixels - * @return The scale factor to convert font units to pixels - */ - float GetUnitsToPixels() const; - - /** - * Get the glyph metrics for a character - * @param[in] character the character to get glyph metrics for - * @param[out] metrics used to store the glyph metrics . - */ - void GetMetrics(const Dali::Character& character, Dali::Font::Metrics::Impl& metrics) const; - - /** - * @copydoc Dali::PointsToPixels() - */ - static unsigned int PointsToPixels(float pointSize); - - /** - * @copydoc Dali::PixelsToPointsSize() - */ - static float PixelsToPoints(int pixelSize); - - /** - * Validates a font request. - * Provide a requested fontFamily, fontStyle, and point size. - * Will update with valid values for these. - * @param[in,out] fontFamily The font family name to be validated - * @param[in,out] fontStyle The font style to be validated - * @param[in,out] fontPointSize The font point size to be validated - * @param[out] fontFamilyDefault Whether the requested font family is default or not. - * @param[out] fontPointSizeDefault Whether the requested point size is default or not. - */ - static void ValidateFontRequest(std::string& fontFamily, std::string& fontStyle, float& fontPointSize, bool& fontFamilyDefault, bool& fontPointSizeDefault ); - - /** - * @copydoc GlyphAtlasManagerInterface::AddObserver() - */ - void AddObserver(TextObserver& observer); - - /** - * @copydoc GlyphAtlasManagerInterface::RemoveObserver() - */ - void RemoveObserver(TextObserver& observer); - - /** - * @copydoc GlyphAtlasManagerInterface::TextRequired() - */ - TextVertexBuffer* TextRequired( const Integration::TextArray& text, const TextFormat& format ); - - /** - * @copydoc GlyphAtlasManagerInterface::TextNotRequired() - */ - void TextNotRequired( const Integration::TextArray& text, const TextFormat& format, unsigned int textureId ); - - /** - * Add a glyph texture observer - * @param observer atlas observer - */ - void AddTextureObserver(GlyphTextureObserver& observer ); - - /** - * Remove a glyph texture observer - * @param observer atlas observer - */ - void RemoveTextureObserver(GlyphTextureObserver& observer ); - - /** - * Check if the characters are loaded into a texture (atlas). - * @param[in] text text array - * @paran[in] format text format - * @param[in] textureId texture ID of the atlas - * @return true if all characters are available, false if not - */ - bool IsTextLoaded( const Integration::TextArray& text, const TextFormat& format, unsigned int textureId ) const; - - -private: - - /** - * Create a new font object using a font name and size - * @param [in] fontFamily The family's name of the font requested - * @param [in] fontStyle The style of the font requested - * @param [in] size The size of the font in points - * @param [in] platform platform abstraction - * @param [in] resourceClient resourceClient - * @param [in] fontfactory font factory - * @param [in] atlasInterface reference to the atlas manager interface - * @return A newly allocated Font - */ - Font(const std::string& fontFamily, - const std::string& fontStyle, - float size, - Integration::PlatformAbstraction& platform, - ResourceClient& resourceClient, - FontFactory& fontfactory, - GlyphAtlasManagerInterface& atlasInterface); - -protected: - - /** - * A reference counted object may only be deleted by calling Unreference() - */ - virtual ~Font(); - -protected: - bool mIsDefault; ///< Whether the font is a system default font. - bool mIsDefaultSize; ///< Whether the font is a system default size. - std::string mName; ///< Name of the font's family - std::string mStyle; ///< Font's style - FontMetricsIntrusivePtr mMetrics; ///< Pointer to font metrics object - float mPointSize; ///< Point size - float mUnitsToPixels; ///< Used to scale from font metrics to pixels - Integration::PlatformAbstraction& mPlatform; ///< platform abstraction - ResourceClient& mResourceClient; ///< resource client - FontFactory& mFontFactory; ///< font factory - GlyphAtlasManagerInterface& mAtlasManager; ///< glyph atlas manager interface -}; - -} // namespace Internal - -inline const Internal::Font& GetImplementation(const Dali::Font& font) -{ - DALI_ASSERT_ALWAYS( font && "Font handle is empty" ); - - const BaseObject& handle = font.GetBaseObject(); - - return static_cast(handle); -} - - -inline Internal::Font& GetImplementation(Dali::Font& font) -{ - DALI_ASSERT_ALWAYS( font && "Font handle is empty" ); - - BaseObject& handle = font.GetBaseObject(); - - return static_cast(handle); -} - -} // namespace Dali - -#endif // __DALI_INTERNAL_FONT_H__ - diff --git a/dali/internal/event/text/font-layout.cpp b/dali/internal/event/text/font-layout.cpp deleted file mode 100644 index 14aed15..0000000 --- a/dali/internal/event/text/font-layout.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include - - -namespace Dali -{ - -namespace Internal -{ - -namespace -{ -const float INCH_TO_POINTS( 72.f ); -const float POINT_TO_INCHES( 1.f / INCH_TO_POINTS ); -} - -FontLayout::FontLayout() - :mUnitsPerEM(0.0f) -{ -} - -FontLayout::FontLayout( float unitsPerEM, Vector2 dpi ) - :mUnitsPerEM(unitsPerEM), - mDpi(dpi) -{ -} - -void FontLayout::SetMetrics( const Dali::Integration::GlobalMetrics &metrics ) -{ - mMetrics = metrics; - mUnitsPerEM = 1.0f / mMetrics.unitsPerEM; -} - -float FontLayout::GetUnitsToPixels( const float pointSize ) const -{ - const float meanDpi = (mDpi.height + mDpi.width) * 0.5f; - return ((meanDpi * POINT_TO_INCHES) * pointSize) * mUnitsPerEM; -} - -const Dali::Integration::GlobalMetrics& FontLayout::GetGlobalMetrics() const -{ - return mMetrics; -} - -float FontLayout::GetLineHeight() const -{ - return mMetrics.lineHeight; -} - -float FontLayout::GetAscender() const -{ - return mMetrics.ascender; -} - -float FontLayout::GetUnderlinePosition() const -{ - return mMetrics.underlinePosition; -} - -float FontLayout::GetUnderlineThickness() const -{ - return mMetrics.underlineThickness; -} - -float FontLayout::GetUnitsPerEM() const -{ - return mUnitsPerEM; -} - -float FontLayout::GetMaxWidth() const -{ - return mMetrics.maxWidth; -} - -float FontLayout::GetMaxHeight() const -{ - return mMetrics.maxHeight; -} - -float FontLayout::GetPadAdjustX() const -{ - return mMetrics.padAdjustX; -} - -float FontLayout::GetPadAdjustY() const -{ - return mMetrics.padAdjustY; -} - -Vector2 FontLayout::GetDpi() const -{ - return mDpi; -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/font-layout.h b/dali/internal/event/text/font-layout.h deleted file mode 100644 index 201f4bc..0000000 --- a/dali/internal/event/text/font-layout.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef __DALI_INTERNAL_FONT_LAYOUT_H__ -#define __DALI_INTERNAL_FONT_LAYOUT_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * Structure contains the information required to layout text. - * Contains the fonts global metrics, DPI, pad adjust and units per EM. - * All members are POD. - * - * Font-Metrics class will create and and own this struct. - * Text-Metric objects will hold a read only pointer to this struct. - * - */ -struct FontLayout -{ - /** - * Constructor - */ - FontLayout(); - - /** - * Constructor - * @param unitsPerEM units per EM - * @param dpi dots per inch - */ - FontLayout( float unitsPerEM, Vector2 dpi ); - - /** - * Set the global metrics - * @param metrics dali integration global metric object - */ - void SetMetrics( const Dali::Integration::GlobalMetrics &metrics ); - - /** - * Returns the global metrics - * @return global metrics - */ - const Dali::Integration::GlobalMetrics& GetGlobalMetrics() const; - - /** - * Get a multiplier value to scale measurements to pixels based on the given pointSize - * @param[in] pointSize The pointSize - * @return A multiplier value to scale measurements to pixels - */ - float GetUnitsToPixels( const float pointSize ) const; - - /** - * The line height is the vertical distance between the top of the highest character - * to the bottom of the lowest character - * @return the line height of the font in pixels - */ - float GetLineHeight() const; - - /** - * The ascender is the vertical distance from the - * baseline to the highest character coordinate in a font face. - * @return the ascender in pixels - */ - float GetAscender() const; - - /** - * Returns the underline position for this font. - * @return The underline position. - */ - float GetUnderlinePosition() const; - - /** - * Returns the thickness of the underline for this font. - * @return The thickness of the underline. - */ - float GetUnderlineThickness() const; - - /** - * Return the units per em for this font. - * @return units per em - */ - float GetUnitsPerEM() const; - - /** - * Returns the width of the widest glyph in this font in font units - * @return Width of widest glyph - */ - float GetMaxWidth() const; - - /** - * Returns the height of the tallest glyph in this font in font units - * @return Hight of tallest glyph - */ - float GetMaxHeight() const; - - /** - * Returns the horizontal pad adjust for this font in font units - * @return Horizontal pad adjust - */ - float GetPadAdjustX() const; - - /** - * Returns the vertical pad adjust for this font in font units - * @return Vertical pad adjust - */ - float GetPadAdjustY() const; - - /** - * Returns the dots per inch for this font - * @return dpi - */ - Vector2 GetDpi() const; - - -private: - - Dali::Integration::GlobalMetrics mMetrics; ///< integration Metrics - float mUnitsPerEM; ///< Font units/EM. Used to convert from units to pixels. Equal to (1.0f / GlobalMetrics.unitsPerEm) - Vector2 mDpi; ///< Dots per inch. Used to convert from units to pixels. -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_FONT_LAYOUT_H__ diff --git a/dali/internal/event/text/font-metrics-interface.h b/dali/internal/event/text/font-metrics-interface.h deleted file mode 100644 index 3362788..0000000 --- a/dali/internal/event/text/font-metrics-interface.h +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef __DALI_FONT_METRICS_INTERFACE_H__ -#define __DALI_FONT_METRICS_INTERFACE_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include - -// EXTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * - * Abstract interface for requesting information about a font and its metrics. - * - */ -class FontMetricsInterface -{ - -public: - - /** - * Ensures the metrics for each character in the text are loaded and cached. - * @param[in] text The text string to load the metrics for. - */ - virtual void LoadMetricsSynchronously( const Integration::TextArray& text ) = 0; - - /** - * Gets the metrics for a single character. - * The glyph information holds the character dimensions and layout information. - * @note LoadMetricsSynchronously() should be called on the string you wish - * to get the metrics for, before calling GetGlyph() on each character - * @param[in] charIndex character code - * @return pointer to a glyph metric object - */ - virtual const GlyphMetric* GetGlyph( uint32_t charIndex ) const = 0; - - /** - * Get the unique id for the font. - * @return font id - */ - virtual FontId GetFontId() const = 0; - - /** - * Get the font family - * @return the font family name - */ - virtual const std::string& GetFontFamilyName() const = 0; - - /** - * Get the font style - * @return the font style name - */ - virtual const std::string& GetFontStyleName() const = 0; - - /** - * Get the maximum glyph size. - * @param[out] width maximum width of a character in the font - * @param[out] height maximum height of a character in the font - */ - virtual void GetMaximumGylphSize(float& width, float& height) const = 0; - - /** - * Get a multiplier value to scale measurements to pixels based on the given pointSize - * @param[in] pointSize The pointSize - * @return A multiplier value to scale measurements to pixels - */ - virtual float GetUnitsToPixels(const float pointSize) const = 0; - - /** - * The line height is the vertical distance between the top of the highest character - * to the bottom of the lowest character - * @return the line height of the font in pixels - */ - virtual float GetLineHeight() const = 0; - - /** - * The ascender is the vertical distance from the - * baseline to the highest character coordinate in a font face. - * @return the ascender in pixels - */ - virtual float GetAscender() const = 0; - - /** - * Returns the underline position for this font. - * @return The underline position. - */ - virtual float GetUnderlinePosition() const = 0; - - /** - * Returns the thickness of the underline for this font. - * @return The thickness of the underline. - */ - virtual float GetUnderlineThickness() const = 0; - - /** - * Returns the width of the widest glyph in this font in pixels - * @return Width of widest glyph - */ - virtual float GetMaxWidth() const = 0; - - /** - * Returns the height of the tallest glyph in this font in pixels - * @return Height of tallest glyph - */ - virtual float GetMaxHeight() const = 0; - - /** - * Returns the horizontal pad adjust for this font in pixels - * @return Horizontal pad adjust - */ - virtual float GetPadAdjustX() const = 0; - - /** - * Returns the vertical pad adjust for this font in pixels - * @return Vertical pad adjust - */ - virtual float GetPadAdjustY() const = 0; - - -protected: - - /** - * Constructor - */ - FontMetricsInterface() - { - } - - /** - * Destructor. - */ - virtual ~FontMetricsInterface() - { - } - - // Undefined copy constructor. - FontMetricsInterface( const FontMetricsInterface& ); - - // Undefined assignment operator. - FontMetricsInterface& operator=( const FontMetricsInterface& ); - -}; - - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_FONT_METRICS_INTERFACE_H__ diff --git a/dali/internal/event/text/font-metrics.cpp b/dali/internal/event/text/font-metrics.cpp deleted file mode 100644 index f656d83..0000000 --- a/dali/internal/event/text/font-metrics.cpp +++ /dev/null @@ -1,458 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// EXTERNAL HEADERS - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ -namespace Internal -{ - -namespace //unnamed namespace -{ - -const float DEFAULT_UNITS_PER_EM( 1.f ); - -const uint32_t FIRST_NON_CONTROL_CHAR( 0x20 ); // 0x20 is the white space which is the first non control character. -const uint32_t LINE_SEPARATOR( '\n' ); - - -Integration::TextArray GetUniqueCharacters( const Integration::TextArray& text ) -{ - Integration::TextArray utfCodes = text; - std::sort( utfCodes.Begin(), utfCodes.End() ); - Integration::TextArray::Iterator it = std::unique( utfCodes.Begin(), utfCodes.End() ); - utfCodes.Resize( it - utfCodes.Begin() ); - return utfCodes; -} - -} // unnamed namespace - - - -FontMetricsIntrusivePtr FontMetrics::New( const Vector2& dpi, - const std::size_t hashValue, - const FontId fontId, - const std::string& fontFamily, - const std::string& fontStyle ) -{ - return new FontMetrics( dpi, hashValue, fontId, fontFamily, fontStyle ); -} - -void FontMetrics::LoadGlobalMetrics() -{ - // Read global metrics synchronously. - bool success = ReadGlobalMetricsFromCache(); - - if( !success ) - { - Dali::Integration::GlobalMetrics globalMetrics; - - // Read global metrics from platform. - mPlatform.GetGlobalMetrics( mFontFamily, mFontStyle, globalMetrics ); - - // configure the metrics - mFontLayout.SetMetrics( globalMetrics ); - - // write the metrics to a cache - WriteGlobalMetricsToCache(); - } -} - -Vector3 FontMetrics::MeasureText( const Integration::TextArray& text ) -{ - if( 0u == text.Count() ) - { - return Vector3::ZERO; - } - - Integration::TextArray utfCodes = GetUniqueCharacters( text ); - - // ensure all the metrics are loaded for the characters - LoadMetricsSynchronously( utfCodes ); - - // Measure text - // Calculate the natural size of text for the font - Vector3 measurement(Vector3::ZERO); - const GlyphMetric* glyphMetric(NULL); - - float xPos = 0.0f; - - for( Integration::TextArray::ConstIterator it = text.Begin(), endIt = text.End(); it != endIt; ++it ) - { - const uint32_t utfCode( *it ); - - glyphMetric = GetGlyph( utfCode ); - - xPos += glyphMetric->GetXAdvance(); - - measurement.x = std::max(measurement.x, xPos); - } - - if (glyphMetric ) - { - // The glyphs may be wider than their advance, so increase measurement - // by the difference between the width and advance of the last glyph - if (glyphMetric->GetWidth() > glyphMetric->GetXAdvance() ) - { - measurement.x += glyphMetric->GetWidth() - glyphMetric->GetXAdvance(); - } - } - - measurement.y = mFontLayout.GetLineHeight(); - - return measurement; -} - -bool FontMetrics::TextAvailable( const Integration::TextArray& text ) const -{ - TCharMap::const_iterator endIter = mCharMap.end(); - - for( Integration::TextArray::ConstIterator it = text.Begin(), endIt = text.End(); it != endIt; ++it ) - { - const uint32_t utfCode( *it ); - - TCharMap::const_iterator iter = mCharMap.find( utfCode ); - if( iter == endIter ) - { - return false; - } - } - - return true; -} - -unsigned int FontMetrics::GetMissingText( const Integration::TextArray& text, CharacterList& missingText ) const -{ - // sort and remove duplicate character codes - Integration::TextArray utfCodes( GetUniqueCharacters(text) ); - - // scan through the metrics cache, making a list of characters that are missing - TCharMap::const_iterator endIter = mCharMap.end(); - for( Integration::TextArray::ConstIterator it = utfCodes.Begin(), endIt = utfCodes.End(); it != endIt; ++it ) - { - const uint32_t utfCode( *it ); - - TCharMap::const_iterator iter = mCharMap.find( utfCode ); - if( iter == endIter ) - { - missingText.push_back( Integration::TextResourceType::GlyphPosition(utfCode, 0, 0) ); - } - } - return missingText.size(); -} - -void FontMetrics::LoadMetricsSynchronously( const Integration::TextArray& text ) -{ - // check to make sure the metrics cache has loaded - CheckMetricsLoaded(); - - // check if all the characters are cached in memory - bool textCached = TextAvailable( text ); - - if( !textCached ) - { - const Vector2 maxGlyphCell( GetMaxWidth(), GetMaxHeight() ); - - Integration::TextResourceType::CharacterList missingText; - - // find out which characters aren't cached - GetMissingText( text, missingText ); - - if( !missingText.empty() ) - { - // some character metrics aren't cached, so load them now - - // TODO - ADD NEW METRICS RESOURCE TYPE - Integration::TextResourceType resourceType( mHash, mFontStyle, missingText, 0, Integration::TextResourceType::TextQualityHigh, maxGlyphCell, Integration::TextResourceType::GLYPH_CACHE_READ); - // this is a synchronous request - Integration::GlyphSetPointer glyphs = mPlatform.GetGlyphData( resourceType, mFontFamily, false ); - - if (!glyphs) - { - DALI_LOG_WARNING("Font or glyph data not found for font %s-%s !\n", mFontFamily.c_str(), mFontStyle.c_str() ); - return; - } - - // cache the metrics to a cache - WriteMetricsToCache( *glyphs.Get() ); - - // cache the metrics in memory - AddGlyphSet( 0, *glyphs.Get() ); - } - } -} - -const GlyphMetric* FontMetrics::GetGlyph( uint32_t characterCode) const -{ - TCharMap::const_iterator iter = mCharMap.find( characterCode ); - - if( iter != mCharMap.end()) - { - return &iter->second; - } - else - { - // can and will happen if a glyph doesn't exist for the - // given character code - if( characterCode >= FIRST_NON_CONTROL_CHAR ) - { - DALI_LOG_ERROR("failed to find character %lu\n", characterCode ); - } - return NULL; - } -} - -FontId FontMetrics::GetFontId() const -{ - return mFontId; -} - -const std::string& FontMetrics::GetFontFamilyName() const -{ - return mFontFamily; -} - -const std::string& FontMetrics::GetFontStyleName() const -{ - return mFontStyle; -} - -void FontMetrics::GetMaximumGylphSize( float& width, float& height ) const -{ - width = GetMaxWidth(); - height = GetMaxHeight(); -} - -float FontMetrics::GetUnitsToPixels( const float pointSize ) const -{ - return mFontLayout.GetUnitsToPixels( pointSize ); -} - -float FontMetrics::GetLineHeight() const -{ - return mFontLayout.GetLineHeight(); -} - -float FontMetrics::GetAscender() const -{ - return mFontLayout.GetAscender(); -} - -float FontMetrics::GetUnderlinePosition() const -{ - return mFontLayout.GetUnderlinePosition(); -} - -float FontMetrics::GetUnderlineThickness() const -{ - return mFontLayout.GetUnderlineThickness(); -} - -float FontMetrics::GetMaxWidth() const -{ - return mFontLayout.GetMaxWidth(); -} - -float FontMetrics::GetMaxHeight() const -{ - return mFontLayout.GetMaxHeight(); -} - -float FontMetrics::GetPadAdjustX() const -{ - return mFontLayout.GetPadAdjustX(); -} - -float FontMetrics::GetPadAdjustY() const -{ - return mFontLayout.GetPadAdjustY(); -} - - -void FontMetrics::GetMetrics( const Dali::Character& character, Dali::Font::Metrics::Impl& metrics ) -{ - Integration::TextArray utfCodes; - utfCodes.PushBack( character.GetImplementation().GetCharacter() ); - - LoadMetricsSynchronously( utfCodes ); - - const GlyphMetric* glyph; - - glyph = GetGlyph( character.GetImplementation().GetCharacter() ); - - if( glyph ) - { - - metrics.advance = glyph->GetXAdvance(); - metrics.bearing = glyph->GetTop(); - metrics.width = std::max( glyph->GetWidth(), glyph->GetXAdvance() ); - metrics.height = glyph->GetHeight(); - } - else - { - metrics.advance = 0.0f; - metrics.bearing = 0.0f; - metrics.width = 0.0f; - metrics.height = 0.0f; - } -} - -void FontMetrics::IncreaseFontCount() -{ - mFontCount++; -} - -void FontMetrics::DecreaseFontCount() -{ - DALI_ASSERT_DEBUG( mFontCount != 0 ); - mFontCount--; -} - -unsigned int FontMetrics::GetFontUsageCount() const -{ - return mFontCount; -} - -// Called when a metric is loaded -void FontMetrics::AddGlyphSet( Integration::ResourceId id, const Integration::GlyphSet& glyphSet ) -{ - const Integration::GlyphSet::CharacterList& characterList = glyphSet.GetCharacterList(); - - for( Integration::GlyphSet::CharacterConstIter it = characterList.begin(), endIt = characterList.end(); it != endIt; ++it ) - { - Integration::GlyphMetrics glyphMetrics( it->second ); - // the map is used to retrieve character information when measuring a string - AddGlyphMetricToCache( glyphMetrics ); - } -} - -void FontMetrics::CheckMetricsLoaded() -{ - if( mMetricsLoaded ) - { - return; - } - - // read the metrics from the cache - bool success = ReadMetricsFromCache(); - if( !success ) - { - // Create a new one - WriteGlobalMetricsToCache(); - } - - mMetricsLoaded = true; -} - -bool FontMetrics::ReadGlobalMetricsFromCache( ) -{ - Integration::GlobalMetrics globalMetrics; - - bool success = mPlatform.ReadGlobalMetricsFromCache( mFontFamily, mFontStyle, globalMetrics ); - if( success ) - { - mFontLayout.SetMetrics( globalMetrics ); - } - return success; -} - -void FontMetrics::WriteGlobalMetricsToCache() -{ - mPlatform.WriteGlobalMetricsToCache( mFontFamily, mFontStyle, mFontLayout.GetGlobalMetrics() ); -} - - -bool FontMetrics::ReadMetricsFromCache() -{ - std::vector glyphMetricsContainer; - - bool success = mPlatform.ReadMetricsFromCache( mFontFamily, mFontStyle, glyphMetricsContainer ); - if( success ) - { - for( std::size_t i=0, end=glyphMetricsContainer.size(); i - - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -/** - * Used to return metrics for a single character in public API - */ -struct Font::Metrics::Impl -{ - Impl() - : advance( 0.f ), - bearing( 0.f ), - width( 0.f ), - height( 0.f ) - {} - - float advance; ///< The distance between the glyph's current pen position and the pen's position of the next glyph. - float bearing; ///< The horizontal top side bearing. Is the distance between the baseline and the top of the glyph. - float width; ///< The glyph's width. - float height; ///< The glyph's height. -}; - -namespace Integration -{ -class PlatformAbstraction; - -} // namespace Integration - -namespace Internal -{ - -// Forward declarations. - -class FontMetrics; - -typedef IntrusivePtr FontMetricsIntrusivePtr; - -typedef std::map< std::size_t, FontMetricsIntrusivePtr > FontMetricsMap; -typedef FontMetricsMap::iterator FontMetricsIter; -typedef std::pair< std::size_t, FontMetricsIntrusivePtr > FontMetricsPair; - -/** - * Class for storing glyph metrics. Only to be accessed from the event thread. - */ -class FontMetrics : public FontMetricsInterface, public Dali::RefObject -{ -public: - typedef Integration::TextResourceType::CharacterList CharacterList; - - /** - * Creates a new font metrics object. - * @param [in] dpi System dpi. - * @param [in] hashValue Unique identifier for these metrics. - * @param [in] fontId font id. - * @param [in] fontFamily the font family - * @param [in] fontStyle the font style - * @return An intrusive-pointer to the new instance. - */ - static FontMetricsIntrusivePtr New( const Vector2& dpi, - const std::size_t hashValue, - const FontId fontId, - const std::string& fontFamily, - const std::string& fontStyle ); - - - /** - * Loads the global metrics for the font. - * The metrics will either be read from a cache, or from Freetype - * and then saved to the cache. - * - */ - void LoadGlobalMetrics(); - - /** - * Measure the natural size of a text string, as displayed in this font. - * @param[in] text The text string to measure. - * @return The natural size of the text. - */ - Vector3 MeasureText(const Integration::TextArray& text); - - /** - * Check if all characters in a string are currently in the font - * @param[in] text The string to check - * @return true if all characters are currently in the font - */ - bool TextAvailable (const Integration::TextArray& text) const; - - /** - * Given a text array, checks which characters have their metrics loaded. - * Characters which are not loaded are added to the missingText parameter - * @param[in] text The original string. - * @param[out] missingText Characters from text not contained in this font. - * @return number of characters that have not had their metrics loaded - */ - unsigned int GetMissingText(const Integration::TextArray& text, CharacterList& missingText ) const; - -public: // for FontMetricsInterface - - /** - * @copydoc FontMetricsInterface::LoadMetricsSynchronously - */ - virtual void LoadMetricsSynchronously( const Integration::TextArray& text ); - - /** - * @copydoc FontMetricsInterface::GetGlyph() - */ - virtual const GlyphMetric* GetGlyph( uint32_t characterCode) const; - - /** - * @copydoc FontMetricsInterface::GetFontId() - */ - virtual FontId GetFontId() const; - - /** - * @copydoc FontMetricsInterface::GetFontFamilyName() - */ - virtual const std::string& GetFontFamilyName() const; - - /** - * @copydoc FontMetricsInterface::GetFontStyleName() - */ - virtual const std::string& GetFontStyleName() const; - - /** - * @copydoc FontMetricsInterface::GetMaximumGylphSize() - */ - virtual void GetMaximumGylphSize( float& width, float& height ) const; - - /** - * @copydoc FontMetricsInterface::GetUnitsToPixels() - */ - virtual float GetUnitsToPixels(const float pointSize) const; - - /** - * @copydoc FontMetricsInterface::GetLineHeight() - */ - virtual float GetLineHeight() const; - - /** - * @copydoc FontMetricsInterface::GetAscender() - */ - virtual float GetAscender() const; - - /** - * @copydoc FontMetricsInterface::GetUnderlinePosition() - */ - virtual float GetUnderlinePosition() const; - - /** - * @copydoc FontMetricsInterface::GetUnderlineThickness() - */ - virtual float GetUnderlineThickness() const; - - /** - * @copydoc FontMetricsInterface::GetMaxWidth() - */ - virtual float GetMaxWidth() const; - - /** - * @copydoc FontMetricsInterface::GetMaxHeight() - */ - virtual float GetMaxHeight() const; - - /** - * @copydoc FontMetricsInterface::GetPadAdjustX() - */ - virtual float GetPadAdjustX() const; - - /** - * @copydoc FontMetricsInterface::GetPadAdjustY() - */ - virtual float GetPadAdjustY() const; - - -public: - - /** - * Get the glyph metrics for a character - * @param[in] character the character to get glyph metrics for - * @param[out] metrics used to store the glyph metrics . - */ - void GetMetrics( const Dali::Character& character, Dali::Font::Metrics::Impl& metrics ); - - /** - * Increase the number of fonts using the metrics object - * Used by the font-factory to decided whether the metrics should be removed - * from the cache. - * This does not determine the life time of the object. - */ - void IncreaseFontCount(); - - /** - * Decrease the number of fonts using the metrics object - * Used by the font-factory to decided whether the metrics should be removed - * from the cache. - * This does not determine the life time of the object. - */ - void DecreaseFontCount(); - - /** - * Used by font-factory to remove the metrics from its cache when - * the font usage count reaches zero. - * @return the number of fonts using this metrics object - */ - unsigned int GetFontUsageCount() const; - -private: - - - /** - * Add glyphs to font - * @param[in] id resource id, used to find the ticket use for the request - * @param[in] glyphSet The set of glyphs to insert into this font - */ - void AddGlyphSet( Integration::ResourceId id, const Integration::GlyphSet& glyphSet ); - - /** - * Checks that the glyph metrics have been loaded - * if they haven't, then they are loaded. - */ - void CheckMetricsLoaded(); - - /** - * Reads global glyph metrics from glyph cache. - * @return \e true if global metrics have been read correctly. - */ - bool ReadGlobalMetricsFromCache(); - - /** - * Reads Glyph metrics from Glyph cache. - * @return \e true if global metrics have been read correctly. - */ - bool ReadMetricsFromCache(); - - /** - * Writes global glyph metrics to the cache. - */ - void WriteGlobalMetricsToCache(); - - /** - * Writes glyph metrics to the cache. - * @param[in] glyphSet The set of glyphs to insert into the cache. - */ - void WriteMetricsToCache( const Integration::GlyphSet& glyphSet ); - - /** - * Private contructor use FontMetrics::New() - * @param[in] dpi System dpi - * @param[in] hashValue Unique identifier for these metrics - * @param [in] fontId font id. - * @param [in] fontFamily the font family - * @param [in] fontStyle the font style - */ - FontMetrics( const Vector2& dpi, - const std::size_t hashValue, - const FontId fontId, - const std::string& fontFamily, - const std::string& fontStyle ); - - /** - * Virtual destructor. - * Relies on default destructors. - */ - virtual ~FontMetrics(); - - /** - * Adds glyph metrics to the cache - * @param glyphMetric the glyph metric - */ - void AddGlyphMetricToCache(const Integration::GlyphMetrics& glyphMetric); - - typedef std::map TCharMap; - - std::string mFontFamily; ///< font family name - std::string mFontStyle; ///< font style - TCharMap mCharMap; ///< Cache of GlyphMetric objects. - FontLayout mFontLayout; ///< font layout information (metrics, padding, dpi etc). - std::size_t mHash; ///< Unique identifier for these metrics. - FontId mFontId; ///< Unique identifier for the font - unsigned int mFontCount; ///< How many font objects are using this font, used to know when it should be deleted from font factory - bool mMetricsLoaded; ///< Whether the metrics cache has been loaded - Integration::PlatformAbstraction& mPlatform; ///< platform abstraction -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_FONT_METRICS_H__ diff --git a/dali/internal/event/text/generator/text-vertex-generator.cpp b/dali/internal/event/text/generator/text-vertex-generator.cpp deleted file mode 100644 index 1498c46..0000000 --- a/dali/internal/event/text/generator/text-vertex-generator.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// FILE HEADER -#include "text-vertex-generator.h" - -// INTERNAL INCLUDES -#include -#include -#include -#include - -// EXTERNAL INCLUDES -#include // for std::sin - -namespace Dali -{ - -namespace Internal -{ - -namespace // unnamed namespace -{ - -#if defined(DEBUG_ENABLED) -Debug::Filter* gTextVertsLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_TEXT_VERTEX_FILTER" ); -#endif - -typedef std::vector VertexBuffer; - -void RepositionData( TextVertexBuffer& buffer ) -{ - /* - * - * As 0,0 is the middle of the actor, text will be displayed like this - * - * |-------------------------------| - * | Actor | - * | | - * | | - * | (0,0)|---------- | (x) - * | | Hello World | - * | | | - * | | | - * |-------------------------------| - * (y) - * - * Below it is repositioned to the centre of the actor - * |-------------------------------| - * | Actor | - * | | - * | | - * | Hello World------ | (x) - * | | | - * | | | - * | | | - * |-------------------------------| - */ - - // move the vertices so 0,0 is the centre of the text string. - float minX=1e8f, maxX=-1e8f; - float minY=1e8f, maxY=-1e8f; - std::vector& vertices = buffer.mVertices; - - for (std::size_t i=0, size = vertices.size() ; i < size; ++i) - { - TextVertex2D& vertex = vertices[i]; - minX = std::min(minX, vertex.mX); - maxX = std::max(maxX, vertex.mX); - - minY = std::min(minY, vertex.mY); - maxY = std::max(maxY, vertex.mY); - } - - Vector2 offset; - offset.x = ( maxX + minX ) * 0.5f; - offset.y = ( maxY + minY ) * 0.5f; - - for (std::size_t i=0, size = vertices.size() ; i< size; ++i) - { - TextVertex2D& vertex = vertices[i]; - vertex.mX -= offset.x; - vertex.mY -= offset.y; - } - - buffer.mGeometryExtent.width = maxX - minX; - buffer.mGeometryExtent.height = maxY - minY; -} - -void AddVertex( VertexBuffer& vertexBuffer, - const float xPos, - const float yPos, - const float charWidth, - const float charHeight, - const UvRect& uv, - const Vector2& uvShadow ) -{ - /* - * Create 4 vertices - * 1 --- 2 - * | /| - * | A | - * | / | - * 0 --- 3 - * - * 2 triangles with clock wise winding: 0->1->2 and 0->2->3 - */ - - TextVertex2D v; - - // set U1,V1 for all vertices - v.mU1 = uvShadow.x; - v.mV1 = uvShadow.y; - - // bottom left, 0 - v.mX = xPos; - v.mY = yPos; - v.mU = uv.u0; - v.mV = uv.v0; - vertexBuffer.push_back(v); - - // top left, 1 - v.mX = xPos; - v.mY = yPos + charHeight; - v.mU = uv.u0; - v.mV = uv.v2; - vertexBuffer.push_back(v); - - // top right, 2 - v.mX = xPos + charWidth; - v.mY = yPos + charHeight; - v.mU = uv.u2; - v.mV = uv.v2; - vertexBuffer.push_back(v); - - // bottom right, 3 - v.mX = xPos + charWidth; - v.mY = yPos; - v.mU = uv.u2; - v.mV = uv.v0; - vertexBuffer.push_back(v); -} - -/** - * Adjust the vertex data for italics. - * Skews the vertices by a value - */ -void AdjustForItalics( VertexBuffer& vertexBuffer, - const float italicsTopDisplacement, - const float italicsBottomDisplacement) -{ - - std::size_t index = vertexBuffer.size()-4; - TextVertex2D &v1 = vertexBuffer.at( index ); - v1.mX+= italicsBottomDisplacement; - - - // top left - index++; - TextVertex2D &v2 = vertexBuffer.at( index ); - v2.mX+= italicsTopDisplacement; - - - // top right - index++; - TextVertex2D &v3 = vertexBuffer.at( index ); - v3.mX+= italicsTopDisplacement; - - // bottom right - index++; - TextVertex2D &v4 = vertexBuffer.at( index ); - v4.mX+= italicsBottomDisplacement; -} - -void AddUnderline( VertexBuffer& vertexBuffer, - const float totalWidth, - const float thickness, - const float yPosition, - const UvRect& uv ) -{ - /* - * Add an underline to a string of text. - * - * - * A thin vertical slice of the underline character is stretched to the - * length of the string. - * - * If we stretch the entire underline character (not a thin slice) then - * the rounded edges will be stretched as well, giving inconsistent results. - * - * Underline glyph Only use a thin slice for texturing - * - * |-------------------| (u0,v2)|--------|X|---------|(u2,v2) - * | | | |X| | - * | /-----------\ | | /----|X|-----\ | - * | | underline | | | | |X| | | - * | \___________/ | | \____|X|_____/ | - * | | | |X| | - * | | | |X| | - * |-------------------| |--------|X|---------| - * - * (u0,v0) halfU (u2,v0) - * - * In calculation below - * HalfU = half way between u0 and u2. This gives a thin slice. - * So we use the texture-coordinates from (halfU, v0) -> (halfU, v2). - * - * End result is: A solid edge on the left / right side of the underline: - * A smooth (anti-aliased) edge on the top / bottom of the underline - */ - - TextVertex2D v; - - // set U1,V1 for all vertices - v.mU1 = 1.0f; - v.mV1 = 1.0f; - - float halfU = (uv.u0 + uv.u2)/2.0f; - - /* - * Create 4 vertices - * 1 --- 2 - * | /| - * | A | - * | / | - * 0 --- 3 - */ - - // 0 - v.mX = 0.0f; - v.mY = yPosition; - v.mU = halfU; - v.mV = uv.v2; - vertexBuffer.push_back(v); - - // 1 - v.mX = 0.0f; - v.mY = yPosition + thickness; - v.mU = halfU; - v.mV = uv.v0; - vertexBuffer.push_back(v); - - // 2 - v.mX = totalWidth; - v.mY = yPosition + thickness; - v.mU = halfU; - v.mV = uv.v0; - vertexBuffer.push_back(v); - - // 3 - v.mX = totalWidth; - v.mY = yPosition; - v.mU = halfU; - v.mV = uv.v2; - vertexBuffer.push_back(v); -} - -void GetAdjustedSize(float &charWidth, - float &charHeight, - float &left, - float &top, - float padAdjustX, - float padAdjustY, - float scalar, - const GlyphMetric& glyph) -{ - charWidth = (glyph.GetWidth() + padAdjustX * 2.0f) * scalar; - charHeight = (glyph.GetHeight() + padAdjustY * 2.0f) * scalar; - left = (glyph.GetLeft() - padAdjustX) * scalar; - top = (glyph.GetTop() + padAdjustY) * scalar; -} - -#ifdef DEBUG_VERTS - -void DebugVertexBuffer( VertexBuffer& buffer ) -{ - for (std::size_t i = 0, size = buffer.size(); i< size ; ++i) - { - TextVertex2D &v = buffer.at( i ); - printf("%d: xyuv =, %f , %f, %f, %f \n", (unsigned int) i, v.mX,v.mY, v.mU, v.mV); - } -} -#endif - -} // unnamed namespace - -TextVertexBuffer* TextVertexGenerator::Generate( const Integration::TextArray& text, - const TextFormat& format, - const FontMetricsInterface& metrics, - const AtlasUvInterface& uvInterface, - FontId fontId ) - -{ - TextVertexBuffer* textVertexBuffer = new TextVertexBuffer; - VertexBuffer &vertexBuffer(textVertexBuffer->mVertices); - - const GlyphMetric* glyph( NULL ); - float xPos( 0.0f ); - float yPos( 0.0f ); - float underlineWidth( 0.0f ); - float totalWidth( 0.0f ); - float charWidth( 0.0f ); - float charHeight( 0.0f ); - float left(0.0f); - float top(0.0f); - - float scalar = metrics.GetUnitsToPixels( format.GetPointSize() ); - - // Italics displacement - // the text is rendered upside down - const float sinAngle = format.IsItalic() ? std::sin( format.GetItalicsAngle() ) : 0.0f; - - // get the line height and ascender from the font - const float lineHeight( metrics.GetLineHeight() * scalar ); - const float ascender( metrics.GetAscender() * scalar ); - const float padAdjustX( metrics.GetPadAdjustX() ); - const float padAdjustY( metrics.GetPadAdjustY() ); - const float tileWidth( metrics.GetMaxWidth() * scalar ); - const float tileHeight( metrics.GetMaxHeight() * scalar ); - - for( Integration::TextArray::ConstIterator it = text.Begin(), endIt = text.End(); it != endIt; ++it ) - { - const uint32_t charIndex = *it; - - glyph = metrics.GetGlyph( charIndex ); - - if (charIndex >= SpecialCharacters::FIRST_VISIBLE_CHAR && glyph ) - { - // get char size and offset adjusted for padding in the atlas - GetAdjustedSize(charWidth, charHeight, left, top, padAdjustX, padAdjustY, scalar, *glyph ); - - yPos = (ascender - top); - xPos += left; - - // a combination of character index and font id is used to uniquely identify the character - unsigned int encodedChar = GlyphStatus::GetEncodedValue( charIndex, fontId ); - UvRect uv = uvInterface.GetUvCoordinates( encodedChar ); - - const Vector2 uvShadow( tileWidth / charWidth, tileHeight / charHeight ); - - AddVertex( vertexBuffer, xPos, yPos, charWidth, charHeight, uv, uvShadow ); - - if( format.IsItalic() ) - { - float italicsTopDisplacement = ( top - charHeight ) * sinAngle; - float italicsBottomDisplacement = top * sinAngle; - AdjustForItalics( vertexBuffer, italicsTopDisplacement, italicsBottomDisplacement); - } - - xPos -= left; - } - - if( glyph ) - { - underlineWidth = std::max( underlineWidth, xPos + glyph->GetXAdvance() * scalar ); - xPos += glyph->GetXAdvance() * scalar; - totalWidth = std::max(totalWidth, xPos); - } - } // for - - if( format.IsUnderLined() ) - { - unsigned int encodedChar = GlyphStatus::GetEncodedValue( SpecialCharacters::UNDERLINE_CHARACTER, fontId ); - UvRect uv( uvInterface.GetUvCoordinates( encodedChar )); - - glyph = metrics.GetGlyph( SpecialCharacters::UNDERLINE_CHARACTER ); - - if( glyph ) - { - // Adjust uv coordinates for scaling within atlas tile - GetAdjustedSize(charWidth, charHeight, left, top, padAdjustX, padAdjustY, scalar, *glyph ); - - // Get underline thickness and position. - // These values could be retrieved from the text-format, set to the text-actor through text-style, - // or retrieved directly from the font metrics. - float thickness = 0.f; - float position = 0.f; - - if( fabs( format.GetUnderlineThickness() ) > Math::MACHINE_EPSILON_0 ) - { - // Thickness and position retrieved from the format, which are passed to the - // text-actor through the text-style, it adds the vertical pad adjust used to fit some effects like glow or shadow.. - thickness = -format.GetUnderlineThickness(); - position = format.GetUnderlinePosition(); - } - else - { - // Thickness and position retrieved from the font metrics. - // It adds the vertical pad adjust ( padAdjustY ) used to fit some effects like glow or shadow. - thickness = -( metrics.GetUnderlineThickness() + 2.f * padAdjustY ) * scalar; - position = ascender - ( metrics.GetUnderlinePosition() - padAdjustY ) * scalar; - } - AddUnderline( vertexBuffer, underlineWidth, thickness, position, uv ); - } - } - - textVertexBuffer->mVertexMax = Vector2( totalWidth, lineHeight ); - RepositionData( *textVertexBuffer ); - -#ifdef DEBUG_VERTS - DebugVertexBuffer( vertexBuffer ); -#endif - - DALI_LOG_INFO(gTextVertsLogFilter, Debug::General, "TextVertexBuffer for %c%c%c...: Calculated Extents:(%5.2f, %5.2f)\n Geometry Extents:(%5.2f, %5.2f )\n", - text.Count()>0?(char)text[0]:' ', text.Count()>1?(char)text[1]:' ', text.Count()>2?(char)text[2]:' ', - textVertexBuffer->mVertexMax.x,textVertexBuffer->mVertexMax.y, - textVertexBuffer->mGeometryExtent.width,textVertexBuffer->mGeometryExtent.height); - - return textVertexBuffer; -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/generator/text-vertex-generator.h b/dali/internal/event/text/generator/text-vertex-generator.h deleted file mode 100644 index 97c611d..0000000 --- a/dali/internal/event/text/generator/text-vertex-generator.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef __DALI_INTERNAL_TEXT_VERTEX_GENERATOR_H__ -#define __DALI_INTERNAL_TEXT_VERTEX_GENERATOR_H__ - -/* - * Copyright (c) 2014 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 - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * Creates the vertex data for a string of text. - * - */ -namespace TextVertexGenerator -{ - -/** - * Get the vertex buffer to draw the text. - * The caller takes ownership of the buffer and is responsible for - * deleting it. - * @param[in] text text array - * @param[in] format text format - * @param[in] metrics interface to get metric information - * @param[in] uvInterface interface to get uv co-ordinates of each characters - * @param[in] fontId the font id - * @return text vertex buffer - */ - TextVertexBuffer* Generate(const Integration::TextArray& text, - const TextFormat& format, - const FontMetricsInterface& metrics, - const AtlasUvInterface& uvInterface, - FontId fontId); - - - -}; - - - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_TEXT_VERTEX_GENERATOR_H__ diff --git a/dali/internal/event/text/glyph-metric.cpp b/dali/internal/event/text/glyph-metric.cpp deleted file mode 100644 index 8e3dec6..0000000 --- a/dali/internal/event/text/glyph-metric.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -namespace Dali -{ - -namespace Internal -{ - -GlyphMetric::GlyphMetric() -: mCode(0), - mWidth(0.0f), - mHeight(0.0f), - mTop(0.0f), - mLeft(0.0f), - mXAdvance(0.0f) -{ -} - -GlyphMetric::~GlyphMetric() -{ -} - -GlyphMetric::GlyphMetric( uint32_t characterCode, - float width, - float height, - float top, - float left, - float xAdvance) -: mCode( characterCode ), - mWidth( width ), - mHeight( height ), - mTop( top ), - mLeft( left ), - mXAdvance( xAdvance ) -{ -} - -uint32_t GlyphMetric::GetCharacterCode() const -{ - return mCode; -} - -float GlyphMetric::GetWidth() const -{ - return mWidth; -} - -float GlyphMetric::GetHeight() const -{ - return mHeight; -} - -float GlyphMetric::GetTop() const -{ - return mTop; -} - -float GlyphMetric::GetLeft() const -{ - return mLeft; -} - -float GlyphMetric::GetXAdvance() const -{ - return mXAdvance; -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/glyph-metric.h b/dali/internal/event/text/glyph-metric.h deleted file mode 100644 index 1347c0d..0000000 --- a/dali/internal/event/text/glyph-metric.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef __DALI_INTERNAL_GLYPH_METRIC_H__ -#define __DALI_INTERNAL_GLYPH_METRIC_H__ - -/* - * Copyright (c) 2014 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 // for uint32_t - -namespace Dali -{ - -namespace Internal -{ - - -/** - * Structure that contains the glyph metrics - * Font-Metrics class will create and and own this class. - * All data members are plain old data, so compiler generated copy constructor - * and assignment operator are used. - * - * - */ -struct GlyphMetric -{ - - /** - * Constructor - */ - GlyphMetric(); - - - /** - * Constructor - */ - GlyphMetric( uint32_t characterCode, - float width, - float height, - float top, - float left, - float xAdvance); - - /** - * non-virtual destructor. - */ - ~GlyphMetric(); - - /** - * Helper to return the character code of the glyph - * @return character code - */ - uint32_t GetCharacterCode() const; - - /** - * @return width of character - */ - float GetWidth() const; - - /** - * @return height of character - */ - float GetHeight() const; - - /** - * @return top of character - */ - float GetTop() const; - - /** - * @return left position of character - */ - float GetLeft() const; - - /** - * @return x advance of character - */ - float GetXAdvance() const; - -private: - - uint32_t mCode; ///< character code (UTF-32), max value of 0x10ffff (21 bits) - float mWidth; ///< glyph width in pixels - float mHeight; ///< glyph height in pixels - float mTop; ///< distance between glyph's tallest pixel and baseline - float mLeft; ///< where to place the glyph horizontally in relation to current 'pen' position - float mXAdvance; ///< distance in pixels to move the 'pen' after displaying the character - -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_FONT_METRICS_IMPL_H__ diff --git a/dali/internal/event/text/glyph-status/debug/glyph-status-container-debug.cpp b/dali/internal/event/text/glyph-status/debug/glyph-status-container-debug.cpp deleted file mode 100644 index b258f4b..0000000 --- a/dali/internal/event/text/glyph-status/debug/glyph-status-container-debug.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// HEADER -#include "glyph-status-container-debug.h" - -#ifdef DEBUG_GLYPH_STATUS_CONTAINER - -// EXTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace -{ - -void OutputStatus( const GlyphStatus& status ) -{ - switch ( status.GetLoadState() ) - { - case GlyphStatus::GLYPH_NOT_LOADED : std::cout << ", Not loaded "; break; - case GlyphStatus::GLYPH_LOAD_REQUESTED : std::cout << ", Load Requested"; break; - case GlyphStatus::GLYPH_LOW_QUALITY_LOADED_HIGH_REQUESTED : std::cout << ", Low Q loaded "; break; - case GlyphStatus::GLYPH_HIGH_QUALITY_LOADED : std::cout << ", High Q Loaded "; break; - } -} - - -unsigned int GetUsedSize( StatusSet statusSet ) -{ - unsigned int used = 0; - - for( StatusSet::iterator iter = statusSet.begin(); iter != statusSet.end(); ++iter) - { - const GlyphStatus& status( (*iter) ); - if( status.GetRefCount() > 0) - { - used++; - } - } - return used; -} - -} // un-named namespace - -void DebugGlyphContainer( unsigned int atlasSize, - StatusSet statusSet, - StatusPointerSet deadSet) -{ - std::cout <<"----- Glyph Status Container --- " << std::endl; - - for( StatusSet::iterator iter = statusSet.begin(); iter != statusSet.end(); ++iter) - { - const GlyphStatus& status( (*iter) ); - std::cout << " Character " << status.GetCharacterCode() <<" \""<< (char)status.GetCharacterCode() << "\""; - std::cout << ", Font " << status.GetFontId(); - - OutputStatus(status); - if( status.GetRefCount() ) - { - std::cout << ", Ref count: "<< status.GetRefCount() << std::endl; - } - else - { - std::cout << ", Ref count: 0 : ~DEAD~" << std::endl; - } - } - - std::cout <<" ------------------- " << std::endl; - std::cout <<" -----Dead List------ " << std::endl; - - for( StatusPointerSet::iterator iter = deadSet.begin(); iter != deadSet.end(); ++iter) - { - const GlyphStatus* status( (*iter) ); - std::cout << " Character " << status->GetCharacterCode() <<" \""<< (char)status->GetCharacterCode() << "\""; - std::cout << ", Font " << status->GetFontId(); - std::cout << ", Ref count: "<< status->GetRefCount(); - - OutputStatus(*status); - - std::cout << ", Dead Time: "<< status->GetDeadTime() << std::endl; - } - std::cout <<" ------------------- " << std::endl; - std::cout <<" Atlas Size: "<< atlasSize << ", Used Space " << GetUsedSize(statusSet); - std::cout <<", Dead size (cached): "<< deadSet.size() << std::endl; - std::cout <<" ------------------- " << std::endl; - -}; - -} // namespace Internal - -} // namespace Dali - -#endif // DEBUG_GLYPH_STATUS_CONTAINER diff --git a/dali/internal/event/text/glyph-status/debug/glyph-status-container-debug.h b/dali/internal/event/text/glyph-status/debug/glyph-status-container-debug.h deleted file mode 100644 index 4ec0090..0000000 --- a/dali/internal/event/text/glyph-status/debug/glyph-status-container-debug.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef __DALI_INTERNAL_GLYPH_STATUS_CONTAINER_DEBUG_H__ -#define __DALI_INTERNAL_GLYPH_STATUS_CONTAINER_DEBUG_H__ - -/* - * Copyright (c) 2014 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. - * - */ - -// un-comment to enable -//#define DEBUG_GLYPH_STATUS_CONTAINER - -#ifdef DEBUG_GLYPH_STATUS_CONTAINER - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -// typedefs are only defined if DEBUG_GLYPH_STATUS_CONTAINER is enabled -typedef std::set< GlyphStatus, GlyphStatus::Comparator > StatusSet; -typedef std::set< const GlyphStatus*, GlyphStatus::PointerComparator > StatusPointerSet; - -/** - * If DEBUG_GLYPH_STATUS_CONTAINER is defined, it will display - * the following whenever an item is inserted / reference /un-referenced / deleted - * - * ----- Glyph Status Container --- - * Character 46 ".", Font 0, High Q Loaded , Ref count: 0 : ~DEAD~ - * Character 72 "H", Font 0, High Q Loaded , Ref count: 1 - * Character 78 "N", Font 0, High Q Loaded , Ref count: 1 - * Character 97 "a", Font 0, High Q Loaded , Ref count: 1 - * Character 100 "d", Font 0, High Q Loaded , Ref count: 1 - * Character 101 "e", Font 0, High Q Loaded , Ref count: 2 - * Character 108 "l", Font 0, High Q Loaded , Ref count: 2 - * Character 111 "o", Font 0, High Q Loaded , Ref count: 3 - * Character 112 "p", Font 0, High Q Loaded , Ref count: 1 - * Character 114 "r", Font 0, High Q Loaded , Ref count: 0 : ~DEAD~ - * Character 116 "t", Font 0, High Q Loaded , Ref count: 1 - * Character 119 "w", Font 0, High Q Loaded , Ref count: 1 - * ------------------- - * -----Dead List------ - * Character 46 ".", Font 0, Ref count: 0, High Q Loaded , Dead Time: 0 - * Character 114 "r", Font 0, Ref count: 0, High Q Loaded , Dead Time: 1 - * ------------------- - * Atlas Size: 16, Used Space 10, Dead size (cached): 2 - * ------------------- - * - * @param atlasSize, the size of the container - * @param statusSet glyph status set - * @param deadSet set of dead glyphs - */ -void DebugGlyphContainer( unsigned int atlasSize, - StatusSet statusSet, - StatusPointerSet deadSet); - - -} // namespace Internal - -} // namespace Dali - -#endif // DEBUG_GLYPH_STATUS_CONTAINER -#endif // __DALI_INTERNAL_GLYPH_STATUS_CONTAINER_H__ diff --git a/dali/internal/event/text/glyph-status/glyph-status-container.cpp b/dali/internal/event/text/glyph-status/glyph-status-container.cpp deleted file mode 100644 index 71850da..0000000 --- a/dali/internal/event/text/glyph-status/glyph-status-container.cpp +++ /dev/null @@ -1,424 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include -#include -#include - -// EXTERNAL INCLUDES -#include // std::sort - -namespace Dali -{ - -namespace Internal -{ - -namespace // un-named namespace -{ - -/** - * @return the unique characters in a text array - */ -Integration::TextArray GetUniqueCharacters( const Integration::TextArray &text ) -{ - Integration::TextArray utfCodes( text ); - - std::sort( utfCodes.Begin(), utfCodes.End() ); - Integration::TextArray::Iterator it = std::unique( utfCodes.Begin(), utfCodes.End() ); - utfCodes.Resize(it - utfCodes.Begin()); - return utfCodes; -} - -} // un-named namespace - -GlyphStatusContainer::GlyphStatusContainer( unsigned int numberOfCharacters ) -: mContainerSize( numberOfCharacters ), - mEmptySpace( numberOfCharacters ), - mCharacterLookup( GlyphStatus::CharCodeAndFontComparator ), - mDeadCharacters( GlyphStatus::DeadTimeComparator ), - mTimeStamp( 0 ) -{ - // make sure the dead time has enough range - // to handle every item in the atlas being dead ( cached). - DALI_ASSERT_DEBUG( GlyphStatus::GetMaximumDeadTime() > numberOfCharacters ); -} - -GlyphStatusContainer::~GlyphStatusContainer() -{ -#ifdef DEBUG_ENABLED - // Check every character has ref-count of zero - StatusSet::const_iterator endIter = mCharacterLookup.end(); - - for( StatusSet::iterator iter = mCharacterLookup.begin(); iter != endIter; ++iter) - { - const GlyphStatus& status( (*iter) ); - if(status.GetRefCount()) - { - DALI_LOG_ERROR("glyph still referenced (leaking)"); - } - } -#endif -} - -void GlyphStatusContainer::IncreaseRefCount( uint32_t charCode, FontId fontId) -{ - const GlyphStatus& status = GetStatus( charCode, fontId ); - - if( status.GetRefCount() == 0 ) - { - // if ref-count == zero, then it will have previously been added to the dead characters list. - // which means nothing is using it, but it's distance field is still loaded in to the texture atlas. - // As it is now been used, remove it from the dead list - RemoveDeadCharacter( &status); - } - - status.IncreaseRefCount(); // increase the reference count - -#ifdef DEBUG_GLYPH_STATUS_CONTAINER - DebugGlyphContainer( mContainerSize, mCharacterLookup, mDeadCharacters ); -#endif - -} - -void GlyphStatusContainer::DecreaseRefCount( uint32_t charCode, FontId fontId) -{ - if( charCode < SpecialCharacters::FIRST_VISIBLE_CHAR ) - { - return; - } - - const GlyphStatus* status = FindGlyphStatus( charCode, fontId ); - - if( status == NULL) - { - DALI_LOG_ERROR("Glyph not found in container %d, font %d\n",charCode, fontId); - DALI_ASSERT_ALWAYS( status && "glyph not found (dec)"); - } - - status->DecreaseRefCount(); - - // if it's got a ref count of zero, then it's no longer used. - // Add it to the dead list. - if( status->GetRefCount() == 0 ) - { - AddDeadCharacter( status ); - } - -#ifdef DEBUG_GLYPH_STATUS_CONTAINER - DebugGlyphContainer( mContainerSize, mCharacterLookup, mDeadCharacters ); -#endif -} - -GlyphStatusContainer::InsertResult GlyphStatusContainer::InsertNewCharacter( uint32_t charCode, FontId fontId, unsigned int& deadUniqueId ) -{ - // if there's free space, use it. - if( mEmptySpace > 0 ) - { - mEmptySpace--; - - InsertCharacterIntoLookup( charCode, fontId ); - - return INSERTED_OK; - } - else - { - // there's no empty space, only used and cached space - // the new character has to replace an existing un-used character in the texture atlas - - DALI_ASSERT_ALWAYS( ( mDeadCharacters.empty() == false ) && "no glyph container space"); - - // Erase the oldest character from dead character list. - const GlyphStatus* deadCharacter = RemoveOldestDeadCharacter(); - - // get the unique id, so the caller knows which character was deleted - deadUniqueId = deadCharacter->GetUniqueId(); - - // erase it from the lookup. - mCharacterLookup.erase( *deadCharacter ); - - // insert the new one - InsertCharacterIntoLookup( charCode, fontId ); - - DALI_ASSERT_DEBUG( mEmptySpace == (mContainerSize - mCharacterLookup.size())); - - return REPLACE_DEAD_CHARACTER; - } -} - -const GlyphStatus* GlyphStatusContainer::FindGlyphStatus( uint32_t charCode, FontId fontId) const -{ - GlyphStatus searchStatus( charCode, fontId ); - - StatusSet::iterator iter = mCharacterLookup.find( searchStatus ) ; - - if( iter == mCharacterLookup.end() ) - { - return NULL; - } - else - { - return &(*iter); - } -} - -const GlyphStatus& GlyphStatusContainer::GetStatus( uint32_t charCode, FontId fontId ) const -{ - const GlyphStatus* status = FindGlyphStatus( charCode, fontId ); - - DALI_ASSERT_ALWAYS( status!= NULL && "glyph status code not found" ); - - return *status; -} - -const GlyphStatusContainer::StatusSet& GlyphStatusContainer::GetStatusSet() const -{ - return mCharacterLookup; -} - -bool GlyphStatusContainer::IsTextLoaded( const Integration::TextArray& text, FontId fontId ) const -{ - for( Integration::TextArray::ConstIterator it = text.Begin(), endIt = text.End(); it != endIt; ++it ) - { - const uint32_t charCode = *it; - - // ignore invisible characters - if( charCode < SpecialCharacters::FIRST_VISIBLE_CHAR ) - { - continue; - } - const GlyphStatus& status = GetStatus( charCode, fontId ); - - if( status.IsUploadedToTexture() == false ) - { - return false; - } - } - return true; -} - -void GlyphStatusContainer::GetTextStatus( const Integration::TextArray& text, - FontId fontId, - unsigned int& charsNotLoaded, - bool& fitsInContainer ) const -{ - charsNotLoaded = 0; - fitsInContainer = false; - - Integration::TextArray uniqueText = GetUniqueCharacters( text ); - - for( Integration::TextArray::ConstIterator it = text.Begin(), endIt = text.End(); it != endIt; ++it ) - { - const uint32_t charCode = *it; - - // ignore invisible characters - if( charCode < SpecialCharacters::FIRST_VISIBLE_CHAR ) - { - continue; - } - - const GlyphStatus* status = FindGlyphStatus( charCode, fontId ); - - // check if the glyph exists in the container and isn't marked as dead ( ref = 0) - if( (status == NULL ) || (status->GetRefCount() == 0) ) - { - charsNotLoaded++; - } - } - - // total available space = free space + space used by dead characters that can be used - if( charsNotLoaded <= TotalAvailableSpace() ) - { - fitsInContainer = true; - } -} - -void GlyphStatusContainer::CloneContents( const GlyphStatusContainer& clone ) -{ - // copy the lookup - mCharacterLookup = clone.mCharacterLookup; - - - // adjust the size - mEmptySpace-= mCharacterLookup.size(); - - // for each entry set the loaded status - - StatusSet::const_iterator endIter = mCharacterLookup.end(); - for( StatusSet::iterator iter = mCharacterLookup.begin(); iter != endIter; ++iter) - { - const GlyphStatus& status = (*iter); - - status.SetLoadStatus( GlyphStatus::GLYPH_NOT_LOADED); - status.SetTextureStatus( GlyphStatus::GLYPH_NOT_UPLOADED_TO_TEXTURE ); - } -} - - -void GlyphStatusContainer::GetDeadCharacters( Integration::TextArray& deadList ) -{ - deadList.Reserve( mDeadCharacters.size() ); - - // iterate through the dead character list - - StatusPointerSet::const_iterator endIter = mDeadCharacters.end(); - for( StatusPointerSet::iterator iter = mDeadCharacters.begin(); iter != endIter; ++iter ) - { - const GlyphStatus* glyphStatus(*iter); - deadList.PushBack( glyphStatus->GetUniqueId()); - } - -} - -void GlyphStatusContainer::ClearDeadCharacters() -{ - // iterate through the dead character list, and erase all dead characters from - // the main lookup. - - StatusPointerSet::const_iterator endIter = mDeadCharacters.end(); - for( StatusPointerSet::iterator iter = mDeadCharacters.begin(); iter != endIter; ++iter ) - { - const GlyphStatus* glyphStatus(*iter); - DALI_ASSERT_DEBUG( glyphStatus->GetRefCount() == 0 && "dead character found with ref > 0?"); - mCharacterLookup.erase( *glyphStatus ); - } - - // clear the dead characters - mDeadCharacters.clear(); -} - -bool GlyphStatusContainer::Empty() const -{ - return ( mContainerSize ==TotalAvailableSpace() ); -} - -unsigned int GlyphStatusContainer::GetSize() const -{ - return mContainerSize; -} - -void GlyphStatusContainer::ClearContents() -{ - mCharacterLookup.clear(); - mDeadCharacters.clear(); - mEmptySpace = mContainerSize; - mTimeStamp = 0; -} - -void GlyphStatusContainer::AddDeadCharacter( const GlyphStatus* deadCharacter) -{ - - if( mTimeStamp >= GlyphStatus::GetMaximumDeadTime() ) - { - // the counter has reached the maximum. reset to 0 - ResetTimeStamps(); - } - - // set the time stamp - deadCharacter->SetDeadTime( mTimeStamp++ ); - - // add a pointer to the list, the original data is still held in mCharacterLookup - mDeadCharacters.insert( deadCharacter ); - -} -void GlyphStatusContainer::RemoveDeadCharacter( const GlyphStatus* deadCharacter ) -{ - DALI_ASSERT_DEBUG( mDeadCharacters.find(deadCharacter) != mDeadCharacters.end() ); - - mDeadCharacters.erase( deadCharacter ); -} - -const GlyphStatus* GlyphStatusContainer::RemoveOldestDeadCharacter() -{ - // oldest item, is the first in the set - StatusPointerSet::iterator iter = mDeadCharacters.begin(); - - // calling code will assert before this ever happens - // added to prevent a klocwork warning - if( iter == mDeadCharacters.end() ) - { - return NULL; - } - - const GlyphStatus* glyphStatus = (*iter); - - // remove it from the list - mDeadCharacters.erase( glyphStatus ); - - return glyphStatus; -} - -void GlyphStatusContainer::InsertCharacterIntoLookup(uint32_t charCode, FontId fontId ) -{ - // create a glyph status and set to low quality requested - GlyphStatus status( charCode, fontId, GlyphStatus::GLYPH_LOAD_REQUESTED ); - - // reference it - status.IncreaseRefCount(); - - // add to the lookup - mCharacterLookup.insert( status ); - -#ifdef DEBUG_GLYPH_STATUS_CONTAINER - DebugGlyphContainer( mContainerSize, mCharacterLookup, mDeadCharacters ); -#endif -} - -void GlyphStatusContainer::ResetTimeStamps() -{ - // This should only happen when we've had the reference-count of character(s) hit - // zero 16,384 times (GlyphStatus::GetMaximumDeadTime()) - - // Set the time stamp back to zero - // - mTimeStamp = 0; - - // The dead list is sorted from oldest -> newest. - // We go through the list setting the time stamps from Zero -> Number of items - // - // E.g. if the list was this - // - // 'C' TimeStamp 3500, 'Y' TimeStamp 5604, 'A' = TimeStamp 8000 - // - // The list will be set to - // - // 'C' TimeStamp 0, 'Y' TimeStamp 1, 'A' = TimeStamp 2 - // - - StatusPointerSet::const_iterator endIter = mDeadCharacters.end(); - for( StatusPointerSet::iterator iter = mDeadCharacters.begin(); iter != endIter; ++iter ) - { - const GlyphStatus* glyphStatus(*iter); - glyphStatus->SetDeadTime( mTimeStamp++); - } -} - -unsigned int GlyphStatusContainer::TotalAvailableSpace() const -{ - // return number of un-used spaces, and number of spaces - // that have been used, but arean't any more. - return ( mEmptySpace + mDeadCharacters.size() ); -} - -} // namespace Internal - -} // namespace Dali - diff --git a/dali/internal/event/text/glyph-status/glyph-status-container.h b/dali/internal/event/text/glyph-status/glyph-status-container.h deleted file mode 100644 index 76537e3..0000000 --- a/dali/internal/event/text/glyph-status/glyph-status-container.h +++ /dev/null @@ -1,241 +0,0 @@ -#ifndef __DALI_INTERNAL_GLYPH_STATUS_CONTAINER_H__ -#define __DALI_INTERNAL_GLYPH_STATUS_CONTAINER_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * - * Maintains a set of reference counted characters (glyph status objects). - * The glyph status objects are sorted by character code and font id. - * - * The class provides an API for inserting glyph status objects into - * the container and increasing / decreasing their reference count. - * - * Once a glyph status object reaches a ref count = 0, it remains in - * the container, but a pointer to it is added to the mDeadCharacters list. - * The dead character list is sorted by dead time. - * - * If new glyph objects are inserted when the container is full, - * dead characters (ref = 0) are replaced, starting with the oldest first. - * - * To see what is happening on the console, enable DEBUG_GLYPH_STATUS_CONTAINER in - * glyph-status-container-debug.h - * - */ -class GlyphStatusContainer -{ - -public: - - /** - * Constructor - * @param numberOfCharacters how many characters the container should hold - */ - GlyphStatusContainer( unsigned int numberOfCharacters ); - - /** - * destructor, non-virtual not intended as a base class. - */ - ~GlyphStatusContainer(); - - /** - * Increase the reference count of a character - * @param[in] character code - * @param[in] font id - */ - void IncreaseRefCount( uint32_t charCode, FontId fontId); - - /** - * @param[in] charCode character code - * @param[in] fontId font id - */ - void DecreaseRefCount( uint32_t charCode, FontId fontId); - - /** - * enum to represent the result of a character insertion. - */ - enum InsertResult - { - INSERTED_OK, ///< character was inserted in to an empty space - REPLACE_DEAD_CHARACTER, ///< character replaced a cached dead character. - }; - - /** - * Insert a new character in to the container - * @param[in] charCode character code - * @param[in] fontId font id - * @param[out] deadUniqueId the id of a dead character, if one was replaced - * @return insertion result - */ - InsertResult InsertNewCharacter( uint32_t charCode, FontId fontId, unsigned int& deadUniqueId ); - - /** - * Find the glyph status object given a character code and font id - * @param[in] charCode character code - * @param[in] fontId font id - * @return glyph status object if it exists, NULL if it doesn't - */ - const GlyphStatus* FindGlyphStatus( uint32_t charCode, FontId fontId) const; - - /** - * Return a reference to a glyph status object given a character code and font id - * @param[in] charCode character code - * @param[in] fontId font id - * @return glyph status object - */ - const GlyphStatus& GetStatus( uint32_t charCode, FontId fontId) const; - - /** - * Status set typedef. Uses a custom sort function to sort by character code and font id - */ - typedef std::set< GlyphStatus, GlyphStatus::Comparator > StatusSet; - - /** - * Get the glyph status set - * @todo find a better solution than allowing direct access to the set - * @return the glyph status set - */ - const StatusSet& GetStatusSet() const; - - /** - * Check if all characters in a text array are marked as loaded - * @param[in] text the text array - * @param[in] fontId font id - * @return true if all characters are loaded false if not - */ - bool IsTextLoaded( const Integration::TextArray& text, FontId fontId) const; - - /** - * Given a text array, find how many character are loaded and - * whether it will fit in to the container. - * @param[in] text the text array - * @param[in] fontId font id - * @param[out] charsNotLoaded how many characters are not loaded - * @param[out] fitsInContainer whether the text fits in the container - */ - void GetTextStatus( const Integration::TextArray& text, - FontId fontId, - unsigned int& charsNotLoaded, - bool& fitsInContainer ) const; - - /** - * Clone the contents of one container, into this container - * @param[in] clone the container to clone - */ - void CloneContents( const GlyphStatusContainer& clone ); - - /** - * Get the list of dead characters - * @param[out] deadList to be filled with a list of dead characters - */ - void GetDeadCharacters( Integration::TextArray& deadList ); - - /** - * Clear dead characters. - */ - void ClearDeadCharacters(); - - /** - * Check if the container is empty - * @return true if container is empty - */ - bool Empty() const; - - /** - * @return the container size - */ - unsigned int GetSize() const; - - /** - * Clear the container contents. - */ - void ClearContents(); - -private: - - /** - * Add a character to the dead character list - * @param[in] deadCharacter dead character - */ - void AddDeadCharacter( const GlyphStatus* deadCharacter); - - /** - * Remove a character from the dead character list. - * This happens if a characters reference count goes from 0 -> 1. - * @param[in] deadCharacter dead character - */ - void RemoveDeadCharacter( const GlyphStatus* deadCharacter ); - - /** - * Remove the oldest dead character - * @return oldest dead character - */ - const GlyphStatus* RemoveOldestDeadCharacter( ); - - /** - * Insert a character in to the lookup - * @param[in] charCode character code - * @param[in] fontId font id - */ - void InsertCharacterIntoLookup(uint32_t charCode, FontId fontId ); - - /** - * Reset the dead time stamps of all glyph objects in the - * dead character list. This is called when mTimeStamp value reaches - * GlyphStatus::GetMaximumDeadTime() - */ - void ResetTimeStamps(); - - /** - * Get the total available space in the container. - * This is empty space + space used by dead characters that can be replaced - * @return total space - */ - unsigned int TotalAvailableSpace() const; - - unsigned int mContainerSize; ///< container size - unsigned int mEmptySpace; ///< amount of space that is empty (has never been used) - - /** - * Status pointer set typedef, sorted by custom function - */ - typedef std::set< const GlyphStatus*, GlyphStatus::PointerComparator > StatusPointerSet; - - StatusSet mCharacterLookup; ///< set of glyph status objects sorted by font id and character code - StatusPointerSet mDeadCharacters; ///< set of characters with a ref count of zero, which are still cached. - unsigned int mTimeStamp; ///< current time stamp - -}; - - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_GLYPH_STATUS_CONTAINER_H__ diff --git a/dali/internal/event/text/glyph-status/glyph-status.cpp b/dali/internal/event/text/glyph-status/glyph-status.cpp deleted file mode 100644 index 8f5061c..0000000 --- a/dali/internal/event/text/glyph-status/glyph-status.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ -namespace -{ -const unsigned int MAX_NUMBER_FONTS_SUPPORTED = 0x7FF; ///< total number of font/style combinations Dali can support -const unsigned int MAX_UNICODE_VALUE = 0x10FFFF; ///< maximum unicode value -const unsigned int MAX_DEAD_TIME = 16384; ///< restricted to 14 bits for dead time counter - -} - -GlyphStatus::GlyphStatus() -:mCharacterCode(0), -mFontId( 0 ), -mDeadTime( 0 ), -mLoadState( GLYPH_NOT_LOADED ), -mTextureState( GLYPH_NOT_UPLOADED_TO_TEXTURE ), -mReferenceCount( 0 ) -{ -} - -GlyphStatus::~GlyphStatus() -{ -} - -GlyphStatus::GlyphStatus( unsigned int characterCode, - FontId fontId, - LoadState loadStatus) - :mCharacterCode( characterCode ), - mFontId( fontId ), - mDeadTime( 0 ), - mLoadState( loadStatus ), - mTextureState( GLYPH_NOT_UPLOADED_TO_TEXTURE ), - mReferenceCount( 0 ) -{ -} - -// copy constructor -GlyphStatus::GlyphStatus( const GlyphStatus& rhs) -:mCharacterCode( rhs.mCharacterCode ), - mFontId( rhs.mFontId ), - mDeadTime( rhs.mDeadTime ), - mLoadState( rhs.mLoadState ), - mTextureState( rhs.mTextureState ), - mReferenceCount( rhs.mReferenceCount ) -{ -} - -// assignment operator -GlyphStatus& GlyphStatus::operator=( const GlyphStatus& rhs ) -{ - mCharacterCode = rhs.mCharacterCode; - mFontId = rhs.mFontId; - mDeadTime = rhs.mDeadTime; - mLoadState = rhs.mLoadState; - mTextureState = rhs.mTextureState; - mReferenceCount = rhs.mReferenceCount; - return *this; -} - -unsigned int GlyphStatus::GetCharacterCode() const -{ - return mCharacterCode; -} - -unsigned int GlyphStatus::GetUniqueId() const -{ - return GetEncodedValue( mCharacterCode, mFontId); -} - -void GlyphStatus::IncreaseRefCount() const -{ - mReferenceCount++; -} - -void GlyphStatus::DecreaseRefCount() const -{ - DALI_ASSERT_DEBUG( mReferenceCount!= 0 ); - - mReferenceCount--; -} - -void GlyphStatus::ResetRefCount() const -{ - mReferenceCount = 0; -} - -unsigned int GlyphStatus::GetRefCount() const -{ - return mReferenceCount; -} - -GlyphStatus::LoadState GlyphStatus::GetLoadState() const -{ - return mLoadState; -} - -bool GlyphStatus::IsLoadRequested() const -{ - return ((mLoadState == GLYPH_LOAD_REQUESTED) || (mLoadState == GLYPH_LOW_QUALITY_LOADED_HIGH_REQUESTED)); -} - -bool GlyphStatus::IsUploadedToTexture() const -{ - return (mTextureState == GLYPH_UPLOADED_TO_TEXTURE); -} - -FontId GlyphStatus::GetFontId() const -{ - return mFontId; -} - -void GlyphStatus::SetLoadStatus( GlyphStatus::LoadState loadState ) const -{ - mLoadState = loadState; - -} -void GlyphStatus::SetTextureStatus( GlyphStatus::TextureState textureState ) const -{ - mTextureState = textureState; -} - -unsigned int GlyphStatus::GetDeadTime() const -{ - return mDeadTime; -} - -void GlyphStatus::SetDeadTime( unsigned int deadTime ) const -{ - DALI_ASSERT_ALWAYS( deadTime < MAX_DEAD_TIME ); - mDeadTime = deadTime; -} - -unsigned int GlyphStatus::GetEncodedValue( unsigned int code, FontId fontId ) -{ - DALI_ASSERT_ALWAYS( (fontId < MAX_NUMBER_FONTS_SUPPORTED ) && (code < MAX_UNICODE_VALUE) ); - - // encoded value is a combination of the character code and font id - // - // We can do this because unicode values only go up to 0x10FFFF - // and the font id is a zero based counter, limited to 2048 fonts. - // - // So format is: - // - // bit 0 bit 31 - // | | | - // | font id (11 bits) | character code (21 bits) | - // | | | - - unsigned int combined = (code<<11) | fontId ; - return combined; -} - -void GlyphStatus::GetDecodedValue( unsigned int encodedValue, unsigned int& code, FontId& fontId ) -{ - code = encodedValue >> 11; - fontId = encodedValue & MAX_NUMBER_FONTS_SUPPORTED; -} - -unsigned int GlyphStatus::GetMaximumDeadTime() -{ - return MAX_DEAD_TIME; -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/glyph-status/glyph-status.h b/dali/internal/event/text/glyph-status/glyph-status.h deleted file mode 100644 index 3c551aa..0000000 --- a/dali/internal/event/text/glyph-status/glyph-status.h +++ /dev/null @@ -1,255 +0,0 @@ -#ifndef __DALI_INTERNAL_GLYPH_STATUS_H__ -#define __DALI_INTERNAL_GLYPH_STATUS_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * Structure that contains the glyph metrics and the glyph loaded status. - * All data members are plain old data. Data size = 8 bytes. - */ -struct GlyphStatus -{ - - /** - * The load status of the glyph - */ - enum LoadState - { - GLYPH_NOT_LOADED = 0, ///< the glyphs bitmap has not been loaded - GLYPH_LOAD_REQUESTED = 1, ///< load has been requested - GLYPH_LOW_QUALITY_LOADED_HIGH_REQUESTED = 2, ///< low loaded, high requested - GLYPH_HIGH_QUALITY_LOADED = 3, ///< the glyphs high quality bitmap has been loaded - }; - - /** - * The texture state of the glyph - */ - enum TextureState - { - GLYPH_NOT_UPLOADED_TO_TEXTURE = 0, ///< the glyph has not been uploaded to gl - GLYPH_UPLOADED_TO_TEXTURE = 1, ///< the glyph has been uploaded to gl - }; - - /** - * Constructor - */ - GlyphStatus(); - - /** - * non-virtual destructor, not intended as a base class - */ - ~GlyphStatus(); - - /** - * Constructor - * @param[in] characterCode character code - * @param[in] fontId font identifier - * @param[in] loadStatus load status - */ - GlyphStatus( unsigned int characterCode, - FontId fontId, - LoadState loadStatus = GLYPH_NOT_LOADED); - - /** - * Copy constructor. - */ - GlyphStatus( const GlyphStatus& rhs); - - /** - * Assignment operator - */ - GlyphStatus& operator=( const GlyphStatus& ); - - /** - * Helper to return the character code of the glyph - * @return character code - */ - unsigned int GetCharacterCode() const; - - /** - * Get the unique id which is combination of character code and font id - * @return unique id - */ - unsigned int GetUniqueId() const; - - /** - * Increase the reference count - */ - void IncreaseRefCount() const; - - /** - * Decrease the reference count - */ - void DecreaseRefCount() const; - - /** - * Set the reference count to zero - */ - void ResetRefCount() const; - - /** - * Gets the reference count - * @return the reference count - */ - unsigned int GetRefCount() const; - - /** - * Gets the status of the glyph - * @return glyph status - */ - LoadState GetLoadState() const; - - /** - * Returns if status == low or high quality requested - * @return true if a load is requested - */ - bool IsLoadRequested() const; - - /** - * Returns if the status == Low or High quality uploaded to GL - * @return true if a load is requested - */ - bool IsUploadedToTexture() const; - - /** - * Gets the font id - * @return font id, this character belongs to - */ - FontId GetFontId() const; - - /** - * Set the glyph load status - * @param[in] loadState glyph load status - */ - void SetLoadStatus( LoadState loadState ) const; - - /** - * Set the glyph texture status - * @param[in] textureState glyph texture status - */ - void SetTextureStatus( TextureState textureState ) const; - - /** - * Return the dead time. - * The dead time, is just a counter representing when the object - * died. E.g if x has dead time of 10, and y has dead time of 20, - * then x has been dead the longest. - * @return the dead time - */ - unsigned int GetDeadTime() const; - - /** - * Set the dead time. - * @param[in] deadTime the dead time - */ - void SetDeadTime( unsigned int deadTime ) const; - - /** - * Given a character code and a font id, return - * a single value which is a combination of both of them - * @param[in] code character code - * @param[in] fontId font id - * @return encoded value - */ - static unsigned int GetEncodedValue( unsigned int code, FontId fontId ); - - /** - * Given an encoded value return the font id, and character code - * @param[in] encoded value ( combination of character code and font id) - * @param[out] code character code - * @param[out] font font id - */ - static void GetDecodedValue( unsigned int encodedValue, unsigned int& code, FontId& fontId ); - - /** - * Get the maximum dead time supported. - * Currently glyph status uses a 14 bit counter. - * @return maximum dead time - */ - static unsigned int GetMaximumDeadTime(); - - /** - * Comparator function for sorting glyph status objects by - * font id and then character code. - * To be used with stl containers, like std::set, and std::map. - */ - static bool CharCodeAndFontComparator( const GlyphStatus& lhs, const GlyphStatus& rhs) - { - if( lhs.GetFontId() != rhs.GetFontId() ) - { - return lhs.GetFontId() < rhs.GetFontId(); - } - return lhs.GetCharacterCode() < rhs.GetCharacterCode(); - }; - - /** - * Comparator function for sorting glyph status objects by - * how long they have been dead. - * To be used with stl containers, like std::set, and std::map. - */ - static bool DeadTimeComparator( const GlyphStatus* lhs, const GlyphStatus* rhs ) - { - // we want the oldest to be first in the set - return lhs->GetDeadTime() < rhs->GetDeadTime(); - } - - /** - * typedef compare function pointer, to compare by reference - */ - typedef bool(*Comparator) ( const GlyphStatus& lhs, const GlyphStatus& rhs); - - /** - * typedef compare function pointer, to compare by pointer - */ - typedef bool(*PointerComparator) ( const GlyphStatus* lhs, const GlyphStatus* rhs); - -private: - - // 32 bits for character code and unique font id. - unsigned int mCharacterCode:21; ///< character code - unsigned int mFontId:11; ///< unique font id, support 2048 font files - - /* - * When held in a std::set, character code and font id can be used to sort the item. - * A set only allows const access to elements, so dead time, status and ref count - * are all mutable, to allow adjustment without having to to erase / re-insert the item. - * - * Dead time is currently 14bits = maximum of 16,384 characters in the atlas - * which aren't currently used, but are held in the glTexture. - */ - mutable unsigned int mDeadTime:14; ///< Used to determine which un-refenced characters have been dead the longest (16384) - mutable LoadState mLoadState:2; ///< character load state - mutable TextureState mTextureState:1; ///< character texture state - mutable unsigned int mReferenceCount:12; ///< maximum number of references = 4096 - -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_GLYPH_STATUS_H__ diff --git a/dali/internal/event/text/resource/debug/glyph-resource-debug.cpp b/dali/internal/event/text/resource/debug/glyph-resource-debug.cpp deleted file mode 100644 index ae09422..0000000 --- a/dali/internal/event/text/resource/debug/glyph-resource-debug.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL HEADERS - -// EXTERNAL HEADERS -#include - -namespace Dali -{ -namespace Internal -{ - -#if defined(DEBUG_ENABLED) -Debug::Filter* gTextLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_GLYPH_RESOURCE"); - -std::string DebugCharacterString(const GlyphResourceRequest::CharacterList& characterList) -{ - std::string textString; - - for(std::size_t i=0, length=characterList.size(); i(characterList[i].character) << "(" << characterList[i].xPosition << "," << characterList[i].yPosition << ") "; - textString.append(oss.str()); - } - return textString; -} - -std::string DebugCharacterString(const Integration::GlyphSet& glyphSet) -{ - std::string textString; - const Integration::GlyphSet::CharacterList& charList = glyphSet.GetCharacterList(); - - for(std::size_t i=0, length=charList.size(); i(gm.code) << "(" << gm.xPosition << "," << gm.yPosition - << " " << (gm.quality?"H":"L") << ") "; - textString.append(oss.str()); - } - return textString; -} - -#endif - -} // namespace Internal -} // namespace Dali diff --git a/dali/internal/event/text/resource/debug/glyph-resource-debug.h b/dali/internal/event/text/resource/debug/glyph-resource-debug.h deleted file mode 100644 index 68e23b5..0000000 --- a/dali/internal/event/text/resource/debug/glyph-resource-debug.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _DALI_INTERNAL_GLYPH_RESOURCE_DEBUG_H_ -#define _DALI_INTERNAL_GLYPH_RESOURCE_DEBUG_H_ -/* - * Copyright (c) 2014 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. - * - */ - -#include -#include -#include - -namespace Dali -{ -namespace Internal -{ - -#if defined(DEBUG_ENABLED) - -extern Debug::Filter* gTextLogFilter; - -std::string DebugCharacterString(const GlyphResourceRequest::CharacterList& characterList); -std::string DebugCharacterString(const Integration::GlyphSet& glyphSet); - -#endif - -} // namespace Internal -} // namespace Dali - -#endif // _DALI_INTERNAL_GLYPH_RESOURCE_DEBUG_H_ diff --git a/dali/internal/event/text/resource/font-id.h b/dali/internal/event/text/resource/font-id.h deleted file mode 100644 index 65a656d..0000000 --- a/dali/internal/event/text/resource/font-id.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __DALI_INTERNAL_FONT_ID_H__ -#define __DALI_INTERNAL_FONT_ID_H__ - -/* - * Copyright (c) 2014 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. - * - */ - - - -namespace Dali -{ - -namespace Internal -{ - -/** - * unique identifier for a font. - * This is zero based, so the first font loaded by Dali will be zero. - * - */ -typedef unsigned short FontId; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_FONT_ID_H__ diff --git a/dali/internal/event/text/resource/font-lookup-interface.h b/dali/internal/event/text/resource/font-lookup-interface.h deleted file mode 100644 index 1fe6a52..0000000 --- a/dali/internal/event/text/resource/font-lookup-interface.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef __DALI_INTERNAL_FONT_LOOKUP_INTERFACE_H__ -#define __DALI_INTERNAL_FONT_LOOKUP_INTERFACE_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * Abstract interface for requesting font information given a unique font id. - * - */ -class FontLookupInterface -{ - -public: - - /** - * Given a font id, get the font information. - * @param[in] fontId font id - * @param[out] family font family - * @param[out] style font style - * @param[out] maxGlyphWidth maximum glyph width - * @param[out] maxGlyphHeight maximum glyph height - */ - virtual void GetFontInformation( FontId fontId, - std::string& family, - std::string& style, - float& maxGlyphWidth, - float& maxGlyphHeight ) const = 0; - - -protected: - - /** - * Constructor - */ - FontLookupInterface() - { - } - - /** - * Virtual Destructor. - */ - virtual ~FontLookupInterface() - { - } - - // Undefined copy constructor. - FontLookupInterface( const FontLookupInterface& ); - - // Undefined assignment operator. - FontLookupInterface& operator=( const FontLookupInterface& ); - -}; - - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_FONT_LOOKUP_INTERFACE_H__ diff --git a/dali/internal/event/text/resource/glyph-load-observer.h b/dali/internal/event/text/resource/glyph-load-observer.h deleted file mode 100644 index c59b56d..0000000 --- a/dali/internal/event/text/resource/glyph-load-observer.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef __DALI_INTERNAL_GLYPH_LOAD_OBSERVER_H__ -#define __DALI_INTERNAL_GLYPH_LOAD_OBSERVER_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include // for ResourceId -#include // for glyph set - -namespace Dali -{ - -namespace Internal -{ - -/** - * Abstract observer class to inform the owner that some glyph have been loaded. - * - */ -class GlyphLoadObserver -{ - -public: - - /** - * Called when a glyphset has been loaded. - * The resoure id is the ticket id for the original request. - * @param[in] id resource id - * @param[in] glyphSet reference to the glyphset - * @param[in] complete if this is the last glyph set - */ - virtual void GlyphsLoaded( Integration::ResourceId id, const Integration::GlyphSet& glyphSet, Integration::LoadStatus loadStatus ) = 0; - - -protected: - - /** - * Constructor - */ - GlyphLoadObserver() - { - - } - - /** - * Destructor. - */ - virtual ~GlyphLoadObserver() - { - - } - -private: - - // Undefined copy constructor. - GlyphLoadObserver( const GlyphLoadObserver& ); - - // Undefined assignment operator. - GlyphLoadObserver& operator=( const GlyphLoadObserver& ); - -}; - - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_GLYPH_LOAD_OBSERVER_H__ diff --git a/dali/internal/event/text/resource/glyph-resource-manager.cpp b/dali/internal/event/text/resource/glyph-resource-manager.cpp deleted file mode 100644 index 0d4513e..0000000 --- a/dali/internal/event/text/resource/glyph-resource-manager.cpp +++ /dev/null @@ -1,415 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - - -// CLASS HEADER -#include "glyph-resource-manager.h" - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include - -using namespace Dali::Integration; - -namespace Dali -{ - -namespace Internal -{ - -namespace -{ -/** - * Convert the quality level into a loaded status - */ -GlyphResourceObserver::Quality GetGlyphStatus( unsigned int quality ) -{ - if( quality == Integration::GlyphMetrics::LOW_QUALITY) - { - return GlyphResourceObserver::LOW_QUALITY_LOADED; - } - else - { - return GlyphResourceObserver::HIGH_QUALITY_LOADED; - } -} -} // un-named namespace - -GlyphResourceManager::GlyphResourceManager( const FontLookupInterface& fontLookup ) -:mFontLookup( fontLookup ), - mResourceClient( ThreadLocalStorage::Get().GetResourceClient() ) -{ -} - -GlyphResourceManager::~GlyphResourceManager() -{ - -} - -unsigned int GlyphResourceManager::CreateTexture(unsigned int size ) -{ - // create a new texture. Using Alpha 8 = 1 byte per pixel - ResourceTicketPtr ticket = mResourceClient.AllocateTexture( size, size, Pixel::A8 ); - - mTextureTickets.push_back( ticket ); - - // return the texture id - return ticket->GetId(); -} - -void GlyphResourceManager::AddObserver( GlyphResourceObserver& observer) -{ - DALI_ASSERT_DEBUG( ( mObservers.find( &observer ) == mObservers.end() ) && "Observer already exists"); - mObservers.insert( &observer ); -} - -void GlyphResourceManager::RemoveObserver( GlyphResourceObserver& observer) -{ - DALI_ASSERT_DEBUG( ( mObservers.find( &observer ) != mObservers.end() ) && "Observer not found"); - mObservers.erase( &observer ); -} - -void GlyphResourceManager::AddTextObserver( TextObserver& observer) -{ - DALI_ASSERT_DEBUG( ( mTextObservers.find( &observer ) == mTextObservers.end() ) && "Observer already exists"); - mTextObservers.insert( &observer ); -} - -void GlyphResourceManager::RemoveTextObserver( TextObserver& observer) -{ - DALI_ASSERT_DEBUG( ( mTextObservers.find( &observer ) != mTextObservers.end() ) && "Observer doesn't exists"); - mTextObservers.erase( &observer ); -} - - -void GlyphResourceManager::AddRequests( const GlyphRequestList& requestList, - GlyphResourceObserver& observer, - ResourceId atlasTextureId) -{ - // each entry in the request list is for a specific font, - // style, quality and a list of characters - for( std::size_t n = 0, size = requestList.size(); n < size ; ++n ) - { - const GlyphResourceRequest& request( requestList[n] ); - SendRequests( request, observer, atlasTextureId ); - } - -} - -void GlyphResourceManager::GlyphsLoaded( Integration::ResourceId id, const Integration::GlyphSet& glyphSet, LoadStatus loadStatus ) -{ - // Get the the observer - GlyphResourceObserver* observer = GetObserver( id ); - - DALI_LOG_INFO( gTextLogFilter, Debug::General, - "GlyphResourceManager::GlyphsLoaded: id:%d, status:%s textureId:%d observer:%p\n", - id, - loadStatus==RESOURCE_LOADING?"LOADING":loadStatus==RESOURCE_PARTIALLY_LOADED?"PARTIAL":"COMPLETED", - glyphSet.GetAtlasResourceId(), - observer); - - DALI_LOG_INFO( gTextLogFilter, Debug::Verbose, "GlyphResourceManager::GlyphsLoaded: %s\n", DebugCharacterString(glyphSet).c_str() ); - - if( observer ) - { - FontId fontId = glyphSet.mFontHash; - - // Stage 1. Inform the observer of the characters that have been loaded - UpdateObserver( observer, fontId, glyphSet, GLYPH_LOADED_FROM_FILE ); - - // Stage 2. Tell the observers the glyphs have been uploaded to GL (Resource manager is - // responsible for this now) - // - // @todo If there is an issue with the timing of the text-loaded signal from text-actor - // we can set this status after the upload instead of before (using uploaded callback on texture ticket). - UpdateObserver( observer, fontId, glyphSet, GLYPH_UPLOADED_TO_GL ); - - // Stage 3. Tell the text-observers some text has been loaded. - // They can then query if the text they are using has been uploaded - NotifyTextObservers(); - - // Only remove the ticket when all the responses have been received - if( loadStatus == RESOURCE_COMPLETELY_LOADED ) - { - mGlyphLoadTickets.erase( id ); - } - } - else - { - // The observer has been deleted after the resource request was sent. - // Note, we may still get responses that are already in the system - in this case, - // ignore them. - mGlyphLoadTickets.erase( id ); - } -} - -void GlyphResourceManager::SendRequests( const GlyphResourceRequest& request, GlyphResourceObserver& observer, ResourceId atlasTextureId ) -{ - Integration::PlatformAbstraction& platform = Internal::ThreadLocalStorage::Get().GetPlatformAbstraction(); - - // get the font information from the lookup, using the font id - std::string family, style; - float maxGlyphWidth, maxGlyphHeight; - FontId fontId = request.GetFontId(); - mFontLookup.GetFontInformation( fontId, family, style, maxGlyphWidth, maxGlyphHeight ); - - // List of requested characters - const Integration::TextResourceType::CharacterList& requestedCharacters = request.GetCharacterList(); - const size_t requestedCharacterCount = requestedCharacters.size(); - - DALI_LOG_INFO( gTextLogFilter, Debug::Verbose, "GlyphResourceManager::SendRequests() - requested character list: %s\n", - DebugCharacterString(requestedCharacters).c_str() ); - - // create a new resource request for the characters - Integration::TextResourceType resourceType( fontId, style, requestedCharacters, atlasTextureId, - Integration::TextResourceType::TextQualityHigh, // TODO: Remove - Vector2 (maxGlyphWidth, maxGlyphHeight), - Integration::TextResourceType::GLYPH_CACHE_WRITE ); - - // Try to synchronously load cached versions of the glyph bitmaps - Integration::GlyphSetPointer cachedGlyphs = platform.GetCachedGlyphData( resourceType, family ); - const GlyphSet::CharacterList& cachedCharacters = cachedGlyphs->GetCharacterList(); // list of cached glyphs - const size_t cachedCharacterCount = cachedCharacters.size(); // number of cached glyphs - - // Any glyphs loaded from cache? - if( 0u != cachedCharacterCount ) - { - // yes..Upload cached bitmaps to texture - UploadGlyphsToTexture( &observer, fontId, *(cachedGlyphs.Get()) ); - UpdateObserver( &observer, fontId, *(cachedGlyphs.Get()), GLYPH_UPLOADED_TO_GL ); - NotifyTextObservers(); - } - - // Any glyphs still missing? - if( requestedCharacterCount != cachedCharacterCount ) - { - // create a list of uncached/missing glyphs - Integration::TextResourceType::CharacterList uncachedCharacters; - for( size_t i = 0; i < requestedCharacterCount; ++i ) - { - uint32_t charCode = requestedCharacters[ i ].character; - bool isCached = false; - for( size_t j = 0; j < cachedCharacterCount; ++j ) - { - if( cachedCharacters[ j ].second.code == charCode ) - { - isCached = true; - break; - } - } - if( !isCached ) - { - uncachedCharacters.push_back( requestedCharacters[ i ] ); - } - } - - // replace requested character list with missing character list for resource request - resourceType.mCharacterList.assign( uncachedCharacters.begin(), uncachedCharacters.end() ); - - // Make asynchronous request for the missing glyphs - ResourceTicketPtr ticket = mResourceClient.RequestResource( resourceType, family ); - - // store the ticket - mGlyphLoadTickets[ ticket->GetId() ] = ( ObserverTicketPair(ticket, &observer) ); - - DALI_LOG_INFO( gTextLogFilter, Debug::General, "GlyphResourceManager::SendRequests() - id:%d observer:%p\n", - ticket->GetId(), &observer ); - - DALI_LOG_INFO( gTextLogFilter, Debug::Verbose, "GlyphResourceManager::SendRequests() - uncached character list:%s\n", - DebugCharacterString(uncachedCharacters).c_str() ); - - // Also synchronously load low quality version of glyphs - resourceType.mQuality = Integration::TextResourceType::TextQualityLow; - Integration::GlyphSetPointer lowQualityGlyphPointer = platform.GetGlyphData( resourceType, family, true ); - Integration::GlyphSet& lowQualityGlyphs = *(lowQualityGlyphPointer.Get()); - size_t lowQualityCharacterCount = lowQualityGlyphs.GetCharacterList().size(); - - // Any low quality glyphs loaded? - if( 0u != lowQualityCharacterCount ) - { - // yes..Upload cached bitmaps to texture - UploadGlyphsToTexture( &observer, fontId, lowQualityGlyphs ); - // Update atlas load status in update thread - mResourceClient.UpdateAtlasStatus( ticket->GetId(), resourceType.mTextureAtlasId, RESOURCE_PARTIALLY_LOADED ); - // Notify observers and text observers that a partial load has occured - GlyphsLoaded( ticket->GetId(), lowQualityGlyphs, RESOURCE_PARTIALLY_LOADED ); - } - } -} - -void GlyphResourceManager::UploadGlyphsToTexture( GlyphResourceObserver* observer, - FontId fontId, - const Integration::GlyphSet& glyphSet ) -{ - // the glyphset contains an array of bitmap / characters . - // The function uploads the bitmaps to a texture - const Integration::GlyphSet::CharacterList& charList( glyphSet.GetCharacterList() ); - BitmapUploadArray uploadArray; - for(std::size_t i = 0, count = charList.size() ; i < count; i++ ) - { - const Integration::GlyphSet::Character& character( charList[i] ); - uint32_t charCode = character.second.code; - unsigned int xPos,yPos; - // ask the observer (atlas) where the bitmap should be uploaded to - bool inUse = observer->GetGlyphTexturePosition( charCode, fontId, xPos, yPos ); - if( !inUse ) - { - // if it's no longer used, don't upload - continue; - } - // grab a pointer to the bitmap - Integration::Bitmap* bitmap( charList[ i ].first.Get() ); - unsigned int bitmapWidth = bitmap->GetImageWidth(); - unsigned int bitmapHeight = bitmap->GetImageHeight(); - Bitmap::PackedPixelsProfile* packedBitmap = bitmap->GetPackedPixelsProfile(); - if( NULL != packedBitmap ) - { - bitmapWidth = packedBitmap->GetBufferWidth(); - bitmapHeight = packedBitmap->GetBufferHeight(); - } - - // create a bitmap upload object, then add it to the array - BitmapUpload upload( bitmap->ReleaseBuffer(), // Inform the bitmap we're taking ownership of it's pixel buffer. - xPos, // x position in the texture to upload the bitmap to - yPos, // y position in the texture to upload the bitmap to - bitmapWidth, // bitmap width - bitmapHeight, // bitmap height - BitmapUpload::DISCARD_PIXEL_DATA ); // tell the the texture to delete the bitmap pixel buffer when it's done - uploadArray.push_back( upload ); - } - // update the texture - mResourceClient.UpdateTexture( observer->GetTextureId(), uploadArray ); -} - -void GlyphResourceManager::NotifyTextObservers() -{ - // copy this list so, the observers can remove themselves during the call back - TextObserverList observerList( mTextObservers ); - - TextObserverList::iterator iter( observerList.begin() ); - TextObserverList::const_iterator endIter( observerList.end() ); - for( ; iter != endIter; ++iter ) - { - TextObserver* observer((*iter)); - observer->TextLoaded(); - } -} - -void GlyphResourceManager::DeleteOldTextures( GlyphResourceObserver* observer ) -{ - // see if the observer is doing a texture-resize operation - GlyphResourceObserver::TextureState textureState = observer->GetTextureState(); - - if( textureState == GlyphResourceObserver::TEXTURE_RESIZED ) - { - unsigned int newTexture; - TextureIdList oldTextures; - - observer->GetNewTextureId( oldTextures, newTexture ); - - // the old texture(s) can be deleted, - // this is done automatically when we release the ticket - for( std::size_t i = 0; i< oldTextures.size(); i++ ) - { - DeleteTextureTicket( oldTextures[i] ); - } - } -} - -void GlyphResourceManager::UpdateObserver( GlyphResourceObserver* observer, - FontId fontId, - const Integration::GlyphSet& glyphSet, - GlyphUpdateType updateType) -{ - const Integration::GlyphSet::CharacterList& charList( glyphSet.GetCharacterList() ); - - for(std::size_t i = 0, count = charList.size() ; i < count; i++ ) - { - const Integration::GlyphSet::Character& character( charList[i] ); - - uint32_t charCode = character.second.code; - uint32_t quality = character.second.quality; - - if( updateType == GLYPH_LOADED_FROM_FILE) - { - observer->GlyphLoadedFromFile( charCode, fontId, GetGlyphStatus( quality ) ); - } - else // updateType == GLYPH_UPLOADED_TO_GL - { - observer->GlyphUpLoadedToTexture( charCode, fontId ); - } - } - - if( updateType == GLYPH_UPLOADED_TO_GL ) - { - DeleteOldTextures(observer); - } -} - -GlyphResourceObserver* GlyphResourceManager::GetObserver( Integration::ResourceId id ) -{ - GlyphResourceObserver* observer = NULL; - - // Get the observer for a resource - TicketList::iterator iter = mGlyphLoadTickets.find( id ); - - if( iter != mGlyphLoadTickets.end() ) // Only check for observers if the ticket is still alive - { - ObserverTicketPair& observerTicket ( (*iter).second ); - observer = observerTicket.second; - - // check if the atlas is still alive and in the observer list - if( mObservers.find( observer ) == mObservers.end() ) - { - observer = NULL; - } - } - - return observer; -} - -void GlyphResourceManager::DeleteTextureTicket(unsigned int id ) -{ - TextureTickets::iterator endIter; - - for( TextureTickets::iterator iter = mTextureTickets.begin(); iter != endIter; ++iter ) - { - ResourceTicketPtr ticket = (*iter); - if( ticket->GetId() == id ) - { - mTextureTickets.erase( iter ); - return; - } - } -} - -Integration::TextResourceType::TextQuality GlyphResourceManager::GetQuality( GlyphResourceRequest::GlyphQuality quality ) -{ - if( quality == GlyphResourceRequest::LOW_QUALITY) - { - return Integration::TextResourceType::TextQualityLow; - } - return Integration::TextResourceType::TextQualityHigh; -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/resource/glyph-resource-manager.h b/dali/internal/event/text/resource/glyph-resource-manager.h deleted file mode 100644 index a155b9f..0000000 --- a/dali/internal/event/text/resource/glyph-resource-manager.h +++ /dev/null @@ -1,236 +0,0 @@ -#ifndef __DALI_INTERNAL_GLYPH_RESOURCE_MANAGER_H__ -#define __DALI_INTERNAL_GLYPH_RESOURCE_MANAGER_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -class ResourceClient; - -/** - * Responsible for managing the resources used by a GlyphAtlas. - * This includes - * - Texture for holding the atlas - * - GlyphSets for uploading glyphs to a Texture. - * - * It implements the GlyphLoadObserver interface, so that resource-client - * can inform it when glyphs are loaded. - */ -class GlyphResourceManager : public GlyphLoadObserver -{ - -public: - - /** - * Constructor - * @param[in] fontLookup font lookup interface - */ - GlyphResourceManager( const FontLookupInterface& fontLookup ); - - /** - * Destructor - */ - virtual ~GlyphResourceManager(); - - /** - * Create a texture which can be used to upload character bitmaps to. - * @param[in] size the width and height of the square texture - * @return texture resource id - */ - unsigned int CreateTexture(unsigned int size ); - - /** - * Add a glyph resource observer - * @param[in] observer The observer to add. - */ - void AddObserver( GlyphResourceObserver& observer); - - /** - * Remove a glyph resource observer. - * @param[in] observer The observer to remove. - */ - void RemoveObserver( GlyphResourceObserver& observer); - - /** - * Adds a text observer. - * The observer will get a call back whenever new text is loaded. - * The observer is responsible for calling RemoveObserver() when - * all it's text is loaded or before destruction - * @param[in] observer The observer to add. - */ - void AddTextObserver( TextObserver& observer ); - - /** - * Removes a text observer. - * @param[in] observer The observer to remove. - */ - void RemoveTextObserver( TextObserver& observer ); - - /** - * Adds a texture observer, to detect atlas resize / split changes - * @param[in] observer The observer to add. - */ - void AddTextureObserver( GlyphTextureObserver& observer); - - /** - * Removes a texture observer - * @param[in] observer The texture observer to remove. - */ - void RemoveTextureObserver( GlyphTextureObserver& observer); - - /** - * Add a list of requests to load glyphs - * @param[in] request list glyph request list - * @param[in] observer the observer that sent the request - * @param[in] atlasTextureId the texture ID of the atlas - */ - void AddRequests( const GlyphRequestList& requestList, GlyphResourceObserver& observer, - Integration::ResourceId atlasTextureId ); - -public: // for GlyphLoadObserver - - /** - * @copydoc GlyphLoadObserver::GlyphsLoaded() - */ - virtual void GlyphsLoaded( Integration::ResourceId id, const Integration::GlyphSet& glyphSet, Integration::LoadStatus loadStatus ); - -private: - - /** - * Send resource requests to load glyphs. - * @param[in]request glyph resource request - * @param[in] observer glyph resource observer - * @param[in] atlasTextureId the texture ID of the atlas - */ - void SendRequests( const GlyphResourceRequest& request, GlyphResourceObserver& observer, - Integration::ResourceId atlasTextureId ); - /** - * Upload a glyphset to a texture - * @param[in] observer glyph resource observer - * @param[in] fontId font id - * @param[in] glyphSet glyph set (contains the bitmaps to upload) - */ - void UploadGlyphsToTexture( GlyphResourceObserver* observer, - FontId fontId, - const Integration::GlyphSet& glyphSet ); - - /** - * Notify text observers that some characters have been loaded - */ - void NotifyTextObservers(); - - /** - * notify texture observers, that a texture has been replaced - * @param[in] oldTextureIds list of old texture id's that have been replaced by the new texture id - * @paran[in] newTextureId new texture id - */ - void NotifyTextureReplaced( TextureIdList& oldTextureIds, unsigned int newTextureId); - - /** - * New atlas texture has been updated - delete old textures. - * @param[in] observer glyph resource observer - */ - void DeleteOldTextures( GlyphResourceObserver* observer ); - - /** - * glyph update type - */ - enum GlyphUpdateType - { - GLYPH_LOADED_FROM_FILE, ///< loaded from file - GLYPH_UPLOADED_TO_GL, ///< uploaded to gl - }; - - /** - * update a glyph observer to say whether either the glyphs have been - * loaded from file, or have been uploaded to gl. - * @param[in] observer glyph resource observer - * @param[in] fontId font id - * @param[in] glyphSet glyph set - * @param[in] updateType glyph update type - */ - void UpdateObserver( GlyphResourceObserver* observer, - FontId fontId, - const Integration::GlyphSet& glyphSet, - GlyphUpdateType updateType); - - - /** - * Given a resource id, return the observer watching that resource - * @param[in] id resource id - * @return glyph resource observer - */ - GlyphResourceObserver* GetObserver( Integration::ResourceId id ); - - /** - * Delete a texture ticket - * @param[in] id texture id - */ - void DeleteTextureTicket(unsigned int id ); - - /** - * Convert between GlyphQuality enum and integration TextQuality - * @param[in] quality GlyphQuality - * @return integration TextQuality - */ - Integration::TextResourceType::TextQuality GetQuality( GlyphResourceRequest::GlyphQuality quality ); - - - // Undefined copy constructor. - GlyphResourceManager( const GlyphResourceManager& ); - - // Undefined assignment operator. - GlyphResourceManager& operator=( const GlyphResourceManager& ); - - - typedef std::pair< ResourceTicketPtr, GlyphResourceObserver* > ObserverTicketPair; ///< ticket & observer pair - typedef std::map< Integration::ResourceId, ObserverTicketPair > TicketList; ///< key = resource id = key, data = ticket+observer - typedef std::list< ResourceTicketPtr > TextureTickets; ///< list of texture tickets - typedef std::set ObserverList; ///< Observer list typedef - typedef std::set TextObserverList; - - ObserverList mObservers; ///< unique set of glyph observers - TextObserverList mTextObservers; ///< unique set of text observers - TicketList mGlyphLoadTickets; ///< list of tickets for glyphset load requests - TextureTickets mTextureTickets; ///< list of tickets for texture requests - const FontLookupInterface& mFontLookup; ///< font lookup - ResourceClient& mResourceClient; ///< resource client -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_GLYPH_RESOURCE_MANAGER_H__ diff --git a/dali/internal/event/text/resource/glyph-resource-observer.h b/dali/internal/event/text/resource/glyph-resource-observer.h deleted file mode 100644 index 4e5bf91..0000000 --- a/dali/internal/event/text/resource/glyph-resource-observer.h +++ /dev/null @@ -1,143 +0,0 @@ -#ifndef __DALI_INTERNAL_GLYPH_RESOURCE_OBSERVER_H__ -#define __DALI_INTERNAL_GLYPH_RESOURCE_OBSERVER_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include - -// EXTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - - -typedef std::vector< unsigned int > TextureIdList; ///< list of texture id's - -/** - * Glyph resource observer interface. - * - * Used to inform an Atlas that a glyph has been loaded from file or uploaded to a texture. - * - */ -class GlyphResourceObserver -{ -public: - - /** - * Glyph quality flag, used to inform the observer - * whether a low or high quality glyph was loaded. - */ - enum Quality - { - LOW_QUALITY_LOADED, - HIGH_QUALITY_LOADED - }; - - /** - * Called when a glyph is loaded from file - * @param[in] code character code - * @param[in] fontId font id - * @param[in] status quality flag - */ - virtual void GlyphLoadedFromFile( uint32_t code, FontId fontId, Quality status ) = 0; - - /** - * Called when a glyph has been uploaded to a Texture - * @param[in] code character code - * @param[in] fontId font id - */ - virtual void GlyphUpLoadedToTexture( uint32_t code, FontId fontId ) = 0; - - /** - * Call to find the x,y position of the where the glyph should go in the atlas - * @param[in] code character code - * @param[in] fontId font id - * @param[in] xPos x position in the texture - * @param[in] yPos y position in the texture - * @return true if the glyph is still in use, false if not - */ - virtual bool GetGlyphTexturePosition( uint32_t code, FontId fontId, unsigned int &xPos, unsigned int &yPos) const = 0; - - /** - * Call to the find the texture used to display the glyphs - * @return texture id - */ - virtual unsigned int GetTextureId( ) const = 0; - - /** - * Texture Status - */ - enum TextureState - { - NO_CHANGE, ///< no change - TEXTURE_RESIZED, ///< texture has resized - TEXTURE_SPLIT ///< texture has split - }; - - /** - * Find out if the texture has been resized - * @return the texture state - */ - virtual TextureState GetTextureState() = 0; - - /** - * Should be called if GetTextureState does not return NO_CHANGE - * Gets a list of texture id's, that have been replaced by a new texture. - * @param[in] oldTextureIds list of old texture id's that have been replaced - * @param[in] newTextureId the new texture id - */ - virtual void GetNewTextureId( TextureIdList& oldTextureIds, unsigned int& newTextureId ) = 0; - -protected: - - /** - * Constructor - */ - GlyphResourceObserver() - { - - } - - /** - * Virtual Destructor - */ - virtual ~GlyphResourceObserver() - { - - } - -private: - - // Undefined copy constructor. - GlyphResourceObserver( const GlyphResourceObserver& ); - - // Undefined assignment operator. - GlyphResourceObserver& operator=( const GlyphResourceObserver& ); - -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_GLYPH_RESOURCE_OBSERVER diff --git a/dali/internal/event/text/resource/glyph-resource-request.cpp b/dali/internal/event/text/resource/glyph-resource-request.cpp deleted file mode 100644 index ea8c65e..0000000 --- a/dali/internal/event/text/resource/glyph-resource-request.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2014 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 INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -using Integration::TextResourceType; - -GlyphResourceRequest::GlyphResourceRequest() -:mFontId( 0 ), - mQuality( LOW_QUALITY ) -{ - -} - -GlyphResourceRequest::GlyphResourceRequest( FontId fontId, GlyphQuality quality ) -:mFontId( fontId ), - mQuality( quality ) -{ - -} - -// copy constructor -GlyphResourceRequest::GlyphResourceRequest( const GlyphResourceRequest& rhs ) -:mFontId( rhs.mFontId ), - mQuality( rhs.mQuality ), - mCharacterList( rhs.mCharacterList ) -{ -} - -// assignment operator. -GlyphResourceRequest& GlyphResourceRequest::operator=( const GlyphResourceRequest& rhs ) -{ - mFontId = rhs.mFontId; - mQuality = rhs.mQuality; - mCharacterList = rhs.mCharacterList; - return *this; -} - -FontId GlyphResourceRequest::GetFontId() const -{ - return mFontId; -} - -GlyphResourceRequest::GlyphQuality GlyphResourceRequest::GetQuality() const -{ - return mQuality; -} - -void GlyphResourceRequest::InsertCharacter( unsigned int code, unsigned int xPos, unsigned int yPos ) -{ - // insert the character, checking for duplicates first. - for( std::size_t i=0, count = mCharacterList.size(); i< count; ++i) - { - if( mCharacterList[i].character == code ) - { - // already exists in list - return; - } - } - // insert in to list - mCharacterList.push_back( TextResourceType::GlyphPosition(code, xPos, yPos) ); -} - -const GlyphResourceRequest::CharacterList& GlyphResourceRequest::GetCharacterList() const -{ - return mCharacterList; -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/resource/glyph-resource-request.h b/dali/internal/event/text/resource/glyph-resource-request.h deleted file mode 100644 index 3b01f7c..0000000 --- a/dali/internal/event/text/resource/glyph-resource-request.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef __DALI_INTERNAL_GLYPH_RESOURCE_REQUEST_H__ -#define __DALI_INTERNAL_GLYPH_RESOURCE_REQUEST_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * Structure for requesting an array of characters to be loaded - * at a certain quality, for a certain font. - * Resource requests are generated by glyph-atlas - */ -class GlyphResourceRequest -{ -public: - typedef Integration::TextResourceType::CharacterList CharacterList; - typedef Integration::ResourceId ResourceId; - - /** - * Glyph quality - */ - enum GlyphQuality - { - LOW_QUALITY, - HIGH_QUALITY - }; - - /** - * Constructor - * @param[in] fontId font id - * @param[in] quality - */ - GlyphResourceRequest( FontId fontId, GlyphQuality quality ); - - /** - * non-virtual destructor - */ - ~GlyphResourceRequest() - { - } - - /** - * Copy constructor - */ - GlyphResourceRequest( const GlyphResourceRequest& ); - - /** - * Assignment operator - */ - GlyphResourceRequest& operator=( const GlyphResourceRequest& ); - - /** - * Get the font id - * @return the font id of the request - */ - FontId GetFontId() const; - - /** - * Get the request quality - * @return quality - */ - GlyphQuality GetQuality() const; - - /** - * Inserts a character in to the request - * @param[in] code character code - */ - void InsertCharacter( unsigned int code, unsigned int xPos, unsigned int yPos ); - - /** - * Get the character list in the request - * @return character list - */ - const CharacterList& GetCharacterList() const; - -private: - - /** - * constructor - */ - GlyphResourceRequest(); - - FontId mFontId; ///< font id - GlyphQuality mQuality; ///< quality - CharacterList mCharacterList; ///< character list -}; - -typedef std::vector< GlyphResourceRequest > GlyphRequestList; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_GLYPH_RESOURCE_REQUEST_H__ diff --git a/dali/internal/event/text/resource/glyph-texture-observer.h b/dali/internal/event/text/resource/glyph-texture-observer.h deleted file mode 100644 index 8d5d315..0000000 --- a/dali/internal/event/text/resource/glyph-texture-observer.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef __DALI_INTERNAL_GLYPH_ATLAS_OBSERVER_H__ -#define __DALI_INTERNAL_GLYPH_ATLAS_OBSERVER_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -typedef std::vector< unsigned int > TextureIdList; - -/** - * Glyph texture observers are notified when a texture is re-sized or split. - * - */ -class GlyphTextureObserver -{ -public: - - /** - * Constructor - */ - GlyphTextureObserver() - { - } - - /** - * Virtual destructor - */ - virtual ~GlyphTextureObserver() - { - } - - /** - * Called when the atlas has been resized. - * As textures can not be resized, a new one is created. - * @param oldTextureId's list of textures id's that have been replaced by a new texture id - * @param newTextureId the new texture id - */ - virtual void TextureResized( const TextureIdList& oldTextureIds, unsigned int newTextureId ) = 0; - - /** - * Called when the atlas is split - * @param fontId the current texture id - * @param oldTextureId's list of textures id's that have been replaced by a new texture id - * @param newTextureId the new texture id - */ - virtual void TextureSplit( FontId fontId, const TextureIdList& oldTextureIds, unsigned int newTextureId ) = 0; - -private: - - // undefined copy constructor - GlyphTextureObserver( const GlyphTextureObserver& ); - - // underfined assignment operator - GlyphTextureObserver& operator=( const GlyphTextureObserver& ); -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_GLYPH_ATLAS_OBSERVER_H__ diff --git a/dali/internal/event/text/special-characters.h b/dali/internal/event/text/special-characters.h deleted file mode 100644 index 7fe546a..0000000 --- a/dali/internal/event/text/special-characters.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __DALI_INTERNAL_SPECIAL_CHARACTERS_H__ -#define __DALI_INTERNAL_SPECIAL_CHARACTERS_H__ - -/* - * Copyright (c) 2014 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. - * - */ - -namespace Dali -{ - -namespace Internal -{ - -namespace SpecialCharacters -{ - -const unsigned int FIRST_VISIBLE_CHAR( 0x21 ); // 0x20 is the white space -const unsigned int UNDERLINE_CHARACTER( 0x0332 ); // = 818 in decimal - -} // Special Characters - -} // Internal - -} // Dali -#endif // __DALI_INTERNAL_SPECIAL_CHARACTERS_H__ diff --git a/dali/internal/event/text/text-format.cpp b/dali/internal/event/text/text-format.cpp deleted file mode 100644 index 2061339..0000000 --- a/dali/internal/event/text/text-format.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -TextFormat::TextFormat() -: mUnderline(false), - mItalics(false), - mItalicsAngle(0.0f), - mPointSize(0.0f), - mUnderlineThickness( 0.f ), - mUnderlinePosition( 0.f ) -{} - -TextFormat::TextFormat( bool underline, - bool italics, - Dali::Radian italicsAngle, - float pointSize, - float underlineThickness, - float underlinePosition ) -: mUnderline( underline ), - mItalics( italics ), - mItalicsAngle( italicsAngle ), - mPointSize( pointSize ), - mUnderlineThickness( underlineThickness ), - mUnderlinePosition( underlinePosition ) -{ -} - -TextFormat::TextFormat( const TextFormat& rhs ) -: mUnderline( rhs.mUnderline ), - mItalics( rhs.mItalics ), - mItalicsAngle( rhs.mItalicsAngle ), - mPointSize( rhs.mPointSize ), - mUnderlineThickness( rhs.mUnderlineThickness ), - mUnderlinePosition( rhs.mUnderlinePosition ) -{ -} - -TextFormat& TextFormat::operator=( const TextFormat& rhs ) -{ - mUnderline = rhs.mUnderline; - mItalics = rhs.mItalics; - mItalicsAngle = rhs.mItalicsAngle; - mPointSize = rhs.mPointSize; - mUnderlineThickness = rhs.mUnderlineThickness; - mUnderlinePosition = rhs.mUnderlinePosition; - - return *this; -} - -TextFormat::~TextFormat() -{ -} - -bool TextFormat::IsUnderLined() const -{ - return mUnderline; -} - -bool TextFormat::IsItalic() const -{ - return mItalics; -} - -Dali::Radian TextFormat::GetItalicsAngle() const -{ - return mItalicsAngle; -} - -float TextFormat::GetPointSize() const -{ - return mPointSize; -} - -unsigned int TextFormat::GetUnderLineCharacter() const -{ - return SpecialCharacters::UNDERLINE_CHARACTER; -} - -float TextFormat::GetUnderlineThickness() const -{ - return mUnderlineThickness; -} - -float TextFormat::GetUnderlinePosition() const -{ - return mUnderlinePosition; -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/text-format.h b/dali/internal/event/text/text-format.h deleted file mode 100644 index 13323bc..0000000 --- a/dali/internal/event/text/text-format.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef __DALI_INTERNAL_TEXT_FORMAT_H__ -#define __DALI_INTERNAL_TEXT_FORMAT_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * - * Text formatting controls how the vertex data - * for a string of text is created. - * E.g. if italics is turned on, the vertices are modified - * to created slanted characters. - * If underline is true, a thin line is added to underline the - * text (as a quad) - */ -struct TextFormat -{ - - /** - * Constructor - */ - TextFormat(); - - /** - * Constructor - * @param[in] underline whether to underline the text - * @param[in] italics whether italics is enabled - * @param[in] italicsAngle italics angle - * @param[in] pointSize the point size - */ - TextFormat( bool underline, - bool italics, - Dali::Radian italicsAngle, - float pointSize, - float underlineThickness, - float underlinePosition ); - - /** - * Copy constructor. - * @param[in] rhs object to copy - */ - TextFormat( const TextFormat& rhs); - - /** - * Assignment operator - * @param[in] rhs object to assign from - * @return this - */ - TextFormat& operator=( const TextFormat& rhs ); - - - /** - * Destructor - */ - ~TextFormat(); - - /** - * Whether underline is enabled - * @return true if underline is enabled - */ - bool IsUnderLined() const; - - /** - * whether italics are enabled - * @return true if italics enabled - */ - bool IsItalic() const; - - /** - * Get the italics angle - * @return italics angle - */ - Dali::Radian GetItalicsAngle() const; - - /** - * Get point size - * @return font point size - */ - float GetPointSize() const; - - /** - * Get the character used for underlining. - * @return under line character - */ - unsigned int GetUnderLineCharacter() const; - - /** - * @return The underline's thickness. - */ - float GetUnderlineThickness() const; - - /** - * @return The underline's position. - */ - float GetUnderlinePosition() const; - -private: - - bool mUnderline:1; ///< whether to underline the text - bool mItalics:1; ///< whether to apply italics - Dali::Radian mItalicsAngle; ///< italics angle if applied - float mPointSize; ///< Point size. Used to scale the vertices by this amount. - float mUnderlineThickness; ///< The underline's thickness. - float mUnderlinePosition; ///< The underline's position. -}; - - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_TEXT_FORMAT_H__ diff --git a/dali/internal/event/text/text-impl.cpp b/dali/internal/event/text/text-impl.cpp deleted file mode 100644 index 7b2650a..0000000 --- a/dali/internal/event/text/text-impl.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// HEADER CLASS -#include - -// INTERNAL INCLUDES -#include -#include - -// EXTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -namespace -{ -static const Integration::TextArray VOID_TEXT_ARRAY; ///< A void text array to be used in the helper Internal::GetTextArray() function. -} // namespace - -Text::Text() -: mString() -{ -} - -Text::Text( const std::string& text ) -: mString() -{ - const std::size_t length = text.size(); - - // minimize allocations for ascii strings - mString.Reserve( length ); - - // break string into UTF-8 tokens - UTF8Tokenize( reinterpret_cast( text.c_str() ), length, mString ); -} - -Text::Text( const Character& character ) -: mString() -{ - mString.PushBack( character.GetCharacter() ); -} - -Text::Text( const Text& text ) -: mString( text.mString ) -{ -} - -void Text::GetText( std::string& text ) const -{ - // minimize allocations for ascii strings - text.reserve( mString.Count() ); - - for( Integration::TextArray::ConstIterator it = mString.Begin(), endIt = mString.End(); it != endIt; ++it ) - { - unsigned char utf8Data[4]; - unsigned int utf8Length; - - utf8Length = UTF8Write( *it, utf8Data ); - - text.append( reinterpret_cast( utf8Data ), utf8Length ); - } -} - -Text& Text::operator=( const Text& text ) -{ - mString = text.mString; - - return *this; -} - -Text::~Text() -{ - Clear(); - mString.Release(); -} - -void Text::Clear() -{ - mString.Clear(); -} - -Dali::Character Text::operator[]( size_t position ) const -{ - DALI_ASSERT_ALWAYS( position < mString.Count() && "Text::operator[]: Character position is out of bounds" ); - - const uint32_t c = *( mString.Begin() + position ); - - Dali::Character character( new Character( c ) ); - - return character; -} - -bool Text::IsEmpty() const -{ - return 0u == mString.Count(); -} - -size_t Text::GetLength() const -{ - return mString.Count(); -} - -void Text::Append( const Dali::Text& text ) -{ - const Integration::TextArray& utfCodes = text.GetImplementation().GetTextArray(); - - mString.Insert( mString.End(), utfCodes.Begin(), utfCodes.End() ); -} - -void Text::Remove( size_t position, size_t numberOfCharacters ) -{ - DALI_ASSERT_ALWAYS( position < mString.Count() && "Text::Remove: Character position is out of bounds" ); - DALI_ASSERT_ALWAYS( position + numberOfCharacters <= mString.Count() && "Text::Remove: Character position + numberOfCharacters is out of bounds" ); - - mString.Erase( mString.Begin() + position, mString.Begin() + position + numberOfCharacters ); -} - -void Text::Find( uint32_t character, std::size_t from, std::size_t to, Vector& positions ) const -{ - std::size_t position = from; - - for( Integration::TextArray::ConstIterator it = mString.Begin() + from, endIt = mString.Begin() + to + 1u; it != endIt; ++position, ++it ) - { - if( *it == character ) - { - positions.PushBack( position ); - } - } -} - -void Text::FindWhiteSpace( std::size_t from, std::size_t to, Vector& positions ) const -{ - std::size_t position = from; - - for( Integration::TextArray::ConstIterator it = mString.Begin() + from, endIt = mString.Begin() + to + 1u; it != endIt; ++position, ++it ) - { - if( Character::IsWhiteSpace( *it ) ) - { - positions.PushBack( position ); - } - } -} - -void Text::FindNewLine( std::size_t from, std::size_t to, Vector& positions ) const -{ - std::size_t position = from; - - for( Integration::TextArray::ConstIterator it = mString.Begin() + from, endIt = mString.Begin() + to + 1u; it != endIt; ++position, ++it ) - { - if( Character::IsNewLine( *it ) ) - { - positions.PushBack( position ); - } - } -} - -void Text::GetSubText( std::size_t from, std::size_t to, Text* subText ) const -{ - if( to < from ) - { - std::swap( from, to ); - subText->mString.Insert( subText->mString.End(), mString.Begin() + from, mString.Begin() + to + 1u ); - std::reverse( subText->mString.Begin(), subText->mString.End() ); - } - else - { - subText->mString.Insert( subText->mString.End(), mString.Begin() + from, mString.Begin() + to + 1u ); - } -} - -bool Text::IsWhiteSpace( std::size_t index ) const -{ - if( index < mString.Count() ) - { - return Character::IsWhiteSpace( *( mString.Begin() + index ) ); - } - - return false; -} - -bool Text::IsNewLine( std::size_t index ) const -{ - if( index < mString.Count() ) - { - return Character::IsNewLine( *( mString.Begin() + index ) ); - } - - return false; -} - -const Integration::TextArray& Text::GetTextArray() const -{ - return mString; -} - -const Integration::TextArray& GetTextArray( const Dali::Text& text ) -{ - if( text.IsEmpty() ) - { - return VOID_TEXT_ARRAY; - } - - return text.GetImplementation().GetTextArray(); -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/text-impl.h b/dali/internal/event/text/text-impl.h deleted file mode 100644 index 96157cf..0000000 --- a/dali/internal/event/text/text-impl.h +++ /dev/null @@ -1,162 +0,0 @@ -#ifndef __DALI_INTERNAL_TEXT_H__ -#define __DALI_INTERNAL_TEXT_H__ - -/* - * Copyright (c) 2014 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 - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * Implementation class for Dali::Text. - * @see Dali::Text. - */ -class Text -{ -public: - - /** - * @copydoc Dali::Text::Text(). - */ - Text(); - - /** - * @copydoc Dali::Text::Text( const std::string& text ). - */ - Text( const std::string& text ); - - /** - * @copydoc Dali::Text::Text( const Character& character ). - */ - Text( const Character& character ); - - /** - * @copydoc Dali::Text::Text( const Text& text ). - */ - Text( const Text& text ); - - /** - * @copydoc Dali::Text::operator=( const Text& text ) - */ - Text& operator=( const Text& text ); - - /** - * Non-virtual destructor. - */ - ~Text(); - - /** - * Clears the text. - */ - void Clear(); - - /** - * Converts stored text encoded in UTF-32 to a std::string encoded with UTF-8. - * @param [out] text The text resultant of the UTF-32 to UTF-8 conversion. - */ - void GetText( std::string& text ) const; - - /** - * @copydoc Dali::Text::operator[]() - */ - Dali::Character operator[]( size_t position ) const; - - /** - * @copydoc Dali::Text::IsEmpty() - */ - bool IsEmpty() const; - - /** - * @copydoc Dali::Text::GetLength() - */ - size_t GetLength() const; - - /** - * @copydoc Dali::Text::Append( const Text& text ) - */ - void Append( const Dali::Text& text ); - - /** - * @copydoc Dali::Text::Remove() - */ - void Remove( size_t position, size_t numberOfCharacters ); - - /** - * @copydoc Dali::Text::Find( const Character& character, std::size_t from, std::size_t to, Vector& positions ) - */ - void Find( uint32_t character, std::size_t from, std::size_t to, Vector& positions ) const; - - /** - * @copydoc Dali::Text::Find( SpecialCharacter character, std::size_t from, std::size_t to, Vector& positions ) - */ - void FindWhiteSpace( std::size_t from, std::size_t to, Vector& positions ) const; - - /** - * @copydoc Dali::Text::Find( SpecialCharacter character, std::size_t from, std::size_t to, Vector& positions ) - */ - void FindNewLine( std::size_t from, std::size_t to, Vector& positions ) const; - - /** - * @copydoc Dali::Text::GetSubText() - */ - void GetSubText( std::size_t from, std::size_t to, Text* subText ) const; - - /** - * @copydoc Dali::Text::IsWhiteSpace() - */ - bool IsWhiteSpace( std::size_t index ) const; - - /** - * @copydoc Dali::Text::IsNewLine() - */ - bool IsNewLine( std::size_t index ) const; - - /** - * Retrieves a reference to the UTF-32 encoded string. - * @return A reference to the UTF-32 encoded string. - */ - const Integration::TextArray& GetTextArray() const; - -private: - - Integration::TextArray mString; ///< Stores an array of unicodes. -}; - -/** - * @brief Helper function to get the Integration::TextArray from a Dali::Text. - * - * @param[in] text A Dali::Text. - * - * @return The Text's Integration::TextArray. - */ - const Integration::TextArray& GetTextArray( const Dali::Text& text ); - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_TEXT_H__ diff --git a/dali/internal/event/text/text-observer.h b/dali/internal/event/text/text-observer.h deleted file mode 100644 index ba3df31..0000000 --- a/dali/internal/event/text/text-observer.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef __DALI_INTERNAL_TEXT_OBSERVER_H__ -#define __DALI_INTERNAL_TEXT_OBSERVER_H__ - -/* - * Copyright (c) 2014 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. - * - */ - -namespace Dali -{ - -namespace Internal -{ - -/** - * Text observers are notified when characters have been loaded for a particular font. - * - * Note, the specific characters loaded are not specified. - * The internal user of this class has to use Font::TextAvailable to - * find if the the glyphs for a text string is loaded. - */ -class TextObserver -{ -public: - - - /** - * Called when the text has been loaded. - */ - virtual void TextLoaded() = 0; - -protected: - - /** - * constructor - */ - TextObserver() - { - } - - /** - * Virtual destructor. - */ - virtual ~TextObserver() - { - } - - /** - * Undefined copy constructor. - */ - TextObserver( const TextObserver& ); - - /** - * Undefined assignment operator - */ - TextObserver& operator=( const TextObserver& ); - -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_TEXT_OBSERVER_H__ diff --git a/dali/internal/event/text/text-request-helper.cpp b/dali/internal/event/text/text-request-helper.cpp deleted file mode 100644 index 692a102..0000000 --- a/dali/internal/event/text/text-request-helper.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include "text-request-helper.h" - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -TextRequestHelper::TextRequestHelper( GlyphTextureObserver& observer) -:mTextureId(0), - mTextureObserverInstalled( false ), - mTextureObserver( observer ) -{ -} - -TextRequestHelper::~TextRequestHelper() -{ - TextNotRequired(); - - if( mTextureObserverInstalled && mFont ) - { - mFont->RemoveTextureObserver( mTextureObserver); - } -} - -TextVertexBuffer* TextRequestHelper::SetText(const Integration::TextArray& text, const TextFormat& format) -{ - // current text no longer required. - TextNotRequired(); - - mText = text; - - return TextRequired( format ); -} - -TextVertexBuffer* TextRequestHelper::SetFont( const FontPointer& font, const TextFormat& format ) -{ - // current text no longer required. - TextNotRequired(); - - mFont = font; - - // request text with new font - return TextRequired( format ); -} - -TextVertexBuffer* TextRequestHelper::SetTextAndFont( const Integration::TextArray& text, - const FontPointer& font, - const TextFormat& format ) -{ - // current text no longer required. - TextNotRequired(); - - mText = text; - - mFont = font; - - // request new text with new font - return TextRequired( format ); -} - -void TextRequestHelper::TextNotRequired() -{ - if( mFont && ( 0u < mText.Count() ) ) - { - mFont->TextNotRequired( mText, mFormat, mTextureId ); - } -} - -TextVertexBuffer* TextRequestHelper::TextRequired( const TextFormat& format ) -{ - mFormat = format; - - if( mFont && ( 0u < mText.Count() ) ) - { - // watch out for texture resizes / splits - AddTextureObserver(); - - // get the vertex buffer required to display the text - TextVertexBuffer* buffer = mFont->TextRequired( mText, format ); - if( buffer ) - { - // keep track of the texture id, ( texture id == atlas id) - mTextureId = buffer->mTextureId; - - return buffer; - } - } - else if( 0u == mText.Count() ) - { - // create an empty vertex buffer - TextVertexBuffer* buffer = new TextVertexBuffer; - buffer->mVertexMax = Vector2::ZERO; - buffer->mTextureId = 0; - - return buffer; - } - return NULL; -} - -void TextRequestHelper::TextureChanged( unsigned int oldTextureId, unsigned int newTextureId ) -{ - DALI_ASSERT_DEBUG( oldTextureId == mTextureId); - mTextureId = newTextureId; -} - -bool TextRequestHelper::IsTextLoaded() const -{ - if( mTextureId == 0 || (!mFont) || ( 0u == mText.Count() ) ) - { - return false; - } - return mFont->IsTextLoaded( mText, mFormat, mTextureId ); -} - -void TextRequestHelper::AddTextureObserver() -{ - if( !mTextureObserverInstalled ) - { - mTextureObserverInstalled = true; - mFont->AddTextureObserver( mTextureObserver); - } -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/text-request-helper.h b/dali/internal/event/text/text-request-helper.h deleted file mode 100644 index 01572b9..0000000 --- a/dali/internal/event/text/text-request-helper.h +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef __DALI_INTERNAL_TEXT_REQUEST_HELPER_H__ -#define __DALI_INTERNAL_TEXT_REQUEST_HELPER_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * Used to control text requests passed to a font object. - * Characters are reference counted by the font object. This - * class ensures the correct characters are reference / unreferenced. - * - */ -class TextRequestHelper -{ - -public: - - /** - * constructor - * @param[in] observer glyph texture observer - */ - TextRequestHelper( GlyphTextureObserver& observer ); - - /** - * destructor - */ - ~TextRequestHelper(); - - - /** - * Set the text to request - * @param [in] text text string - * @param [in] format text format - * @return the vertex data required to draw the text - */ - TextVertexBuffer* SetText(const Integration::TextArray& text, const TextFormat& format ); - - /** - * Set the font - * @param [in] font - * @param [in] format text format - * @return the vertex data required to draw the text - */ - TextVertexBuffer* SetFont( const FontPointer& font, const TextFormat& format ); - - /** - * Set the text and font to request - * @param [in] text the text string - * @param [in] font new font to request from - * @param [in] format text format - * @return the vertex data required to draw the text - */ - TextVertexBuffer* SetTextAndFont(const Integration::TextArray& text, const FontPointer& font, const TextFormat& format ); - - /** - * Called when the texture id has changed - * @param[in] old texture id - * @param[in] new texture id - */ - void TextureChanged( unsigned int oldTextureId, unsigned int newTextureId ); - - /** - * Check if the text is loaded - * @return true if text is loaded - */ - bool IsTextLoaded() const; - -private: - - /** - * Tell the font we have stopped using a string of characters - */ - void TextNotRequired(); - - /** - * Tell the font we require some text - * @param[in] format the text format - * @return the vertex data required to draw the text - */ - TextVertexBuffer* TextRequired( const TextFormat& format ); - - /** - * start observing global atlas changes such as atlas resize / split - */ - void AddTextureObserver(); - - unsigned int mTextureId; ///< the texture id of the glyph atlas being used - Integration::TextArray mText; ///< text string - TextFormat mFormat; ///< text format - FontPointer mFont; ///< the font - bool mTextureObserverInstalled:1; ///< whether texture observer is installed - GlyphTextureObserver& mTextureObserver; ///< texture observer - -}; - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_TEXT_REQUEST_HELPER_H__ diff --git a/dali/internal/event/text/utf8-impl.cpp b/dali/internal/event/text/utf8-impl.cpp deleted file mode 100644 index 5fa4e41..0000000 --- a/dali/internal/event/text/utf8-impl.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -size_t UTF8SequenceLength(const unsigned char leadByte) -{ - size_t length = 0; - - if ((leadByte & 0x80) == 0 ) //ASCII character (lead bit zero) - { - length = 1; - } - else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx - { - length = 2; - } - else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx - { - length = 3; - } - else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx - { - length = 4; - } - else - { - DALI_LOG_WARNING("Unrecognized lead byte %c\n", leadByte); - } - - return length; -} - -uint32_t UTF8Read(const unsigned char* utf8Data, const size_t sequenceLength) -{ - uint32_t code = 0; - - if (sequenceLength == 1) - { - code = *utf8Data; - } - else if (sequenceLength == 2) - { - code = *utf8Data++ & 0x1f; - code <<= 6; - code |= *utf8Data & 0x3f; - } - else if (sequenceLength == 3) - { - code = *utf8Data++ & 0x0f; - code <<= 6; - code |= *utf8Data++ & 0x3f; - code <<= 6; - code |= *utf8Data & 0x3f; - } - else if (sequenceLength == 4) - { - code = *utf8Data++ & 0x07; - code <<= 6; - code |= *utf8Data++ & 0x3f; - code <<= 6; - code |= *utf8Data++ & 0x3f; - code <<= 6; - code |= *utf8Data & 0x3f; - } - - return code; -} - -size_t UTF8Write(const uint32_t code, unsigned char* utf8Data) -{ - size_t sequenceLength = 0; - if (code < 0x80u) - { - *utf8Data = code; - sequenceLength = 1; - } - else if (code < 0x800u) - { - *utf8Data++ = static_cast( code >> 6) | 0xc0; // lead byte for 2 byte sequence - *utf8Data = static_cast( code & 0x3f) | 0x80; // continuation byte - sequenceLength = 2; - } - else if (code < 0x10000u) - { - *utf8Data++ = static_cast( code >> 12) | 0xe0; // lead byte for 2 byte sequence - *utf8Data++ = static_cast((code >> 6) & 0x3f) | 0x80; // continuation byte - *utf8Data = static_cast( code & 0x3f) | 0x80; // continuation byte - sequenceLength = 3; - } - else if (code < 0x200000u) - { - *utf8Data++ = static_cast( code >> 18) | 0xf0; // lead byte for 2 byte sequence - *utf8Data++ = static_cast((code >> 12) & 0x3f) | 0x80; // continuation byte - *utf8Data++ = static_cast((code >> 6) & 0x3f) | 0x80; // continuation byte - *utf8Data = static_cast( code & 0x3f) | 0x80; // continuation byte - sequenceLength = 4; - } - - return sequenceLength; -} - -size_t UTF8Tokenize(const unsigned char* utf8Data, const size_t utf8DataLength, Integration::TextArray& tokens) -{ - size_t dataLength = utf8DataLength; - - while (dataLength) - { - uint32_t code; - size_t sequenceLength = UTF8SequenceLength(*utf8Data); - - if (!sequenceLength) - { - break; - } - - if (sequenceLength > dataLength) - { - // utf8 data error - break; - } - - code = UTF8Read(utf8Data, sequenceLength); - tokens.PushBack(code); - - utf8Data += sequenceLength; - dataLength -= sequenceLength; - } - return tokens.Count(); -} - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/event/text/utf8-impl.h b/dali/internal/event/text/utf8-impl.h deleted file mode 100644 index 2c28181..0000000 --- a/dali/internal/event/text/utf8-impl.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef __DALI_INTERNAL_UTF8_H__ -#define __DALI_INTERNAL_UTF8_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include - -namespace Dali -{ - -namespace Internal -{ - -/** - * Determine the length (in bytes) of a UTF-8 character - * @param[in] leadByte The lead byte of a UTF-8 character sequence - * @return The length of the sequence, or zero if the UTF-8 character is invalid. - */ -size_t UTF8SequenceLength(const unsigned char leadByte); - -/** - * Converts a UTF-8 character into a UTF-32 code - * @param[in] utf8Data A pointer to the lead byte of the UTF-8 character - * @param[in] sequenceLength The length of the UTF-8 character. See UTF8SequenceLength. - * @return The UTF-32 code, (or zero if the sequenceLength is not between 1..4 - */ -uint32_t UTF8Read(const unsigned char* utf8Data, const size_t sequenceLength); - -/** - * Converts a UTF-32 code into a UTF-8 sequence - * @param[in] code The UTF-32 code - * @param[out] utf8Data The UTF-8 buffer that receives the sequence - * @return The length of the sequence written to utf8Data, or zero if the code was invalid - */ -size_t UTF8Write(const uint32_t code, unsigned char* utf8Data); - -/** - * Converts a stream of UTF-8 codes into an aarray of UTF-32 codes - * @param[in] utf8Data The UTF-8 buffer containing the UTF-8 string - * @param[in] utf8DataLength The size of the data, in bytes, at utf8Data - * @param[out] tokens A vector which will receive the converted UTF-32 codes - * @return The number of UTF-32 codes. - */ -size_t UTF8Tokenize(const unsigned char* utf8Data, const size_t utf8DataLength, Integration::TextArray& tokens); - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_UTF8_H__ - diff --git a/dali/internal/file.list b/dali/internal/file.list index 709fabd..74e5a10 100644 --- a/dali/internal/file.list +++ b/dali/internal/file.list @@ -5,7 +5,6 @@ internal_src_files = \ $(internal_src_dir)/common/core-impl.cpp \ $(internal_src_dir)/common/internal-constants.cpp \ $(internal_src_dir)/common/message-buffer.cpp \ - $(internal_src_dir)/common/text-parameters.cpp \ $(internal_src_dir)/common/image-sampler.cpp \ $(internal_src_dir)/common/dali-hash.cpp \ \ @@ -15,13 +14,11 @@ internal_src_files = \ $(internal_src_dir)/event/actor-attachments/light-attachment-impl.cpp \ $(internal_src_dir)/event/actor-attachments/mesh-attachment-impl.cpp \ $(internal_src_dir)/event/actor-attachments/renderable-attachment-impl.cpp \ - $(internal_src_dir)/event/actor-attachments/text-attachment-impl.cpp \ $(internal_src_dir)/event/actors/actor-impl.cpp \ $(internal_src_dir)/event/actors/custom-actor-internal.cpp \ $(internal_src_dir)/event/actors/image-actor-impl.cpp \ $(internal_src_dir)/event/actors/layer-impl.cpp \ $(internal_src_dir)/event/actors/layer-list.cpp \ - $(internal_src_dir)/event/actors/text-actor-impl.cpp \ $(internal_src_dir)/event/actors/mesh-actor-impl.cpp \ $(internal_src_dir)/event/actors/camera-actor-impl.cpp \ $(internal_src_dir)/event/actors/light-actor-impl.cpp \ @@ -79,7 +76,6 @@ internal_src_files = \ $(internal_src_dir)/event/images/image-factory.cpp \ $(internal_src_dir)/event/images/image-factory-cache.cpp \ $(internal_src_dir)/event/images/nine-patch-image-impl.cpp \ - $(internal_src_dir)/event/images/emoji-factory.cpp \ $(internal_src_dir)/event/modeling/animatable-mesh-impl.cpp \ $(internal_src_dir)/event/modeling/cloth-impl.cpp \ $(internal_src_dir)/event/modeling/entity-impl.cpp \ @@ -99,30 +95,6 @@ internal_src_files = \ $(internal_src_dir)/event/resources/resource-client.cpp \ $(internal_src_dir)/event/resources/resource-ticket.cpp \ $(internal_src_dir)/event/resources/resource-type-path.cpp \ - $(internal_src_dir)/event/text/character-impl.cpp \ - $(internal_src_dir)/event/text/glyph-metric.cpp \ - $(internal_src_dir)/event/text/font-layout.cpp \ - $(internal_src_dir)/event/text/font-factory.cpp \ - $(internal_src_dir)/event/text/font-impl.cpp \ - $(internal_src_dir)/event/text/font-metrics.cpp \ - $(internal_src_dir)/event/text/text-format.cpp \ - $(internal_src_dir)/event/text/text-request-helper.cpp \ - $(internal_src_dir)/event/text/text-impl.cpp \ - $(internal_src_dir)/event/text/utf8-impl.cpp \ - $(internal_src_dir)/event/text/glyph-status/glyph-status.cpp \ - $(internal_src_dir)/event/text/glyph-status/glyph-status-container.cpp \ - $(internal_src_dir)/event/text/glyph-status/debug/glyph-status-container-debug.cpp \ - $(internal_src_dir)/event/text/atlas/atlas.cpp \ - $(internal_src_dir)/event/text/atlas/atlas-size.cpp \ - $(internal_src_dir)/event/text/atlas/atlas-ranking.cpp \ - $(internal_src_dir)/event/text/atlas/atlas-rank-generator.cpp \ - $(internal_src_dir)/event/text/atlas/debug/atlas-debug.cpp \ - $(internal_src_dir)/event/text/atlas/glyph-atlas.cpp \ - $(internal_src_dir)/event/text/atlas/glyph-atlas-manager.cpp \ - $(internal_src_dir)/event/text/resource/glyph-resource-manager.cpp \ - $(internal_src_dir)/event/text/resource/glyph-resource-request.cpp \ - $(internal_src_dir)/event/text/resource/debug/glyph-resource-debug.cpp \ - $(internal_src_dir)/event/text/generator/text-vertex-generator.cpp \ \ $(internal_src_dir)/render/common/culling-algorithms.cpp \ $(internal_src_dir)/render/common/performance-monitor.cpp \ @@ -151,7 +123,6 @@ internal_src_files = \ $(internal_src_dir)/render/renderers/scene-graph-mesh-renderer.cpp \ $(internal_src_dir)/render/renderers/scene-graph-renderer.cpp \ $(internal_src_dir)/render/renderers/scene-graph-renderer-debug.cpp \ - $(internal_src_dir)/render/renderers/scene-graph-text-renderer.cpp \ $(internal_src_dir)/render/shaders/custom-uniform.cpp \ $(internal_src_dir)/render/shaders/program.cpp \ $(internal_src_dir)/render/shaders/program-controller.cpp \ @@ -190,14 +161,12 @@ internal_src_files = \ $(internal_src_dir)/update/node-attachments/scene-graph-light-attachment.cpp \ $(internal_src_dir)/update/node-attachments/scene-graph-mesh-attachment.cpp \ $(internal_src_dir)/update/node-attachments/scene-graph-renderable-attachment.cpp \ - $(internal_src_dir)/update/node-attachments/scene-graph-text-attachment.cpp \ $(internal_src_dir)/update/nodes/node.cpp \ $(internal_src_dir)/update/nodes/node-messages.cpp \ $(internal_src_dir)/update/nodes/scene-graph-layer.cpp \ $(internal_src_dir)/update/render-tasks/scene-graph-render-task.cpp \ $(internal_src_dir)/update/render-tasks/scene-graph-render-task-list.cpp \ $(internal_src_dir)/update/resources/bitmap-metadata.cpp \ - $(internal_src_dir)/update/resources/atlas-request-status.cpp \ $(internal_src_dir)/update/resources/resource-manager.cpp \ $(internal_src_dir)/update/resources/resource-tracker.cpp \ $(internal_src_dir)/update/resources/sync-resource-tracker.cpp \ diff --git a/dali/internal/render/renderers/scene-graph-text-renderer.cpp b/dali/internal/render/renderers/scene-graph-text-renderer.cpp deleted file mode 100644 index 7ed5e8c..0000000 --- a/dali/internal/render/renderers/scene-graph-text-renderer.cpp +++ /dev/null @@ -1,544 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(DEBUG_ENABLED) -namespace -{ -Debug::Filter* gTextFilter = Debug::Filter::New(Debug::Concise, false, "LOG_SCENE_GRAPH_TEXT_RENDERER"); -} -#endif - -namespace Dali -{ - -namespace Internal -{ - -namespace SceneGraph -{ - -TextRenderer* TextRenderer::New( RenderDataProvider& dataprovider ) -{ - return new TextRenderer( dataprovider ); -} - -TextRenderer::~TextRenderer() -{ - if(mTextureId > 0) - { - mTextureCache->RemoveObserver(mTextureId, this); - } - - GlCleanup(); - - delete mTextColor; -} - -void TextRenderer::TextureDiscarded( ResourceId textureId ) -{ - DALI_ASSERT_DEBUG( mTextureId == textureId || mTextureId == 0 ); - - mTextureId = 0; - mTexture = NULL; -} - -void TextRenderer::AllocateTextParameters() -{ - if( !mTextParameters ) - { - mTextParameters = new TextParameters; - } -} - -void TextRenderer::SetTextureId( ResourceId textureId ) -{ - DALI_LOG_INFO( gTextFilter, Debug::General, "TextRenderer::SetTextureId(%d)\n", textureId ); - - if(mTextureId > 0) - { - mTextureCache->RemoveObserver(mTextureId, this); - } - - mTextureId = textureId; - mTexture = NULL; - - if(textureId > 0) - { - mTextureCache->AddObserver(textureId, this); - } -} - -void TextRenderer::UpdateIndexBuffer( std::size_t size ) -{ - if( size == 0) - { - return; - } - DALI_ASSERT_DEBUG( (size % 4 == 0) && "Invalid vertex length"); - - // @todo need to create a simple gpu-buffer-manager class which allow us - // to use a single indice buffer for all text-renderers and image renderers (minus 9 patch). - - // number of indices(points) = number of (vertices / 4 ) = number of quads * 6 - // to display the quad as two triangles (each triangle has 3 points). - // equivalent to 1.5 * number verts, which can be done with bit shifting. - std::size_t numberIndices = size + (size >> 1); - - std::size_t numberQuads = size >> 2; // quads = verts / 4 - - GLushort* indices = new GLushort[ numberIndices ]; - - std::size_t n = 0; - for( std::size_t i = 0; i < numberQuads; ++i ) - { - /* - * 1 --- 2 - * | /| - * | A | - * | / | - * 0 --- 3 - * - * Draw 2 triangles with clock wise winding: 0->1->2 and 0->2->3 - */ - std::size_t vertIndex = i << 2; // vert index = i * 4 - - indices[ n++ ] = 0 + vertIndex; - indices[ n++ ] = 1 + vertIndex; - indices[ n++ ] = 2 + vertIndex; - - indices[ n++ ] = 0 + vertIndex; - indices[ n++ ] = 2 + vertIndex; - indices[ n++ ] = 3 + vertIndex; - } - - mIndexBuffer->UpdateDataBuffer( numberIndices * sizeof(GLushort),indices ); - - delete []indices; -} - -void TextRenderer::SetVertexData( TextVertexBuffer* vertexData ) -{ - DALI_LOG_INFO( gTextFilter, Debug::General, "TextRenderer::SetVertexData(this: %p, vertexData: %p)\n", this, vertexData ); - - if( !vertexData ) - { - DALI_ASSERT_DEBUG( 0 && "No vertex data"); // vertex data structure is required even for empty strings - return; - } - if( vertexData->mVertices.size() > 0 ) - { - SetTextureId(vertexData->mTextureId); - - if ( !mVertexBuffer ) - { - mVertexBuffer = new GpuBuffer( *mContext, GpuBuffer::ARRAY_BUFFER, GpuBuffer::DYNAMIC_DRAW ); - } - - if ( !mIndexBuffer ) - { - mIndexBuffer = new GpuBuffer( *mContext, GpuBuffer::ELEMENT_ARRAY_BUFFER, GpuBuffer::STATIC_DRAW ); - } - - mVertexBuffer->UpdateDataBuffer( vertexData->mVertices.size() * sizeof(TextVertex2D), &vertexData->mVertices[0] ); - - UpdateIndexBuffer( vertexData->mVertices.size() ); // Used in DoRender() - - // Get inverted text size, as this is faster for the shader to operate on, - // and shader won't throw any errors performing a multiplication rather than a divide by zero - // on a bad size value. - mGeometryExtent = vertexData->mGeometryExtent; - } - else - { - // no text to display, delete the GPU buffers, this will stop anything rendering. - mVertexBuffer.Reset(); - mIndexBuffer.Reset(); - } - // vertex data no longer required. - delete vertexData; -} - -void TextRenderer::SetFontSize( float pixelSize ) -{ - mPixelSize = pixelSize; -} - -void TextRenderer::SetGradient( const Vector4& color, const Vector2& startPoint, const Vector2& endPoint ) -{ - AllocateTextParameters(); - mTextParameters->SetGradient( color, startPoint, endPoint ); -} - -void TextRenderer::SetTextColor( const Vector4& color ) -{ - if( NULL == mTextColor ) - { - mTextColor = new Vector4( color ); - } - else - { - *mTextColor = color; - } -} - -void TextRenderer::SetOutline( const bool enable, const Vector4& color, const Vector2& params ) -{ - AllocateTextParameters(); - - mTextParameters->SetOutline( enable, color, params ); -} - -void TextRenderer::SetGlow( const bool enable, const Vector4& color, const float params ) -{ - AllocateTextParameters(); - - mTextParameters->SetGlow( enable, color, params ); -} - -void TextRenderer::SetDropShadow( const bool enable, const Vector4& color, const Vector2& offset, const float size ) -{ - AllocateTextParameters(); - - mTextParameters->SetShadow( enable, color, offset, size ); -} - -void TextRenderer::SetSmoothEdge( float params ) -{ - mSmoothing = params; -} - -void TextRenderer::GlContextDestroyed() -{ - if( mVertexBuffer ) - { - mVertexBuffer->GlContextDestroyed(); - } - if( mIndexBuffer ) - { - mIndexBuffer->GlContextDestroyed(); - } -} - -void TextRenderer::GlCleanup() -{ - mVertexBuffer.Reset(); - mIndexBuffer.Reset(); -} - -bool TextRenderer::RequiresDepthTest() const -{ - return false; -} - -bool TextRenderer::CheckResources() -{ - if ( ! ( mVertexBuffer && mIndexBuffer ) ) - { - // This character has no geometry, must be a white space - return true; - } - - if( !mVertexBuffer->BufferIsValid() ) - { - return false; - } - - if( mTexture == NULL ) - { - mTexture = mTextureCache->GetTexture( mTextureId ); - - if( mTexture == NULL ) - { - // texture atlas hasn't been created yet - return false; - } - } - if( mTexture->GetTextureId() == 0 ) - { - return false; - } - - return true; -} - -void TextRenderer::ResolveGeometryTypes( BufferIndex bufferIndex, GeometryType& outType, ShaderSubTypes& outSubType ) -{ - outType = GEOMETRY_TYPE_TEXT; - - // If we have a color gradient, then we cannot use the default shader. - - outSubType = SHADER_DEFAULT; - if( mTextParameters ) - { - if( mTextParameters->IsOutlineEnabled() ) - { - if( mTextParameters->IsGlowEnabled() ) - { - outSubType = SHADER_GRADIENT_OUTLINE_GLOW; - } - else - { - outSubType = SHADER_GRADIENT_OUTLINE; - } - } - else if( mTextParameters->IsGlowEnabled() ) - { - outSubType = SHADER_GRADIENT_GLOW; - } - else if( mTextParameters->IsDropShadowEnabled() ) - { - outSubType = SHADER_GRADIENT_SHADOW; - } - else - { - outSubType = SHADER_GRADIENT; - } - } -} - -bool TextRenderer::IsOutsideClipSpace( const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix ) -{ - mContext->IncrementRendererCount(); - - Rect boundingBox(mGeometryExtent.width*-0.5f, mGeometryExtent.height*-0.5f, mGeometryExtent.width, mGeometryExtent.height); - DEBUG_BOUNDING_BOX( *mContext, boundingBox, modelViewProjectionMatrix ); - - if(Is2dBoxOutsideClipSpace( modelMatrix, modelViewProjectionMatrix, boundingBox ) ) - { - mContext->IncrementCulledCount(); - return true; - } - return false; -} - -void TextRenderer::DoRender( BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix ) -{ - DALI_ASSERT_DEBUG( NULL != mTexture && "TextRenderer::DoRender. mTexture == NULL." ); - if( NULL == mTexture ) - { - // Nothing to render. - return; - } - - DALI_LOG_INFO( gTextFilter, Debug::General, "TextRenderer::DoRender(this: %p) textureId:%d\n", this, mTextureId ); - - mTextureCache->BindTexture( mTexture, mTextureId, GL_TEXTURE_2D, TEXTURE_UNIT_TEXT ); - if( mTexture->GetTextureId() == 0 ) - { - return; // early out if we haven't got a GL texture yet (e.g. due to context loss) - } - - // Set sampler uniform - const GLint samplerLoc = program.GetUniformLocation( Program::UNIFORM_SAMPLER ); - if( Program::UNIFORM_UNKNOWN != samplerLoc ) - { - // set the uniform - program.SetUniform1i( samplerLoc, TEXTURE_UNIT_TEXT ); - } - - mTexture->ApplySampler( TEXTURE_UNIT_TEXT, mSamplerBitfield ); - - const float SMOOTHING_ADJUSTMENT( 12.0f ); - const float SMOOTHING_ADJUSTMENT_PIXEL_SIZE( 32.0f ); - - float smoothWidth = SMOOTHING_ADJUSTMENT / mPixelSize; - float smoothing = mSmoothing; - - const GLint smoothingLoc = program.GetUniformLocation( Program::UNIFORM_SMOOTHING ); - if( Program::UNIFORM_UNKNOWN != smoothingLoc ) - { - smoothWidth = std::min( std::min(mSmoothing, 1.0f - mSmoothing), smoothWidth ); - - if( mPixelSize < SMOOTHING_ADJUSTMENT_PIXEL_SIZE ) - { - smoothing *= Lerp( mPixelSize / SMOOTHING_ADJUSTMENT_PIXEL_SIZE, 0.5f, 1.0f ); - } - - program.SetUniform2f( smoothingLoc, std::max(0.0f, smoothing - smoothWidth), std::min(1.0f, smoothing + smoothWidth) ); - } - - if( mTextParameters ) - { - if( mTextParameters->IsOutlineEnabled() ) - { - const GLint outlineLoc = program.GetUniformLocation( Program::UNIFORM_OUTLINE ); - const GLint outlineColorLoc = program.GetUniformLocation( Program::UNIFORM_OUTLINE_COLOR ); - - if( Program::UNIFORM_UNKNOWN != outlineLoc && Program::UNIFORM_UNKNOWN != outlineColorLoc ) - { - const Vector2& outline = mTextParameters->GetOutlineThickness(); - const Vector4& outlineColor = mTextParameters->GetOutlineColor(); - float outlineWidth = outline[1] + smoothWidth; - float outlineStart = outline[0]; - float outlineEnd = std::min( 1.0f, outlineStart + outlineWidth ); - - program.SetUniform2f(outlineLoc, outlineStart, outlineEnd); - program.SetUniform4f(outlineColorLoc, outlineColor.r, outlineColor.g, outlineColor.b, outlineColor.a); - } - } - - if( mTextParameters->IsGlowEnabled() ) - { - const GLint glowLoc = program.GetUniformLocation( Program::UNIFORM_GLOW ); - const GLint glowColorLoc = program.GetUniformLocation( Program::UNIFORM_GLOW_COLOR ); - - if( Program::UNIFORM_UNKNOWN != glowLoc && Program::UNIFORM_UNKNOWN != glowColorLoc ) - { - // if mGlow is > mSmoothing we get an inverted glyph, so clamp the value - program.SetUniform1f(glowLoc, std::min(mTextParameters->GetGlowIntensity(), mSmoothing)); - const Vector4& glowColor = mTextParameters->GetGlowColor(); - program.SetUniform4f(glowColorLoc, glowColor.r, glowColor.g, glowColor.b, glowColor.a); - } - } - - if( mTextParameters->IsDropShadowEnabled() ) - { - const GLint shadowLoc = program.GetUniformLocation( Program::UNIFORM_SHADOW ); - const GLint shadowColorLoc = program.GetUniformLocation( Program::UNIFORM_SHADOW_COLOR ); - const GLint shadowSmoothingLoc = program.GetUniformLocation( Program::UNIFORM_SHADOW_SMOOTHING ); - - if( Program::UNIFORM_UNKNOWN != shadowLoc && Program::UNIFORM_UNKNOWN != shadowColorLoc && Program::UNIFORM_UNKNOWN != shadowSmoothingLoc ) - { - // convert shadow offset from tile to atlas coordinates - const Vector2& offset( mTextParameters->GetDropShadowOffset() / mTexture->GetWidth()); - float shadowSmoothing = std::max(0.0f, smoothing - mTextParameters->GetDropShadowSize() ); - program.SetUniform2f(shadowLoc, offset.x, offset.y); - const Vector4& dropShadowColor = mTextParameters->GetDropShadowColor(); - program.SetUniform4f(shadowColorLoc, dropShadowColor.r, dropShadowColor.g, dropShadowColor.b, dropShadowColor.a); - program.SetUniform2f( shadowSmoothingLoc, std::max(0.0f, shadowSmoothing - smoothWidth), std::min(1.0f, shadowSmoothing + smoothWidth) ); - } - } - } - - // Set the text color uniform - const GLint textColorLoc = program.GetUniformLocation( Program::UNIFORM_TEXT_COLOR ); - if( Program::UNIFORM_UNKNOWN != textColorLoc ) - { - Vector4 textColor( (NULL != mTextColor) ? *mTextColor : TextStyle::DEFAULT_TEXT_COLOR ); - - program.SetUniform4f(textColorLoc, textColor.r, textColor.g, textColor.b, textColor.a); - } - - if( mTextParameters ) - { - // All shaders except default shader require the uGradientLine.zw uniform to be set - // at the very least. (setting it to vec2(0.0, 0.0) will disable gradient) - Vector2 projection( Vector2::ZERO ); - Vector2 startPoint( TextStyle::DEFAULT_GRADIENT_START_POINT ); - startPoint = mTextParameters->GetGradientStartPoint(); - projection = mTextParameters->GetGradientEndPoint() - startPoint; - if( mTextParameters->IsGradientEnabled() ) // same as: mGradientEndPoint != mGradientStartPoint - { - projection /= projection.LengthSquared(); - - // For valid gradients Gradient Color and Text Size information must be set. - const GLint gradientColorLoc = program.GetUniformLocation( Program::UNIFORM_GRADIENT_COLOR ); - const GLint textSizeLoc = program.GetUniformLocation( Program::UNIFORM_INVERSE_TEXT_SIZE ); - - if( Program::UNIFORM_UNKNOWN != gradientColorLoc && Program::UNIFORM_UNKNOWN != textSizeLoc ) - { - const Vector4& color = mTextParameters->GetGradientColor(); - program.SetUniform4f( gradientColorLoc, color.r, color.g, color.b, color.a ); - - Vector2 invTextSize( mGeometryExtent ); - invTextSize.x = invTextSize.x > Math::MACHINE_EPSILON_1 ? 1.0f / invTextSize.x : 1.0f; - invTextSize.y = invTextSize.y > Math::MACHINE_EPSILON_1 ? 1.0f / invTextSize.y : 1.0f; - - program.SetUniform2f( textSizeLoc, invTextSize.width, invTextSize.height ); - } - } - - // If we don't have a gradient present (mGradientEnabled) but the shader requires - // gradient information (gradientRequired), then we set - // uGradientLine.zw = vec2(0.0, 0.0) to force vColor = uColor in the expression. - // If we do have a gradient present, then we set up all information. - const GLint gradientLineLoc = program.GetUniformLocation( Program::UNIFORM_GRADIENT_LINE ); - if( Program::UNIFORM_UNKNOWN != gradientLineLoc ) - { - program.SetUniform4f( gradientLineLoc, - startPoint.x - 0.5f, - startPoint.y - 0.5f, - projection.x, - projection.y ); - } - } - - const GLint positionLoc = program.GetAttribLocation(Program::ATTRIB_POSITION); - const GLint texCoordLoc = program.GetAttribLocation(Program::ATTRIB_TEXCOORD); - - mContext->EnableVertexAttributeArray( positionLoc ); - mContext->EnableVertexAttributeArray( texCoordLoc ); - - // bind the buffers - DALI_ASSERT_DEBUG( mVertexBuffer->BufferIsValid() ); - mVertexBuffer->Bind(); - DALI_ASSERT_DEBUG( mIndexBuffer->BufferIsValid() ); - mIndexBuffer->Bind(); - - TextVertex2D* v = 0; - mContext->VertexAttribPointer(positionLoc, 2, GL_FLOAT, GL_FALSE, sizeof(TextVertex2D), &v->mX); - mContext->VertexAttribPointer(texCoordLoc, 4, GL_FLOAT, GL_FALSE, sizeof(TextVertex2D), &v->mU); - - const GLsizei indexCount = mIndexBuffer->GetBufferSize() / sizeof(GLushort); // compiler will optimize this to >> if possible - mContext->DrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_SHORT, (void *) 0); - DRAW_ELEMENT_RECORD( indexCount ); - - mContext->DisableVertexAttributeArray( positionLoc ); - mContext->DisableVertexAttributeArray( texCoordLoc ); - -} - -TextRenderer::TextRenderer( RenderDataProvider& dataprovider ) -: Renderer( dataprovider ), - mTexture( NULL ), - mTextColor( NULL ), - mVertexBuffer(), - mIndexBuffer(), - mTextParameters(), - mGeometryExtent(), - mTextureId( 0 ), - mSmoothing( Dali::TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD ), - mPixelSize(0.0f) -{ -} - -} // namespace SceneGraph - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/render/renderers/scene-graph-text-renderer.h b/dali/internal/render/renderers/scene-graph-text-renderer.h deleted file mode 100644 index fdb18ad..0000000 --- a/dali/internal/render/renderers/scene-graph-text-renderer.h +++ /dev/null @@ -1,202 +0,0 @@ -#ifndef __DALI_INTERNAL_SCENE_GRAPH_TEXT_RENDERER_H__ -#define __DALI_INTERNAL_SCENE_GRAPH_TEXT_RENDERER_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -class TextParameters; - -namespace SceneGraph -{ - -class RenderDataProvider; -class TextureCache; - -/** - * Renders text from a font atlas. - */ -class TextRenderer : public Renderer, public TextureObserver -{ -public: - - /** - * Construct a new TextRenderer. - * @param dataprovider to render - * @return The newly allocated TextRenderer - */ - static TextRenderer* New( RenderDataProvider& dataprovider ); - - /** - * Virtual destructor - */ - virtual ~TextRenderer(); - - /** - * Set the vertex data used for rendering the text. - * Deletes the data once it has been uploaded to GL. - * @param[in] vertexData The vertex data. - */ - void SetVertexData( TextVertexBuffer* vertexData ); - - /** - * Set the pixel size of the font, required by the shader - * @param pixelSize The pixel size - */ - void SetFontSize( float pixelSize ); - - /** - * @see Dali::TextActor::SetGradientColor() - * @see Dali::TextActor::SetGradientStartPoint() - * @see Dali::TextActor::SetGradientEndPoint() - */ - void SetGradient( const Vector4& color, const Vector2& startPoint, const Vector2& endPoint ); - - /** - * @copydoc Dali::TextActor::SetTextColor() - */ - void SetTextColor( const Vector4& color ); - - /** - * @copydoc Dali::TextActor::SetOutline(const bool,const Vector4&,const Vector2&) - */ - void SetOutline( bool enable, const Vector4& color, const Vector2& params ); - - /** - * @copydoc Dali::TextActor::SetGlow(const bool,const Vector4&,const float) - */ - void SetGlow( bool enable, const Vector4& color, float params ); - - /** - * @copydoc Dali::TextActor::SetShadow(const bool,const Vector4&,const Vector2&,const float) - */ - void SetDropShadow( bool enable, const Vector4& color, const Vector2& offset, const float size ); - - /** - * @copydoc Dali::TextActor::SetSmoothEdge(const float) - */ - void SetSmoothEdge( float params ); - - /** - * @copydoc Dali::Internal::GlResourceOwner::GlContextDestroyed() - */ - virtual void GlContextDestroyed(); - - /** - * @copydoc Dali::Internal::GlResourceOwner::GlCleanup() - */ - virtual void GlCleanup(); - - /** - * @copydoc Dali::Internal::SceneGraph::Renderer::RequiresDepthTest() - */ - virtual bool RequiresDepthTest() const; - - /** - * @copydoc Dali::Internal::SceneGraph::Renderer::CheckResources() - */ - virtual bool CheckResources(); - - /** - * @copydoc Dali::Internal::SceneGraph::Renderer::ResolveGeometryTypes() - */ - virtual void ResolveGeometryTypes( BufferIndex bufferIndex, GeometryType& outType, ShaderSubTypes& outSubType ); - - /** - * @copydoc Dali::Internal::SceneGraph::Renderer::IsOutsideClipSpace() - */ - virtual bool IsOutsideClipSpace( const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix ); - - /** - * @copydoc Dali::Internal::SceneGraph::Renderer::DoRender() - */ - virtual void DoRender( BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix ); - -protected: // TextureObserver implementation - /** - * @copydoc Dali::Internal::TextureObserver::TextureDiscarded() - */ - virtual void TextureDiscarded( ResourceId textureId ); - -private: - /** - * Set the texture used to render. - * @param[in] textureId The id of the texture used to render. - */ - void SetTextureId( ResourceId textureId ); - - /** - * Update the index buffer - * @param size number of verts - */ - void UpdateIndexBuffer( std::size_t size ); - - /** - * Allocate a TextParameters object on this TextRenderer if one does not exist - */ - void AllocateTextParameters(); - - /** - * Private constructor. @see New() - */ - TextRenderer( RenderDataProvider& dataprovider ); - - // Undefined - TextRenderer( const TextRenderer& copy ); - - // Undefined - TextRenderer& operator=(const TextRenderer& rhs); - -private: - - Texture* mTexture; ///< pointer to texture - Vector4* mTextColor; ///< optional color - - OwnerPointer< GpuBuffer > mVertexBuffer; ///< GPU Buffer containing Vertex coordinate (and texture coordinate) information - OwnerPointer< GpuBuffer > mIndexBuffer; ///< GPU Buffer containing Index information - OwnerPointer< TextParameters > mTextParameters; ///< Optional text parameters - - Vector2 mGeometryExtent; // actual geometry extent - - ResourceId mTextureId; - - float mSmoothing; - float mPixelSize; -}; - -} // namespace SceneGraph - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_SCENE_GRAPH_TEXT_RENDERER_H__ diff --git a/dali/internal/render/shader-source/text-distance-field-glow.txt b/dali/internal/render/shader-source/text-distance-field-glow.txt deleted file mode 100644 index bc18e0e..0000000 --- a/dali/internal/render/shader-source/text-distance-field-glow.txt +++ /dev/null @@ -1,58 +0,0 @@ - - -attribute mediump vec3 aPosition; -attribute mediump vec2 aTexCoord; - -uniform mediump mat4 uMvpMatrix; -uniform lowp vec4 uColor; -uniform lowp vec4 uTextColor; -uniform lowp vec4 uGradientColor; -uniform mediump vec4 uGradientLine; -uniform mediump vec2 uInvTextSize; - -varying mediump vec2 vTexCoord; -varying lowp vec4 vColor; - -void main() -{ - gl_Position = uMvpMatrix * vec4(aPosition, 1.0); - vTexCoord = aTexCoord; - - lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw ); - - vColor = mix(uTextColor, uGradientColor, f); -} - - - - - -uniform mediump sampler2D sTexture; -uniform lowp vec4 uColor; -uniform highp vec2 uSmoothing; -uniform highp float uGlow; -uniform lowp vec4 uGlowColor; - -varying mediump vec2 vTexCoord; -varying lowp vec4 vColor; - -void main() -{ - // sample distance field - mediump float distance = texture2D(sTexture, vTexCoord).a; - - mediump float glowBlend = smoothstep(uSmoothing[0], uSmoothing[1], distance); - - // blend fragment color between glow color and text color - lowp vec4 clampedColor = clamp( vColor, 0.0, 1.0 ); - lowp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a ); - lowp vec4 color = mix(glowColor, clampedColor, glowBlend); - - // fade out glow between uSmoothing and uGlow - color.a *= smoothstep(uGlow, uSmoothing[0], distance); - - // final color multiplied by Actor color - gl_FragColor = uColor * color; -} - - diff --git a/dali/internal/render/shader-source/text-distance-field-outline-glow.txt b/dali/internal/render/shader-source/text-distance-field-outline-glow.txt deleted file mode 100644 index 6196349..0000000 --- a/dali/internal/render/shader-source/text-distance-field-outline-glow.txt +++ /dev/null @@ -1,68 +0,0 @@ - - -attribute mediump vec3 aPosition; -attribute mediump vec2 aTexCoord; - -uniform mediump mat4 uMvpMatrix; -uniform lowp vec4 uColor; -uniform lowp vec4 uTextColor; -uniform lowp vec4 uGradientColor; -uniform mediump vec4 uGradientLine; -uniform mediump vec2 uInvTextSize; - -varying mediump vec2 vTexCoord; -varying lowp vec4 vColor; - -void main() -{ - gl_Position = uMvpMatrix * vec4(aPosition, 1.0); - vTexCoord = aTexCoord; - - lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw ); - - vColor = mix(uTextColor, uGradientColor, f); -} - - - - - -uniform mediump sampler2D sTexture; -uniform lowp vec4 uColor; -uniform highp vec2 uSmoothing; -uniform highp vec2 uOutline; -uniform lowp vec4 uOutlineColor; -uniform highp float uGlow; -uniform lowp vec4 uGlowColor; - -varying mediump vec2 vTexCoord; -varying lowp vec4 vColor; - -void main() -{ - // sample distance field - mediump float distance = texture2D(sTexture, vTexCoord).a; - - // blend fragment color between outline color and text color - mediump float outlineBlend = smoothstep(uOutline[0], uOutline[1], distance); - - lowp vec4 clampedColor = clamp( vColor, 0.0, 1.0 ); - - // create blend between text color and outline color using outlineBlend - lowp vec4 outlineColor = vec4( uOutlineColor.rgb, uOutlineColor.a * clampedColor.a ); - lowp vec4 color = mix(outlineColor, clampedColor, outlineBlend); - - mediump float glowBlend = smoothstep(uSmoothing[0], uSmoothing[1], distance); - - // blend fragment color between glow color and text color - lowp vec4 glowColor = vec4( uGlowColor.rgb, uGlowColor.a * clampedColor.a ); - color = mix(glowColor, color, glowBlend); - - // fade out glow between uSmoothing and uGlow - color.a *= smoothstep(uGlow, uSmoothing[0], distance); - - // final color multiplied by Actor color - gl_FragColor = uColor * color; -} - - diff --git a/dali/internal/render/shader-source/text-distance-field-outline.txt b/dali/internal/render/shader-source/text-distance-field-outline.txt deleted file mode 100644 index 2e786d5..0000000 --- a/dali/internal/render/shader-source/text-distance-field-outline.txt +++ /dev/null @@ -1,57 +0,0 @@ - - -attribute mediump vec3 aPosition; -attribute mediump vec2 aTexCoord; - -uniform mediump mat4 uMvpMatrix; -uniform lowp vec4 uColor; -uniform lowp vec4 uTextColor; -uniform lowp vec4 uGradientColor; -uniform mediump vec4 uGradientLine; -uniform mediump vec2 uInvTextSize; - -varying mediump vec2 vTexCoord; -varying lowp vec4 vColor; - -void main() -{ - gl_Position = uMvpMatrix * vec4(aPosition, 1.0); - vTexCoord = aTexCoord; - - lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw ); - - vColor = mix(uTextColor, uGradientColor, f); -} - - - - - -uniform mediump sampler2D sTexture; -uniform lowp vec4 uColor; -uniform highp vec2 uSmoothing; -uniform mediump vec2 uOutline; -uniform lowp vec4 uOutlineColor; - -varying highp vec2 vTexCoord; -varying lowp vec4 vColor; - -void main() -{ - // sample distance field - highp float distance = texture2D(sTexture, vTexCoord).a; - - // blend fragment color between outline color and text color - highp float outlineBlend = smoothstep(uOutline[0], uOutline[1], distance); - lowp vec4 clampedColor = clamp( vColor, 0.0, 1.0 ); - lowp vec4 outlineColor = vec4( uOutlineColor.rgb, uOutlineColor.a * clampedColor.a ); - lowp vec4 color = mix(outlineColor, clampedColor, outlineBlend); - - // adjust fragment alpha by sampled distance - color.a *= smoothstep(uSmoothing[0], uSmoothing[1], distance); - - // final color multiplied by Actor color - gl_FragColor = uColor * color; -} - - diff --git a/dali/internal/render/shader-source/text-distance-field-shadow.txt b/dali/internal/render/shader-source/text-distance-field-shadow.txt deleted file mode 100644 index a7c99ee..0000000 --- a/dali/internal/render/shader-source/text-distance-field-shadow.txt +++ /dev/null @@ -1,80 +0,0 @@ - - -attribute mediump vec3 aPosition; -attribute highp vec4 aTexCoord; - -uniform mediump mat4 uMvpMatrix; -uniform lowp vec4 uColor; -uniform lowp vec4 uTextColor; -uniform highp vec2 uShadow; -uniform lowp vec4 uGradientColor; -uniform mediump vec4 uGradientLine; -uniform mediump vec2 uInvTextSize; - -varying highp vec2 vTexCoord; -varying highp vec2 vShadowCoord; -varying lowp vec4 vColor; - -void main() -{ - gl_Position = uMvpMatrix * vec4(aPosition, 1.0); - vTexCoord = aTexCoord.xy; - vShadowCoord = vTexCoord - (uShadow * aTexCoord.zw); - - lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw ); - vColor = mix(uTextColor, uGradientColor, f); -} - - - - - -uniform mediump sampler2D sTexture; -uniform lowp vec4 uColor; -uniform highp vec2 uSmoothing; -uniform highp vec2 uShadowSmoothing; -uniform lowp vec4 uShadowColor; - -varying highp vec2 vTexCoord; -varying highp vec2 vShadowCoord; -varying lowp vec4 vColor; - -void main() -{ - // sample distance field - mediump float distance = texture2D(sTexture, vTexCoord).a; - mediump float shadow_distance = texture2D(sTexture, vShadowCoord).a; - - mediump float inText = smoothstep(uSmoothing[0], uSmoothing[1], distance); - mediump float inShadow = smoothstep(uShadowSmoothing[0], uShadowSmoothing[1], shadow_distance); - - lowp vec4 color; - - mediump float oneMinusSrcAlpha = (1.0 - inText) * inShadow; - - lowp vec4 clampedColor = clamp( vColor, 0.0, 1.0 ); - lowp vec4 cText = vec4( clampedColor.rgb, clampedColor.a * inText ); - lowp vec4 cShadow = vec4(uShadowColor.rgb, uShadowColor.a * clampedColor.a * inShadow); - - // completely outside shadow, maybe inside text - if( inShadow <= 0.0 ) - { - color = cText; - } - // completely outside text, definitely inside shadow - else if( inText <= 0.0 ) - { - color = cShadow; - } - // inside text and/or shadow border(s) - else - { - color.rgb = mix( cText.rgb, cShadow.rgb, oneMinusSrcAlpha ); - color.a = max(cText.a, cShadow.a); - } - - // final color multiplied by Actor color - gl_FragColor = uColor * color; -} - - diff --git a/dali/internal/render/shader-source/text-distance-field.txt b/dali/internal/render/shader-source/text-distance-field.txt deleted file mode 100644 index a02a980..0000000 --- a/dali/internal/render/shader-source/text-distance-field.txt +++ /dev/null @@ -1,69 +0,0 @@ - - -attribute mediump vec3 aPosition; -attribute mediump vec2 aTexCoord; - -uniform mediump mat4 uModelView; -uniform mediump mat4 uProjection; -uniform mediump mat4 uMvpMatrix; -uniform mediump mat3 uNormalMatrix; -uniform lowp vec4 uColor; -uniform lowp vec4 uTextColor; - -varying mediump vec2 vTexCoord; - -#ifdef USE_GRADIENT -uniform lowp vec4 uGradientColor; -uniform mediump vec4 uGradientLine; -uniform mediump vec2 uInvTextSize; - -varying lowp vec4 vColor; -#endif - -void main() -{ - gl_Position = uMvpMatrix * vec4(aPosition, 1.0); - vTexCoord = aTexCoord; - -#ifdef USE_GRADIENT - lowp float f = dot( aPosition.xy * uInvTextSize - uGradientLine.xy, uGradientLine.zw ); - vColor = mix(uTextColor, uGradientColor, f); -#endif -} - - - - - -uniform mediump sampler2D sTexture; -uniform highp vec4 sTextureRect; -uniform lowp vec4 uColor; -uniform highp vec2 uSmoothing; - -varying highp vec2 vTexCoord; - -#ifdef USE_GRADIENT -varying lowp vec4 vColor; -#else -uniform lowp vec4 uTextColor; -#endif - -void main() -{ - // sample distance field - highp float distance = texture2D(sTexture, vTexCoord).a; - -#ifdef USE_GRADIENT - lowp vec4 color = clamp(vColor, 0., 1.); // gradiant calculation can overflow. -#else - lowp vec4 color = uTextColor; -#endif - - // adjust fragment alpha by sampled distance - color.a *= smoothstep(uSmoothing[0], uSmoothing[1], distance ); - - // final color multiplied by Actor color - gl_FragColor = uColor * color; -} - - diff --git a/dali/internal/render/shaders/program.cpp b/dali/internal/render/shaders/program.cpp index 8b145fc..5ba1279 100644 --- a/dali/internal/render/shaders/program.cpp +++ b/dali/internal/render/shaders/program.cpp @@ -102,19 +102,7 @@ const char* gStdUniforms[ Program::UNIFORM_TYPE_LAST ] = "sEffectRect", // UNIFORM_EFFECT_SAMPLER_RECT "uTimeDelta", // UNIFORM_TIME_DELTA "sOpacityTexture", // UNIFORM_SAMPLER_OPACITY - "sNormalMapTexture", // UNIFORM_SAMPLER_NORMAL_MAP - "uTextColor", // UNIFORM_TEXT_COLOR - "uSmoothing", // UNIFORM_SMOOTHING - "uOutline", // UNIFORM_OUTLINE - "uOutlineColor", // UNIFORM_OUTLINE_COLOR - "uGlow", // UNIFORM_GLOW - "uGlowColor", // UNIFORM_GLOW_COLOR - "uShadow", // UNIFORM_SHADOW - "uShadowColor", // UNIFORM_SHADOW_COLOR - "uShadowSmoothing", // UNIFORM_SHADOW_SMOOTHING - "uGradientColor", // UNIFORM_GRADIENT_COLOR - "uGradientLine", // UNIFORM_GRADIENT_LINE - "uInvTextSize" // UNIFORM_INVERSE_TEXT_SIZE + "sNormalMapTexture" // UNIFORM_SAMPLER_NORMAL_MAP }; } // namespace diff --git a/dali/internal/render/shaders/program.h b/dali/internal/render/shaders/program.h index 3968cb0..67663a7 100644 --- a/dali/internal/render/shaders/program.h +++ b/dali/internal/render/shaders/program.h @@ -46,13 +46,7 @@ class ProgramCache; /* * A program contains a vertex & fragment shader. * - * A program will contain vertex attributes and uniform variables - * E.g. inside the code for our text fragment shaders we have the line: - * \code - * uniform lowp vec4 uColor - * \endcode - * - * This describes a variable used to color text as it is drawn. + * A program will contain vertex attributes and uniform variables. * * uColor is set to the value specified by Actor::SetColor and is * animatable through the property Actor::COLOR @@ -111,19 +105,6 @@ public: UNIFORM_SAMPLER_OPACITY, UNIFORM_SAMPLER_NORMAL_MAP, - UNIFORM_TEXT_COLOR, - UNIFORM_SMOOTHING, - UNIFORM_OUTLINE, - UNIFORM_OUTLINE_COLOR, - UNIFORM_GLOW, - UNIFORM_GLOW_COLOR, - UNIFORM_SHADOW, - UNIFORM_SHADOW_COLOR, - UNIFORM_SHADOW_SMOOTHING, - UNIFORM_GRADIENT_COLOR, - UNIFORM_GRADIENT_LINE, - UNIFORM_INVERSE_TEXT_SIZE, - UNIFORM_TYPE_LAST }; diff --git a/dali/internal/render/shaders/shader.cpp b/dali/internal/render/shaders/shader.cpp index 5d20a67..e23b2e3 100644 --- a/dali/internal/render/shaders/shader.cpp +++ b/dali/internal/render/shaders/shader.cpp @@ -84,10 +84,6 @@ inline unsigned int GetGeometryTypeIndex(GeometryType type) { index = Log::value; } - else if ( type & GEOMETRY_TYPE_TEXT ) - { - index = Log::value; - } else if ( type & GEOMETRY_TYPE_UNTEXTURED_MESH ) { index = Log::value; @@ -257,7 +253,7 @@ void Shader::SetProgram( GeometryType geometryType, } const unsigned int geometryIndex = GetGeometryTypeIndex( geometryType ); - if(geometryType != GEOMETRY_TYPE_TEXT && subType == SHADER_SUBTYPE_ALL) + if(subType == SHADER_SUBTYPE_ALL) { mPrograms[geometryIndex].Resize(1); mPrograms[geometryIndex][theSubType] = program; diff --git a/dali/internal/update/manager/prepare-render-instructions.cpp b/dali/internal/update/manager/prepare-render-instructions.cpp index bae7711..cdbe555 100644 --- a/dali/internal/update/manager/prepare-render-instructions.cpp +++ b/dali/internal/update/manager/prepare-render-instructions.cpp @@ -53,7 +53,7 @@ inline void SetOpaqueRenderFlags( RenderList& renderList, bool transparentRender // and this renderer does not need depth test against itself (for example a mesh actor) // if this layer has got exactly one opaque renderer // and this renderer is not interested in depth testing - // (i.e. is an image or text and not a model) + // (i.e. is an image and not a model) if ( ( ( renderList.Count() == 1 ) && ( !transparentRenderersExist ) && ( !renderList.GetRenderer( 0 )->RequiresDepthTest() ) ) || diff --git a/dali/internal/update/manager/update-algorithms.cpp b/dali/internal/update/manager/update-algorithms.cpp index 0c9e900..50636ee 100644 --- a/dali/internal/update/manager/update-algorithms.cpp +++ b/dali/internal/update/manager/update-algorithms.cpp @@ -246,7 +246,7 @@ inline void UpdateNodeWorldMatrix( Node& node, RenderableAttachment& updatedRend { if( updatedRenderable.UsesGeometryScaling() ) { - // scaling, i.e. Text or Mesh + // scaling, i.e. Mesh Vector3 scaling; updatedRenderable.GetScaleForSize( node.GetSize( updateBufferIndex ), scaling ); if( node.GetInhibitLocalTransform() ) diff --git a/dali/internal/update/node-attachments/scene-graph-text-attachment.cpp b/dali/internal/update/node-attachments/scene-graph-text-attachment.cpp deleted file mode 100644 index ae81d64..0000000 --- a/dali/internal/update/node-attachments/scene-graph-text-attachment.cpp +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(DEBUG_ENABLED) -namespace -{ -Debug::Filter* gTextFilter = Debug::Filter::New(Debug::Concise, false, "LOG_SCENE_GRAPH_TEXT_ATTACHMENT"); -} -#endif - -namespace Dali -{ - -namespace Internal -{ - -namespace SceneGraph -{ - -TextAttachment* TextAttachment::New( ) -{ - return new TextAttachment; -} - -TextAttachment::TextAttachment() -: RenderableAttachment( true ), // scale enabled - mTextRenderer( NULL ), - mGeometrySize(), // Vector2::ZERO - mGeometryScaling(), // Vector2::ZERO - mAtlasId(0) -{ - DALI_LOG_INFO(gTextFilter, Debug::General, "TextAttachment::constructor(this=%p)\n", this); -} - -void TextAttachment::ConnectToSceneGraph2( BufferIndex updateBufferIndex ) -{ - DALI_ASSERT_DEBUG( NULL != mSceneController ); - - // Create the renderer, passing ownership to the render-thread - mTextRenderer = TextRenderer::New( *mParent ); - mTextRenderer->SetUseBlend( true ); // Text renderer always requires blending - - mSceneController->GetRenderMessageDispatcher().AddRenderer( *mTextRenderer ); -} - -void TextAttachment::OnDestroy2() -{ - DALI_ASSERT_DEBUG( NULL != mSceneController ); - - // Request deletion in the next Render - mSceneController->GetRenderMessageDispatcher().RemoveRenderer( *mTextRenderer ); - mTextRenderer = NULL; -} - -TextAttachment::~TextAttachment() -{ -} - -Renderer& TextAttachment::GetRenderer() -{ - return *mTextRenderer; -} - -const Renderer& TextAttachment::GetRenderer() const -{ - return *mTextRenderer; -} - -void TextAttachment::SetTextVertexBuffer( BufferIndex updateBufferIndex, TextVertexBuffer* vertexBuffer ) -{ - DALI_LOG_INFO( gTextFilter, Debug::Verbose, "TextAttachment::SetTextVertexBuffer( vertexBuffer:%p\n", vertexBuffer ); - - if( vertexBuffer ) - { - mGeometrySize = vertexBuffer->mVertexMax; - SetRecalculateScaleForSize(); // update cached scaling if geometry is changed - mAtlasId = vertexBuffer->mTextureId; - - typedef MessageValue1< TextRenderer, OwnerPointer< TextVertexBuffer> > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( mTextRenderer, &TextRenderer::SetVertexData, vertexBuffer ); - } -} - -void TextAttachment::SetTextFontSize( BufferIndex updateBufferIndex, float pixelSize ) -{ - typedef MessageValue1< TextRenderer, float > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( mTextRenderer, &TextRenderer::SetFontSize, pixelSize ); -} - -void TextAttachment::SetGradient( BufferIndex updateBufferIndex, const Vector4& color, const Vector2& startPoint, const Vector2& endPoint ) -{ - DALI_ASSERT_DEBUG(mSceneController); - - typedef MessageValue3< TextRenderer, Vector4, Vector2, Vector2 > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( mTextRenderer, &TextRenderer::SetGradient, color, startPoint, endPoint ); -} - -void TextAttachment::SetTextColor( BufferIndex updateBufferIndex, const Vector4& color ) -{ - DALI_ASSERT_DEBUG(mSceneController); - - typedef MessageValue1< TextRenderer, Vector4 > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( mTextRenderer, &TextRenderer::SetTextColor, color ); -} - -void TextAttachment::SetOutline( BufferIndex updateBufferIndex, const bool enable, const Vector4& color, const Vector2& params ) -{ - DALI_ASSERT_DEBUG(mSceneController); - - typedef MessageValue3< TextRenderer, bool, Vector4, Vector2 > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( mTextRenderer, &TextRenderer::SetOutline, enable, color, params ); -} - -void TextAttachment::SetGlow( BufferIndex updateBufferIndex, const bool enable, const Vector4& color, const float params ) -{ - DALI_ASSERT_DEBUG(mSceneController); - - typedef MessageValue3< TextRenderer, bool, Vector4, float > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( mTextRenderer, &TextRenderer::SetGlow, enable, color, params ); -} - -void TextAttachment::SetDropShadow( BufferIndex updateBufferIndex, const bool enable, const Vector4& color, const Vector2& offset, const float size ) -{ - DALI_ASSERT_DEBUG(mSceneController); - - typedef MessageValue4< TextRenderer, bool, Vector4, Vector2, float > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( mTextRenderer, &TextRenderer::SetDropShadow, enable, color, offset, size ); -} - -void TextAttachment::SetSmoothEdge( BufferIndex updateBufferIndex, const float params ) -{ - DALI_ASSERT_DEBUG(mSceneController); - - typedef MessageValue1< TextRenderer, float > DerivedType; - - // Reserve some memory inside the render queue - unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) ); - - // Construct message in the render queue memory; note that delete should not be called on the return value - new (slot) DerivedType( mTextRenderer, &TextRenderer::SetSmoothEdge, params ); -} - -void TextAttachment::ShaderChanged( BufferIndex updateBufferIndex ) -{ - // nothing to do -} - -void TextAttachment::SizeChanged( BufferIndex updateBufferIndex ) -{ - SetRecalculateScaleForSize(); -} - -bool TextAttachment::DoPrepareResources( BufferIndex updateBufferIndex, ResourceManager& resourceManager ) -{ - bool resourcesAvailable = false; - mFinishedResourceAcquisition = false; - - if( mAtlasId > 0) - { - if( resourceManager.IsResourceLoaded( mAtlasId ) ) - { - // Check if currently loading glyph sets have finished writing to atlas - resourcesAvailable = true; - - Integration::LoadStatus status = resourceManager.GetAtlasLoadStatus( mAtlasId ); - - if( status == Integration::RESOURCE_COMPLETELY_LOADED) - { - // all glyphs are loaded with high quality - mFinishedResourceAcquisition = true; - } - } - } - - DALI_LOG_INFO(gTextFilter, Debug::Verbose, "TextAttachment::DoPrepareResources(this=%p) == %d Complete:%d\n", this, resourcesAvailable, mFinishedResourceAcquisition); - - return resourcesAvailable; -} - -void TextAttachment::DoPrepareRender( BufferIndex updateBufferIndex ) -{ -} - -void TextAttachment::DoGetScaleForSize( const Vector3& nodeSize, Vector3& scaling ) -{ - // update cached scale for size if needed - if( IsScaleForSizeDirty() ) - { - // scale the geometry to fill the actor - if( mGeometrySize.width > 0.0f ) - { - mGeometryScaling.width = nodeSize.width / mGeometrySize.width; - } - if( mGeometrySize.height > 0.0f ) - { - mGeometryScaling.height = nodeSize.height / mGeometrySize.height; - } - } - // use the already calculated value - scaling.width = mGeometryScaling.width; - scaling.height = mGeometryScaling.height; - scaling.depth = 1.0f; -} - -} // namespace SceneGraph - -} // namespace Internal - -} // namespace Dali diff --git a/dali/internal/update/node-attachments/scene-graph-text-attachment.h b/dali/internal/update/node-attachments/scene-graph-text-attachment.h deleted file mode 100644 index 4fc873b..0000000 --- a/dali/internal/update/node-attachments/scene-graph-text-attachment.h +++ /dev/null @@ -1,298 +0,0 @@ -#ifndef __DALI_INTERNAL_SCENE_GRAPH_TEXT_ATTACHMENT_H__ -#define __DALI_INTERNAL_SCENE_GRAPH_TEXT_ATTACHMENT_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include -#include - -namespace Dali -{ - -namespace Internal -{ - -class TextParameters; - -namespace SceneGraph -{ - -class TextRenderer; -class Shader; -class RenderQueue; - -/** - * An attachment for rendering text from a font atlas. - */ -class TextAttachment : public RenderableAttachment -{ -public: - - /** - * Construct a new TextAttachment. - * @return a new TextAttachment - */ - static TextAttachment* New(); - - /** - * Virtual destructor - */ - virtual ~TextAttachment(); - - /** - * @copydoc RenderableAttachment::GetRenderer(). - */ - virtual Renderer& GetRenderer(); - - /** - * @copydoc RenderableAttachment::GetRenderer(). - */ - virtual const Renderer& GetRenderer() const; - - /** - * Set the text vertex buffer; ownership is passed to the renderer. - * This is to avoid duplicate data being held in the text-attachment and the scene-graph-text-attachment. - * @param[in] updateBufferIndex The current update buffer index. - * @param[in] vertexBuffer vertex buffer - */ - void SetTextVertexBuffer( BufferIndex updateBufferIndex, TextVertexBuffer* vertexBuffer ); - - /** - * Set the pixel size of the font, this is passed to the renderer - * @param updateBufferIndex The current update buffer index. - * @param pixelSize The new pixel size - */ - void SetTextFontSize( BufferIndex updateBufferIndex, float pixelSize ); - - /** - * Sets the gradient start point, the gradient end point and the color associated with the gradient end point. - * @param[in] updateBufferIndex The current update buffer index. - * @param[in] color The gradient color (end-point color) - * @param[in] startPoint The relative position of the gradient start point. - * @param[in] endPoint The relative position of the gradient end point. - */ - void SetGradient( BufferIndex updateBufferIndex, const Vector4& color, const Vector2& startPoint, const Vector2& endPoint ); - - /** - * Set the text color. - * @param[in] updateBufferIndex The current update buffer index. - * @param[in] color The text color. - */ - void SetTextColor( BufferIndex updateBufferIndex, const Vector4& color ); - - /** - * Set text outlining. - * @param[in] updateBufferIndex The current update buffer index. - * @param[in] enable Set to true to enable text outlining. - * @param[in] color Outline color. - * @param[in] thickness Thickness of outline. - */ - void SetOutline( BufferIndex updateBufferIndex, bool enable, const Vector4& color, const Vector2& thickness ); - - /** - * Set text glow. - * @param[in] updateBufferIndex The current update buffer index. - * @param[in] enable Set to true to enable text outer glow. - * @param[in] color Glow color. - * @param[in] intensity Determines the amount of glow around text. - */ - void SetGlow( BufferIndex updateBufferIndex, bool enable, const Vector4& color, float intensity ); - - /** - * Set text shadow. - * @param[in] updateBufferIndex The current update buffer index. - * @param[in] enable Set to true to enable text drop shadow. - * @param[in] color Shadow color. - * @param[in] offset Offset in pixels. To avoid cropping of the drop shadow limit the offset to PointSize / 3.5. - * @param[in] size Size of shadow in pixels. 0 means the shadow is the same size as the text. - */ - void SetDropShadow( BufferIndex updateBufferIndex, bool enable, const Vector4& color, const Vector2& offset, const float size ); - - /** - * Set soft edge smoothing. - * @param[in] updateBufferIndex The current update buffer index. - * @param[in] smoothEdge Specify the distance field value for the center of the text edge. - */ - void SetSmoothEdge( BufferIndex updateBufferIndex, float smoothEdge ); - - /** - * @copydoc RenderableAttachment::ShaderChanged() - */ - virtual void ShaderChanged( BufferIndex updateBufferIndex ); - - /** - * @copydoc RenderableAttachment::SizeChanged() - */ - virtual void SizeChanged( BufferIndex updateBufferIndex ); - - /** - * @copydoc RenderableAttachment::DoPrepareRender() - */ - virtual void DoPrepareRender( BufferIndex updateBufferIndex ); - - /** - * @copydoc RenderableAttachment::IsFullyOpaque() - */ - virtual bool IsFullyOpaque( BufferIndex updateBufferIndex ) - { - return false; // false since drawing text requires alpha - } - - /** - * @copydoc RenderableAttachment::GetScaleForSize() - */ - virtual void DoGetScaleForSize( const Vector3& nodeSize, Vector3& scaling ); - -protected: - - /** - * Protected constructor. See New() - */ - TextAttachment(); - -private: - - /** - * @copydoc RenderableAttachment::ConnectToSceneGraph2(). - */ - virtual void ConnectToSceneGraph2( BufferIndex updateBufferIndex ); - - /** - * @copydoc RenderableAttachment::OnDestroy2(). - */ - virtual void OnDestroy2(); - - /** - * @copydoc RenderableAttachment::DoPrepareResources() - */ - virtual bool DoPrepareResources( BufferIndex updateBufferIndex, ResourceManager& resourceManager ); - - // Undefined - TextAttachment(const TextAttachment&); - - // Undefined - TextAttachment& operator=(const TextAttachment& rhs); - -private: - - TextRenderer* mTextRenderer; ///< Raw-pointers to renderer that is owned by RenderManager - Vector2 mGeometrySize; ///< used for geometry scaling - Vector2 mGeometryScaling; ///< used for geometry scaling - - unsigned int mAtlasId; ///< atlas Id from last vertex buffer - -}; - -inline void SetTextVertexBufferMessage( EventToUpdate& eventToUpdate, const TextAttachment& attachment, TextVertexBuffer& buffer) -{ - typedef MessageDoubleBuffered1< TextAttachment, OwnerPointer< TextVertexBuffer> > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &attachment, &TextAttachment::SetTextVertexBuffer, &buffer ); -} - -inline void SetTextFontSizeMessage( EventToUpdate& eventToUpdate, const TextAttachment& attachment, float pixelSize ) -{ - typedef MessageDoubleBuffered1< TextAttachment, float > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &attachment, &TextAttachment::SetTextFontSize, pixelSize ); -} - -inline void SetGradientMessage( EventToUpdate& eventToUpdate, const TextAttachment& attachment, const Vector4& color, const Vector2& startPoint, const Vector2& endPoint ) -{ - typedef MessageDoubleBuffered3< TextAttachment, Vector4, Vector2, Vector2 > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &attachment, &TextAttachment::SetGradient, color, startPoint, endPoint ); -} - -inline void SetTextColorMessage( EventToUpdate& eventToUpdate, const TextAttachment& attachment, const Vector4& color ) -{ - typedef MessageDoubleBuffered1< TextAttachment, Vector4 > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &attachment, &TextAttachment::SetTextColor, color ); -} - -inline void SetOutlineMessage( EventToUpdate& eventToUpdate, const TextAttachment& attachment, bool enable, const Vector4& color, const Vector2& params ) -{ - typedef MessageDoubleBuffered3< TextAttachment, bool, Vector4, Vector2 > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &attachment, &TextAttachment::SetOutline, enable, color, params ); -} - -inline void SetGlowMessage( EventToUpdate& eventToUpdate, const TextAttachment& attachment, bool enable, const Vector4& color, float params ) -{ - typedef MessageDoubleBuffered3< TextAttachment, bool, Vector4, float > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &attachment, &TextAttachment::SetGlow, enable, color, params ); -} - -inline void SetDropShadowMessage( EventToUpdate& eventToUpdate, const TextAttachment& attachment, bool enable, const Vector4& color, const Vector2& offset, const float size ) -{ - typedef MessageDoubleBuffered4< TextAttachment, bool, Vector4, Vector2, float > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &attachment, &TextAttachment::SetDropShadow, enable, color, offset, size ); -} - -inline void SetSmoothEdgeMessage( EventToUpdate& eventToUpdate, const TextAttachment& attachment, float params ) -{ - typedef MessageDoubleBuffered1< TextAttachment, float > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &attachment, &TextAttachment::SetSmoothEdge, params ); -} - -} // namespace SceneGraph - -} // namespace Internal - -} // namespace Dali - -#endif // __DALI_INTERNAL_SCENE_GRAPH_TEXT_ATTACHMENT_H__ diff --git a/dali/internal/update/resources/atlas-request-status.cpp b/dali/internal/update/resources/atlas-request-status.cpp deleted file mode 100644 index dc865fa..0000000 --- a/dali/internal/update/resources/atlas-request-status.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include - -using namespace Dali::Integration; -using std::make_pair; - -namespace Dali -{ -namespace Internal -{ - -AtlasRequestStatus::AtlasRequestStatus() -{ -} - -AtlasRequestStatus::~AtlasRequestStatus() -{ -} - -void AtlasRequestStatus::CheckAndSaveTextRequest( ResourceId id, const ResourceTypePath& typePath ) -{ - if( typePath.type->id == ResourceText ) - { - const TextResourceType* textResource = static_cast(typePath.type); - ResourceId atlasId = textResource->mTextureAtlasId; - - AtlasStatusIter iter = mAtlasStatus.find(atlasId); - if( iter == mAtlasStatus.end() ) - { - // Create new one - GlyphLoadStatusContainer glyphStatusMap; - glyphStatusMap.insert(make_pair(id, RESOURCE_LOADING)); - mAtlasStatus.insert(make_pair(atlasId, glyphStatusMap)); - } - else - { - // append - iter->second.insert(make_pair(id, RESOURCE_LOADING)); - } - } -} - -void AtlasRequestStatus::Update( ResourceId id, ResourceId atlasId, LoadStatus loadStatus ) -{ - AtlasStatusIter iter = mAtlasStatus.find(atlasId); - if( iter != mAtlasStatus.end() ) - { - GlyphLoadStatusContainer& glyphRequests = iter->second; - GlyphLoadStatusIter glyphIter = glyphRequests.find(id); - DALI_ASSERT_DEBUG( glyphIter != glyphRequests.end() ); - if( glyphIter != glyphRequests.end() ) - { - glyphIter->second = loadStatus; - } - } -} - -bool AtlasRequestStatus::IsLoadComplete( ResourceId atlasId ) -{ - bool complete = false; - if( ! mAtlasStatus.empty() ) - { - AtlasStatusIter iter = mAtlasStatus.find(atlasId); - if( iter != mAtlasStatus.end() ) - { - GlyphLoadStatusContainer& glyphRequests = iter->second; - if( ! glyphRequests.empty() ) - { - complete = true; - for( GlyphLoadStatusIter glyphIter = glyphRequests.begin(), glyphEnd = glyphRequests.end() ; - glyphIter != glyphEnd ; - glyphIter++) - { - if(glyphIter->second != RESOURCE_COMPLETELY_LOADED) - { - complete = false; - break; - } - } - } - } - } - return complete; -} - -LoadStatus AtlasRequestStatus::GetLoadStatus( ResourceId atlasId ) -{ - // status initially set to loaded - // if a partially loaded glyphset is encountered it is set to RESOURCE_PARTIALLY_LOADED - // if a loading glyphset is found RESOURCE_LOADING is returned instantly - LoadStatus loadStatus = RESOURCE_COMPLETELY_LOADED; - - if( ! mAtlasStatus.empty() ) - { - AtlasStatusIter iter = mAtlasStatus.find(atlasId); - if( iter != mAtlasStatus.end() ) - { - GlyphLoadStatusContainer& glyphRequests = iter->second; - if( ! glyphRequests.empty() ) - { - for( GlyphLoadStatusIter glyphIter = glyphRequests.begin(), glyphEnd = glyphRequests.end() ; - glyphIter != glyphEnd ; - glyphIter++) - { - if( glyphIter->second == RESOURCE_LOADING ) - { - // return if a glyphset is still being loaded - return RESOURCE_LOADING; - } - else if( glyphIter->second == RESOURCE_PARTIALLY_LOADED ) - { - loadStatus = RESOURCE_PARTIALLY_LOADED; - } - } - } - } - } - return loadStatus; -} - - -void AtlasRequestStatus::Remove( ResourceId atlasId ) -{ - mAtlasStatus.erase(atlasId); -} - -} // Internal -} // Dali diff --git a/dali/internal/update/resources/atlas-request-status.h b/dali/internal/update/resources/atlas-request-status.h deleted file mode 100644 index a2d7e5e..0000000 --- a/dali/internal/update/resources/atlas-request-status.h +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef __DALI_INTERNAL_UPDATE_RESOURCES_ATLAS_REQUEST_STATUS_H__ -#define __DALI_INTERNAL_UPDATE_RESOURCES_ATLAS_REQUEST_STATUS_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include - -namespace Dali -{ - -namespace Integration -{ -class GlyphSet; -} - -namespace Internal -{ - -/** - * This class stores the loading status of each glyph set associated with each atlas. - * Although the glyph set resources are transient, their load status is kept here - * after the request is completed. - */ -class AtlasRequestStatus -{ -public: - // Structures to store the load status for each glyph set of an atlas - typedef std::pair GlyphLoadStatusPair; - typedef std::map GlyphLoadStatusContainer; - typedef GlyphLoadStatusContainer::iterator GlyphLoadStatusIter; - - typedef std::pair AtlasStatusPair; - typedef std::map AtlasStatusContainer; - typedef AtlasStatusContainer::iterator AtlasStatusIter; - - /** - * Constructor - */ - AtlasRequestStatus(); - - /** - * Destructor - */ - ~AtlasRequestStatus(); - - /** - * If this is a text request, add it to the atlas status - * @param[in] id Resource id of a resource to load - * @param[in] typePath Type of a resource to load - */ - void CheckAndSaveTextRequest( Integration::ResourceId id, const ResourceTypePath& typePath ); - - /** - * After a text resource load response, update the atlas with it's status - * @param[in] id Id of the text request - * @param[in] atlasId The atlas Id - * @param[in] loadStatus status of the glyph set - */ - void Update( Integration::ResourceId id, Integration::ResourceId atlasId, Integration::LoadStatus loadStatus ); - - /** - * Check if all the glyph requests have completed - * @param[in] atlasId Resource id of the atlas - * @return true if all associated glyph requests have finished loading - */ - bool IsLoadComplete( Integration::ResourceId atlasId ); - - /** - * Check the current load status of requests in the atlas. - * If any requests are still loading it will return loading. - * @param[in] atlasId Resource id of the atlas - * @return Load status of for the atlas - */ - Integration::LoadStatus GetLoadStatus( Integration::ResourceId atlasId ); - - /** - * Remove atlas status - * @param[in] atlasId Resource ID of the atlas - */ - void Remove( Integration::ResourceId atlasId ); - -private: - /** Undefined copy constructor */ - AtlasRequestStatus(const AtlasRequestStatus& rhs); - - /** Undefined assignment operator */ - AtlasRequestStatus& operator=(const AtlasRequestStatus& rhs); - - AtlasStatusContainer mAtlasStatus; ///< glyph request status for each atlas -}; - -} // Internal -} // Dali - -#endif // __DALI_INTERNAL_UPDATE_RESOURCES_ATLAS_REQUEST_STATUS_H__ diff --git a/dali/internal/update/resources/resource-manager.cpp b/dali/internal/update/resources/resource-manager.cpp index cb430cf..405b93a 100644 --- a/dali/internal/update/resources/resource-manager.cpp +++ b/dali/internal/update/resources/resource-manager.cpp @@ -28,7 +28,6 @@ #include #include -#include #include #include @@ -36,13 +35,10 @@ #include #include #include -#include -#include #include #include #include -#include #include #include @@ -157,8 +153,6 @@ struct ResourceManager::ResourceManagerImpl LiveRequestContainer saveRequests; ///< copy of id's being saved (must also be in newCompleteRequests or oldCompleteRequests) LiveRequestContainer completeSaveRequests; ///< successful save ids are moved from saveRequests to here - AtlasRequestStatus atlasStatus; ///< load status of text atlases - /** * This is the resource cache. It's filled/emptied from within Core::Update() */ @@ -286,11 +280,6 @@ void ResourceManager::HandleLoadResourceRequest( ResourceId id, const ResourceTy // Add ID to the loading set mImpl->loadingRequests.insert(id); - // Update atlas status if this request is a text request - mImpl->atlasStatus.CheckAndSaveTextRequest(id, typePath); - - ClearRequestedGlyphArea(id, typePath); - // Make the load request last mImpl->mPlatformAbstraction.LoadResource(ResourceRequest(id, *typePath.type, typePath.path, priority)); } @@ -303,13 +292,6 @@ void ResourceManager::HandleDecodeResourceRequest( { DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: HandleDecodeResourceRequest(id:%u, buffer.size:%u, type.id:%u)\n", id, buffer->GetVector().Size(), typePath.type->id); - // We would update atlas status and clear the glyph area if text were supported and this request was a text request: - if( typePath.type->id == ResourceText ) - { - DALI_LOG_WARNING("Decoding from memory buffers not supported for Text resources."); - return; - } - // Add ID to the loading set mImpl->loadingRequests.insert(id); @@ -533,10 +515,6 @@ void ResourceManager::HandleSaveResourceRequest( ResourceId id, const ResourceTy { break; } - case ResourceText: - { - break; - } } if( resource ) // i.e. if it's a saveable resource @@ -620,11 +598,6 @@ void ResourceManager::HandleDiscardResourceRequest( ResourceId deadId, ResourceT } } -void ResourceManager::HandleAtlasUpdateRequest( ResourceId id, ResourceId atlasId, LoadStatus loadStatus ) -{ - mImpl->atlasStatus.Update(id, atlasId, loadStatus ); -} - /******************************************************************************** ******************** Event thread object direct interface ********************* ********************************************************************************/ @@ -732,16 +705,6 @@ ShaderDataPtr ResourceManager::GetShaderData(ResourceId id) return shaderData; } -bool ResourceManager::IsAtlasLoaded(ResourceId id) -{ - return mImpl->atlasStatus.IsLoadComplete(id); -} - -LoadStatus ResourceManager::GetAtlasLoadStatus( ResourceId atlasId ) -{ - return mImpl->atlasStatus.GetLoadStatus( atlasId ); -} - /******************************************************************************** ************************* ResourceCache Implementation ************************ ********************************************************************************/ @@ -839,17 +802,6 @@ void ResourceManager::LoadResponse( ResourceId id, ResourceTypeId type, Resource { break; } - - case ResourceText: - { - /* here we return a vector of Characters (glyph data + bitmap)*/ - GlyphSetPointer glyphSet = static_cast(resource.Get()); - DALI_ASSERT_DEBUG( glyphSet ); - UploadGlyphsToTexture(*glyphSet); - mImpl->atlasStatus.Update(id, glyphSet->GetAtlasResourceId(), loadStatus ); - SendToClient( LoadingGlyphSetSucceededMessage( *mImpl->mResourceClient, id, glyphSet, loadStatus) ); - break; - } } // Let ResourceClient know that the resource manager has loaded something that its clients might want to hear about: @@ -932,63 +884,6 @@ void ResourceManager::SaveFailed(ResourceId id, ResourceFailure failure) ********************************* Private Methods ***************************** ********************************************************************************/ -void ResourceManager::ClearRequestedGlyphArea( ResourceId id, const ResourceTypePath& typePath ) -{ - if( typePath.type->id == ResourceText ) - { - const TextResourceType *textResourceType = static_cast(typePath.type); - ResourceId atlasId = textResourceType->mTextureAtlasId; - - BitmapClearArray clearAreas; - - float blockSize = GlyphAtlasSize::GetBlockSize(); - // Get x, y from each character: - for( TextResourceType::CharacterList::const_iterator iter = textResourceType->mCharacterList.begin(), - end = textResourceType->mCharacterList.end() ; - iter != end ; iter ++ ) - { - Vector2 clearArea( iter->xPosition, iter->yPosition ); - clearAreas.push_back(clearArea); - } - - mImpl->mTextureCacheDispatcher.DispatchClearAreas( atlasId, clearAreas, blockSize, 0x00 ); - } -} - -void ResourceManager::UploadGlyphsToTexture( const GlyphSet& glyphSet ) -{ - // the glyphset contains an array of bitmap / characters . - // This function uploads the bitmaps to the associated texture atlas - - const GlyphSet::CharacterList& charList( glyphSet.GetCharacterList() ); - BitmapUploadArray uploadArray; - - for(std::size_t i = 0, count = charList.size() ; i < count; i++ ) - { - const GlyphSet::Character& character( charList[i] ); - - // grab a pointer to the bitmap - Bitmap* bitmap( character.first.Get() ); - - // create a bitmap upload object, then add it to the array - BitmapUpload upload( bitmap->ReleaseBuffer(), // Inform the bitmap we're taking ownership of it's pixel buffer. - character.second.xPosition, // x position in the texture to which upload the bitmap - character.second.yPosition, // y position in the texture to which upload the bitmap - bitmap->GetImageWidth(), // bitmap width - bitmap->GetImageHeight(), // bitmap height - BitmapUpload::DISCARD_PIXEL_DATA ); // tell the the texture to delete the bitmap pixel buffer when it's done - - uploadArray.push_back( upload ); - } - - ResourceId textureId = glyphSet.GetAtlasResourceId(); - if( IsResourceLoaded( textureId ) ) - { - mImpl->mTextureCacheDispatcher.DispatchUploadBitmapArrayToTexture( textureId, uploadArray ); - } -} - - void ResourceManager::NotifyTickets() { DALI_ASSERT_DEBUG( mImpl->mResourceClient != NULL ); @@ -1072,11 +967,6 @@ void ResourceManager::DiscardDeadResources( BufferIndex updateBufferIndex ) } break; - case ResourceText: - { - break; - } - case ResourceShader: { ShaderCacheIter shaderIter = mImpl->mShaders.find(iter->first); @@ -1087,8 +977,6 @@ void ResourceManager::DiscardDeadResources( BufferIndex updateBufferIndex ) } } - mImpl->atlasStatus.Remove(iter->first); - // Erase the item and increment the iterator mImpl->deadRequests.erase(iter++); } diff --git a/dali/internal/update/resources/resource-manager.h b/dali/internal/update/resources/resource-manager.h index 2a2a947..854f7fb 100644 --- a/dali/internal/update/resources/resource-manager.h +++ b/dali/internal/update/resources/resource-manager.h @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -254,11 +253,6 @@ public: // Used by ResourceClient void HandleAllocateMeshRequest (ResourceId id, MeshData* meshData); /** - * Requests allocation of a font resource - */ - void HandleAllocateFontRequest(ResourceId id, const std::string& familyNameAndStyle); - - /** * Load a shader program from a file * @param[in] id The resource id * @param[in] typePath The type & path of the resource @@ -301,14 +295,6 @@ public: // Used by ResourceClient */ void HandleDiscardResourceRequest( ResourceId id, Integration::ResourceTypeId typeId ); - /** - * Update font texture atlas status - * @param[in] id The resource id - * @param[in] atlasId texture ID of the atlas - * @param[in] loadStatus The status update. - */ - void HandleAtlasUpdateRequest( ResourceId id, ResourceId atlasId, Integration::LoadStatus loadStatus ); - /******************************************************************************** ******************** Event thread object direct interface ********************* ********************************************************************************/ @@ -362,21 +348,6 @@ public: // Used by ResourceClient */ Integration::ShaderDataPtr GetShaderData(ResourceId id); - /** - * Check if current set of glyph requests on given atlas have finished loading - * @param[in] id Request Id of the text atlas texture - * @return true if the current set of glyph requests have all completed, false - * if there are outstanding glyph requests that haven't finished. - */ - bool IsAtlasLoaded(ResourceId id); - - /** - * Check the load status of a given atlas. - * @param[in] id Request Id of the text atlas texture - * @return LoadStatus - */ - Integration::LoadStatus GetAtlasLoadStatus( ResourceId atlasId ); - /******************************************************************************** ************************* ResourceCache Implementation ************************ ********************************************************************************/ @@ -406,17 +377,6 @@ public: ********************************* Private Methods ***************************** ********************************************************************************/ private: - /** - * @param[in] id Resource id to clear - * @param[in] typePath Glyphs to be loaded, and cleared beforehand - */ - void ClearRequestedGlyphArea( ResourceId id, const ResourceTypePath& typePath ); - - /** - * Sends loaded glyphs to texture atlas for uploading - * @param[in] glyphSet Loaded glyphs - */ - void UploadGlyphsToTexture( const Integration::GlyphSet& glyphSet ); /** * Sends notification messages for load sucess & failure, @@ -588,20 +548,6 @@ inline void RequestAllocateMeshMessage( EventToUpdate& eventToUpdate, new (slot) LocalType( &manager, &ResourceManager::HandleAllocateMeshRequest, id, meshData.Release() ); } -inline void RequestAllocateFontMessage( EventToUpdate& eventToUpdate, - ResourceManager& manager, - ResourceId id, - const std::string& familyNameAndStyle) -{ - typedef MessageValue2< ResourceManager, ResourceId, std::string > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &manager, &ResourceManager::HandleAllocateFontRequest, id, familyNameAndStyle ); -} - inline void RequestLoadShaderMessage( EventToUpdate& eventToUpdate, ResourceManager& manager, ResourceId id, @@ -690,21 +636,6 @@ inline void RequestDiscardResourceMessage( EventToUpdate& eventToUpdate, new (slot) LocalType( &manager, &ResourceManager::HandleDiscardResourceRequest, id, typeId ); } -inline void RequestAtlasUpdateMessage( EventToUpdate& eventToUpdate, - ResourceManager& manager, - ResourceId id, - ResourceId atlasId, - Integration::LoadStatus loadStatus ) -{ - typedef MessageValue3< ResourceManager, ResourceId, ResourceId, Integration::LoadStatus > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &manager, &ResourceManager::HandleAtlasUpdateRequest, id, atlasId, loadStatus ); -} - } // namespace Internal } // namespace Dali diff --git a/dali/public-api/actors/mesh-actor.cpp b/dali/public-api/actors/mesh-actor.cpp index c73ac89..f327292 100644 --- a/dali/public-api/actors/mesh-actor.cpp +++ b/dali/public-api/actors/mesh-actor.cpp @@ -19,6 +19,7 @@ #include // INTERNAL INCLUDES +#include #include #include #include diff --git a/dali/public-api/actors/text-actor.cpp b/dali/public-api/actors/text-actor.cpp deleted file mode 100644 index f87df0d..0000000 --- a/dali/public-api/actors/text-actor.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include - -namespace Dali -{ - -using std::string; - -const char* const TextActor::SIGNAL_TEXT_LOADING_FINISHED = "text-loading-finished"; - -TextActor::TextActor() -{ -} - -TextActor TextActor::New() -{ - TextActorParameters parameters; - Internal::TextActorPtr internal = Internal::TextActor::New( Integration::TextArray(), parameters ); - - return TextActor( internal.Get() ); -} - -TextActor TextActor::New( const Text& text ) -{ - TextActorParameters parameters( TextStyle(), TextActorParameters::FONT_DETECTION_ON ); - return New( text, parameters ); -} - -TextActor TextActor::New( const Text& text, const TextActorParameters& parameters ) -{ - Internal::TextActorPtr internal = Internal::TextActor::New( Internal::GetTextArray( text ), parameters ); - - return TextActor( internal.Get() ); -} - -TextActor TextActor::DownCast( BaseHandle handle ) -{ - return TextActor( dynamic_cast(handle.GetObjectPtr()) ); -} - -TextActor::~TextActor() -{ -} - -TextActor::TextActor(const TextActor& copy) -: RenderableActor(copy) -{ -} - -TextActor& TextActor::operator=(const TextActor& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} - -string TextActor::GetText() const -{ - return GetImplementation(*this).GetText(); -} - -void TextActor::SetText(const Text& text) -{ - GetImplementation(*this).SetText( Internal::GetTextArray( text ) ); -} - -void TextActor::SetToNaturalSize() -{ - GetImplementation(*this).SetToNaturalSize(); -} - -Font TextActor::GetFont() const -{ - Internal::Font* font = GetImplementation(*this).GetFont(); - - return Font(font); -} - -void TextActor::SetFont(Font& font) -{ - GetImplementation(*this).SetFont(GetImplementation(font)); -} - -void TextActor::SetGradientColor( const Vector4& color ) -{ - GetImplementation(*this).SetGradientColor( color ); -} - -Vector4 TextActor::GetGradientColor() const -{ - return GetImplementation(*this).GetGradientColor(); -} - -void TextActor::SetGradientStartPoint( const Vector2& position ) -{ - GetImplementation(*this).SetGradientStartPoint( position ); -} - -Vector2 TextActor::GetGradientStartPoint() const -{ - return GetImplementation(*this).GetGradientStartPoint(); -} - -void TextActor::SetGradientEndPoint( const Vector2& position ) -{ - GetImplementation(*this).SetGradientEndPoint( position ); -} - -Vector2 TextActor::GetGradientEndPoint() const -{ - return GetImplementation(*this).GetGradientEndPoint(); -} - -void TextActor::SetTextStyle( const TextStyle& style ) -{ - GetImplementation(*this).SetTextStyle( style ); -} - -TextStyle TextActor::GetTextStyle() const -{ - return GetImplementation(*this).GetTextStyle(); -} - -void TextActor::SetTextColor( const Vector4& color ) -{ - GetImplementation(*this).SetTextColor(color); -} - -Vector4 TextActor::GetTextColor() const -{ - return GetImplementation(*this).GetTextColor(); -} - -void TextActor::SetSmoothEdge( float smoothEdge ) -{ - GetImplementation(*this).SetSmoothEdge(smoothEdge); -} - -void TextActor::SetOutline( bool enable, const Vector4& color, const Vector2& thickness ) -{ - GetImplementation(*this).SetOutline(enable, color, thickness); -} - -void TextActor::SetGlow( bool enable, const Vector4& color, float intensity ) -{ - GetImplementation(*this).SetGlow(enable, color, intensity); -} - -void TextActor::SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size ) -{ - GetImplementation(*this).SetShadow(enable, color, offset, size); -} - -void TextActor::SetItalics( bool enabled, Degree angle ) -{ - GetImplementation(*this).SetItalics( enabled ? Radian(angle) : Radian( 0.0f ) ); -} - -void TextActor::SetItalics( bool enabled, Radian angle ) -{ - GetImplementation(*this).SetItalics( enabled ? angle : Radian( 0.0f ) ); -} - -bool TextActor::GetItalics() const -{ - return GetImplementation(*this).GetItalics(); -} - -Radian TextActor::GetItalicsAngle() const -{ - return GetImplementation(*this).GetItalicsAngle(); -} - -void TextActor::SetUnderline( bool enable ) -{ - GetImplementation(*this).SetUnderline( enable, 0.f, 0.f ); -} - -bool TextActor::GetUnderline() const -{ - return GetImplementation(*this).GetUnderline(); -} - -void TextActor::SetWeight( TextStyle::Weight weight ) -{ - GetImplementation(*this).SetWeight( weight ); -} - -TextStyle::Weight TextActor::GetWeight() const -{ - return GetImplementation(*this).GetWeight(); -} - -void TextActor::SetFontDetectionAutomatic(bool value) -{ - GetImplementation(*this).SetFontDetectionAutomatic(value); -} - -bool TextActor::IsFontDetectionAutomatic() const -{ - return GetImplementation(*this).IsFontDetectionAutomatic(); -} - -LoadingState TextActor::GetLoadingState() const -{ - return GetImplementation(*this).GetLoadingState(); -} - -TextActor::TextActor(Internal::TextActor* internal) -: RenderableActor(internal) -{ -} - -} // namespace Dali diff --git a/dali/public-api/actors/text-actor.h b/dali/public-api/actors/text-actor.h deleted file mode 100644 index 15d46c1..0000000 --- a/dali/public-api/actors/text-actor.h +++ /dev/null @@ -1,417 +0,0 @@ -#ifndef __DALI_TEXT_ACTOR_H__ -#define __DALI_TEXT_ACTOR_H__ - -/* - * Copyright (c) 2014 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 - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -struct TextActorParameters; -class Font; - -namespace Internal DALI_INTERNAL -{ -class TextActor; -} - -/** - * @brief TextActor is a basic actor for displaying a text label - * - * By default the text actor always uses the natural size of the text when SetText is called, - * unless SetSize is called to override the size or size is animated to some other size. - * Natural size for TextActor is the same as the size returned by Font::MeasureText( string ) - * using the font that the TextActor is using. - * - * By default CullFaceMode is set to CullNone to enable the TextActor to be viewed from all angles. - */ -class DALI_IMPORT_API TextActor : public RenderableActor -{ -public: - - typedef SignalV2< void (TextActor) > TextSignalV2; ///< Text available signal type - - //Signal Names - static const char* const SIGNAL_TEXT_LOADING_FINISHED; ///< name "text-loading-finished" - - // Default Properties; additional to RenderableActor properties - static const Property::Index TEXT; ///< name "text" type STRING - static const Property::Index FONT; ///< name "font" type STRING - static const Property::Index FONT_STYLE; ///< name "font-style" type STRING - static const Property::Index OUTLINE_ENABLE; ///< name "outline-enable" type BOOLEAN - static const Property::Index OUTLINE_COLOR; ///< name "outline-color" type VECTOR4 - static const Property::Index OUTLINE_THICKNESS_WIDTH; ///< name "outline-thickness-width" type VECTOR2 - static const Property::Index SMOOTH_EDGE; ///< name "smooth-edge" type FLOAT - static const Property::Index GLOW_ENABLE; ///< name "glow-enable" type BOOLEAN - static const Property::Index GLOW_COLOR; ///< name "glow-color" type VECTOR4 - static const Property::Index GLOW_INTENSITY; ///< name "glow-intensity" type FLOAT - static const Property::Index SHADOW_ENABLE; ///< name "shadow-enable" type BOOLEAN - static const Property::Index SHADOW_COLOR; ///< name "shadow-color" type VECTOR4 - static const Property::Index SHADOW_OFFSET; ///< name "shadow-offset" type VECTOR2 - static const Property::Index ITALICS_ANGLE; ///< name "italics-angle" type FLOAT - static const Property::Index UNDERLINE; ///< name "underline" type BOOLEAN - static const Property::Index WEIGHT; ///< name "weight" type INTEGER - static const Property::Index FONT_DETECTION_AUTOMATIC; ///< name "font-detection-automatic" type BOOLEAN - static const Property::Index GRADIENT_COLOR; ///< name "gradient-color" type VECTOR4 - static const Property::Index GRADIENT_START_POINT; ///< name "gradient-start-point" type VECTOR2 - static const Property::Index GRADIENT_END_POINT; ///< name "gradient-end-point" type VECTOR2 - static const Property::Index SHADOW_SIZE; ///< name "shadow-size" type FLOAT - static const Property::Index TEXT_COLOR; ///< name "text-color" type VECTOR4 - - /** - * @brief Create an uninitialized TextActor handle. - * - * This can be initialised with TextActor::New(). - * Calling member functions with an uninitialized handle is not allowed. - */ - TextActor(); - - /** - * @brief Create a TextActor object with no text. - * - * @return A handle to a newly allocated Dali resource. - */ - static TextActor New(); - - /** - * @brief Create a TextActor object with text, a default style and font detection. - * - * @param[in] text The text which will be displayed - */ - static TextActor New( const Text& text ); - - /** - * @brief Create a TextActor object with text. - * - * The style and whether to automatically detect the font could be set in the parameters. - * - * @param[in] text The text which will be displayed - * @param[in] parameters Text parameters. - */ - static TextActor New( const Text& text, const TextActorParameters& parameters ); - - /** - * @brief Downcast an Object handle to TextActor. - * - * If handle points to a TextActor the downcast produces valid - * handle. If not the returned handle is left uninitialized. - * @param[in] handle to An object - * @return handle to a TextActor or an uninitialized handle - */ - static TextActor DownCast( BaseHandle handle ); - - /** - * @brief Destructor - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~TextActor(); - - /** - * @brief Copy constructor - * - * @param [in] copy The actor to copy. - */ - TextActor(const TextActor& copy); - - /** - * @brief Assignment operator - * - * @param [in] rhs The actor to copy. - */ - TextActor& operator=(const TextActor& rhs); - - /** - * @brief Get the text label displayed by the actor. - * - * @pre The text actor has been initialized. - * @return The text label - */ - std::string GetText() const; - - /** - * @brief Set the text label displayed by the actor. - * - * @pre The text actor has been initialized. - * @param [in] text The new text label - */ - void SetText(const Text& text); - - /** - * @brief Set text to the natural size of the text string. - * - * After this method the text actor always uses the natural size of the text - * when SetText is called unless SetSize is called to override the size. - */ - void SetToNaturalSize(); - - /** - * @brief Get the font used to display the text label displayed by the actor. - * - * @pre The text actor has been initialized. - * @return The font currently in use - */ - Font GetFont() const; - - /** - * @brief Set the font used to display the text label displayed by the actor. - * - * @pre The text actor has been initialized. - * @param [in] font The new font - */ - void SetFont(Font& font); - - // styling and effects - - /** - * @brief Set the gradient color. - * - * This is the color associated with the gradient end point. - * @param[in] color The gradient color (end-point color) - */ - void SetGradientColor( const Vector4& color ); - - /** - * @brief Get the gradient color. - * - * This is the color associated with the gradient end point. - * @return The gradient color (end-point color) - */ - Vector4 GetGradientColor() const; - - /** - * @brief Set the gradient start point. - * - * This is a 2D position between the coordinate range: - * 0.0,0.0 (Left,Top) to 1.0,1.0 (Right,Bottom) within - * the outputted Text. Actor::COLOR will represent this point - * in the gradient. - * @param[in] position The relative position of the gradient start point. - */ - void SetGradientStartPoint( const Vector2& position ); - - /** - * @brief Get the gradient start point. - * - * @return The relative position of the gradient start point. - */ - Vector2 GetGradientStartPoint() const; - - /** - * @brief Set the gradient end point. - * - * This is a 2D position between the coordinate range: - * 0.0,0.0 (Left,Top) to 1.0,1.0 (Right,Bottom) within - * the outputted Text. TextActor::GRADIENT_COLOR will represent - * this point in the gradient. - * @param[in] position The relative position of the gradient end point. - */ - void SetGradientEndPoint( const Vector2& position ); - - /** - * @brief Get the gradient end point. - * - * @return The relative position of the gradient end point. - */ - Vector2 GetGradientEndPoint() const; - - /** - * @brief Sets text style. - * - * @param[in] style The text style. - */ - void SetTextStyle( const TextStyle& style ); - - /** - * @brief Retrieves a copy of the text style. - * - * @return The text style. - */ - TextStyle GetTextStyle() const; - - /** - * @brief Set the text color. - * - * This is blended with the Actor color - * @param[in] color The text color (Default: WHITE) - */ - void SetTextColor( const Vector4& color ); - - /** - * @brief Get the text color. - * - * @return The text color. - */ - Vector4 GetTextColor() const; - - /** - * @brief Set soft edge smoothing. - * - * @param[in] smoothEdge Specify the distance field value for the center of the text edge. - * 0 <= smoothEdge <= 1 - */ - void SetSmoothEdge( float smoothEdge = TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD ); - - /** - * @brief Set text outlining. - * - * @param[in] enable Set to true to enable text outlining. - * @param[in] color Outline color. - * @param[in] thickness Thickness of outline. The outline thickness is determined by two parameters. - * thickness[0] Specifies the distance field value for the center of the outline. - * thickness[1] Specifies the softness/width/anti-aliasing of the outlines inner edge. - * SetSmoothEdge() specifies the smoothness/anti-aliasing of the text outer edge. - * 0 <= smoothEdge[0] <= 1. - * 0 <= smoothEdge[1] <= 1. - */ - void SetOutline( bool enable, const Vector4& color, const Vector2& thickness = TextStyle::DEFAULT_OUTLINE_THICKNESS ); - - /** - * @brief Set text glow. - * - * @param[in] enable Set to true to enable text outer glow. - * @param[in] color Glow color. - * @param[in] intensity Determines the amount of glow around text. - * The edge of the text is at the value set with SetSmoothEdge(). - * SetSmoothEdge() The distance field value at which the glow becomes fully transparent. - */ - void SetGlow( bool enable, const Vector4& color, float intensity = TextStyle::DEFAULT_GLOW_INTENSITY ); - - /** - * @brief Set text shadow. - * - * @param[in] enable Set to true to enable text drop shadow. - * @param[in] color Shadow color - * @param[in] offset Offset in pixels. To avoid cropping of the drop shadow limit the offset to PointSize / 3.5 - * @param[in] size Size of shadow in pixels. 0 means the shadow is the same size as the text. - */ - void SetShadow( bool enable, const Vector4& color, const Vector2& offset = TextStyle::DEFAULT_SHADOW_OFFSET, - float size = TextStyle::DEFAULT_SHADOW_SIZE ); - - /** - * @brief Enable italics on the text actor, the text will be sheared by the given angle. - * - * @param[in] enabled True will enable italics, false disable it. - * @param[in] angle Italics angle in degrees. - */ - void SetItalics( bool enabled, Degree angle = TextStyle::DEFAULT_ITALICS_ANGLE ); - - /** - * @brief Enable italics on the text actor, the text will be sheared by the given angle. - * - * @param[in] enabled True will enable italics, false disable it. - * @param[in] angle Italics angle in radians. - */ - void SetItalics( bool enabled, Radian angle ); - - /** - * @brief Get text italics for the actor. - * - * @returns True if italics is enabled. - */ - bool GetItalics() const; - - /** - * @brief Get text italics angle. - * - * @returns Angle as a Radian. - */ - Radian GetItalicsAngle() const; - - /** - * @brief Set text underline. - * - * @param[in] enable Boolean indicating if the text should be underlined or not. - */ - void SetUnderline( bool enable ); - - /** - * @brief Get text underline. - * - * @return Boolean indicating if the text should be underlined or not. - */ - bool GetUnderline() const; - - /** - * @brief Set text weight. - * - * @param weight Text weight. - */ - void SetWeight( TextStyle::Weight weight ); - - /** - * @brief Get text weight. - * - * @return Text weight. - */ - TextStyle::Weight GetWeight() const; - - /** - * @brief Try to detect font in case text is not supported with current one. - * - * @param [in] value true or false - */ - void SetFontDetectionAutomatic(bool value); - - /** - * @brief Query whether TextActor is using automatic font detection. - * - * @return true or false - */ - bool IsFontDetectionAutomatic() const; - - /** - * @brief Query whether the font has been loaded and built. - * - * Should be used by the application to determine whether the font - * is ready to be queried for metrics - * @return The loading state, either Loading, Success or Failed. - */ - LoadingState GetLoadingState() const; - - /** - * @brief Emitted when text loads successfully and is available for displaying, or when the loading fails. - * - * @return A signal object to Connect() with. - */ - TextSignalV2& TextAvailableSignal(); - -public: // Not intended for use by Application developers - - /** - * @brief This constructor is used by Dali New() methods - * e - * @param [in] actor A pointer to a newly allocated Dali resource - */ - explicit DALI_INTERNAL TextActor(Internal::TextActor* actor); -}; - -} // namespace Dali - -#endif // __DALI_TEXT_ACTOR_H__ diff --git a/dali/public-api/dali-core.h b/dali/public-api/dali-core.h index 2408982..dae624e 100644 --- a/dali/public-api/dali-core.h +++ b/dali/public-api/dali-core.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -94,7 +93,6 @@ #include #include #include -#include #include #include #include @@ -157,13 +155,6 @@ #include -#include -#include -#include -#include -#include -#include - #include #endif // __DALI_CORE_H__ diff --git a/dali/public-api/file.list b/dali/public-api/file.list index 5629dcc..43d6104 100644 --- a/dali/public-api/file.list +++ b/dali/public-api/file.list @@ -11,7 +11,6 @@ public_api_src_files = \ $(public_api_src_dir)/actors/light-actor.cpp \ $(public_api_src_dir)/actors/model-actor-factory.cpp \ $(public_api_src_dir)/actors/mesh-actor.cpp \ - $(public_api_src_dir)/actors/text-actor.cpp \ $(public_api_src_dir)/actors/renderable-actor.cpp \ $(public_api_src_dir)/animation/active-constraint.cpp \ $(public_api_src_dir)/animation/animation.cpp \ @@ -65,7 +64,6 @@ public_api_src_files = \ $(public_api_src_dir)/images/frame-buffer-image.cpp \ $(public_api_src_dir)/images/encoded-buffer-image.cpp \ $(public_api_src_dir)/images/nine-patch-image.cpp \ - $(public_api_src_dir)/images/glyph-image.cpp \ $(public_api_src_dir)/math/angle-axis.cpp \ $(public_api_src_dir)/math/compile-time-math.cpp \ $(public_api_src_dir)/math/degree.cpp \ @@ -109,13 +107,6 @@ public_api_src_files = \ $(public_api_src_dir)/signals/functor-delegate.cpp \ $(public_api_src_dir)/object/type-info.cpp \ $(public_api_src_dir)/object/type-registry.cpp \ - $(public_api_src_dir)/text/character.cpp \ - $(public_api_src_dir)/text/font.cpp \ - $(public_api_src_dir)/text/font-parameters.cpp \ - $(public_api_src_dir)/text/text.cpp \ - $(public_api_src_dir)/text/text-actor-parameters.cpp \ - $(public_api_src_dir)/text/text-style.cpp \ - $(public_api_src_dir)/text/utf8.cpp \ $(public_api_src_dir)/dali-core-version.cpp # Add public header files here @@ -137,7 +128,6 @@ public_api_core_actors_header_files = \ $(public_api_src_dir)/actors/light-actor.h \ $(public_api_src_dir)/actors/mesh-actor.h \ $(public_api_src_dir)/actors/model-actor-factory.h \ - $(public_api_src_dir)/actors/text-actor.h \ $(public_api_src_dir)/actors/renderable-actor.h \ $(public_api_src_dir)/actors/sampling.h @@ -212,7 +202,6 @@ public_api_core_images_header_files = \ $(public_api_src_dir)/images/distance-field.h \ $(public_api_src_dir)/images/encoded-buffer-image.h \ $(public_api_src_dir)/images/frame-buffer-image.h \ - $(public_api_src_dir)/images/glyph-image.h \ $(public_api_src_dir)/images/image.h \ $(public_api_src_dir)/images/image-attributes.h \ $(public_api_src_dir)/images/native-image.h \ @@ -284,12 +273,3 @@ public_api_core_signals_header_files = \ $(public_api_src_dir)/signals/signal-slot-connections.h \ $(public_api_src_dir)/signals/signal-slot-observers.h \ $(public_api_src_dir)/signals/slot-delegate.h - -public_api_core_text_header_files = \ - $(public_api_src_dir)/text/character.h \ - $(public_api_src_dir)/text/font.h \ - $(public_api_src_dir)/text/font-parameters.h \ - $(public_api_src_dir)/text/text.h \ - $(public_api_src_dir)/text/text-actor-parameters.h \ - $(public_api_src_dir)/text/text-style.h \ - $(public_api_src_dir)/text/utf8.h diff --git a/dali/public-api/images/glyph-image.cpp b/dali/public-api/images/glyph-image.cpp deleted file mode 100644 index b319581..0000000 --- a/dali/public-api/images/glyph-image.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ - -GlyphImage::GlyphImage() -{ -} - -GlyphImage::GlyphImage( Internal::Image* internal ) -: Image( internal ) -{ -} - -GlyphImage::~GlyphImage() -{ -} - -GlyphImage::GlyphImage(const GlyphImage& handle) -: Image(handle) -{ -} - -GlyphImage& GlyphImage::operator=(const GlyphImage& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} - -GlyphImage GlyphImage::New( const Character& character ) -{ - // Retrieves the font family name for the given character. - const std::string fontFamilyName = Font::GetFamilyForText( character ); - - // Create a text style and set the font family name. - TextStyle style; - style.SetFontName( fontFamilyName ); - - return GlyphImage::New( character, style ); -} - -GlyphImage GlyphImage::New( const Character& character, const TextStyle& style ) -{ - Image image; - - // Retrieves the font family name for the given character if is not defined in the text style. - std::string fontFamilyName = style.GetFontName(); - if( fontFamilyName.empty() ) - { - fontFamilyName = Font::GetFamilyForText( character ); - } - - // Creates a font with the parameters given in the text style. - const Font font = Font::New( FontParameters( fontFamilyName, style.GetFontStyle(), style.GetFontPointSize() ) ); - - if( GlyphImage::IsColorGlyph( character ) ) - { - // Work around. Create images from .png files in the file system. - - // Get the glyph metrics. - const Font::Metrics metrics = font.GetMetrics( character ); - - // Set the image size. - ImageAttributes attributes; - attributes.SetSize( metrics.GetWidth(), metrics.GetHeight() ); - - image = Image::New( DALI_EMOTICON_DIR + Internal::ThreadLocalStorage::Get().GetEmojiFactory().GetEmojiFileNameFromCharacter( character.GetImplementation().GetCharacter() ), attributes ); - } - else - { - // Retrieves the alpha bitmap from the font. - - Integration::PlatformAbstraction& platform = Internal::ThreadLocalStorage::Get().GetPlatformAbstraction(); - - Integration::BitmapPtr bitmapPtr = platform.GetGlyphImage( font.GetName(), - font.GetStyle(), - font.GetPointSize(), - character.GetImplementation().GetCharacter() ); - - if( bitmapPtr ) - { - // Create a color bitmap with the alpha bitmap retrieved from the platform and the color specified - // in the text style. - // - // TODO: support more text decoration features: outline, glow, shadow, underline, ... - const std::size_t width = bitmapPtr->GetImageWidth(); - const std::size_t height = bitmapPtr->GetImageHeight(); - BitmapImage bitmapImage = BitmapImage::New( width, height, Pixel::RGBA8888 ); - - // Point the source bitmap buffer. - unsigned char* src = bitmapPtr->GetBuffer(); - - // Point the destination image buffer. - unsigned char* dst = bitmapImage.GetBuffer(); - - //Retrieve the color from the text style. - const Vector4& color = style.GetTextColor(); - - std::size_t srcOffset = 0; - std::size_t dstOffset = 0; - for( std::size_t y = 0; y < height; ++y ) - { - for( std::size_t x = 0; x < width; ++x ) - { - const float srcAlpha = static_cast( src[ srcOffset ] ); - - dst[ dstOffset + 0 ] = static_cast( srcAlpha * color.r ); - dst[ dstOffset + 1 ] = static_cast( srcAlpha * color.g ); - dst[ dstOffset + 2 ] = static_cast( srcAlpha * color.b ); - dst[ dstOffset + 3 ] = static_cast( srcAlpha * color.a ); - ++srcOffset; - dstOffset += 4u; - } - } - - bitmapImage.Update(); - - image = bitmapImage; - } - } - - return GlyphImage( static_cast( image.GetObjectPtr() ) ); -} - -GlyphImage GlyphImage::DownCast( BaseHandle handle ) -{ - return GlyphImage( dynamic_cast( handle.GetObjectPtr() ) ); -} - -bool GlyphImage::IsColorGlyph( const Character& character ) -{ - return Internal::ThreadLocalStorage::Get().GetEmojiFactory().IsEmoji( character.GetImplementation().GetCharacter() ); -} - -} // namespace Dali diff --git a/dali/public-api/images/glyph-image.h b/dali/public-api/images/glyph-image.h deleted file mode 100644 index a158c7d..0000000 --- a/dali/public-api/images/glyph-image.h +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef __DALI_GLYPH_IMAGE_H__ -#define __DALI_GLYPH_IMAGE_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include - -namespace Dali -{ - -class Character; -class TextStyle; - -/** - * @brief A GlyphImage object is an image resource which represents a character. - */ -class DALI_IMPORT_API GlyphImage : public Image -{ -public: - /** - * @brief Constructor which creates an uninitialized GlyphImage object. - * - * Use GlyphImage::New(...) to create an initialised object. - */ - GlyphImage(); - - /** - * @brief Create a new GlyphImage representing the given character. - * - * It uses a default TextStyle to create the glyph image. - * @see GlyphImage::New( const Character& character, const TextStyle& style ) - * - * @param[in] character The character to get the glyph image. - * - * @return A handle to a new instance of a GlyphImage. - */ - static GlyphImage New( const Character& character ); - - /** - * @brief Create a new GlyphImage representing the given character. - * - * If the given character is a color glyph, no style is used to create the image. - * - * If it's not, it uses the font family name, font style and font size defined in the text-style - * to create a font. The text color is also retrieved from the text style to create the glyph image. - * - * @note current implementation ignores any other text style parameter. - * - * @param[in] character The character to get the glyph image. - * @param[in] style TextStyle to be used to create the glyph image. - * - * @return A handle to a new instance of a GlyphImage. - */ - static GlyphImage New( const Character& character, const TextStyle& style ); - - /** - * @brief Downcast an Object handle to GlyphImage handle. - * - * If handle points to a GlyphImage object the - * downcast produces valid handle. If not the returned handle is left uninitialized. - * @param[in] handle to An object - * @return handle to a GlyphImage object or an uninitialized handle - */ - static GlyphImage DownCast( BaseHandle handle ); - - /** - * @brief Whether the given characters is a color glyph. - * - * @param[in] character The given character. - * - * @return \e true if \e character is a color glyph. - */ - static bool IsColorGlyph( const Character& character ); - - /** - * @brief Destructor - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~GlyphImage(); - - /** - * @brief This copy constructor is required for (smart) pointer semantics. - * - * @param [in] handle A reference to the copied handle - */ - GlyphImage(const GlyphImage& handle); - - /** - * @brief This assignment operator is required for (smart) pointer semantics. - * - * @param [in] rhs A reference to the copied handle - * @return A reference to this - */ - GlyphImage& operator=(const GlyphImage& rhs); - -public: // Not intended for application developers - - explicit DALI_INTERNAL GlyphImage( Internal::Image* ); -}; //class GlyphImage - -} // namespace Dali - -#endif // __DALI_GLYPH_IMAGE_H__ diff --git a/dali/public-api/scripting/scripting.h b/dali/public-api/scripting/scripting.h index 6e801b2..0de8a14 100644 --- a/dali/public-api/scripting/scripting.h +++ b/dali/public-api/scripting/scripting.h @@ -225,14 +225,10 @@ DALI_IMPORT_API Image NewImage( const Property::Value& map ); * "fragment": type STRING * "vertex-prefix": type STRING * "fragment-prefix": type STRING - * "text-vertex": type STRING - * "text-fragment": type STRING * "vertex-filename": type STRING * "fragment-filename": type STRING * "vertex-prefix-filename": type STRING * "fragment-prefix-filename":type STRING - * "text-vertex-filename": type STRING - * "text-fragment-filename": type STRING * "geometry-type": type STRING (enum) * "geometry-hints": type STRING (enum) * } diff --git a/dali/public-api/shader-effects/shader-effect.cpp b/dali/public-api/shader-effects/shader-effect.cpp index 6f440e1..a431e18 100644 --- a/dali/public-api/shader-effects/shader-effect.cpp +++ b/dali/public-api/shader-effects/shader-effect.cpp @@ -83,40 +83,6 @@ ShaderEffect ShaderEffect::NewWithPrefix( const std::string& vertexShaderPrefix, return ShaderEffect( internal.Get() ); } -ShaderEffect ShaderEffect::New( const std::string& imageVertexShader, - const std::string& imageFragmentShader, - const std::string& textVertexShader, - const std::string& textFragmentShader, - GeometryHints hints) -{ - Internal::ShaderEffectPtr internal = Internal::ShaderEffect::New( hints ); - - internal->SetPrograms( GEOMETRY_TYPE_IMAGE, imageVertexShader, imageFragmentShader ); - internal->SetPrograms( GEOMETRY_TYPE_TEXT, textVertexShader, textFragmentShader ); - - return ShaderEffect( internal.Get() ); -} - -ShaderEffect ShaderEffect::New( const std::string& imageVertexShader, - const std::string& imageFragmentShader, - const std::string& textVertexShader, - const std::string& textFragmentShader, - const std::string& texturedMeshVertexShader, - const std::string& texturedMeshFragmentShader, - const std::string& meshVertexShader, - const std::string& meshFragmentShader, - GeometryHints hints) -{ - Internal::ShaderEffectPtr internal = Internal::ShaderEffect::New( hints ); - - internal->SetPrograms( GEOMETRY_TYPE_IMAGE, imageVertexShader, imageFragmentShader ); - internal->SetPrograms( GEOMETRY_TYPE_TEXT, textVertexShader, textFragmentShader ); - internal->SetPrograms( GEOMETRY_TYPE_TEXTURED_MESH, texturedMeshVertexShader, texturedMeshFragmentShader ); - internal->SetPrograms( GEOMETRY_TYPE_UNTEXTURED_MESH, meshVertexShader, meshFragmentShader ); - - return ShaderEffect( internal.Get() ); -} - ShaderEffect ShaderEffect::DownCast( BaseHandle handle ) { return ShaderEffect( dynamic_cast(handle.GetObjectPtr()) ); diff --git a/dali/public-api/shader-effects/shader-effect.h b/dali/public-api/shader-effects/shader-effect.h index 13ce2c2..d84bfff 100644 --- a/dali/public-api/shader-effects/shader-effect.h +++ b/dali/public-api/shader-effects/shader-effect.h @@ -67,10 +67,9 @@ class ShaderEffect; enum GeometryType { GEOMETRY_TYPE_IMAGE = 0x01, ///< image, with flat color or texture - GEOMETRY_TYPE_TEXT = 0x02, ///< text, with flat color or texture - GEOMETRY_TYPE_UNTEXTURED_MESH = 0x04,///< Complex meshes, with flat color - GEOMETRY_TYPE_TEXTURED_MESH = 0x08, ///< Complex meshes, with texture - GEOMETRY_TYPE_LAST = 0x10 + GEOMETRY_TYPE_UNTEXTURED_MESH = 0x02,///< Complex meshes, with flat color + GEOMETRY_TYPE_TEXTURED_MESH = 0x04, ///< Complex meshes, with texture + GEOMETRY_TYPE_LAST = 0x08 }; /** @@ -109,38 +108,6 @@ enum GeometryType * uniform vec4 uColor; * varying vec2 vTexCoord; * - * and for text: - *
- * \#extension GL_OES_standard_derivatives : enable
- * uniform   mediump sampler2D sTexture;
- * uniform   lowp    vec4      uColor;
- * uniform   lowp    vec4      uTextColor;
- * uniform   mediump float     uSmoothing;
- * varying   mediump vec2      vTexCoord;
- * 
- * and the custom shader is expected to output the fragment color. - * The basic fragment shader for images would contain: - *
- * void main()
- * {
- *   gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;
- * }
- * 
- * and for text:: - *
- *  void main()
- *  {
- *    // sample distance field
- *    mediump float distance = texture2D(sTexture, vTexCoord).a;
- *    mediump float smoothWidth = fwidth(distance);
- *    // set fragment color
- *    lowp vec4 color = uTextColor;
- *    // adjust alpha by sampled distance
- *    color.a *= smoothstep(uSmoothing - smoothWidth, uSmoothing + smoothWidth, distance);
- *    // fragment color multiplied with uColor.
- *    glFragColor = color * uColor;
- *  }
- * 
*
* * Note: In order for fade and color animations to work, the fragment shader needs to multiply the fragment color @@ -258,44 +225,6 @@ public: GeometryHints hints = GeometryHints(HINT_NONE) ); /** - * @brief Create ShaderEffect. - * @param imageVertexShader code for the effect. If you pass in an empty string, the default version will be used - * @param imageFragmentShader code for the effect. If you pass in an empty string, the default version will be used - * @param textVertexShader code for the effect. If you pass in an empty string, the default version will be used - * @param textFragmentShader code for the effect. If you pass in an empty string, the default version will be used - * @param hints GeometryHints to define the geometry of the rendered object - * @return A handle to a shader effect - */ - static ShaderEffect New( const std::string& imageVertexShader, - const std::string& imageFragmentShader, - const std::string& textVertexShader, - const std::string& textFragmentShader, - GeometryHints hints = GeometryHints(HINT_NONE) ); - - /** - * @brief Create ShaderEffect. - * @param imageVertexShader code for the effect. If you pass in an empty string, the default version will be used - * @param imageFragmentShader code for the effect. If you pass in an empty string, the default version will be used - * @param textVertexShader code for the effect. If you pass in an empty string, the default version will be used - * @param textFragmentShader code for the effect. If you pass in an empty string, the default version will be used - * @param texturedMeshVertexShader code for the effect. If you pass in an empty string, the default version will be used - * @param texturedMeshFragmentShader code for the effect. If you pass in an empty string, the default version will be used - * @param meshVertexShader code for the effect. If you pass in an empty string, the default version will be used - * @param meshFragmentShader code for the effect. If you pass in an empty string, the default version will be used - * @param hints GeometryHints to define the geometry of the rendered object - * @return A handle to a shader effect - */ - static ShaderEffect New( const std::string& imageVertexShader, - const std::string& imageFragmentShader, - const std::string& textVertexShader, - const std::string& textFragmentShader, - const std::string& texturedMeshVertexShader, - const std::string& texturedMeshFragmentShader, - const std::string& meshVertexShader, - const std::string& meshFragmentShader, - GeometryHints hints = GeometryHints(HINT_NONE) ); - - /** * @brief Downcast an Object handle to ShaderEffect. * * If handle points to a ShaderEffect the downcast produces valid diff --git a/dali/public-api/text/character.cpp b/dali/public-api/text/character.cpp deleted file mode 100644 index f85d133..0000000 --- a/dali/public-api/text/character.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// HEADER CLASS -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -Character::Character( const Character& character ) -: mImpl( new Internal::Character( character.mImpl->GetCharacter() ) ) -{ -} - -Character& Character::operator=( const Character& character ) -{ - if( &character != this ) - { - mImpl->SetCharacter( character.mImpl->GetCharacter() ); - } - - return *this; -} - -Character::~Character() -{ - delete mImpl; -} - -bool Character::operator==( const Character& character ) const -{ - return mImpl->GetCharacter() == character.mImpl->GetCharacter(); -} - -bool Character::operator!=( const Character& character ) const -{ - return mImpl->GetCharacter() != character.mImpl->GetCharacter(); -} - -Character::CharacterDirection Character::GetCharacterDirection() const -{ - return mImpl->GetCharacterDirection(); -} - -Character::Script Character::GetScript() const -{ - return mImpl->GetScript(); -} - -bool Character::IsWhiteSpace() const -{ - return mImpl->IsWhiteSpace(); -} - -bool Character::IsNewLine() const -{ - return mImpl->IsNewLine(); -} - -Character::Character( Internal::Character* impl ) -: mImpl( impl ) -{ -} - -const Internal::Character& Character::GetImplementation() const -{ - return *mImpl; -} - -Internal::Character& Character::GetImplementation() -{ - return *mImpl; -} - -} // namespace Dali diff --git a/dali/public-api/text/character.h b/dali/public-api/text/character.h deleted file mode 100644 index 6bfe058..0000000 --- a/dali/public-api/text/character.h +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef __DALI_CHARACTER_H__ -#define __DALI_CHARACTER_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include - -namespace Dali -{ - -namespace Internal DALI_INTERNAL -{ - class Character; -} - -/** - * @brief The Character class encapsulates a character implementation to support multiple languages. - * - * This class is provided for convenience. A user can't instantiate Characters directly. - * However, by instantiating a Text object, Characters are returned by Text::operator[]. - */ -class DALI_IMPORT_API Character -{ -public: - - /** - * @brief CharacterDirection - * - * Characters can be classified under one of five direction types, which determines the - * direction in which they are displayed. - * - * English is a left-to-right language. - * If English were instead right-to-left, then the word English would be displayed as - * "hsilgnE" - */ - enum CharacterDirection - { - LeftToRight, ///< Left to Right characters are the most common (e.g. English and other Indo-European languages) - RightToLeft, ///< Right to Left characters are less common (e.g. Hebrew and Arabic) - LeftToRightWeak, ///< Weak Left to Right characters (e.g. numbers) - RightToLeftWeak, ///< Weak Right to Left characters - Neutral ///< Neutral characters follow the direction of characters surrounding them (e.g. whitespace ' ') - }; - - /** - * @brief Script - * - * Script is the writing system used by a language. - * Typically one script can be used to write different languages although one language could be written in different scrips. - * - * i.e Many of the western languages like English, latin languages, etc use the latin script. Japanese uses the kanji, hiragana, katakana and latin scrips. - */ - enum Script - { - LATIN, ///< The latin script. Used by many western languages. - ARABIC, ///< The arabic script. Used by Arab and Urdu among others. - DEVANAGARI, ///< The devanagari script. Used by Hindi, Marathi, Sindhi, Nepali and Sanskrit. - BENGALI, ///< The Bengali script. Used by Bangla, Assamese, Bishnupriya Manipuri, Daphla, Garo, Hallam, Khasi, Mizo, Munda, Naga, Rian, and Santali. - GURMUKHI, ///< The Gurmukhi script. Used by Punjabi. - GUJARATI, ///< The Gujarati script. Used by Gujarati. - ORIYA, ///< The Oriya script. Used by Oriya, Khondi, and Santali. - TAMIL, ///< The Tamil script. Used by Tamil, Badaga, and Saurashtra. - TELUGU, ///< The Telugu script. Used by Telugu, Gondi, and Lambadi. - KANNADA, ///< The Kannada script. Used by Kannada and Tulu. - MALAYALAM, ///< The Malayalam script. Used by Malayalam. - SINHALA, ///< The Sinhala script. Used by Sinhala and Pali. - UNKNOWN ///< The script is unknown. - }; - -public: - - /** - * @brief Copy constructor. - * - * @param [in] character Character to be copied. - */ - Character( const Character& character ); - - /** - * @brief Assignment operator. - * - * @param [in] character Character to be assigned. - * @return a reference to this - */ - Character& operator=( const Character& character ); - - /** - * @brief Non virtual destructor. - */ - ~Character(); - - /** - * @brief Equality operator. - * - * @param [in] character The character to be compared. - * @return true if the character is identical - */ - bool operator==( const Character& character ) const; - - /** - * @brief Inequality operator. - * - * @param [in] character The character to be compared. - * @return true if the character is not identical - */ - bool operator!=( const Character& character ) const; - - /** - * @brief Returns direction of this character. - * - * @return The character's direction is returned see CharacterDirection - */ - CharacterDirection GetCharacterDirection() const; - - - /** - * @brief Returns the script of this character. - */ - Script GetScript() const; - - /** - * @brief Returns whether this character is white space (true) - * or not (false). - * - * @return true if a whitespace character, false otherwise. - */ - bool IsWhiteSpace() const; - - /** - * @brief Returns whether this character is a new line character (true). - * - * or not (false). - * @return true if a new line character, false otherwise. - */ - bool IsNewLine() const; - -private: - Internal::Character* mImpl; - - /** - * @brief Default constructor. - * - * Not defined. - */ - DALI_INTERNAL Character(); - -public: // Not intended for application developers - DALI_INTERNAL Character( Internal::Character* impl ); - - DALI_INTERNAL const Internal::Character& GetImplementation() const; - - DALI_INTERNAL Internal::Character& GetImplementation(); -}; - -} // namespace Dali - -#endif // __DALI_CHARACTER_H__ diff --git a/dali/public-api/text/font-parameters.cpp b/dali/public-api/text/font-parameters.cpp deleted file mode 100644 index 2c5bc86..0000000 --- a/dali/public-api/text/font-parameters.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// FILE HEADER -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -// Default font parameters. Adaptor will choose default system parameters. -FontParameters DEFAULT_FONT_PARAMETERS( std::string( "" ), std::string( "" ), PointSize( 0.f ) ); - -PointSize::PointSize(float val) -: value(val) -{ -} - -PointSize::operator float() const -{ - return value; -} - -bool PointSize::operator==( PointSize pointSize ) -{ - return fabs( value - pointSize.value ) < GetRangedEpsilon( value, pointSize.value ); -} - -bool PointSize::operator!=( PointSize pointSize ) -{ - return !( *this == pointSize ); -} - -PixelSize::PixelSize(unsigned int val) -: value(val) -{ -} - -PixelSize::operator unsigned int() const -{ - return value; -} - -CapsHeight::CapsHeight(unsigned int val) -: value(val) -{ -} - -CapsHeight::operator unsigned int() const -{ - return value; -} - -struct FontParameters::Impl -{ - Impl( const std::string& familyName, const std::string& style, float size ) - : mFamilyName( familyName ), - mStyle( style ), - mSize( size ) - {} - - std::string mFamilyName; - std::string mStyle; - float mSize; ///< font size in points. -}; - -FontParameters::FontParameters() -: mImpl( new FontParameters::Impl( std::string( "" ), std::string( "" ), PointSize( 0.f ) ) ) -{ -} - -FontParameters::FontParameters( const std::string& familyName, const std::string& style, PointSize size ) -: mImpl( new FontParameters::Impl( familyName, style, size ) ) -{ -} - -FontParameters::FontParameters( const std::string& familyName, const std::string& style, PixelSize size ) -: mImpl( new FontParameters::Impl( familyName, style, Font::PixelsToPoints( size ) ) ) -{ -} - -FontParameters::FontParameters( const std::string& familyName, const std::string& style, CapsHeight size ) -: mImpl( NULL ) -{ - PixelSize pixelSize = Font::GetLineHeightFromCapsHeight( familyName, style, size ); - mImpl = new FontParameters::Impl( familyName, style, Font::PixelsToPoints( pixelSize ) ); -} - -FontParameters::~FontParameters() -{ - delete mImpl; -} - -FontParameters::FontParameters( const FontParameters& parameters ) -: mImpl( new FontParameters::Impl( parameters.mImpl->mFamilyName, parameters.mImpl->mStyle, parameters.mImpl->mSize ) ) -{ -} - -FontParameters& FontParameters::operator=( const FontParameters& parameters ) -{ - if( ¶meters != this ) - { - mImpl->mFamilyName = parameters.GetFamilyName(); - mImpl->mStyle = parameters.GetStyle(); - mImpl->mSize = parameters.GetSize(); - } - return *this; -} - -const std::string& FontParameters::GetFamilyName() const -{ - return mImpl->mFamilyName; -} - -const std::string& FontParameters::GetStyle() const -{ - return mImpl->mStyle; -} - -PointSize FontParameters::GetSize() const -{ - return PointSize( mImpl->mSize ); -} - -} // namespace Dali diff --git a/dali/public-api/text/font-parameters.h b/dali/public-api/text/font-parameters.h deleted file mode 100644 index 2fa4087..0000000 --- a/dali/public-api/text/font-parameters.h +++ /dev/null @@ -1,203 +0,0 @@ -#ifndef __DALI_FONT_PARAMETERS_H__ -#define __DALI_FONT_PARAMETERS_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include - -namespace Dali -{ - -/** - * @brief Font size in points. - * - * This reduces ambiguity when using methods which accept size in pixels or points. - */ -struct DALI_IMPORT_API PointSize -{ - /** - * @brief Create size in points. - * - * @param[in] value The value in points. - */ - explicit PointSize(float value); - - /** - * @brief Float cast operator. - */ - operator float() const; - - /** - * @brief Equality operator. - * - * @param pointSize The point size to be compared. - * @return \e true if \e pointSize is equal to the point size stored in this object. - */ - bool operator==( PointSize pointSize ); - - /** - * @brief Inequality operator. - * - * @param pointSize The point size to be compared. - * @return \e true if \e pointSize is not equal to the point size stored in this object. - */ - bool operator!=( PointSize pointSize ); - - float value; ///< The value in points -}; - -/** - * @brief Font size in pixels. - * - * This reduces ambiguity when using methods which accept size in pixels or points. - */ -struct DALI_IMPORT_API PixelSize -{ - /** - * @brief Create size in pixels. - * - * @param[in] value The value in pixels. - */ - explicit PixelSize(unsigned int value); - - /** - * @brief Cast operator - */ - operator unsigned int() const; - - unsigned int value; ///< The value in pixels -}; - -/** - * @brief Font size in Caps height - */ -struct DALI_IMPORT_API CapsHeight -{ - /** - * @brief Size in CapsHeight - */ - explicit CapsHeight( unsigned int value); - - /** - * @brief Cast operator - */ - operator unsigned int() const; - - unsigned int value; ///< The value in pixels -}; - -/** - * @brief Encapsulates all font parameters. - */ -struct DALI_IMPORT_API FontParameters -{ - /** - * @brief Default constructor. - * - * Default system font family name, default system font style and default system size - * will be used to build the font. - */ - FontParameters(); - - /** - * @brief Constructor. - * - * Creates font parameters with the given family's name, style and size in points from the font requested. - * @param[in] familyName The family's name of the font requested. - * @param[in] style The style of the font requested. - * @param[in] size The size of the font requested in points. - */ - FontParameters( const std::string& familyName, const std::string& style, PointSize size ); - - /** - * @brief Constructor. - * - * Creates font parameters with the given family's name, style and size in pixels from the font requested. - * @param[in] familyName The family's name of the font requested. - * @param[in] style The style of the font requested. - * @param[in] size The size of the font requested in pixels. - */ - FontParameters( const std::string& familyName, const std::string& style, PixelSize size ); - - /** - * @brief Constructor. - * - * Creates font parameters with the given family's name, style and the caps-height size in pixels from the font requested. - * @param[in] familyName The family's name of the font requested. - * @param[in] style The style of the font requested. - * @param[in] size The caps-height of the font requested in pixels. - */ - FontParameters( const std::string& familyName, const std::string& style, CapsHeight size ); - - /** - * @brief Destructor. - * - * Destroys the internal implementation. - */ - ~FontParameters(); - - /** - * @brief Copy constructor. - * - * Reset the internal implementation with new given values. - * @param[in] parameters The new font parameters. - */ - FontParameters( const FontParameters& parameters ); - - /** - * @brief Assignment operator. - * - * @param[in] parameters The new font parameters. - * @return A reference to this - */ - FontParameters& operator=( const FontParameters& parameters ); - - /** - * @brief Retrieves the name of the font's family. - * - * @return The name of the font's family. - */ - const std::string& GetFamilyName() const; - - /** - * @brief Retrieves the style of the font. - * - * @return The style of the font. - */ - const std::string& GetStyle() const; - - /** - * @brief Retrieves the size of the font. - * - * @return The size of the font in Points. - */ - PointSize GetSize() const; - -private: - struct Impl; - Impl* mImpl; ///< Internal implementation. Not intended for application developers. - -}; - -DALI_IMPORT_API extern FontParameters DEFAULT_FONT_PARAMETERS; ///< Used to choose the platform's font parameters - -} // namespace Dali - -#endif // __DALI_FONT_PARAMETERS_H__ diff --git a/dali/public-api/text/font.cpp b/dali/public-api/text/font.cpp deleted file mode 100644 index 5ccb899..0000000 --- a/dali/public-api/text/font.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES -#include -#include -#include - -namespace Dali -{ - -Font::Metrics::Metrics() -: mImpl( new Font::Metrics::Impl() ) -{ -} - -Font::Metrics::~Metrics() -{ - delete mImpl; -} - -Font::Metrics::Metrics( const Font::Metrics& metrics ) -: mImpl( new Font::Metrics::Impl() ) -{ - mImpl->advance = metrics.mImpl->advance; - mImpl->bearing = metrics.mImpl->bearing; - mImpl->width = metrics.mImpl->width; - mImpl->height = metrics.mImpl->height; -} - -Font::Metrics& Font::Metrics::operator=( const Font::Metrics& metrics ) -{ - if( &metrics != this ) - { - mImpl->advance = metrics.mImpl->advance; - mImpl->bearing = metrics.mImpl->bearing; - mImpl->width = metrics.mImpl->width; - mImpl->height = metrics.mImpl->height; - } - return *this; -} - -float Font::Metrics::GetAdvance() const -{ - return mImpl->advance; -} - -float Font::Metrics::GetBearing() const -{ - return mImpl->bearing; -} - -float Font::Metrics::GetWidth() const -{ - return mImpl->width; -} - -float Font::Metrics::GetHeight() const -{ - return mImpl->height; -} - -Font::Metrics::Metrics( const Impl& implementation ) -: mImpl( new Font::Metrics::Impl() ) -{ - mImpl->advance = implementation.advance; - mImpl->bearing = implementation.bearing; - mImpl->width = implementation.width; - mImpl->height = implementation.height; -} - -Font::Font() -{ -} - -Font::Font(Internal::Font* internal) -: BaseHandle(internal) -{ -} - -Font Font::New( const FontParameters& fontParameters ) -{ - Internal::Font* internal = Internal::Font::New(fontParameters.GetFamilyName(), fontParameters.GetStyle(), fontParameters.GetSize() ); - return Font(internal); -} - -Font Font::DownCast( BaseHandle handle ) -{ - return Font( dynamic_cast(handle.GetObjectPtr()) ); -} - -const std::string Font::GetFamilyForText(const Text& text) -{ - return Internal::Font::GetFamilyForText( Internal::GetTextArray( text ) ); -} - -Font::~Font() -{ -} - -Font::Font(const Font& handle) -: BaseHandle(handle) -{ -} - -Font& Font::operator=(const Font& rhs) -{ - BaseHandle::operator=(rhs); - return *this; -} - -PixelSize Font::GetLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, const CapsHeight& capsHeight) -{ - return Internal::Font::GetLineHeightFromCapsHeight(fontFamily,fontStyle,capsHeight); -} - -std::vector Font::GetInstalledFonts( FontListMode mode ) -{ - std::vector fontList; - Internal::Font::GetInstalledFonts( mode, fontList ); - - // VCC TODO: deprecate this method and add void Font::GetInstalledFonts( FontListMode mode, std::vector& fontList ) - return fontList; -} - -float Font::MeasureTextWidth(const Text& text, float textHeightPx) const -{ - return GetImplementation(*this).MeasureTextWidth( Internal::GetTextArray( text ), textHeightPx ); -} - -float Font::MeasureTextHeight(const Text& text, float textWidthPx) const -{ - return GetImplementation(*this).MeasureTextHeight( Internal::GetTextArray( text ), textWidthPx ); -} - -Vector3 Font::MeasureText(const Text& text) const -{ - return GetImplementation(*this).MeasureText( Internal::GetTextArray( text ) ); -} - -bool Font::AllGlyphsSupported(const Text& text) const -{ - return GetImplementation(*this).AllGlyphsSupported( Internal::GetTextArray( text ) ); -} - -float Font::GetLineHeight() const -{ - return GetImplementation(*this).GetLineHeight() * GetImplementation(*this).GetUnitsToPixels(); -} - -float Font::GetAscender() const -{ - return GetImplementation(*this).GetAscender() * GetImplementation(*this).GetUnitsToPixels(); -} - -float Font::GetUnderlineThickness() const -{ - return GetImplementation(*this).GetUnderlineThickness() * GetImplementation(*this).GetUnitsToPixels(); -} - -float Font::GetUnderlinePosition() const -{ - return GetImplementation(*this).GetUnderlinePosition() * GetImplementation(*this).GetUnitsToPixels(); -} - -Font::Metrics Font::GetMetrics(const Character& character) const -{ - Font::Metrics::Impl metricsImpl; - GetImplementation(*this).GetMetrics(character, metricsImpl); - return Font::Metrics( metricsImpl ); -} - -bool Font::IsDefaultSystemFont() const -{ - return GetImplementation(*this).IsDefaultSystemFont(); -} - -bool Font::IsDefaultSystemSize() const -{ - return GetImplementation(*this).IsDefaultSystemSize(); -} - -const std::string& Font::GetName() const -{ - return GetImplementation(*this).GetName(); -} - -const std::string& Font::GetStyle() const -{ - return GetImplementation(*this).GetStyle(); -} - -float Font::GetPointSize() const -{ - return GetImplementation(*this).GetPointSize(); -} - -unsigned int Font::GetPixelSize() const -{ - return GetImplementation(*this).GetPixelSize(); -} - -unsigned int Font::PointsToPixels( float pointSize ) -{ - return Internal::Font::PointsToPixels( pointSize ); -} - -float Font::PixelsToPoints( unsigned int pixelsSize ) -{ - return Internal::Font::PixelsToPoints( pixelsSize ); -} - -} // namespace Dali diff --git a/dali/public-api/text/font.h b/dali/public-api/text/font.h deleted file mode 100644 index 2f6dc81..0000000 --- a/dali/public-api/text/font.h +++ /dev/null @@ -1,370 +0,0 @@ -#ifndef __DALI_FONT_H__ -#define __DALI_FONT_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include -#include -#include - -namespace Dali -{ - -struct Vector3; - -namespace Internal DALI_INTERNAL -{ -class Font; -} - -/** - * @brief Encapsulates a font resource. - * Fonts are managed by the font manager, which loads any new fonts requested by applications. The font - * manager keeps a cache of the most recently used fonts, and if a new font is requested when the cache - * is full it will delete an old one (if there is one not in use). - * This font class will request a font from the font manager in a manner which is not visible to the - * application. - * - * Fonts will be created from a font name (like courier or comic) and font size (specified in points). - */ -class DALI_IMPORT_API Font : public BaseHandle -{ -public: - /** - * @brief Stores glyph's metrics. - * - *
    - *
  • \e Advance. The distance between the glyph's current pen position and the pen's position of the next glyph. - *
  • \e Bearing. The horizontal top side bearing. Is the distance between the baseline and the top of the glyph. - *
  • \e Width. The glyph's width. - *
  • \e Height. The glyph's height. - *
- */ - class Metrics - { - public: - /** - * @brief Default constructor. - * - * Creates the implentation instance. - */ - Metrics(); - - /** - * @brief Destructor. - * - * Destroyes the implementaiton instance. - */ - virtual ~Metrics(); - - /** - * @brief Copy constructor. - * - * @param [in] metrics Metrics to be copied. - */ - Metrics( const Metrics& metrics ); - - /** - * @brief Assignment operator. - * - * @param [in] metrics Metrics to be assigned. - * @return a reference to this - */ - Metrics& operator=( const Metrics& metrics ); - - /** - * @brief Retrieves the advance metric. - * - * @return the advance metric. - */ - float GetAdvance() const; - - /** - * @brief Retrieves the bearing metric. - * - * @return the bearing metric. - */ - float GetBearing() const; - - /** - * @brief Retrieves the width metric. - * - * @return the width metric. - */ - float GetWidth() const; - - /** - * @brief Retrieves the height metric. - * - * @return the height metric. - */ - float GetHeight() const; - - public: // Not intended for application developers - struct Impl; - - /** - * @brief Constructor. - * - * Initialization with metrics data. - * @param implementation Glyph's metrics. - */ - Metrics( const Impl& implementation ); - - private: - Impl* mImpl; ///< Implementation. - }; - -public: - /** - * @brief Create an empty Font. - * - * This can be initialised with Font::New(...) - */ - Font(); - - /** - * @brief Create an initialised Font with the given parameters. If no parameters are given, system defaults are used. - * - * @param [in] fontParameters The font parameters. - * @return A handle to a newly allocated font. - */ - static Font New( const FontParameters& fontParameters = DEFAULT_FONT_PARAMETERS ); - - /** - * @brief Downcast an Object handle to Font handle. - * - * If handle points to a Font object the downcast produces valid - * handle. If not the returned handle is left uninitialized. - * - * @param[in] handle to An object - * @return handle to a Font object or an uninitialized handle - */ - static Font DownCast( BaseHandle handle ); - - /** - * @brief Try to detect font for text. - * - * @param [in] text displayed text - * @return string containing a font name, or an empty string. - */ - static const std::string GetFamilyForText(const Text& text); - - /** - * @brief Destructor - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~Font(); - - /** - * @brief This copy constructor is required for (smart) pointer semantics. - * - * @param [in] handle A reference to the copied handle - */ - Font(const Font& handle); - - /** - * @brief This assignment operator is required for (smart) pointer semantics. - * - * @param [in] rhs A reference to the copied handle - * @return A reference to this - */ - Font& operator=(const Font& rhs); - - /** - * @brief Convert a PixelSize from CapsHeight to it's equivalent LineHeight. - * - * @param [in] fontFamily The family's name of the font requested - * @param [in] fontStyle The style of the font requested. - * @param [in] capsHeight The size of the font ascenders required in pixels - * @return The equivalent LineHeight (baseline to baseline) for the font - */ - static PixelSize GetLineHeightFromCapsHeight(const std::string& fontFamily, const std::string& fontStyle, const CapsHeight& capsHeight); - - /** - * @brief The mode for GetInstalledFonts() - */ - enum FontListMode - { - LIST_SYSTEM_FONTS, ///< List system fonts - LIST_APPLICATION_FONTS, ///< List application fonts - LIST_ALL_FONTS ///< List all fonts - }; - - /** - * @brief Gets the list of available fonts. - * - * @param mode which fonts to include in the list, default is LIST_SYSTEM_FONTS - * @return a list of font family names - */ - static std::vector GetInstalledFonts( FontListMode mode = LIST_SYSTEM_FONTS ); - - /** - * @brief Returns the width of the area needed to display some text if the text is textHeightPx pixels high. - * - * Note that the text is not processed in any way before this calculation is performed (no stretching/scaling) - * @param [in] text The text to measure - * @param [in] textHeightPx The text height required - * @return The displayed width in pixels - */ - float MeasureTextWidth(const Text& text, float textHeightPx) const; - - /** - * @brief Returns the height of the area needed to display the text if the text is textWidthPx pixels wide. - * - * Note that the text is not processed in any way before this calculation is performed (no stretching/scaling) - * @param [in] text The text to measure - * @param [in] textWidthPx The text width required - * @return The displayed height in pixels - */ - float MeasureTextHeight(const Text& text, float textWidthPx) const; - - /** - * @brief Measure the natural size of a text string, as displayed in this font. - * - * @param[in] text The text string to measure. - * @return The natural size of the text. - */ - Vector3 MeasureText(const Text& text) const; - - /** - * @brief Tells whether text is supported with font. - * - * @param [in] text glyphs to test - * @return true if the glyphs are all supported by the font - */ - bool AllGlyphsSupported(const Text& text) const; - - /** - * @brief Retrieves the line height. - * - * The line height is the distance between two consecutive base lines. - * @return The line height. - */ - float GetLineHeight() const; - - /** - * @brief Retrieves the ascender metric. - * - * The ascender metric is the distance between the base line and the top of the highest character in the font. - * @return The ascender metric. - */ - float GetAscender() const; - - /** - * @brief Retrieves the underline's thickness. - * - * - * It includes the vertical pad adjust used to add effects like glow or shadow. - * - * @return The underline's thickness. - */ - float GetUnderlineThickness() const; - - /** - * @brief Retrieves the underline's position. - * - * - * It includes the vertical pad adjust used to add effects like glow or shadow. - * - * @return The underline's position. - */ - float GetUnderlinePosition() const; - - /** - * @brief Retrieves glyph metrics. - * - * @see Font::Metrics. - * @param [in] character The character which its metrics are going to be retrieved. - * @return The glyph metrics. - */ - Metrics GetMetrics(const Character& character) const; - - /** - * @brief Retrieves whether this font was created with a default system font. - * - * @return \e true if this font was created as a default system font. - */ - bool IsDefaultSystemFont() const; - - /** - * @brief Retrieves whether this font was created with a default system size. - * - * @return \e true if this font was created as a default system size. - */ - bool IsDefaultSystemSize() const; - - /** - * @brief Gets the name of the font's family. - * - * @return The name of the font's family. - */ - const std::string& GetName() const; - - /** - * @brief Gets the font's style. - * - * @return The font's style. - */ - const std::string& GetStyle() const; - - /** - * @brief Return font size in points. - * - * @return size in points - */ - float GetPointSize() const; - - /** - * @brief Return font size in pixels. - * - * @return size in pixels - */ - unsigned int GetPixelSize() const; - - /** - * @brief Retrieves the size of the font in pixels from a given size in points. - * - * @param[in] pointSize Size of the font in points. - * @return size of the font in pixels. - */ - static unsigned int PointsToPixels( float pointSize ); - - /** - * @brief Retrieves the size of the font in points from a given size in pixels - * @param[in] pixelsSize Size of the font in pixels. - * - * @return size of the font in points. - */ - static float PixelsToPoints( unsigned int pixelsSize ); - -public: // Not intended for application developers - - /** - * @brief This constructor is used by Dali New() methods - * - * @param [in] font A pointer to a newly allocated Dali resource - */ - explicit DALI_INTERNAL Font(Internal::Font* font); -}; - -} // namespace Dali - -#endif // __DALI_FONT_H__ diff --git a/dali/public-api/text/text-actor-parameters.cpp b/dali/public-api/text/text-actor-parameters.cpp deleted file mode 100644 index 6e7e0d0..0000000 --- a/dali/public-api/text/text-actor-parameters.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// FILE HEADER -#include - -// INTERNAL INCLUDES -#include - -namespace Dali -{ - -namespace -{ - -static const TextStyle DEFAULT_STYLE; -static const TextActorParameters::AutomaticFontDetection DEFAULT_AUTOMATIC_FONT_DETECTION = TextActorParameters::FONT_DETECTION_ON; - -} // namespace - -// Default font parameters. Adaptor will choose default system parameters. -TextActorParameters DEFAULT_TEXT_ACTOR_PARAMETERS; - -struct TextActorParameters::Impl -{ - Impl() - : mStyle(), - mFontDetection( DEFAULT_AUTOMATIC_FONT_DETECTION ) - { - } - - Impl( const TextStyle& style, AutomaticFontDetection fontDetection ) - : mStyle( style ), - mFontDetection( fontDetection ) - {} - - TextStyle mStyle; - AutomaticFontDetection mFontDetection; -}; - -TextActorParameters::TextActorParameters() -: mImpl( NULL ) -{ -} - -TextActorParameters::TextActorParameters( const TextStyle& style, AutomaticFontDetection fontDetection ) -: mImpl( new Impl( style, fontDetection ) ) -{ -} - -TextActorParameters::~TextActorParameters() -{ - delete mImpl; -} - -TextActorParameters::TextActorParameters( const TextActorParameters& parameters ) -: mImpl( NULL ) -{ - *this = parameters; -} - -TextActorParameters& TextActorParameters::operator=( const TextActorParameters& parameters ) -{ - if( ¶meters != this ) - { - if( NULL == parameters.mImpl ) - { - delete mImpl; - mImpl = NULL; - } - else if( NULL == mImpl ) - { - mImpl = new Impl( parameters.mImpl->mStyle, - parameters.mImpl->mFontDetection ); - } - else - { - mImpl->mStyle = parameters.mImpl->mStyle; - mImpl->mFontDetection = parameters.mImpl->mFontDetection; - } - } - - return *this; -} - -const TextStyle& TextActorParameters::GetTextStyle() const -{ - return ( NULL == mImpl ) ? DEFAULT_STYLE : mImpl->mStyle; -} - -bool TextActorParameters::IsAutomaticFontDetectionEnabled() const -{ - return ( NULL == mImpl ) ? ( DEFAULT_AUTOMATIC_FONT_DETECTION == TextActorParameters::FONT_DETECTION_ON ) : ( mImpl->mFontDetection == TextActorParameters::FONT_DETECTION_ON ); -} - -} // namespace Dali diff --git a/dali/public-api/text/text-actor-parameters.h b/dali/public-api/text/text-actor-parameters.h deleted file mode 100644 index 42b4fb5..0000000 --- a/dali/public-api/text/text-actor-parameters.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef __DALI_TEXT_ACTOR_PARAMETERS_H__ -#define __DALI_TEXT_ACTOR_PARAMETERS_H__ - -/* - * Copyright (c) 2014 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 INCLUDES -#include - -namespace Dali -{ - -// Forward declarations -class TextStyle; - -/** - * @brief Encapsulates text-actor parameters. - */ -struct DALI_IMPORT_API TextActorParameters -{ - /** - * @brief Enumeration of the automatic font detection medes. - */ - enum AutomaticFontDetection - { - FONT_DETECTION_OFF, ///< Font detection disabled. - FONT_DETECTION_ON ///< Font detection enabled. - }; - - /** - * @brief Default constructor. - * - * By default the text style is de default one and the automatic font detection is enabled. - */ - TextActorParameters(); - - /** - * @brief Constructor. - * - * @param[in] style The text style. - * @param[in] fontDetection Whether to automatically detect if the font support the characters and replace it if not. - */ - TextActorParameters( const TextStyle& style, AutomaticFontDetection fontDetection ); - - /** - * @brief Destructor. - * - * Destroys the internal implementation. - */ - ~TextActorParameters(); - - /** - * @brief Copy constructor. - * - * Reset the internal implementation with new given values. - * @param[in] parameters The new text-actor parameters. - */ - TextActorParameters( const TextActorParameters& parameters ); - - /** - * @brief Assignment operator. - * - * @param[in] parameters The new text-actor parameters. - * @return A reference to this - */ - TextActorParameters& operator=( const TextActorParameters& parameters ); - - /** - * @brief Retrieves the text style. - * - * @return the text style. - */ - const TextStyle& GetTextStyle() const; - - /** - * @brief Whether the automatic font detection is enabled. - * - * @return \e true if the automatic font detection is enabled. - */ - bool IsAutomaticFontDetectionEnabled() const; - -private: - struct Impl; - Impl* mImpl; -}; - -DALI_IMPORT_API extern TextActorParameters DEFAULT_TEXT_ACTOR_PARAMETERS; ///< By default the text style is the default one and the automatic font detection is enabled. - -} // namespace Dali - -#endif // __DALI_TEXT_ACTOR_PARAMETERS_H__ diff --git a/dali/public-api/text/text-style.cpp b/dali/public-api/text/text-style.cpp deleted file mode 100644 index aea843c..0000000 --- a/dali/public-api/text/text-style.cpp +++ /dev/null @@ -1,2512 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER - -#include - -// INTERNAL INCLUDES - -#include -#include -#include - -// EXTERNAL INCLUDES - -#include - -namespace -{ - -// Number of bits for an index mask - increase if more attributes are added... -const unsigned int PARAMETER_BITS = 3u; -const uint64_t ONE = 1lu; - -// Set mask for this number of bits -const uint64_t PARAMETER_MASK = ~( -1l << PARAMETER_BITS ); - -// Shift values for attribute indices -const unsigned int COMMON_INDEX_SHIFT = 0u; // starts at bit 0 -const unsigned int WEIGHT_INDEX_SHIFT = PARAMETER_BITS * 1; // starts at bit 3 -const unsigned int ITALICS_INDEX_SHIFT = PARAMETER_BITS * 2; // starts at bit 6 -const unsigned int UNDERLINE_INDEX_SHIFT = PARAMETER_BITS * 3; // starts at bit 9 -const unsigned int DROP_SHADOW_INDEX_SHIFT = PARAMETER_BITS * 4; // starts at bit 12 -const unsigned int GLOW_INDEX_SHIFT = PARAMETER_BITS * 5; // starts at bit 15 -const unsigned int OUTLINE_INDEX_SHIFT = PARAMETER_BITS * 6; // starts at bit 18 -const unsigned int GRADIENT_INDEX_SHIFT = PARAMETER_BITS * 7; // starts at bit 21 -const unsigned int PARAMETER_FLAGS = PARAMETER_BITS * 8; // 24 == 3 x 8 - -// Position in flags for attribute index -const uint64_t COMMON_INDEX = 0lu; // bits 0 .. 2 -const uint64_t WEIGHT_INDEX = PARAMETER_MASK << WEIGHT_INDEX_SHIFT; // bits 3 .. 5 -const uint64_t ITALICS_INDEX = PARAMETER_MASK << ITALICS_INDEX_SHIFT; // bits 6 .. 8 -const uint64_t UNDERLINE_INDEX = PARAMETER_MASK << UNDERLINE_INDEX_SHIFT; // bits 9 .. 11 -const uint64_t DROP_SHADOW_INDEX = PARAMETER_MASK << DROP_SHADOW_INDEX_SHIFT; // bits 12 .. 14 -const uint64_t GLOW_INDEX = PARAMETER_MASK << GLOW_INDEX_SHIFT; // bits 15 .. 17 -const uint64_t OUTLINE_INDEX = PARAMETER_MASK << OUTLINE_INDEX_SHIFT; // bits 18 .. 20 -const uint64_t GRADIENT_INDEX = PARAMETER_MASK << GRADIENT_INDEX_SHIFT; // bits 21 .. 23 - -// Flag positions and enables for attributes -const uint64_t ITALICS_ENABLED = ONE << PARAMETER_FLAGS; // bit 24 -const uint64_t UNDERLINE_ENABLED = ONE << ( PARAMETER_FLAGS + 1 ); // bit 25 -const uint64_t DROP_SHADOW_ENABLED = ONE << ( PARAMETER_FLAGS + 2 ); // bit 26 -const uint64_t GLOW_ENABLED = ONE << ( PARAMETER_FLAGS + 3 ); // bit 27 -const uint64_t OUTLINE_ENABLED = ONE << ( PARAMETER_FLAGS + 4 ); // bit 28 -const uint64_t GRADIENT_ENABLED = ONE << ( PARAMETER_FLAGS + 5 ); // bit 29 - -const uint64_t FONT_NAME_EXISTS = ONE << ( PARAMETER_FLAGS + 6 ); // bit 30 -const uint64_t FONT_STYLE_EXISTS = ONE << ( PARAMETER_FLAGS + 7 ); // bit 31 -const uint64_t FONT_SIZE_EXISTS = ONE << ( PARAMETER_FLAGS + 8 ); // bit 32 -const uint64_t TEXT_COLOR_EXISTS = ONE << ( PARAMETER_FLAGS + 9 ); // bit 33 -const uint64_t COMMON_PARAMETERS_EXISTS = ( FONT_NAME_EXISTS | FONT_STYLE_EXISTS | FONT_SIZE_EXISTS | TEXT_COLOR_EXISTS ); -const uint64_t FONT_WEIGHT_EXISTS = ONE << ( PARAMETER_FLAGS + 10 ); // bit 34 -const uint64_t SMOOTH_EDGE_EXISTS = ONE << ( PARAMETER_FLAGS + 11 ); // bit 35 -const uint64_t SMOOTH_WEIGHT_EXISTS = ( FONT_WEIGHT_EXISTS | SMOOTH_EDGE_EXISTS ); -const uint64_t ITALICS_EXISTS = ONE << ( PARAMETER_FLAGS + 12 ); // bit 36 -const uint64_t UNDERLINE_EXISTS = ONE << ( PARAMETER_FLAGS + 13 ); // bit 37 -const uint64_t DROP_SHADOW_EXISTS = ONE << ( PARAMETER_FLAGS + 14 ); // bit 38 -const uint64_t GLOW_EXISTS = ONE << ( PARAMETER_FLAGS + 15 ); // bit 39 -const uint64_t OUTLINE_EXISTS = ONE << ( PARAMETER_FLAGS + 16 ); // bit 40 -const uint64_t GRADIENT_EXISTS = ONE << ( PARAMETER_FLAGS + 17 ); // bit 41 -const uint64_t ATTRIBUTE_END = GRADIENT_EXISTS; - -const std::string DEFAULT_NAME; -const Dali::PointSize DEFAULT_FONT_POINT_SIZE( 0.f ); - -} // unnamed namespace - -namespace Dali -{ - -const Vector4 TextStyle::DEFAULT_TEXT_COLOR( Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); // cannot use Color::WHITE because it may or may not be initialized yet. -const TextStyle::Weight TextStyle::DEFAULT_FONT_WEIGHT( TextStyle::REGULAR ); -const float TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD( 0.46f ); -const Degree TextStyle::DEFAULT_ITALICS_ANGLE( 20.0f ); -const float TextStyle::DEFAULT_UNDERLINE_THICKNESS( 0.f ); -const float TextStyle::DEFAULT_UNDERLINE_POSITION( 0.f ); -const Vector4 TextStyle::DEFAULT_SHADOW_COLOR( Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) ); // cannot use Color::BLACK because it may or may not be initialized yet. -const Vector2 TextStyle::DEFAULT_SHADOW_OFFSET( 1.0f, 1.0f ); -const float TextStyle::DEFAULT_SHADOW_SIZE( 0.0f ); -const Vector4 TextStyle::DEFAULT_GLOW_COLOR( Vector4( 1.0f, 1.0f, 0.0f, 1.0f ) ); // cannot use Color::YELLOW because it may or may not be initialized yet. -const float TextStyle::DEFAULT_GLOW_INTENSITY( 0.05f ); -const Vector4 TextStyle::DEFAULT_OUTLINE_COLOR( Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) ); // cannot use Color::BLACK because it may or may not be initialized yet. -const Vector2 TextStyle::DEFAULT_OUTLINE_THICKNESS( 0.51f, 0.00f ); -const Vector4 TextStyle::DEFAULT_GRADIENT_COLOR( 1.0f, 1.0f, 1.0f, 1.0f ); // cannot use Color::WHITE because it may or may not be initialized yet. -const Vector2 TextStyle::DEFAULT_GRADIENT_START_POINT( 0.0f, 0.0f ); -const Vector2 TextStyle::DEFAULT_GRADIENT_END_POINT( 0.0f, 0.0f ); - -class TextStyleContainer -{ -private: - - TextStyleContainer() - : mFlags( 0 ) - { - } - - ~TextStyleContainer() - { - if( mFlags & COMMON_PARAMETERS_EXISTS ) - { - StyleCommonAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) ); - delete attrPtr; - } - if( mFlags & SMOOTH_WEIGHT_EXISTS ) - { - StyleWeightAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> WEIGHT_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - delete attrPtr; - } - if( mFlags & ITALICS_EXISTS ) - { - StyleItalicsAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> ITALICS_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - delete attrPtr; - } - if( mFlags & UNDERLINE_EXISTS ) - { - StyleUnderlineAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> UNDERLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - delete attrPtr; - } - if( mFlags & DROP_SHADOW_EXISTS ) - { - StyleShadowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - delete attrPtr; - } - if( mFlags & GLOW_EXISTS ) - { - StyleGlowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - delete attrPtr; - } - if( mFlags & OUTLINE_EXISTS ) - { - StyleOutlineAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> OUTLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - delete attrPtr; - } - if( mFlags & GRADIENT_EXISTS ) - { - StyleGradientAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - delete attrPtr; - } - } - - struct StyleCommonAttributes - { - StyleCommonAttributes() - : mFontPointSize( 0.0f ) - {} - - std::string mFontName; - std::string mFontStyle; - PointSize mFontPointSize; - Vector4 mTextColor; - }; - - struct StyleWeightAttributes - { - StyleWeightAttributes() - : mWeight( TextStyle::DEFAULT_FONT_WEIGHT ), - mSmoothEdge( 0.0f ) - {} - - TextStyle::Weight mWeight; - float mSmoothEdge; - }; - - struct StyleItalicsAttributes - { - StyleItalicsAttributes() - : mItalicsAngle( Degree( 0.0f ) ) - {} - Degree mItalicsAngle; - }; - - struct StyleUnderlineAttributes - { - float mUnderlineThickness; - float mUnderlinePosition; - }; - - struct StyleShadowAttributes - { - Vector4 mShadowColor; - Vector2 mShadowOffset; - float mShadowSize; - }; - - struct StyleGlowAttributes - { - Vector4 mGlowColor; - float mGlowIntensity; - }; - - struct StyleOutlineAttributes - { - Vector4 mOutlineColor; - Vector2 mOutlineThickness; - }; - - struct StyleGradientAttributes - { - Vector4 mColor; - Vector2 mStartPoint; - Vector2 mEndPoint; - }; - - void SetCommonDefaults( StyleCommonAttributes* attr ); - void SetFontName( const std::string& fontName ); - void SetFontStyle( const std::string& fontStyle ); - void SetFontPointSize( PointSize fontPointSize ); - void SetTextColor( const Vector4& textColor ); - void SetWeight( TextStyle::Weight weight ); - void SetSmoothEdge( float smoothEdge ); - void SetItalics( bool enable, Degree angle ); - void SetUnderline( bool enable, float thickness, float position ); - void SetShadow( bool enable, const Vector4& shadowColor, const Vector2& shadowOffset, float shadowSize ); - void SetGlow( bool enable, const Vector4& glowColor, float glowIntensity ); - void SetOutline( bool enable, const Vector4& outlineColor, const Vector2& outlineThickness ); - void SetGradient( bool enable, const Vector4& color, const Vector2& startPosition, const Vector2& endPosition ); - - const std::string& GetFontName() const; - const std::string& GetFontStyle() const; - PointSize GetFontPointSize() const; - const Vector4& GetTextColor() const; - TextStyle::Weight GetWeight() const; - float GetSmoothEdge() const; - Degree GetItalicsAngle() const; - float GetUnderlineThickness() const; - float GetUnderlinePosition() const; - const Vector4& GetShadowColor() const; - const Vector2& GetShadowOffset() const; - float GetShadowSize() const; - const Vector4& GetGlowColor() const; - float GetGlowIntensity() const; - const Vector2& GetOutlineThickness() const; - const Vector4& GetOutlineColor() const; - const Vector4& GetGradientColor() const; - const Vector2& GetGradientStartPoint() const; - const Vector2& GetGradientEndPoint() const; - - void UpdateIndex( std::size_t index ); - void ResetFontName(); - void ResetFontStyle(); - void ResetFontSize(); - void ResetTextColor(); - void ResetFontWeight(); - void ResetSmoothEdge(); - void ResetItalics(); - void ResetUnderline(); - void ResetShadow(); - void ResetGlow(); - void ResetOutline(); - void ResetGradient(); - - // Private and not implemented. - TextStyleContainer( const TextStyleContainer& ); - TextStyleContainer& operator=( const TextStyleContainer& ); - - Vector< char* > mParameters; ///< container for used style parameters. - uint64_t mFlags; ///< flags for used attributes, packed with position in container - friend class TextStyle; -}; - -TextStyle::TextStyle() -: mContainer( NULL ) -{ -} - -TextStyle::~TextStyle() -{ - delete mContainer; -} - -TextStyle::TextStyle( const TextStyle& textStyle ) -: mContainer( NULL ) -{ - TextStyle::operator=( textStyle ); -} - -TextStyle& TextStyle::operator=( const TextStyle& textStyle ) -{ - if( this == &textStyle ) - { - // Return 'this' if trying to assign the object itself. - return *this; - } - - if ( textStyle.mContainer == NULL ) - { - // If text-style to be assigned is default, delete the container to make 'this' default. - delete mContainer; - mContainer = NULL; - return *this; - } - else - { - int resetMask = TextStyle::NONE; - - if( textStyle.IsFontNameDefault() ) - { - if( !IsFontNameDefault() ) - { - resetMask |= TextStyle::FONT; - } - } - else - { - SetFontName( textStyle.GetFontName() ); - } - - if( textStyle.IsFontStyleDefault() ) - { - if( !IsFontStyleDefault() ) - { - resetMask |= TextStyle::STYLE; - } - } - else - { - SetFontStyle( textStyle.GetFontStyle() ); - } - - if( textStyle.IsFontSizeDefault() ) - { - if( !IsFontSizeDefault() ) - { - resetMask |= TextStyle::SIZE; - } - } - else - { - SetFontPointSize( textStyle.GetFontPointSize() ); - } - - if( textStyle.IsTextColorDefault() ) - { - if( !IsTextColorDefault() ) - { - resetMask |= TextStyle::COLOR; - } - } - else - { - SetTextColor( textStyle.GetTextColor() ); - } - - if( textStyle.IsFontWeightDefault() ) - { - if( !IsFontWeightDefault() ) - { - resetMask |= TextStyle::WEIGHT; - } - } - else - { - SetWeight( textStyle.GetWeight() ); - } - - if( textStyle.IsSmoothEdgeDefault() ) - { - if( !IsSmoothEdgeDefault() ) - { - resetMask |= TextStyle::SMOOTH; - } - } - else - { - SetSmoothEdge( textStyle.GetSmoothEdge() ); - } - - if( textStyle.IsItalicsDefault() ) - { - if( !IsItalicsDefault() ) - { - resetMask |= TextStyle::ITALICS; - } - } - else - { - SetItalics( textStyle.IsItalicsEnabled(), textStyle.GetItalicsAngle() ); - } - - if( textStyle.IsUnderlineDefault() ) - { - if( !IsUnderlineDefault() ) - { - resetMask |= TextStyle::UNDERLINE; - } - } - else - { - SetUnderline( textStyle.IsUnderlineEnabled(), textStyle.GetUnderlineThickness(), textStyle.GetUnderlinePosition() ); - } - - if ( textStyle.IsShadowDefault() ) - { - if( !IsShadowDefault() ) - { - resetMask |= TextStyle::SHADOW; - } - } - else - { - SetShadow( textStyle.IsShadowEnabled(), textStyle.GetShadowColor(), textStyle.GetShadowOffset(), textStyle.GetShadowSize() ); - } - - if ( textStyle.IsGlowDefault() ) - { - if( !IsGlowDefault() ) - { - resetMask |= TextStyle::GLOW; - } - } - else - { - SetGlow( textStyle.IsGlowEnabled(), textStyle.GetGlowColor(), textStyle.GetGlowIntensity() ); - } - - if ( textStyle.IsOutlineDefault() ) - { - if( !IsOutlineDefault() ) - { - resetMask |= TextStyle::OUTLINE; - } - } - else - { - SetOutline( textStyle.IsOutlineEnabled(), textStyle.GetOutlineColor(), textStyle.GetOutlineThickness() ); - } - - if ( textStyle.IsGradientDefault() ) - { - if( !IsGradientDefault() ) - { - resetMask |= TextStyle::GRADIENT; - } - } - else - { - SetGradient( textStyle.IsGradientEnabled(), textStyle.GetGradientColor(), textStyle.GetGradientStartPoint(), textStyle.GetGradientEndPoint() ); - } - - Reset( static_cast( resetMask ) ); - } - - return *this; -} - -bool TextStyle::operator==( const TextStyle& textStyle ) const -{ - // If both Implementations are uninitialized then return equal - if ( mContainer == NULL && textStyle.mContainer == NULL ) - { - return true; - } - // Otherwise if either one of the Implemetations are uninitialized then return not equal - else if ( mContainer == NULL || textStyle.mContainer == NULL ) - { - return false; - } - // If the number of style parameters set are different or - // different flags are set, without taking into account the indices, then return not equal. - // Two equal styles can have different indices if the parameters have been set in different order. - else if( ( mContainer->mParameters.Size() != textStyle.mContainer->mParameters.Size() ) || - ( mContainer->mFlags >> PARAMETER_FLAGS ) != ( textStyle.mContainer->mFlags >> PARAMETER_FLAGS ) ) - { - return false; - } - - if( ( !IsFontWeightDefault() && - ( GetWeight() != textStyle.GetWeight() ) ) || - - ( !IsFontSizeDefault() && - ( fabsf( GetFontPointSize() - textStyle.GetFontPointSize() ) > Math::MACHINE_EPSILON_1000 ) ) || - - ( !IsItalicsDefault() && - ( GetItalicsAngle() != textStyle.GetItalicsAngle() ) ) || - - ( !IsSmoothEdgeDefault() && - ( fabsf( GetSmoothEdge() - textStyle.GetSmoothEdge() ) > Math::MACHINE_EPSILON_1000 ) ) || - - ( !IsUnderlineDefault() && - ( ( fabsf( GetUnderlineThickness() - textStyle.GetUnderlineThickness() ) > Math::MACHINE_EPSILON_1000 ) || - ( fabsf( GetUnderlinePosition() - textStyle.GetUnderlinePosition() ) > Math::MACHINE_EPSILON_1000 ) ) ) || - - ( !IsFontNameDefault() && - ( GetFontName() != textStyle.GetFontName() ) ) || - - ( !IsFontStyleDefault() && - ( GetFontStyle() != textStyle.GetFontStyle() ) ) || - - ( !IsTextColorDefault() && - ( GetTextColor() != textStyle.GetTextColor() ) ) || - - ( !IsGlowDefault() && - ( ( fabsf( GetGlowIntensity() - textStyle.GetGlowIntensity() ) > Math::MACHINE_EPSILON_1000 ) || - ( GetGlowColor() != textStyle.GetGlowColor() ) ) ) || - - ( !IsOutlineDefault() && - ( ( GetOutlineThickness() != textStyle.GetOutlineThickness() ) || - ( GetOutlineColor() != textStyle.GetOutlineColor() ) ) ) || - - ( !IsShadowDefault() && - ( ( fabsf( GetShadowSize() - textStyle.GetShadowSize() ) > Math::MACHINE_EPSILON_1000 ) || - ( GetShadowOffset() != textStyle.GetShadowOffset() ) || - ( GetShadowColor() != textStyle.GetShadowColor() ) ) ) || - - ( !IsGradientDefault() && - ( ( GetGradientStartPoint() != textStyle.GetGradientStartPoint() ) || - ( GetGradientEndPoint() != textStyle.GetGradientEndPoint() ) || - ( GetGradientColor() != textStyle.GetGradientColor() ) ) ) ) - { - return false; - } - - return true; -} - -bool TextStyle::operator!=( const TextStyle& textStyle ) const -{ - return !( *this == textStyle ); -} - -void TextStyle::Copy( const TextStyle& textStyle, Mask mask ) -{ - // If we're attemping to copy ourselves then just return - if ( this == &textStyle ) - { - return; - } - - // Check to see if we're copying a default style ? - if ( textStyle.mContainer == NULL ) - { - // Yes, so if we're coping entirely then re-create a default style, else the mask resets attributes to defaults - if ( mContainer && mask == ALL ) - { - delete mContainer; - mContainer = NULL; - } - else - { - if( NULL != mContainer ) - { - int resetMask = TextStyle::NONE; - - if( mask & FONT ) - { - resetMask |= FONT; - } - if( mask & STYLE ) - { - resetMask |= STYLE; - } - if( mask & SIZE ) - { - resetMask |= SIZE; - } - if( mask & COLOR ) - { - resetMask |= COLOR; - } - if( mask & WEIGHT ) - { - resetMask |= WEIGHT; - } - if( mask & SMOOTH ) - { - resetMask |= SMOOTH; - } - if( mask & ITALICS ) - { - resetMask |= ITALICS; - } - if( mask & UNDERLINE ) - { - resetMask |= UNDERLINE; - } - if ( mask & SHADOW ) - { - resetMask |= SHADOW; - } - if ( mask & GLOW ) - { - resetMask |= GLOW; - } - if ( mask & OUTLINE ) - { - resetMask |= OUTLINE; - } - if ( mask & GRADIENT ) - { - resetMask |= GRADIENT; - } - - Reset( static_cast( resetMask ) ); - } - } - return; - } - - // Source has a container, so the target will also need one - CreateContainerJustInTime(); - - if( mask == ALL ) - { - *this = textStyle; - } - else - { - int resetMask = TextStyle::NONE; - - if( mask & FONT ) - { - if( textStyle.IsFontNameDefault() ) - { - resetMask |= FONT; - } - else - { - SetFontName( textStyle.GetFontName() ); - } - } - if( mask & STYLE ) - { - if( textStyle.IsFontStyleDefault() ) - { - resetMask |= STYLE; - } - else - { - SetFontStyle( textStyle.GetFontStyle() ); - } - } - if( mask & SIZE ) - { - if( textStyle.IsFontSizeDefault() ) - { - resetMask |= SIZE; - } - else - { - SetFontPointSize( textStyle.GetFontPointSize() ); - } - } - if( mask & COLOR ) - { - if( textStyle.IsTextColorDefault() ) - { - resetMask |= COLOR; - } - else - { - SetTextColor( textStyle.GetTextColor() ) ; - } - } - if( mask & WEIGHT ) - { - if( textStyle.IsFontWeightDefault() ) - { - resetMask |= WEIGHT; - } - else - { - SetWeight( textStyle.GetWeight() ); - } - } - if( mask & SMOOTH ) - { - if( textStyle.IsSmoothEdgeDefault() ) - { - resetMask |= SMOOTH; - } - else - { - SetSmoothEdge( textStyle.GetSmoothEdge() ); - } - } - if( mask & ITALICS ) - { - if( textStyle.IsItalicsDefault() ) - { - resetMask |= ITALICS; - } - else - { - SetItalics( textStyle.IsItalicsEnabled(), textStyle.GetItalicsAngle() ); - } - } - if( mask & UNDERLINE ) - { - if( textStyle.IsUnderlineDefault() ) - { - resetMask |= UNDERLINE; - } - else - { - SetUnderline( textStyle.IsUnderlineEnabled(), textStyle.GetUnderlineThickness(), textStyle.GetUnderlinePosition() ); - } - } - if ( mask & SHADOW ) - { - if( textStyle.IsShadowDefault() ) - { - resetMask |= SHADOW; - } - else - { - SetShadow( textStyle.IsShadowEnabled(), textStyle.GetShadowColor(), textStyle.GetShadowOffset(), textStyle.GetShadowSize() ); - } - } - if ( mask & GLOW ) - { - if( textStyle.IsGlowDefault() ) - { - resetMask |= GLOW; - } - else - { - SetGlow( textStyle.IsGlowEnabled(), textStyle.GetGlowColor(), textStyle.GetGlowIntensity() ); - } - } - if ( mask & OUTLINE ) - { - if( textStyle.IsOutlineDefault() ) - { - resetMask |= OUTLINE; - } - else - { - SetOutline( textStyle.IsOutlineEnabled(), textStyle.GetOutlineColor(), textStyle.GetOutlineThickness() ); - } - } - if ( mask & GRADIENT ) - { - if( textStyle.IsGradientDefault() ) - { - resetMask |= GRADIENT; - } - else - { - SetGradient( textStyle.IsGradientEnabled(), textStyle.GetGradientColor(), textStyle.GetGradientStartPoint(), textStyle.GetGradientEndPoint() ); - } - } - - Reset( static_cast( resetMask ) ); - } -} - -void TextStyle::Merge( const TextStyle& textStyle, Mask mask ) -{ - // If we're attemping to merge ourselves then just return - if ( this == &textStyle ) - { - return; - } - - // Check to see if we're merging from default style ? - if ( textStyle.mContainer == NULL ) - { - // nothing to merge. - return; - } - - if( mask & FONT ) - { - if( !textStyle.IsFontNameDefault() ) - { - SetFontName( textStyle.GetFontName() ); - } - } - if( mask & STYLE ) - { - if( !textStyle.IsFontStyleDefault() ) - { - SetFontStyle( textStyle.GetFontStyle() ); - } - } - if( mask & SIZE ) - { - if( !textStyle.IsFontSizeDefault() ) - { - SetFontPointSize( textStyle.GetFontPointSize() ); - } - } - if( mask & COLOR ) - { - if( !textStyle.IsTextColorDefault() ) - { - SetTextColor( textStyle.GetTextColor() ) ; - } - } - if( mask & WEIGHT ) - { - if( !textStyle.IsFontWeightDefault() ) - { - SetWeight( textStyle.GetWeight() ); - } - } - if( mask & SMOOTH ) - { - if( !textStyle.IsSmoothEdgeDefault() ) - { - SetSmoothEdge( textStyle.GetSmoothEdge() ); - } - } - if( mask & ITALICS ) - { - if( !textStyle.IsItalicsDefault() ) - { - SetItalics( textStyle.IsItalicsEnabled(), textStyle.GetItalicsAngle() ); - } - } - if( mask & UNDERLINE ) - { - if( !textStyle.IsUnderlineDefault() ) - { - SetUnderline( textStyle.IsUnderlineEnabled(), textStyle.GetUnderlineThickness(), textStyle.GetUnderlinePosition() ); - } - } - if( mask & SHADOW ) - { - if( !textStyle.IsShadowDefault() ) - { - SetShadow( textStyle.IsShadowEnabled(), textStyle.GetShadowColor(), textStyle.GetShadowOffset(), textStyle.GetShadowSize() ); - } - } - if( mask & GLOW ) - { - if( !textStyle.IsGlowDefault() ) - { - SetGlow( textStyle.IsGlowEnabled(), textStyle.GetGlowColor(), textStyle.GetGlowIntensity() ); - } - } - if( mask & OUTLINE ) - { - if( !textStyle.IsOutlineDefault() ) - { - SetOutline( textStyle.IsOutlineEnabled(), textStyle.GetOutlineColor(), textStyle.GetOutlineThickness() ); - } - } - if( mask & GRADIENT ) - { - if( !textStyle.IsGradientDefault() ) - { - SetGradient( textStyle.IsGradientEnabled(), textStyle.GetGradientColor(), textStyle.GetGradientStartPoint(), textStyle.GetGradientEndPoint() ); - } - } -} - -void TextStyle::Reset( Mask mask ) -{ - if( NULL == mContainer ) - { - // nothing to do if any text-style parameter is set. - return; - } - - if( TextStyle::NONE == mask ) - { - // nothing to do if the mask is NONE. - return; - } - - // Check first if all text-style parameters are going to be reset. - - // Reset all if the mask is the default (ALL). - bool resetAll = ALL == mask; - - if( !resetAll ) - { - resetAll = true; - - // Checks if a style parameter is set in the style but is not in the mask. - if( ( mContainer->mFlags & FONT_NAME_EXISTS ) && !( mask & FONT ) ) - { - resetAll = false; - } - else if( ( mContainer->mFlags & FONT_STYLE_EXISTS ) && !( mask & STYLE ) ) - { - resetAll = false; - } - else if( ( mContainer->mFlags & FONT_SIZE_EXISTS ) && !( mask & SIZE ) ) - { - resetAll = false; - } - else if( ( mContainer->mFlags & TEXT_COLOR_EXISTS ) && !( mask & COLOR ) ) - { - resetAll = false; - } - else if( ( mContainer->mFlags & FONT_WEIGHT_EXISTS ) && !( mask & WEIGHT ) ) - { - resetAll = false; - } - else if( ( mContainer->mFlags & SMOOTH_EDGE_EXISTS ) && !( mask & SMOOTH ) ) - { - resetAll = false; - } - else if( ( mContainer->mFlags & ITALICS_EXISTS ) && !( mask & ITALICS ) ) - { - resetAll = false; - } - else if( ( mContainer->mFlags & UNDERLINE_EXISTS ) && !( mask & UNDERLINE ) ) - { - resetAll = false; - } - else if( ( mContainer->mFlags & DROP_SHADOW_EXISTS ) && !( mask & SHADOW ) ) - { - resetAll = false; - } - else if( ( mContainer->mFlags & GLOW_EXISTS ) && !( mask & GLOW ) ) - { - resetAll = false; - } - else if( ( mContainer->mFlags & OUTLINE_EXISTS ) && !( mask & OUTLINE ) ) - { - resetAll = false; - } - else if( ( mContainer->mFlags & GRADIENT_EXISTS ) && !( mask & GRADIENT ) ) - { - resetAll = false; - } - } - - if( resetAll ) - { - // delete the container if all text-style parametes are reset. - delete mContainer; - mContainer = NULL; - - return; - } - - if( mask & FONT ) - { - mContainer->ResetFontName(); - } - if( mask & STYLE ) - { - mContainer->ResetFontStyle(); - } - if( mask & SIZE ) - { - mContainer->ResetFontSize(); - } - if( mask & COLOR ) - { - mContainer->ResetTextColor(); - } - if( mask & WEIGHT ) - { - mContainer->ResetFontWeight(); - } - if( mask & SMOOTH ) - { - mContainer->ResetSmoothEdge(); - } - if( mask & ITALICS ) - { - mContainer->ResetItalics(); - } - if( mask & UNDERLINE ) - { - mContainer->ResetUnderline(); - } - if ( mask & SHADOW ) - { - mContainer->ResetShadow(); - } - if ( mask & GLOW ) - { - mContainer->ResetGlow(); - } - if ( mask & OUTLINE ) - { - mContainer->ResetOutline(); - } - if ( mask & GRADIENT ) - { - mContainer->ResetGradient(); - } -} - -const std::string& TextStyle::GetFontName() const -{ - if ( mContainer ) - { - return mContainer->GetFontName(); - } - else - { - return DEFAULT_NAME; - } -} - -void TextStyle::SetFontName( const std::string& fontName ) -{ - CreateContainerJustInTime(); - mContainer->SetFontName( fontName ); -} - -const std::string& TextStyle::GetFontStyle() const -{ - if ( mContainer ) - { - return mContainer->GetFontStyle(); - } - else - { - return DEFAULT_NAME; - } -} - -void TextStyle::SetFontStyle( const std::string& fontStyle ) -{ - CreateContainerJustInTime(); - mContainer->SetFontStyle( fontStyle ); -} - -PointSize TextStyle::GetFontPointSize() const -{ - if ( mContainer ) - { - return mContainer->GetFontPointSize(); - } - else - { - return DEFAULT_FONT_POINT_SIZE; - } -} - -void TextStyle::SetFontPointSize( PointSize fontPointSize ) -{ - CreateContainerJustInTime(); - mContainer->SetFontPointSize( fontPointSize ); -} - -const Vector4& TextStyle::GetTextColor() const -{ - if ( mContainer ) - { - return mContainer->GetTextColor(); - } - else - { - return DEFAULT_TEXT_COLOR; - } -} - -void TextStyle::SetTextColor( const Vector4& textColor ) -{ - CreateContainerJustInTime(); - mContainer->SetTextColor( textColor ); -} - -TextStyle::Weight TextStyle::GetWeight() const -{ - if ( mContainer ) - { - return mContainer->GetWeight(); - } - else - { - return TextStyle::DEFAULT_FONT_WEIGHT; - } -} - -void TextStyle::SetWeight( TextStyle::Weight weight ) -{ - CreateContainerJustInTime(); - mContainer->SetWeight( weight ); -} - -float TextStyle::GetSmoothEdge() const -{ - if ( mContainer ) - { - return mContainer->GetSmoothEdge(); - } - else - { - return DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD; - } -} - -void TextStyle::SetSmoothEdge( float smoothEdge ) -{ - CreateContainerJustInTime(); - mContainer->SetSmoothEdge( smoothEdge ); -} - -bool TextStyle::IsItalicsEnabled() const -{ - if ( mContainer ) - { - return ( ( mContainer->mFlags & ITALICS_ENABLED ) != 0 ); - } - else - { - return false; - } -} - -Degree TextStyle::GetItalicsAngle() const -{ - if ( mContainer ) - { - return mContainer->GetItalicsAngle(); - } - else - { - return DEFAULT_ITALICS_ANGLE; - } -} - -void TextStyle::SetItalics( bool enable, Degree angle ) -{ - CreateContainerJustInTime(); - mContainer->SetItalics( enable, angle ); -} - -bool TextStyle::IsUnderlineEnabled() const -{ - if ( mContainer ) - { - return ( ( mContainer->mFlags & UNDERLINE_ENABLED ) != 0 ); - } - else - { - return false; - } -} - -float TextStyle::GetUnderlineThickness() const -{ - if ( mContainer ) - { - return mContainer->GetUnderlineThickness(); - } - else - { - return DEFAULT_UNDERLINE_THICKNESS; - } -} - -float TextStyle::GetUnderlinePosition() const -{ - if ( mContainer ) - { - return mContainer->GetUnderlinePosition(); - } - else - { - return DEFAULT_UNDERLINE_POSITION; - } -} - -void TextStyle::SetUnderline( bool enable, float thickness, float position ) -{ - CreateContainerJustInTime(); - mContainer->SetUnderline( enable, thickness, position ); -} - -bool TextStyle::IsShadowEnabled() const -{ - if ( mContainer ) - { - return ( ( mContainer->mFlags & DROP_SHADOW_ENABLED ) != 0 ); - } - else - { - return false; - } -} - -const Vector4& TextStyle::GetShadowColor() const -{ - if ( mContainer ) - { - return mContainer->GetShadowColor(); - } - else - { - return DEFAULT_SHADOW_COLOR; - } -} - -const Vector2& TextStyle::GetShadowOffset() const -{ - if ( mContainer ) - { - return mContainer->GetShadowOffset(); - } - else - { - return DEFAULT_SHADOW_OFFSET; - } -} - -float TextStyle::GetShadowSize() const -{ - if ( mContainer ) - { - return mContainer->GetShadowSize(); - } - else - { - return DEFAULT_SHADOW_SIZE; - } -} - -void TextStyle::SetShadow( bool enabled, const Vector4& shadowColor, const Vector2& shadowOffset, float shadowSize ) -{ - CreateContainerJustInTime(); - mContainer->SetShadow( enabled, shadowColor, shadowOffset, shadowSize ); -} - -bool TextStyle::IsGlowEnabled() const -{ - if ( mContainer ) - { - return ( ( mContainer->mFlags & GLOW_ENABLED ) != 0 ); - } - else - { - return false; - } -} - -const Vector4& TextStyle::GetGlowColor() const -{ - if ( mContainer ) - { - return mContainer->GetGlowColor(); - } - else - { - return DEFAULT_GLOW_COLOR; - } -} - -float TextStyle::GetGlowIntensity() const -{ - if ( mContainer ) - { - return mContainer->GetGlowIntensity(); - } - else - { - return DEFAULT_GLOW_INTENSITY; - } -} - -void TextStyle::SetGlow( bool enabled, const Vector4& glowColor, float glowIntensity ) -{ - CreateContainerJustInTime(); - mContainer->SetGlow( enabled, glowColor, glowIntensity ); -} - -bool TextStyle::IsOutlineEnabled() const -{ - if ( mContainer ) - { - return ( ( mContainer->mFlags & OUTLINE_ENABLED ) != 0 ); - } - else - { - return false; - } -} - -const Vector2& TextStyle::GetOutlineThickness() const -{ - if ( mContainer ) - { - return mContainer->GetOutlineThickness(); - } - else - { - return DEFAULT_OUTLINE_THICKNESS; - } -} - -const Vector4& TextStyle::GetOutlineColor() const -{ - if ( mContainer ) - { - return mContainer->GetOutlineColor(); - } - else - { - return DEFAULT_OUTLINE_COLOR; - } -} - -void TextStyle::SetOutline( bool enabled, const Vector4& outlineColor, const Vector2& outlineThickness ) -{ - CreateContainerJustInTime(); - mContainer->SetOutline( enabled, outlineColor, outlineThickness ); -} - -bool TextStyle::IsGradientEnabled() const -{ - if ( mContainer ) - { - return ( ( mContainer->mFlags & GRADIENT_ENABLED ) != 0 ); - } - else - { - return false; - } -} - -const Vector4& TextStyle::GetGradientColor() const -{ - if ( mContainer ) - { - return mContainer->GetGradientColor(); - } - else - { - return DEFAULT_GRADIENT_COLOR; - } -} - -const Vector2& TextStyle::GetGradientStartPoint() const -{ - if ( mContainer ) - { - return mContainer->GetGradientStartPoint(); - } - else - { - return DEFAULT_GRADIENT_START_POINT; - } -} - -const Vector2& TextStyle::GetGradientEndPoint() const -{ - if ( mContainer ) - { - return mContainer->GetGradientEndPoint(); - } - else - { - return DEFAULT_GRADIENT_END_POINT; - } -} - -void TextStyle::SetGradient( bool enabled, const Vector4& color, const Vector2& startPoint, const Vector2& endPoint ) -{ - CreateContainerJustInTime(); - mContainer->SetGradient( enabled, color, startPoint, endPoint ); -} - -bool TextStyle::IsFontNameDefault() const -{ - if( mContainer ) - { - return( ( mContainer->mFlags & FONT_NAME_EXISTS ) == 0 ); - } - else - { - return true; - } -} - -bool TextStyle::IsFontStyleDefault() const -{ - if( mContainer ) - { - return( ( mContainer->mFlags & FONT_STYLE_EXISTS ) == 0 ); - } - else - { - return true; - } -} - -bool TextStyle::IsFontSizeDefault() const -{ - if( mContainer ) - { - return( ( mContainer->mFlags & FONT_SIZE_EXISTS ) == 0 ); - } - else - { - return true; - } -} - -bool TextStyle::IsTextColorDefault() const -{ - if( mContainer ) - { - return( ( mContainer->mFlags & TEXT_COLOR_EXISTS ) == 0 ); - } - else - { - return true; - } -} - -bool TextStyle::IsFontWeightDefault() const -{ - if( mContainer ) - { - return( ( mContainer->mFlags & FONT_WEIGHT_EXISTS ) == 0 ); - } - else - { - return true; - } -} - -bool TextStyle::IsSmoothEdgeDefault() const -{ - if( mContainer ) - { - return ( ( mContainer->mFlags & SMOOTH_EDGE_EXISTS ) == 0 ); - } - else - { - return true; - } -} - -bool TextStyle::IsItalicsDefault() const -{ - if( mContainer ) - { - return( ( mContainer->mFlags & ITALICS_EXISTS ) == 0 ); - } - else - { - return true; - } -} - -bool TextStyle::IsUnderlineDefault() const -{ - if( mContainer ) - { - return( ( mContainer->mFlags & UNDERLINE_EXISTS ) == 0 ); - } - else - { - return true; - } -} - -bool TextStyle::IsShadowDefault() const -{ - if( mContainer ) - { - return( ( mContainer->mFlags & DROP_SHADOW_EXISTS ) == 0 ); - } - else - { - return true; - } -} - -bool TextStyle::IsGlowDefault() const -{ - if( mContainer ) - { - return( ( mContainer->mFlags & GLOW_EXISTS ) == 0 ); - } - else - { - return true; - } -} - -bool TextStyle::IsOutlineDefault() const -{ - if( mContainer ) - { - return( ( mContainer->mFlags & OUTLINE_EXISTS ) == 0 ); - } - else - { - return true; - } -} - -bool TextStyle::IsGradientDefault() const -{ - if( mContainer ) - { - return( ( mContainer->mFlags & GRADIENT_EXISTS ) == 0 ); - } - else - { - return true; - } -} - -//-------------------------------------------------------------- - -void TextStyle::CreateContainerJustInTime() -{ - if ( !mContainer ) - { - mContainer = new TextStyleContainer; - } -} - -//-------------------------------------------------------------- - -void TextStyleContainer::SetCommonDefaults( StyleCommonAttributes* attr ) -{ - attr->mFontName = DEFAULT_NAME; - attr->mFontStyle = DEFAULT_NAME; - attr->mFontPointSize = DEFAULT_FONT_POINT_SIZE; - attr->mTextColor = TextStyle::DEFAULT_TEXT_COLOR; -} - -void TextStyleContainer::SetFontName( const std::string& fontName ) -{ - if ( mFlags & COMMON_PARAMETERS_EXISTS ) - { - StyleCommonAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) ); - attrPtr->mFontName = fontName; - mFlags |= FONT_NAME_EXISTS; - } - else - { - StyleCommonAttributes* attr = new StyleCommonAttributes(); - SetCommonDefaults( attr ); - attr->mFontName = fontName; - mFlags |= ( mFlags & ~COMMON_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) | FONT_NAME_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } -} - -void TextStyleContainer::SetFontStyle( const std::string& fontStyle ) -{ - if ( mFlags & COMMON_PARAMETERS_EXISTS ) - { - StyleCommonAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) ); - attrPtr->mFontStyle = fontStyle; - mFlags |= FONT_STYLE_EXISTS; - } - else - { - StyleCommonAttributes* attr = new StyleCommonAttributes(); - SetCommonDefaults( attr ); - attr->mFontStyle = fontStyle; - mFlags |= ( mFlags & ~COMMON_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) | FONT_STYLE_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } -} - -void TextStyleContainer::SetFontPointSize( PointSize fontPointSize ) -{ - if ( mFlags & COMMON_PARAMETERS_EXISTS ) - { - StyleCommonAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) ); - attrPtr->mFontPointSize = fontPointSize; - mFlags |= FONT_SIZE_EXISTS; - } - else - { - StyleCommonAttributes* attr = new StyleCommonAttributes(); - SetCommonDefaults( attr ); - attr->mFontPointSize = fontPointSize; - mFlags |= ( mFlags & ~COMMON_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) | FONT_SIZE_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } -} - -void TextStyleContainer::SetTextColor( const Vector4& textColor ) -{ - if ( mFlags & COMMON_PARAMETERS_EXISTS ) - { - StyleCommonAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) ); - attrPtr->mTextColor = textColor; - mFlags |= TEXT_COLOR_EXISTS; - } - else - { - StyleCommonAttributes* attr = new StyleCommonAttributes(); - SetCommonDefaults( attr ); - attr->mTextColor = textColor; - mFlags |= ( mFlags & ~COMMON_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) | TEXT_COLOR_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } -} - -void TextStyleContainer::SetWeight( TextStyle::Weight weight ) -{ - if ( mFlags & SMOOTH_WEIGHT_EXISTS ) - { - StyleWeightAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> WEIGHT_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - attrPtr->mWeight = weight; - mFlags |= FONT_WEIGHT_EXISTS; - } - else - { - StyleWeightAttributes* attr = new StyleWeightAttributes(); - attr->mSmoothEdge = TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD; - attr->mWeight = weight; - mFlags |= ( ( mFlags & ~WEIGHT_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << WEIGHT_INDEX_SHIFT ) | FONT_WEIGHT_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } -} - -void TextStyleContainer::SetSmoothEdge( float smoothEdge ) -{ - if ( mFlags & SMOOTH_WEIGHT_EXISTS ) - { - StyleWeightAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> WEIGHT_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - attrPtr->mSmoothEdge = smoothEdge; - mFlags |= SMOOTH_EDGE_EXISTS; - } - else - { - StyleWeightAttributes* attr = new StyleWeightAttributes(); - attr->mSmoothEdge = smoothEdge; - attr->mWeight = TextStyle::DEFAULT_FONT_WEIGHT; - mFlags |= ( ( mFlags & ~WEIGHT_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << WEIGHT_INDEX_SHIFT ) | SMOOTH_EDGE_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } -} - -void TextStyleContainer::SetItalics( bool enable, Degree angle ) -{ - if ( mFlags & ITALICS_EXISTS ) - { - StyleItalicsAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> ITALICS_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - attrPtr->mItalicsAngle = angle; - } - else - { - StyleItalicsAttributes* attr = new StyleItalicsAttributes(); - attr->mItalicsAngle = angle; - mFlags |= ( ( mFlags & ~ITALICS_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << ITALICS_INDEX_SHIFT ) | ITALICS_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } - - if( enable ) - { - mFlags |= ITALICS_ENABLED; - } - else - { - mFlags &= ~ITALICS_ENABLED; - } -} - -void TextStyleContainer::SetUnderline( bool enable, float thickness, float position ) -{ - if ( mFlags & UNDERLINE_EXISTS ) - { - StyleUnderlineAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> UNDERLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - attrPtr->mUnderlineThickness = thickness; - attrPtr->mUnderlinePosition = position; - } - else - { - StyleUnderlineAttributes* attr = new StyleUnderlineAttributes(); - attr->mUnderlineThickness = thickness; - attr->mUnderlinePosition = position; - mFlags |= ( ( mFlags & ~UNDERLINE_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << UNDERLINE_INDEX_SHIFT ) | UNDERLINE_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } - - if( enable ) - { - mFlags |= UNDERLINE_ENABLED; - } - else - { - mFlags &= ~UNDERLINE_ENABLED; - } -} - -void TextStyleContainer::SetShadow( bool enable, const Vector4& shadowColor, const Vector2& shadowOffset, float shadowSize ) -{ - if ( mFlags & DROP_SHADOW_EXISTS ) - { - StyleShadowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - attrPtr->mShadowColor = shadowColor; - attrPtr->mShadowOffset = shadowOffset; - attrPtr->mShadowSize = shadowSize; - } - else - { - StyleShadowAttributes* attr = new StyleShadowAttributes(); - attr->mShadowColor = shadowColor; - attr->mShadowOffset = shadowOffset; - attr->mShadowSize = shadowSize; - mFlags |= ( ( mFlags & ~DROP_SHADOW_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << DROP_SHADOW_INDEX_SHIFT ) | DROP_SHADOW_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } - - if( enable ) - { - mFlags |= DROP_SHADOW_ENABLED; - } - else - { - mFlags &= ~DROP_SHADOW_ENABLED; - } -} - -void TextStyleContainer::SetGlow( bool enable, const Vector4& glowColor, float glowIntensity ) -{ - if ( mFlags & GLOW_EXISTS ) - { - StyleGlowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - attrPtr->mGlowColor = glowColor; - attrPtr->mGlowIntensity = glowIntensity; - } - else - { - StyleGlowAttributes* attr = new StyleGlowAttributes(); - attr->mGlowColor = glowColor; - attr->mGlowIntensity = glowIntensity; - mFlags |= ( ( mFlags & ~GLOW_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << GLOW_INDEX_SHIFT ) | GLOW_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } - - if( enable ) - { - mFlags |= GLOW_ENABLED; - } - else - { - mFlags &= ~GLOW_ENABLED; - } -} - -void TextStyleContainer::SetOutline( bool enable, const Vector4& outlineColor, const Vector2& outlineThickness ) -{ - if ( mFlags & OUTLINE_EXISTS ) - { - StyleOutlineAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> OUTLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - attrPtr->mOutlineColor = outlineColor; - attrPtr->mOutlineThickness = outlineThickness; - } - else - { - StyleOutlineAttributes* attr = new StyleOutlineAttributes(); - attr->mOutlineColor = outlineColor; - attr->mOutlineThickness = outlineThickness; - mFlags |= ( ( mFlags & ~OUTLINE_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << OUTLINE_INDEX_SHIFT ) | OUTLINE_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } - - if( enable ) - { - mFlags |= OUTLINE_ENABLED; - } - else - { - mFlags &= ~OUTLINE_ENABLED; - } -} - -void TextStyleContainer::SetGradient( bool enable, const Vector4& color, const Vector2& startPoint, const Vector2& endPoint ) -{ - if ( mFlags & GRADIENT_EXISTS ) - { - StyleGradientAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - attrPtr->mColor = color; - attrPtr->mStartPoint = startPoint; - attrPtr->mEndPoint = endPoint; - } - else - { - StyleGradientAttributes* attr = new StyleGradientAttributes(); - attr->mColor = color; - attr->mStartPoint = startPoint; - attr->mEndPoint = endPoint; - mFlags |= ( ( mFlags & ~GRADIENT_INDEX ) | ( ( mParameters.Size() & PARAMETER_MASK ) << GRADIENT_INDEX_SHIFT ) | GRADIENT_EXISTS ); - mParameters.PushBack( reinterpret_cast( attr ) ); - } - - if( enable ) - { - mFlags |= GRADIENT_ENABLED; - } - else - { - mFlags &= ~GRADIENT_ENABLED; - } -} - -//----------------------------------- - -const std::string& TextStyleContainer::GetFontName() const -{ - if ( mFlags & FONT_NAME_EXISTS ) - { - const StyleCommonAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) ); - return attrPtr->mFontName; - } - else - { - return DEFAULT_NAME; - } -} - -const std::string& TextStyleContainer::GetFontStyle() const -{ - if ( mFlags & FONT_STYLE_EXISTS ) - { - const StyleCommonAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) ); - return attrPtr->mFontStyle; - } - else - { - return DEFAULT_NAME; - } -} - -PointSize TextStyleContainer::GetFontPointSize() const -{ - if ( mFlags & FONT_SIZE_EXISTS ) - { - const StyleCommonAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) ); - return attrPtr->mFontPointSize; - } - else - { - return ( static_cast( 0.f ) ); - } -} - -const Vector4& TextStyleContainer::GetTextColor() const -{ - if ( mFlags & TEXT_COLOR_EXISTS ) - { - const StyleCommonAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( mFlags & PARAMETER_MASK ) ) ); - return attrPtr->mTextColor; - } - else - { - return TextStyle::DEFAULT_TEXT_COLOR; - } -} - -TextStyle::Weight TextStyleContainer::GetWeight() const -{ - if ( mFlags & FONT_WEIGHT_EXISTS ) - { - const StyleWeightAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> WEIGHT_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - return attrPtr->mWeight; - } - else - { - return TextStyle::DEFAULT_FONT_WEIGHT; - } -} - -float TextStyleContainer::GetSmoothEdge() const -{ - if ( mFlags & SMOOTH_EDGE_EXISTS ) - { - const StyleWeightAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> WEIGHT_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - return attrPtr->mSmoothEdge; - } - else - { - return TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD; - } -} - -Degree TextStyleContainer::GetItalicsAngle() const -{ - if ( mFlags & ITALICS_EXISTS ) - { - const StyleItalicsAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() +( ( mFlags >> ITALICS_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - return attrPtr->mItalicsAngle; - } - else - { - return TextStyle::DEFAULT_ITALICS_ANGLE; - } -} - -float TextStyleContainer::GetUnderlineThickness() const -{ - if ( mFlags & UNDERLINE_EXISTS ) - { - const StyleUnderlineAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> UNDERLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - return attrPtr->mUnderlineThickness; - } - else - { - return TextStyle::DEFAULT_UNDERLINE_THICKNESS; - } -} - -float TextStyleContainer::GetUnderlinePosition() const -{ - if ( mFlags & UNDERLINE_EXISTS ) - { - const StyleUnderlineAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() +( ( mFlags >> UNDERLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - return attrPtr->mUnderlinePosition; - } - else - { - return TextStyle::DEFAULT_UNDERLINE_POSITION; - } -} - -const Vector4& TextStyleContainer::GetShadowColor() const -{ - if ( mFlags & DROP_SHADOW_EXISTS ) - { - const StyleShadowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - return attrPtr->mShadowColor; - } - else - { - return TextStyle::DEFAULT_SHADOW_COLOR; - } -} - -const Vector2& TextStyleContainer::GetShadowOffset() const -{ - if ( mFlags & DROP_SHADOW_EXISTS ) - { - const StyleShadowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - return attrPtr->mShadowOffset; - } - else - { - return TextStyle::DEFAULT_SHADOW_OFFSET; - } -} - -float TextStyleContainer::GetShadowSize() const -{ - if ( mFlags & DROP_SHADOW_EXISTS ) - { - const StyleShadowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - return attrPtr->mShadowSize; - } - else - { - return TextStyle::DEFAULT_SHADOW_SIZE; - } -} - -const Vector4& TextStyleContainer::GetGlowColor() const -{ - if ( mFlags & GLOW_EXISTS ) - { - const StyleGlowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - return attrPtr->mGlowColor; - } - else - { - return TextStyle::DEFAULT_GLOW_COLOR; - } -} - -float TextStyleContainer::GetGlowIntensity() const -{ - if ( mFlags & GLOW_EXISTS ) - { - const StyleGlowAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GLOW_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - return attrPtr->mGlowIntensity; - } - else - { - return TextStyle::DEFAULT_GLOW_INTENSITY; - } -} - -const Vector2& TextStyleContainer::GetOutlineThickness() const -{ - if ( mFlags & OUTLINE_EXISTS ) - { - const StyleOutlineAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> OUTLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - return attrPtr->mOutlineThickness; - } - else - { - return TextStyle::DEFAULT_OUTLINE_THICKNESS; - } -} - -const Vector4& TextStyleContainer::GetOutlineColor() const -{ - if ( mFlags & OUTLINE_EXISTS ) - { - const StyleOutlineAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> OUTLINE_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - return attrPtr->mOutlineColor; - } - else - { - return TextStyle::DEFAULT_OUTLINE_COLOR; - } -} - -const Vector4& TextStyleContainer::GetGradientColor() const -{ - if ( mFlags & GRADIENT_EXISTS ) - { - const StyleGradientAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - return attrPtr->mColor; - } - else - { - return TextStyle::DEFAULT_GRADIENT_COLOR; - } -} - -const Vector2& TextStyleContainer::GetGradientStartPoint() const -{ - if ( mFlags & GRADIENT_EXISTS ) - { - const StyleGradientAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - return attrPtr->mStartPoint; - } - else - { - return TextStyle::DEFAULT_GRADIENT_START_POINT; - } -} - -const Vector2& TextStyleContainer::GetGradientEndPoint() const -{ - if ( mFlags & GRADIENT_EXISTS ) - { - const StyleGradientAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + ( ( mFlags >> GRADIENT_INDEX_SHIFT ) & PARAMETER_MASK ) ) ); - return attrPtr->mEndPoint; - } - else - { - return TextStyle::DEFAULT_GRADIENT_END_POINT; - } -} - -void TextStyleContainer::UpdateIndex( std::size_t index ) -{ - // If a style parameter is reset to default, the value is removed from the vector. - // To remove a value (pointed by index) from the vector, it's swapped with the - // value of the last position. The index in the mFlag needs to be swapped as well. - - // Find where in the flag is pointing to the last position of the vector - - const std::size_t lastIndex = mParameters.Size() - 1u; - bool found = false; - - for( uint64_t flagIndex = mFlags, mask = PARAMETER_MASK; !found; flagIndex = flagIndex >> PARAMETER_BITS, mask = mask << PARAMETER_BITS, index = index << PARAMETER_BITS ) - { - if( ( flagIndex & PARAMETER_MASK ) == lastIndex ) - { - mFlags &= ~mask; - mFlags |= index; - found = true; - } - } -} - -void TextStyleContainer::ResetFontName() -{ - if( !( mFlags & FONT_NAME_EXISTS ) ) - { - // nothing to do if the font name is not set. - return; - } - - const std::size_t fontNameIndex = mFlags & PARAMETER_MASK; - - // Check whether the other parameters stored in the same index are default. - if( ( mFlags & FONT_STYLE_EXISTS ) || - ( mFlags & FONT_SIZE_EXISTS ) || - ( mFlags & TEXT_COLOR_EXISTS ) ) - { - // Style, size or color exist, so just set the default font name (""). - StyleCommonAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + fontNameIndex ) ); - attrPtr->mFontName = DEFAULT_NAME; - } - else - { - if( fontNameIndex < mParameters.Size() - 1u ) - { - // The index of the moved value needs to be updated. - UpdateIndex( fontNameIndex ); - } - - // Reset the common index. - mFlags &= ~PARAMETER_MASK; - - Vector::Iterator index = mParameters.Begin() + fontNameIndex; - char* toDelete = *index; - - // Swaps the index to be removed with the last one and removes it. - mParameters.Remove( index ); - - delete reinterpret_cast( toDelete ); - } - - // Reset the FONT_NAME_EXISTS flag - mFlags &= ~FONT_NAME_EXISTS; -} - -void TextStyleContainer::ResetFontStyle() -{ - if( !( mFlags & FONT_STYLE_EXISTS ) ) - { - // nothing to do if the font style is not set. - return; - } - - const std::size_t fontStyleIndex = mFlags & PARAMETER_MASK; - - // Check whether the other parameters stored in the same index are default. - if( ( mFlags & FONT_NAME_EXISTS ) || - ( mFlags & FONT_SIZE_EXISTS ) || - ( mFlags & TEXT_COLOR_EXISTS ) ) - { - // Name, size or color exist, so just set the default font style ("") and reset the FONT_STYLE_EXISTS flag. - StyleCommonAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + fontStyleIndex ) ); - attrPtr->mFontStyle = DEFAULT_NAME; - } - else - { - if( fontStyleIndex < mParameters.Size() - 1u ) - { - // The index of the moved value needs to be updated. - UpdateIndex( fontStyleIndex ); - } - - // Reset the common index. - mFlags &= ~PARAMETER_MASK; - - Vector::Iterator index = mParameters.Begin() + fontStyleIndex; - char* toDelete = *index; - - // Swaps the index to be removed with the last one and removes it. - mParameters.Remove( index ); - - delete reinterpret_cast( toDelete ); - } - - // Reset the FONT_STYLE_EXISTS flag - mFlags &= ~FONT_STYLE_EXISTS; -} - -void TextStyleContainer::ResetFontSize() -{ - if( !( mFlags & FONT_SIZE_EXISTS ) ) - { - // nothing to do if the font size is not set. - return; - } - - const std::size_t fontSizeIndex = mFlags & PARAMETER_MASK; - - // Check whether the other parameters stored in the same index are default. - if( ( mFlags & FONT_NAME_EXISTS ) || - ( mFlags & FONT_STYLE_EXISTS ) || - ( mFlags & TEXT_COLOR_EXISTS ) ) - { - // Name, style or color exist, so just set the default font size (0.0) and reset the FONT_SIZE_EXISTS flag. - StyleCommonAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + fontSizeIndex ) ); - attrPtr->mFontPointSize = DEFAULT_FONT_POINT_SIZE; - } - else - { - if( fontSizeIndex < mParameters.Size() - 1u ) - { - // The index of the moved value needs to be updated. - UpdateIndex( fontSizeIndex ); - } - - // Reset the common index. - mFlags &= ~PARAMETER_MASK; - - Vector::Iterator index = mParameters.Begin() + fontSizeIndex; - char* toDelete = *index; - - // Swaps the index to be removed with the last one and removes it. - mParameters.Remove( index ); - - delete reinterpret_cast( toDelete ); - } - - // Reset the FONT_SIZE_EXISTS flag - mFlags &= ~FONT_SIZE_EXISTS; -} - -void TextStyleContainer::ResetTextColor() -{ - if( !( mFlags & TEXT_COLOR_EXISTS ) ) - { - // nothing to do if the text color is not set. - return; - } - - const std::size_t textColorIndex = mFlags & PARAMETER_MASK; - - // Check whether the other parameters stored in the same index are default. - if( ( mFlags & FONT_NAME_EXISTS ) || - ( mFlags & FONT_STYLE_EXISTS ) || - ( mFlags & FONT_SIZE_EXISTS ) ) - { - // Name, style or size exist, so just set the default color (WHITE) and reset the TEXT_COLOR_EXISTS flag. - StyleCommonAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + textColorIndex ) ); - attrPtr->mTextColor = TextStyle::DEFAULT_TEXT_COLOR; - } - else - { - if( textColorIndex < mParameters.Size() - 1u ) - { - // The index of the moved value needs to be updated. - UpdateIndex( textColorIndex ); - } - - // Reset the common index. - mFlags &= ~PARAMETER_MASK; - - Vector::Iterator index = mParameters.Begin() + textColorIndex; - char* toDelete = *index; - - // Swaps the index to be removed with the last one and removes it. - mParameters.Remove( index ); - - delete reinterpret_cast( toDelete ); - } - - // Reset the TEXT_COLOR_EXISTS flag - mFlags &= ~TEXT_COLOR_EXISTS; -} - -void TextStyleContainer::ResetFontWeight() -{ - if( !( mFlags & FONT_WEIGHT_EXISTS ) ) - { - // nothing to do if the font weight is not set. - return; - } - - const std::size_t fontWeightIndex = ( mFlags >> WEIGHT_INDEX_SHIFT ) & PARAMETER_MASK; - - // Check whether the smooth edge exists - if( mFlags & SMOOTH_EDGE_EXISTS ) - { - StyleWeightAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + fontWeightIndex ) ); - attrPtr->mWeight = TextStyle::DEFAULT_FONT_WEIGHT; - } - else - { - if( fontWeightIndex < mParameters.Size() - 1u ) - { - // The index of the moved value needs to be updated. - UpdateIndex( fontWeightIndex ); - } - - // Reset the font weight index. - const uint64_t weightMask = PARAMETER_MASK << WEIGHT_INDEX_SHIFT; - mFlags &= ~weightMask; - - Vector::Iterator index = mParameters.Begin() + fontWeightIndex; - char* toDelete = *index; - - // Swaps the index to be removed with the last one and removes it. - mParameters.Remove( index ); - - delete reinterpret_cast( toDelete ); - } - - // Reset the FONT_WEIGHT_EXISTS flag - mFlags &= ~FONT_WEIGHT_EXISTS; -} - -void TextStyleContainer::ResetSmoothEdge() -{ - if( !( mFlags & SMOOTH_EDGE_EXISTS ) ) - { - // nothing to do if the smooth edge is not set. - return; - } - - const std::size_t smoothEdgeIndex = ( mFlags >> WEIGHT_INDEX_SHIFT ) & PARAMETER_MASK; - - // Check whether the weight exists - if( mFlags & FONT_WEIGHT_EXISTS ) - { - StyleWeightAttributes* attrPtr = reinterpret_cast( *( mParameters.Begin() + smoothEdgeIndex ) ); - attrPtr->mSmoothEdge = TextStyle::DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD; - } - else - { - if( smoothEdgeIndex < mParameters.Size() - 1u ) - { - // The index of the moved value needs to be updated. - UpdateIndex( smoothEdgeIndex ); - } - - // Reset the font weight index. (The smooth edge is stored with the weight) - const uint64_t weightMask = PARAMETER_MASK << WEIGHT_INDEX_SHIFT; - mFlags &= ~weightMask; - - Vector::Iterator index = mParameters.Begin() + smoothEdgeIndex; - char* toDelete = *index; - - // Swaps the index to be removed with the last one and removes it. - mParameters.Remove( index ); - - delete reinterpret_cast( toDelete ); - } - - // Reset the SMOOTH_EDGE_EXISTS flag - mFlags &= ~SMOOTH_EDGE_EXISTS; -} - -void TextStyleContainer::ResetItalics() -{ - if( !( mFlags & ITALICS_EXISTS ) ) - { - // nothing to do if the italics is not set. - return; - } - - const std::size_t italicIndex = ( mFlags >> ITALICS_INDEX_SHIFT ) & PARAMETER_MASK; - - if( italicIndex < mParameters.Size() - 1u ) - { - // The index of the moved value needs to be updated. - UpdateIndex( italicIndex ); - } - - // Reset the italics index, the ITALICS_EXISTS and the ITALICS_ENABLED flags. - const uint64_t italicsMask = PARAMETER_MASK << ITALICS_INDEX_SHIFT; - mFlags &= ~( italicsMask | ITALICS_EXISTS | ITALICS_ENABLED ); - - Vector::Iterator index = mParameters.Begin() + italicIndex; - char* toDelete = *index; - - // Swaps the index to be removed with the last one and removes it. - mParameters.Remove( index ); - - delete reinterpret_cast( toDelete ); -} - -void TextStyleContainer::ResetUnderline() -{ - if( !( mFlags & UNDERLINE_EXISTS ) ) - { - // nothing to do if the underline is not set. - return; - } - - const std::size_t underlineIndex = ( mFlags >> UNDERLINE_INDEX_SHIFT ) & PARAMETER_MASK; - - if( underlineIndex < mParameters.Size() - 1u ) - { - // The index of the moved value needs to be updated. - UpdateIndex( underlineIndex ); - } - - // Reset the underline index and the UNDERLINE_EXISTS and the UNDERLINE_ENABLED flags. - const uint64_t underlineMask = PARAMETER_MASK << UNDERLINE_INDEX_SHIFT; - mFlags &= ~( underlineMask | UNDERLINE_EXISTS | UNDERLINE_ENABLED ); - - Vector::Iterator index = mParameters.Begin() + underlineIndex; - char* toDelete = *index; - - // Swaps the index to be removed with the last one and removes it. - mParameters.Remove( index ); - - delete reinterpret_cast( toDelete ); -} - -void TextStyleContainer::ResetShadow() -{ - if( !( mFlags & DROP_SHADOW_EXISTS ) ) - { - // nothing to do if the shadow is not set. - return; - } - - const std::size_t shadowIndex = ( mFlags >> DROP_SHADOW_INDEX_SHIFT ) & PARAMETER_MASK; - - if( shadowIndex < mParameters.Size() - 1u ) - { - // The index of the moved value needs to be updated. - UpdateIndex( shadowIndex ); - } - - // Reset the shadow index and the DROP_SHADOW_EXISTS and the DROP_SHADOW_ENABLED flags. - const uint64_t shadowMask = PARAMETER_MASK << DROP_SHADOW_INDEX_SHIFT; - mFlags &= ~( shadowMask | DROP_SHADOW_EXISTS | DROP_SHADOW_ENABLED ); - - Vector::Iterator index = mParameters.Begin() + shadowIndex; - char* toDelete = *index; - - // Swaps the index to be removed with the last one and removes it. - mParameters.Remove( index ); - - delete reinterpret_cast( toDelete ); -} - -void TextStyleContainer::ResetGlow() -{ - if( !( mFlags & GLOW_EXISTS ) ) - { - // nothing to do if the glow is not set. - return; - } - - const std::size_t glowIndex = ( mFlags >> GLOW_INDEX_SHIFT ) & PARAMETER_MASK; - - if( glowIndex < mParameters.Size() - 1u ) - { - // The index of the moved value needs to be updated. - UpdateIndex( glowIndex ); - } - - // Reset the glow index and the GLOW_EXISTS and the GLOW_ENABLED flags. - const uint64_t glowMask = PARAMETER_MASK << GLOW_INDEX_SHIFT; - mFlags &= ~( glowMask | GLOW_EXISTS | GLOW_ENABLED ); - - Vector::Iterator index = mParameters.Begin() + glowIndex; - char* toDelete = *index; - - // Swaps the index to be removed with the last one and removes it. - mParameters.Remove( index ); - - delete reinterpret_cast( toDelete ); -} - -void TextStyleContainer::ResetOutline() -{ - if( !( mFlags & OUTLINE_EXISTS ) ) - { - // nothing to do if the outline is not set. - return; - } - - const std::size_t outlineIndex = ( mFlags >> OUTLINE_INDEX_SHIFT ) & PARAMETER_MASK; - - if( outlineIndex < mParameters.Size() - 1u ) - { - // The index of the moved value needs to be updated. - UpdateIndex( outlineIndex ); - } - - // Reset the outline index and the OUTLINE_EXISTS and the OUTLINE_ENABLED flags. - const uint64_t outlineMask = PARAMETER_MASK << OUTLINE_INDEX_SHIFT; - mFlags &= ~( outlineMask | OUTLINE_EXISTS | OUTLINE_ENABLED ); - - Vector::Iterator index = mParameters.Begin() + outlineIndex; - char* toDelete = *index; - - // Swaps the index to be removed with the last one and removes it. - mParameters.Remove( index ); - - delete reinterpret_cast( toDelete ); -} - -void TextStyleContainer::ResetGradient() -{ - if( !( mFlags & GRADIENT_EXISTS ) ) - { - // nothing to do if the gradient is not set. - return; - } - - const std::size_t gradientIndex = ( mFlags >> GRADIENT_INDEX_SHIFT ) & PARAMETER_MASK; - - if( gradientIndex < mParameters.Size() - 1u ) - { - // The index of the moved value needs to be updated. - UpdateIndex( gradientIndex ); - } - - // Reset the gradient index and the GRADIENT_EXISTS and the GRADIENT_ENABLED flags. - const uint64_t gradientMask = PARAMETER_MASK << GRADIENT_INDEX_SHIFT; - mFlags &= ~( gradientMask | GRADIENT_EXISTS | GRADIENT_ENABLED ); - - Vector::Iterator index = mParameters.Begin() + gradientIndex; - char* toDelete = *index; - - // Swaps the index to be removed with the last one and removes it. - mParameters.Remove( index ); - - delete reinterpret_cast( toDelete ); -} - -} // namespace Dali diff --git a/dali/public-api/text/text-style.h b/dali/public-api/text/text-style.h deleted file mode 100644 index b6ff62e..0000000 --- a/dali/public-api/text/text-style.h +++ /dev/null @@ -1,523 +0,0 @@ -#ifndef __DALI_TEXT_STYLE_H__ -#define __DALI_TEXT_STYLE_H__ - -/* - * Copyright (c) 2014 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 - -// INTERNAL INCLUDES -#include - -namespace Dali -{ -class TextStyleContainer; - -/** - * @brief Encapsulates style properties for text, such as weight, italics, underline, shadow, etc. - */ -class DALI_IMPORT_API TextStyle -{ -public: - /** - * @brief Mask used to set text styles. - */ - enum Mask - { - NONE = 0, ///< No parameter set. - FONT = 1 << 0, ///< Sets the given font family. - STYLE = 1 << 1, ///< Sets the given font style. - SIZE = 1 << 2, ///< Sets the given font point size. - COLOR = 1 << 3, ///< Sets the given text color. - WEIGHT = 1 << 4, ///< Sets the given font weight and smooth edge. - SMOOTH = 1 << 5, ///< Sets the smooth edge. - ITALICS = 1 << 6, ///< Sets italics. - UNDERLINE = 1 << 7, ///< Sets underline. - SHADOW = 1 << 8, ///< Sets shadow. - GLOW = 1 << 9, ///< Sets glow. - OUTLINE = 1 << 10, ///< Sets outline - GRADIENT = 1 << 11, ///< Sets gradient parameters. - ALL = -1 ///< Sets all given style parameters. - }; - - /** - * @brief Enumeration of various text weights. - */ - enum Weight - { - THIN = 0, - EXTRALIGHT, - LIGHT, - BOOK, - REGULAR, - MEDIUM, - DEMIBOLD, - BOLD, - EXTRABOLD, - BLACK, - EXTRABLACK - }; - -public: - static const Vector4 DEFAULT_TEXT_COLOR; ///< Default color for the text (white) - static const Weight DEFAULT_FONT_WEIGHT; ///< Default weight for the text (regular) - static const float DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD; ///< Default distance field used for edge smooth. @see SetSmoothEdge() - static const Degree DEFAULT_ITALICS_ANGLE; ///< Default angle used for text italics. @see SetItalics() - static const float DEFAULT_UNDERLINE_THICKNESS; ///< Default underline's thickness. - static const float DEFAULT_UNDERLINE_POSITION; ///< Default underline's position. - static const Vector4 DEFAULT_SHADOW_COLOR; ///< Default color for the shadow (black) - static const Vector2 DEFAULT_SHADOW_OFFSET; ///< Default offset used for text shadow. @see SetShadow() - static const float DEFAULT_SHADOW_SIZE; ///< Default size of text shadow. @see SetShadow() - static const Vector4 DEFAULT_GLOW_COLOR; ///< Default color for the glow (white) - static const float DEFAULT_GLOW_INTENSITY; ///< Default intensity used for text glow. @see SetGlow() - static const Vector4 DEFAULT_OUTLINE_COLOR; ///< Default color for the outline (white) - static const Vector2 DEFAULT_OUTLINE_THICKNESS; ///< Default thickness used for text outline. @see SetOutline() - static const Vector4 DEFAULT_GRADIENT_COLOR; ///< Default gradient color - static const Vector2 DEFAULT_GRADIENT_START_POINT; ///< Default gradient start point - static const Vector2 DEFAULT_GRADIENT_END_POINT; ///< Default gradient end point - -public: - - /** - * @brief Default constructor. - * - * The style created used a default font @see Dali::Font, color is white, and is neither underlined nor italics. - * Shadow, glow, outline and gradient are not enabled. - */ - TextStyle(); - - /** - * @brief Destructor. - */ - ~TextStyle(); - - /** - * @brief Copy constructor. - * - * @param[in] textStyle The text style to be copied. - */ - TextStyle( const TextStyle& textStyle ); - - /** - * @brief Assignment operator. - * - * @param[in] textStyle The text style to be assigned. - * @return A reference to this - */ - TextStyle& operator=( const TextStyle& textStyle ); - - /** - * @brief Equality operator. - * - * @param [in] textStyle The text style to be compared. - * @return true if the style is identical - */ - bool operator==( const TextStyle& textStyle ) const; - - /** - * @brief Inequality operator. - * - * @param [in] textStyle The text style to be compared. - * @return true if the text style is not identical - */ - bool operator!=( const TextStyle& textStyle ) const; - - /** - * @brief Copies from the given text style those parameters specified in the given mask. - * - * @param[in] textStyle The given text style. - * @param[in] mask Specifies which text style parameters are going to be copied. By default all parateres are copied. - */ - void Copy( const TextStyle& textStyle, Mask mask = ALL ); - - /** - * @brief Copies from the given text style those parameters specified in the given mask which are not default. - * - * @param[in] textStyle The given text style. - * @param[in] mask Specifies which text style parameters are going to be copied. By default all parateres are copied. - */ - void Merge( const TextStyle& textStyle, Mask mask = ALL ); - - /** - * @brief Resets to default the text style parameters specified in the mask. - * - * @param[in] mask Specifies which text style parameters are going to be reset. By default all parateres are reset. - */ - void Reset( Mask mask = ALL ); - - /** - * @brief Retrieves the font name. - * - * @return The font family name. - */ - const std::string& GetFontName() const; - - /** - * @brief Sets the font name. - * - * @param[in] fontName The font family name. - */ - void SetFontName( const std::string& fontName ); - - /** - * @brief Retrieves the font style. - * - * @return The font style. - */ - const std::string& GetFontStyle() const; - - /** - * @brief Sets the font style. - * - * @param[in] fontStyle - */ - void SetFontStyle( const std::string& fontStyle ); - - /** - * @brief Retrieves the font point size. - * - * @return the point size. - */ - PointSize GetFontPointSize() const; - - /** - * @brief Sets the font point size. - * - * @param[in] fontPointSize The font point size. - */ - void SetFontPointSize( PointSize fontPointSize ); - - /** - * @brief Retrieves the text color. - * - * @return The text color. - */ - const Vector4& GetTextColor() const; - - /** - * @brief Sets the text color. - * - * @param[in] textColor The text color - */ - void SetTextColor( const Vector4& textColor ); - - /** - * @brief Retrieves the font weight. - * - * @return The font weight. - */ - Weight GetWeight() const; - - /** - * @brief Sets the font weight. - * - * @param[in] weight The font weight - */ - void SetWeight( Weight weight ); - - /** - * @brief Retrieves the soft smooth edge. - * - * @return The soft smooth edge. - */ - float GetSmoothEdge() const; - - /** - * @brief Set soft edge smoothing. - * - * @param[in] smoothEdge Specify the distance field value for the center of the text edge. - * 0 <= smoothEdge <= 1 - */ - void SetSmoothEdge( float smoothEdge = DEFAULT_SMOOTH_EDGE_DISTANCE_FIELD ); - - /** - * @brief Whether the italics is enabled. - * - * @return \e true if italics is enabled, otherwise \e false. - */ - bool IsItalicsEnabled() const; - - /** - * @brief Retrieves the italics angle. - * - * @return \e The italics angle in degree. - */ - Degree GetItalicsAngle() const; - - /** - * @brief Enables or disables the italics. - * - * It sets the italics angle in degree. By default DEFAULT_ITALICS_ANGLE. - * - * @param[in] enable \e true enables the italics. - * @param[in] angle The italics angle in degree. - */ - void SetItalics( bool enable, Degree angle = DEFAULT_ITALICS_ANGLE ); - - /** - * @brief Whether text underline is enabled. - * - * @return \e true if underline is enabled, otherwise \e false. - */ - bool IsUnderlineEnabled() const; - - /** - * @brief Retrieves the underline thickness. - * - * @return The underline thickness. - */ - float GetUnderlineThickness() const; - - /** - * @brief Retrieves the underline position. - * - * @return The underline position. - */ - float GetUnderlinePosition() const; - - /** - * @brief Enables or disables the text underline. - * - * It used DEFAULT_UNDERLINE_THICKNESS as default thickness and DEFAULT_UNDERLINE_POSITION as default position. - * - * @param[in] enable \e true enables the text underline. - * @param[in] thickness The underline thickness. - * @param[in] position The underline position. - */ - void SetUnderline( bool enable, float thickness = DEFAULT_UNDERLINE_THICKNESS, float position = DEFAULT_UNDERLINE_POSITION ); - - /** - * @brief Whether the text shadow is enabled. - * - * @return \e true if shadow is enabled, otherwise \e false. - */ - bool IsShadowEnabled() const; - - /** - * @brief Retrieves the shadow color. - * - * @return The shadow color. - */ - const Vector4& GetShadowColor() const; - - /** - * @brief Retrieves the shadow offset - * @return The shadow offset. - */ - const Vector2& GetShadowOffset() const; - - /** - * @brief Retrieves the shadow size - * @return The shadow size. - */ - float GetShadowSize() const; - - /** - * @brief Enables or disables the text shadow. - * - * @param[in] enable \e true enables the text shadow. - * @param[in] shadowColor The color of the shadow - * @param[in] shadowOffset Offset in pixels. - * @param[in] shadowSize Size of shadow in pixels. 0 means the shadow is the same size as the text. - */ - void SetShadow( bool enable, - const Vector4& shadowColor = DEFAULT_SHADOW_COLOR, - const Vector2& shadowOffset = DEFAULT_SHADOW_OFFSET, - float shadowSize = DEFAULT_SHADOW_SIZE ); - - /** - * @brief Whether the text glow is enabled. - * - * @return \e true if glow is enabled, otherwise \e false. - */ - bool IsGlowEnabled() const; - - /** - * @brief Retrieves the glow color. - * - * @return The glow color. - */ - const Vector4& GetGlowColor() const; - - /** - * @brief Retrieve the glow intensity. - * - * @return The glow intensity. - */ - float GetGlowIntensity() const; - - /** - * @brief Enables or disables the text glow. - * - * @param[in] enable \e true enables the text glow. - * @param[in] glowColor The color of the glow. - * @param[in] glowIntensity Determines the amount of glow around text. - * The edge of the text is at the value set with smoothEdge. - * SetSmoothEdge() The distance field value at which the glow becomes fully transparent. - */ - void SetGlow( bool enable, const Vector4& glowColor = DEFAULT_GLOW_COLOR, float glowIntensity = DEFAULT_GLOW_INTENSITY ); - - /** - * @brief Whether the text outline is enabled. - * - * @return \e true if outline is enabled, otherwise \e false. - */ - bool IsOutlineEnabled() const; - - /** - * @brief Retrieves the outline color. - * - * @return The outline color. - */ - const Vector4& GetOutlineColor() const; - - /** - * @brief Retrieves the outline thickness. - * - * @return The outline thickness. - */ - const Vector2& GetOutlineThickness() const; - - /** - * @brief Enables or disables the text outline. - * - * @param[in] enable \e true enables the text outline. - * @param[in] outlineColor The color of the outline. - * @param[in] outlineThickness Thickness of outline. The outline thickness is determined by two parameters. - * outlineThickness[0] Specifies the distance field value for the center of the outline. - * outlineThickness[1] Specifies the softness/width/anti-aliasing of the outlines inner edge. - * SetSmoothEdge() specifies the smoothness/anti-aliasing of the text outer edge. - * 0 <= smoothEdge[0] <= 1. - * 0 <= smoothEdge[1] <= 1. - */ - void SetOutline( bool enable, const Vector4& outlineColor = DEFAULT_OUTLINE_COLOR, const Vector2& outlineThickness = DEFAULT_OUTLINE_THICKNESS ); - - /** - * @brief Whether the text gradient is enabled. - * - * @return \e true if gradient is enabled, otherwise \e false. - */ - bool IsGradientEnabled() const; - - /** - * @brief Retrieves the gradient color. - * - * @return The gradient color. - */ - const Vector4& GetGradientColor() const; - - /** - * @brief Retrieves the gradient start point. - * - * @return The gradient start point. - */ - const Vector2& GetGradientStartPoint() const; - - /** - * @brief Retrieves the gradient end point. - * - * @return The gradient end point. - */ - const Vector2& GetGradientEndPoint() const; - - /** - * @brief Enables or disables the text gradient. - * - * @param[in] enable \e true enables the text gradient. - * @param[in] color The gradient color. - * @param[in] startPoint The start point. - * @param[in] endPoint The end point. - */ - void SetGradient( bool enable, - const Vector4& color = DEFAULT_GRADIENT_COLOR, - const Vector2& startPoint = DEFAULT_GRADIENT_START_POINT, - const Vector2& endPoint = DEFAULT_GRADIENT_END_POINT ); - - /** - * @brief Whether the font name is the default. - */ - bool IsFontNameDefault() const; - - /** - * @brief Whether the font style is the default. - */ - bool IsFontStyleDefault() const; - - /** - * @brief Whether the font size is the default. - */ - bool IsFontSizeDefault() const; - - /** - * @brief Whether the text color is the default. - */ - bool IsTextColorDefault() const; - - /** - * @brief Whether the font weight is the default. - */ - bool IsFontWeightDefault() const; - - /** - * @brief Whether the smooth edge is the default. - */ - bool IsSmoothEdgeDefault() const; - - /** - * @brief Whether the italic is the default. - */ - bool IsItalicsDefault() const; - - /** - * @brief Whether the underline is the default. - */ - bool IsUnderlineDefault() const; - - /** - * @brief Whether the shadow is the default. - */ - bool IsShadowDefault() const; - - /** - * @brief Whether the glow is the default. - */ - bool IsGlowDefault() const; - - /** - * @brief Whether the outline is the default. - */ - bool IsOutlineDefault() const; - - /** - * @brief Whether the gradient is the default. - */ - bool IsGradientDefault() const; - -private: - - /** - * @brief Create a container, when the text-style needs any attributes - */ - void CreateContainerJustInTime(); - TextStyleContainer* mContainer; // container for any needed text style structures - -}; - -} // namespace Dali - -#endif // __DALI_TEXT_STYLE_H__ diff --git a/dali/public-api/text/text.cpp b/dali/public-api/text/text.cpp deleted file mode 100644 index a10e68e..0000000 --- a/dali/public-api/text/text.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// HEADER CLASS -#include - -// INTERNAL INCLUDES -#include -#include -#include - -namespace Dali -{ - -Text::Text() -: mImpl( NULL ) -{ -} - -Text::Text( const char* text ) -: mImpl( ( NULL == text ) ? NULL : new Internal::Text( std::string( text ) ) ) -{ -} - -Text::Text( const std::string& text ) -: mImpl( text.empty() ? NULL : new Internal::Text( text ) ) -{ -} - -Text::Text( const Character& character ) -: mImpl( new Internal::Text( character.GetImplementation() ) ) -{ -} - -Text::Text( const Text& text ) -: mImpl( text.IsEmpty() ? NULL : new Internal::Text( *text.mImpl ) ) -{ -} - -Text& Text::operator=( const Text& text ) -{ - if( &text != this ) - { - if( text.IsEmpty() ) - { - delete mImpl; - mImpl = NULL; - } - else - { - if( NULL == mImpl ) - { - mImpl = new Internal::Text( *text.mImpl ); - } - else - { - *mImpl = *text.mImpl; - } - } - } - - return *this; -} - -Text::~Text() -{ - delete mImpl; -} - -std::string Text::GetText() const -{ - std::string text; - - if( NULL != mImpl ) - { - mImpl->GetText( text ); - } - - return text; -} - -void Text::SetText( const Text& text ) -{ - if( !text.IsEmpty() ) - { - if( NULL == mImpl ) - { - mImpl = new Internal::Text( *text.mImpl ); - } - else - { - *mImpl = *text.mImpl; - } - } - else - { - delete mImpl; - mImpl = NULL; - } -} - -Character Text::operator[]( size_t position ) const -{ - DALI_ASSERT_ALWAYS( NULL != mImpl && "Text::operator[]: Text is uninitialized" ); - - return (*mImpl)[ position ]; -} - -bool Text::IsEmpty() const -{ - bool empty = true; - - if( NULL != mImpl ) - { - empty = mImpl->IsEmpty(); - } - - return empty; -} - -size_t Text::GetLength() const -{ - size_t length = 0; - - if( NULL != mImpl ) - { - length = mImpl->GetLength(); - } - - return length; -} - -void Text::Append( const Text& text ) -{ - if( NULL != text.mImpl ) - { - if( NULL == mImpl ) - { - mImpl = new Internal::Text( *text.mImpl ); - } - else - { - mImpl->Append( text ); - } - } -} - -void Text::Remove( size_t position, size_t numberOfCharacters ) -{ - DALI_ASSERT_ALWAYS( NULL != mImpl && "Text::Remove: Text is uninitialized" ); - - if( 0u == numberOfCharacters ) - { - // nothing to remove. - return; - } - - if( ( 0u == position ) && ( mImpl->GetLength() == numberOfCharacters ) ) - { - // If all characters are removed, delete the internal implementation. - delete mImpl; - mImpl = NULL; - } - else - { - mImpl->Remove( position, numberOfCharacters ); - } -} - -void Text::Find( const Character& character, std::size_t from, std::size_t to, Vector& positions ) const -{ - if( NULL == mImpl ) - { - // nothing to find if the text is not initialized. - return; - } - - mImpl->Find( character.GetImplementation().GetCharacter(), from, to, positions ); -} - -void Text::Find( SpecialCharacter character, std::size_t from, std::size_t to, Vector& positions ) const -{ - // @note There is a different method to find a white space because it is a range of values. - - if( NULL == mImpl ) - { - // nothing to find if the text is not initialized. - return; - } - - switch( character ) - { - case WHITE_SPACE: - { - mImpl->FindWhiteSpace( from, to, positions ); - break; - } - case NEW_LINE: - { - mImpl->FindNewLine( from, to, positions ); - break; - } - } -} - -void Text::GetSubText( std::size_t from, std::size_t to, Text& subText ) const -{ - if( NULL == mImpl ) - { - // nothing to do if the text is not initialized. - return; - } - - const std::size_t length = mImpl->GetLength(); - - if( ( from >= length ) || ( to >= length ) ) - { - // out of bounds access. - return; - } - - // Create an internal implementation if there isn't one. - if( NULL == subText.mImpl ) - { - subText.mImpl = new Internal::Text(); - } - else - { - subText.mImpl->Clear(); - } - - mImpl->GetSubText( from, to, subText.mImpl ); -} - -bool Text::IsWhiteSpace( std::size_t index ) const -{ - if( NULL == mImpl ) - { - // not a white space if the text is not initialized. - return false; - } - - return mImpl->IsWhiteSpace( index ); -} - -bool Text::IsNewLine( std::size_t index ) const -{ - if( NULL == mImpl ) - { - // not a new line if the text is not initialized. - return false; - } - - return mImpl->IsNewLine( index ); -} - -// Note: Theese two methods are needed to retrieve the internal implementation. -// As this class is pimpled but is not inheriting from BaseHandle, a method is needed in the public API. - -const Internal::Text& Text::GetImplementation() const -{ - DALI_ASSERT_ALWAYS( NULL != mImpl && "Text::GetImplementation: Text is uninitialized" ); - - return *mImpl; -} - -Internal::Text& Text::GetImplementation() -{ - DALI_ASSERT_ALWAYS( NULL != mImpl && "Text::GetImplementation: Text is uninitialized" ); - - return *mImpl; -} - -} // namespace Dali diff --git a/dali/public-api/text/text.h b/dali/public-api/text/text.h deleted file mode 100644 index 32490bf..0000000 --- a/dali/public-api/text/text.h +++ /dev/null @@ -1,237 +0,0 @@ -#ifndef __DALI_TEXT_H__ -#define __DALI_TEXT_H__ - -/* - * Copyright (c) 2014 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 - -// INTERNAL INCLUDES -#include -#include -#include - -namespace Dali -{ - -namespace Internal DALI_INTERNAL -{ - class Text; -} - -/** - * @brief Encapsulates a string of characters implementation to support multiple languages. - */ -class DALI_IMPORT_API Text -{ - -public: - - /** - * @brief Enums special characters used to find their positions inside the text. - */ - enum SpecialCharacter - { - WHITE_SPACE, - NEW_LINE - }; - -public: - - /** - * @brief Default constructor. - * - * It creates an empty Text. - */ - Text(); - - /** - * @brief Constructor. - * - * Creates a Text object with the given string. - * @param [in] text An ASCII or UTF-8 encoded array. - */ - Text( const char* text ); - - /** - * @copydoc Text( const char* text ) - */ - Text( const std::string& text ); - - /** - * @brief Constructor. - * - * Creates a Text object with the given character. - * @param [in] character The character. - */ - Text( const Character& character ); - - /** - * @brief Copy Constructor. - * - * @param [in] text Text to be copied. - */ - Text( const Text& text ); - - /** - * @brief Assignment operator. - * - * @param [in] text Text to be assigned. - * @return A reference to this - */ - Text& operator=( const Text& text ); - - /** - * @brief Non-virtual destructor. - * - */ - ~Text(); - - /** - * @brief Retrieves the stored text. - * - * @return An std::string with the stored text. - */ - std::string GetText() const; - - /** - * @brief Sets the given text. - * - * @param [in] text The text to be set. - */ - void SetText( const Text& text ); - - /** - * @brief Retrieves the character stored in the given position. - * - * @pre The given \e position must be a positive value less than the total length of the text. - * @param [in] position The character position. - * @return The character - */ - Character operator[]( size_t position ) const; - - /** - * @brief Whether the text is empty or not. - * - * @return \e true if the text is empty. - */ - bool IsEmpty() const; - - /** - * @brief Retrieves the number of characters. - * - * @return the number of characters. - */ - size_t GetLength() const; - - /** - * @brief Appends the given text. - * - * @param [in] text The text to be appended. - */ - void Append( const Text& text ); - - /** - * @brief Removes a number of characters starting from a given position. - * - * @pre The given \e position plus \e numberOfCharacters must be a positive value less or equal than the total length of the text. - * @param[in] position The position from where characters are going to be removed. - * @param[in] numberOfCharacters The number of characters to remove. - */ - void Remove( size_t position, size_t numberOfCharacters ); - - /** - * @brief Finds all the positions of the given \e character within the \e from, \e to range. - * - * @param[in] character The character to find. - * @param[in] from First position of the range. - * @param[in] to Last position of the range. - * @param[out] positions Contains all the positions of \e character within the \e from, \e to range. - */ - void Find( const Character& character, std::size_t from, std::size_t to, Vector& positions ) const; - - /** - * @brief Finds all the positions of either white space or new line character within the \e from, \e to range. - * - * @param[in] character One of white space or new line. - * @param[in] from First position of the range. - * @param[in] to Last position of the range. - * @param[out] positions Contains all the positions of \e character within the \e from, \e to range. - * - */ - void Find( SpecialCharacter character, std::size_t from, std::size_t to, Vector& positions ) const; - - /** - * @brief Retrieves a subtext withing the \e from, \e to range. - * - * If \e to is smaller than \e from, sub-text will be reversed. - * - * @note \e subText will be untouched if current text is not initialized of the range \e from, \e to is out of bounds. - * - * @param[in] from First position of the range. - * @param[in] to Last position of the range. - * @param[out] subText The subtext. - */ - void GetSubText( std::size_t from, std::size_t to, Text& subText ) const; - - /** - * @brief Whether the character in the \e index position is a white space. - * - * @param[in] index position of the character. - * - * @return \e true if the character pointed by \e index is a white space - */ - bool IsWhiteSpace( std::size_t index ) const; - - /** - * @brief Whether the character in the \e index position is a new line character. - * - * @param[in] index position of the character. - * - * @return \e true if the character pointed by \e index is a new line character. - */ - bool IsNewLine( std::size_t index ) const; - -private: - - Internal::Text* mImpl; ///< Pointer to implementation object - -public: // Not intended for application developers - - /** - * @brief Retrieves the internal implementation. - * - * @note Application developers shouldn't call any GetImplementation() method. - * - * @return The internal implementation. - */ - DALI_INTERNAL const Internal::Text& GetImplementation() const; - - /** - * @brief Retrieves the internal implementation. - * - * @note Application developers shouldn't call any GetImplementation() method. - * - * @return The internal implementation. - */ - DALI_INTERNAL Internal::Text& GetImplementation(); -}; - -} // namespace Dali - -#endif // __DALI_TEXT_H__ diff --git a/dali/public-api/text/utf8.cpp b/dali/public-api/text/utf8.cpp deleted file mode 100644 index 5142c68..0000000 --- a/dali/public-api/text/utf8.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2014 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. - * - */ - -// CLASS HEADER -#include - -#include - -namespace Dali -{ - -size_t Utf8SequenceLength(const unsigned char leadByte) -{ - return Internal::UTF8SequenceLength( leadByte ); -} - -} // namespace Dali diff --git a/dali/public-api/text/utf8.h b/dali/public-api/text/utf8.h deleted file mode 100644 index 0183a90..0000000 --- a/dali/public-api/text/utf8.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef __DALI_UTF8_H__ -#define __DALI_UTF8_H__ - -/* - * Copyright (c) 2014 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. - * - */ - - -#include - -namespace Dali -{ -/** - * @brief Determine the length (in bytes) of a UTF-8 character. - * - * @param[in] leadByte The lead byte of a UTF-8 character sequence - * @return The length of the sequence, or zero if the UTF-8 character is invalid. - */ -DALI_IMPORT_API size_t Utf8SequenceLength(const unsigned char leadByte); - -} // namespace Dali - - -#endif // __DALI_UTF8_H__ -- 2.7.4