build
build.log
tct*core.h
-CMakeLists.txt
+/CMakeLists.txt
results_xml.*
utc-Dali-Gltf2Loader.cpp
utc-Dali-KtxLoader.cpp
utc-Dali-MatrixStack.cpp
+ utc-Dali-MeshDefinition.cpp
utc-Dali-NodeDefinition.cpp
utc-Dali-RendererState.cpp
utc-Dali-ResourceBundle.cpp
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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 <vector>
+
+#include "dali-scene-loader/public-api/mesh-definition.h"
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+using namespace Dali::SceneLoader;
+
+int UtcDaliMeshDefinitionBlobApplyMinMaxBothMinMaxApplied(void)
+{
+ using Container = std::vector<float>;
+
+ Container buffer = { 4.0f, 6.0f, 8.0f, 10.0f, 12.0f };
+ Container minValues = { 5.0f };
+ Container maxValues = { 10.0f };
+ Container result = {5.0f, 6.0f, 8.0f, 10.0f, 10.0f};
+
+ MeshDefinition::Blob::ApplyMinMax(minValues, maxValues, 5, buffer.data());
+
+ for( auto i = 0u; i < result.size(); ++i)
+ {
+ DALI_TEST_EQUALS(buffer[i], result[i], TEST_LOCATION);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliMeshDefinitionBlobApplyMinMaxOnlyMin(void)
+{
+ using Container = std::vector<float>;
+
+ Container buffer = { 4.0f, 6.0f, 8.0f, 10.0f, 12.0f };
+ Container minValues = { 5.0f };
+ Container maxValues = {};
+ Container result = {5.0f, 6.0f, 8.0f, 10.0f, 12.0f};
+
+ MeshDefinition::Blob::ApplyMinMax(minValues, maxValues, 5, buffer.data());
+
+ for( auto i = 0u; i < result.size(); ++i)
+ {
+ DALI_TEST_EQUALS(buffer[i], result[i], TEST_LOCATION);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliMeshDefinitionBlobApplyMinMaxOnlyMax(void)
+{
+ using Container = std::vector<float>;
+
+ Container buffer = { 4.0f, 6.0f, 8.0f, 10.0f, 12.0f };
+ Container minValues = { };
+ Container maxValues = { 10.0f };
+ Container result = {4.0f, 6.0f, 8.0f, 10.0f, 10.0f};
+
+ MeshDefinition::Blob::ApplyMinMax(minValues, maxValues, 5, buffer.data());
+
+ for( auto i = 0u; i < result.size(); ++i)
+ {
+ DALI_TEST_EQUALS(buffer[i], result[i], TEST_LOCATION);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliMeshDefinitionBlobApplyMinMaxBothEmpty(void)
+{
+ using Container = std::vector<float>;
+
+ Container buffer = { 4.0f, 6.0f, 8.0f, 10.0f, 12.0f };
+ Container minValues;
+ Container maxValues;
+ Container result = {4.0f, 6.0f, 8.0f, 10.0f, 12.0f};
+
+ MeshDefinition::Blob::ApplyMinMax(minValues, maxValues, 5, buffer.data());
+
+ for( auto i = 0u; i < result.size(); ++i)
+ {
+ DALI_TEST_EQUALS(buffer[i], result[i], TEST_LOCATION);
+ }
+
+ END_TEST;
+}
+
--- /dev/null
+SET(PKG_NAME "dali-shader-generator")
+
+SET(EXEC_NAME "tct-${PKG_NAME}-core")
+
+PKG_CHECK_MODULES(${EXEC_NAME} REQUIRED
+ dali2-toolkit
+)
+
+ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.cpp)
+
+INSTALL(PROGRAMS ${EXEC_NAME}
+ DESTINATION ${BIN_DIR}/${EXEC_NAME}
+)
+
+SET(SHADER_GENERATOR dali-shader-generator)
+SET(GENERATED_FOLDER ${CMAKE_CURRENT_BINARY_DIR}/shader/generated)
+SET(SHADER_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/shader)
+
+ADD_CUSTOM_TARGET(test_help ALL COMMAND ${SHADER_GENERATOR} -h | grep "DALi Shader Generator" > /dev/null 2>&1 && echo "test_help Succeeded" VERBATIM)
+ADD_CUSTOM_TARGET(test_no_params ALL COMMAND ${SHADER_GENERATOR} > /dev/null 2>&1 || echo "test_no_params Succeeded" VERBATIM)
+ADD_CUSTOM_TARGET(test_version ALL COMMAND ${SHADER_GENERATOR} -v | wc -l | grep 1 > /dev/null 2>&1 && echo "test_version Succeeded" VERBATIM)
+ADD_CUSTOM_TARGET(test_invalid_option ALL COMMAND ${SHADER_GENERATOR} --undeclared > /dev/null 2>&1 || echo "test_invalid_option Succeeded" VERBATIM)
+ADD_CUSTOM_TARGET(test_too_many_params ALL COMMAND ${SHADER_GENERATOR} ONE TWO THREE > /dev/null 2>&1 || echo "test_too_many_params Succeeded" VERBATIM)
+ADD_CUSTOM_TARGET(test_invalid_indir ALL COMMAND ${SHADER_GENERATOR} ONE TWO > /dev/null 2>&1 || echo "test_invalid_indir Succeeded" VERBATIM)
+ADD_CUSTOM_TARGET(
+ test_check_built_in_created
+ ALL
+ COMMAND ${SHADER_GENERATOR} . ${GENERATED_FOLDER} | grep builtin-shader | wc -l | grep 2 > /dev/null 2>&1 && echo "test_check_built_in_created Succeeded"
+ VERBATIM)
+ADD_CUSTOM_TARGET(
+ test_check_built_in_not_created
+ ALL
+ COMMAND ${SHADER_GENERATOR} --skip . ${GENERATED_FOLDER} | grep builtin-shader > /dev/null 2>&1 || echo "test_check_built_in_not_created Succeeded"
+ VERBATIM)
+ADD_CUSTOM_TARGET(
+ test_frag_correct
+ ALL
+ COMMAND ${SHADER_GENERATOR} ${SHADER_FOLDER} ${GENERATED_FOLDER} | grep "SHADER_FRAGMENT_SHADER_FRAG" | grep "fragment-shader-frag.h" > /dev/null 2>&1 && echo "test_frag_correct Succeeded"
+ VERBATIM)
+ADD_CUSTOM_TARGET(
+ test_vert_correct
+ ALL
+ COMMAND ${SHADER_GENERATOR} ${SHADER_FOLDER} ${GENERATED_FOLDER} | grep "SHADER_VERTEX_SHADER_VERT" | grep "vertex-shader-vert.h" > /dev/null 2>&1 && echo "test_vert_correct Succeeded"
+ VERBATIM)
+ADD_CUSTOM_TARGET(
+ test_def_correct
+ ALL
+ COMMAND ${SHADER_GENERATOR} ${SHADER_FOLDER} ${GENERATED_FOLDER} | grep "SHADER_SHADER_DEFINE_DEF" | grep "shader-define-def.h" > /dev/null 2>&1 && echo "test_def_correct Succeeded"
+ VERBATIM)
--- /dev/null
+varying mediump vec2 vTexCoord;
+
+uniform sampler2D sTexture;
+uniform lowp vec4 uColor;
+
+void main()
+{
+ mediump vec4 color = texture2D( sTexture, vTexCoord );
+ if(color.a <= 0.0001)
+ {
+ discard;
+ }
+ gl_FragColor = color * uColor;
+}
--- /dev/null
+#version 300 es
+precision highp float;
--- /dev/null
+attribute mediump vec2 aPosition;
+uniform highp mat4 uMvpMatrix;
+uniform highp vec3 uSize;
+
+uniform mediump vec2 start_point;
+uniform mediump vec2 end_point;
+uniform mediump vec2 rotate_center;
+uniform mediump float rotate_angle;
+
+varying mediump vec2 vTexCoord;
+varying mediump vec2 vStart;
+varying mediump vec2 vEnd;
+
+vec2 rotate(vec2 x, vec2 c, float a)
+{
+ vec2 d = x - c;
+ vec2 r = vec2(d.x * cos(a) - d.y * sin(a), d.x * sin(a) + d.y * cos(a));
+
+#ifdef UNIT_TYPE_BOUNDING_BOX
+ return r + c;
+#endif
+
+ /* UnitType::OBJECT_BOUNDING_BOX */
+#ifdef UNIT_TYPE_USER
+ return (r + c) / uSize.x;
+#endif
+ /* UnitType::USER_SPACE*/
+}
+
+//Visual size and offset
+uniform mediump vec2 offset;
+uniform highp vec2 size;
+uniform mediump vec4 offsetSizeMode;
+uniform mediump vec2 origin;
+uniform mediump vec2 anchorPoint;
+
+vec4 ComputeVertexPosition()
+{
+ vec2 visualSize = mix( uSize.xy*size, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy );
+ return vec4( (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+}
+
+void main()
+{
+ vStart = rotate( start_point, rotate_center, rotate_angle );
+ vEnd = rotate( end_point, rotate_center, rotate_angle );
+ gl_Position = uMvpMatrix * ComputeVertexPosition();
+
+#ifdef UNIT_TYPE_BOUNDING_BOX
+ vTexCoord = vec2(aPosition.x, -aPosition.y);
+#endif
+/* UnitType::OBJECT_BOUNDING_BOX */
+
+#ifdef UNIT_TYPE_USER
+ vTexCoord = vec2(aPosition.x, -aPosition.y * uSize.y / uSize.x);
+#endif
+/* UnitType::USER_SPACE*/
+}
--- /dev/null
+#include <iostream>
+int main(int argc, char * const argv[])
+{
+ std::cout << "All tests run as part of Cmake build." << std::endl;
+ return 0;
+}
utc-Dali-Text-ViewModel.cpp
utc-Dali-TextField-internal.cpp
utc-Dali-TextEditor-internal.cpp
+ utc-Dali-TextLabel-internal.cpp
utc-Dali-TextSelectionPopup-internal.cpp
utc-Dali-TextureManager.cpp
utc-Dali-Visuals-internal.cpp
MarkupProcessData markupProcessData( logicalModel->mColorRuns,
logicalModel->mFontDescriptionRuns,
logicalModel->mEmbeddedItems,
- logicalModel->mAnchors );
+ logicalModel->mAnchors,
+ logicalModel->mUnderlinedCharacterRuns);
Length textSize = 0u;
const uint8_t* utf8 = NULL;
auto control = Control::New();
auto reading_info_type = DevelControl::GetAccessibilityReadingInfoType(control);
+
+ for ( auto i = 0u; i < 4; ++i)
+ DALI_TEST_CHECK ( reading_info_type[ static_cast< Dali::Accessibility::ReadingInfoType >( i ) ]);
+
+ reading_info_type[Dali::Accessibility::ReadingInfoType::DESCRIPTION] = false;
+ reading_info_type[Dali::Accessibility::ReadingInfoType::STATE] = false;
+ reading_info_type[Dali::Accessibility::ReadingInfoType::NAME] = false;
+ reading_info_type[Dali::Accessibility::ReadingInfoType::ROLE] = false;
+
+ DevelControl::SetAccessibilityReadingInfoType(control, reading_info_type);
+
+ reading_info_type = DevelControl::GetAccessibilityReadingInfoType(control);
+
+ for ( auto i = 0u; i < 4; ++i)
+ DALI_TEST_CHECK ( false == reading_info_type[ static_cast< Dali::Accessibility::ReadingInfoType >( i ) ]);
+
reading_info_type[Dali::Accessibility::ReadingInfoType::DESCRIPTION] = true;
reading_info_type[Dali::Accessibility::ReadingInfoType::STATE] = true;
reading_info_type[Dali::Accessibility::ReadingInfoType::NAME] = true;
Vector<FontDescriptionRun> fontRuns;
Vector<EmbeddedItem> items;
Vector<Anchor> anchors;
- MarkupProcessData markupProcessData( colorRuns, fontRuns, items, anchors );
+ Vector<UnderlinedCharacterRun> underlinedCharacterRuns;
+ MarkupProcessData markupProcessData( colorRuns, fontRuns, items, anchors, underlinedCharacterRuns );
ProcessMarkupString( data.xHTMLEntityString, markupProcessData );
for( Vector<EmbeddedItem>::Iterator it = items.Begin(),
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h>
#include <dali-toolkit/internal/controls/text-controls/text-editor-impl.h>
#include <dali-toolkit/internal/text/text-controller.h>
#include <dali-toolkit/internal/text/text-controller-impl.h>
END_TEST;
}
+
+int UtcDaliTextEditorMarkupUnderline(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextEditorMarkupUnderline ");
+
+ TextEditor textEditor = TextEditor::New();
+
+ application.GetScene().Add( textEditor );
+
+ textEditor.SetProperty( TextEditor::Property::TEXT, "<u>ABC</u>EF<u>GH</u>" );
+ textEditor.SetProperty( TextEditor ::Property::ENABLE_MARKUP, true );
+
+ application.SendNotification();
+ application.Render();
+
+ uint32_t expectedNumberOfUnderlinedGlyphs = 5u;
+
+ Toolkit::Internal::TextEditor& textEditorImpl = GetImpl( textEditor );
+ const Text::Length numberOfUnderlineRuns = textEditorImpl.getController()->GetTextModel()->GetNumberOfUnderlineRuns();
+
+ DALI_TEST_EQUALS( numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION );
+
+ Vector<GlyphRun> underlineRuns;
+ underlineRuns.Resize(numberOfUnderlineRuns);
+ textEditorImpl.getController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
+
+ //ABC are underlined
+ DALI_TEST_EQUALS( underlineRuns[0u].glyphIndex, 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS( underlineRuns[1u].glyphIndex, 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS( underlineRuns[2u].glyphIndex, 2u, TEST_LOCATION);
+
+ //GH are underlined
+ DALI_TEST_EQUALS( underlineRuns[3u].glyphIndex, 5u, TEST_LOCATION);
+ DALI_TEST_EQUALS( underlineRuns[4u].glyphIndex, 6u, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliTextEditorFontPointSizeLargerThanAtlas(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextEditorFontPointSizeLargerThanAtlas ");
+
+ // Create a text editor
+ TextEditor textEditor = TextEditor::New();
+ //Set size to avoid automatic eliding
+ textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
+ //Set very large font-size using point-size
+ textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000);
+ //Specify font-family
+ textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
+ //Set text to check if appear or not
+ textEditor.SetProperty(TextEditor::Property::TEXT, "A");
+
+ application.GetScene().Add( textEditor );
+
+ application.SendNotification();
+ application.Render();
+
+ //Check if Glyph is added to AtlasGlyphManger or not
+ int countAtlas = AtlasGlyphManager::Get().GetMetrics().mAtlasMetrics.mAtlasCount;
+ DALI_TEST_EQUALS( countAtlas, 1, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliTextEditorFontPointSizeLargerThanAtlasPlaceholderCase(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextEditorFontPointSizeLargerThanAtlasPlaceholderCase ");
+
+ //Set Map of placeholder: text, font-family and point-size
+ Property::Map placeholderMapSet;
+ placeholderMapSet["text"] = "A";
+ placeholderMapSet["fontFamily"] = "DejaVu Sans";
+ placeholderMapSet["pixelSize"] = 1000.0f;
+
+ // Create a text editor
+ TextEditor textEditor = TextEditor::New();
+ //Set size to avoid automatic eliding
+ textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
+ //Set placeholder
+ textEditor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet) ;
+
+ application.GetScene().Add( textEditor );
+
+ application.SendNotification();
+ application.Render();
+
+ //Check if Glyph is added to AtlasGlyphManger or not
+ int countAtlas = AtlasGlyphManager::Get().GetMetrics().mAtlasMetrics.mAtlasCount;
+ DALI_TEST_EQUALS( countAtlas, 1, TEST_LOCATION );
+
+ END_TEST;
+}
\ No newline at end of file
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h>
#include <dali-toolkit/internal/controls/text-controls/text-field-impl.h>
#include <dali-toolkit/internal/text/text-controller.h>
#include <dali-toolkit/internal/text/text-controller-impl.h>
END_TEST;
}
+
+int UtcDaliTextFieldMarkupUnderline(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldMarkupUnderline ");
+
+ TextField textField = TextField::New();
+
+ application.GetScene().Add( textField );
+
+ textField.SetProperty( TextField::Property::TEXT, "<u>ABC</u>EF<u>GH</u>" );
+ textField.SetProperty( TextField ::Property::ENABLE_MARKUP, true );
+
+ application.SendNotification();
+ application.Render();
+
+ uint32_t expectedNumberOfUnderlinedGlyphs = 5u;
+
+ Toolkit::Internal::TextField& textFieldImpl = GetImpl( textField );
+ const Text::Length numberOfUnderlineRuns = textFieldImpl.getController()->GetTextModel()->GetNumberOfUnderlineRuns();
+
+ DALI_TEST_EQUALS( numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION );
+
+ Vector<GlyphRun> underlineRuns;
+ underlineRuns.Resize(numberOfUnderlineRuns);
+ textFieldImpl.getController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
+
+ //ABC are underlined
+ DALI_TEST_EQUALS( underlineRuns[0u].glyphIndex, 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS( underlineRuns[1u].glyphIndex, 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS( underlineRuns[2u].glyphIndex, 2u, TEST_LOCATION);
+
+ //GH are underlined
+ DALI_TEST_EQUALS( underlineRuns[3u].glyphIndex, 5u, TEST_LOCATION);
+ DALI_TEST_EQUALS( underlineRuns[4u].glyphIndex, 6u, TEST_LOCATION);
+
+ END_TEST;
+
+}
+
+int UtcDaliTextFieldFontPointSizeLargerThanAtlas(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldFontPointSizeLargerThanAtlas ");
+
+ // Create a Text field
+ TextField textField = TextField::New();
+ //Set size to avoid automatic eliding
+ textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
+ //Set very large font-size using point-size
+ textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
+ //Specify font-family
+ textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
+ //Set text to check if appear or not
+ textField.SetProperty( TextField::Property::TEXT, "A");
+
+ application.GetScene().Add( textField );
+
+ application.SendNotification();
+ application.Render();
+
+ //Check if Glyph is added to AtlasGlyphManger or not
+ int countAtlas = AtlasGlyphManager::Get().GetMetrics().mAtlasMetrics.mAtlasCount;
+ DALI_TEST_EQUALS( countAtlas, 1, TEST_LOCATION );
+
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldFontPointSizeLargerThanAtlasPlaceholderCase(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldFontPointSizeLargerThanAtlasPlaceholderCase ");
+
+ //Set Map of placeholder: text, font-family and point-size
+ Property::Map placeholderMapSet;
+ placeholderMapSet["text"] = "A";
+ placeholderMapSet["fontFamily"] = "DejaVu Sans";
+ placeholderMapSet["pixelSize"] = 1000.0f;
+
+ // Create a text editor
+ TextField textField = TextField::New();
+ //Set size to avoid automatic eliding
+ textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
+ //Set placeholder
+ textField.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet) ;
+
+ application.GetScene().Add( textField );
+
+ application.SendNotification();
+ application.Render();
+
+ //Check if Glyph is added to AtlasGlyphManger or not
+ int countAtlas = AtlasGlyphManager::Get().GetMetrics().mAtlasMetrics.mAtlasCount;
+ DALI_TEST_EQUALS( countAtlas, 1, TEST_LOCATION );
+
+
+ END_TEST;
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2020 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 <iostream>
+#include <stdlib.h>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+
+#include <dali-toolkit/internal/controls/text-controls/text-label-impl.h>
+#include <dali-toolkit/internal/text/text-controller.h>
+#include <dali-toolkit/internal/text/text-controller-impl.h>
+
+using namespace Dali;
+using namespace Toolkit;
+using namespace Text;
+
+int UtcDaliTextLabelMarkupUnderline(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextLabelMarkupUnderline ");
+
+ TextLabel textLabel = TextLabel::New();
+
+ application.GetScene().Add( textLabel );
+
+ textLabel.SetProperty( TextLabel::Property::TEXT, "<u>ABC</u>EF<u>GH</u>" );
+ textLabel.SetProperty( TextLabel ::Property::ENABLE_MARKUP, true );
+
+ application.SendNotification();
+ application.Render();
+
+ uint32_t expectedNumberOfUnderlinedGlyphs = 5u;
+
+ Toolkit::Internal::TextLabel& textLabelImpl = GetImpl( textLabel );
+ const Text::Length numberOfUnderlineRuns = textLabelImpl.getController()->GetTextModel()->GetNumberOfUnderlineRuns();
+
+ DALI_TEST_EQUALS( numberOfUnderlineRuns, expectedNumberOfUnderlinedGlyphs, TEST_LOCATION );
+
+ Vector<GlyphRun> underlineRuns;
+ underlineRuns.Resize(numberOfUnderlineRuns);
+ textLabelImpl.getController()->GetTextModel()->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
+
+ //ABC are underlined
+ DALI_TEST_EQUALS( underlineRuns[0u].glyphIndex, 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS( underlineRuns[1u].glyphIndex, 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS( underlineRuns[2u].glyphIndex, 2u, TEST_LOCATION);
+
+ //GH are underlined
+ DALI_TEST_EQUALS( underlineRuns[3u].glyphIndex, 5u, TEST_LOCATION);
+ DALI_TEST_EQUALS( underlineRuns[4u].glyphIndex, 6u, TEST_LOCATION);
+
+ END_TEST;
+
+}
\ No newline at end of file
#define DALI_TOOLKIT_ADAPTOR_IMPL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
void AddWindow( Internal::Adaptor::SceneHolder* window );
void RemoveWindow( Internal::Adaptor::SceneHolder* window );
- void RegisterProcessor( Integration::Processor& processor );
- void UnregisterProcessor( Integration::Processor& processor );
+ void RegisterProcessor( Integration::Processor& processor, bool postProcessor = false);
+ void UnregisterProcessor( Integration::Processor& processor, bool postProcessor = false);
void SetApplication( Dali::TestApplication& testApplication );
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
}
-void Adaptor::RegisterProcessor( Integration::Processor& processor )
+void Adaptor::RegisterProcessor( Integration::Processor& processor, bool postProcessor )
{
Integration::Core& core = mTestApplication->GetCore();
- core.RegisterProcessor( processor );
+ core.RegisterProcessor( processor, postProcessor );
}
-void Adaptor::UnregisterProcessor( Integration::Processor& processor )
+void Adaptor::UnregisterProcessor( Integration::Processor& processor, bool postProcessor )
{
Integration::Core& core = mTestApplication->GetCore();
- core.UnregisterProcessor( processor );
+ core.UnregisterProcessor( processor, postProcessor );
}
void Adaptor::SetApplication( Dali::TestApplication& testApplication )
return *gLogFactory;
}
-void Adaptor::RegisterProcessor( Integration::Processor& processor )
+void Adaptor::RegisterProcessor( Integration::Processor& processor, bool postProcessor)
{
- mImpl->RegisterProcessor( processor );
+ mImpl->RegisterProcessor( processor, postProcessor );
}
-void Adaptor::UnregisterProcessor( Integration::Processor& processor )
+void Adaptor::UnregisterProcessor( Integration::Processor& processor, bool postProcessor)
{
- mImpl->UnregisterProcessor( processor );
+ mImpl->UnregisterProcessor( processor, postProcessor );
}
} // namespace Dali
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <toolkit-vector-animation-renderer.h>
#include <toolkit-event-thread-callback.h>
#include <memory>
+#include <thread>
+#include <chrono>
namespace Dali
{
namespace Adaptor
{
+namespace
+{
+Dali::Internal::Adaptor::VectorAnimationRenderer* gVectorAnimationRenderer = nullptr;
+}
+
class VectorAnimationRenderer: public Dali::BaseObject
{
public:
mRenderer(),
mWidth( 0 ),
mHeight( 0 ),
+ mTotalFrameNumber(VECTOR_ANIMATION_TOTAL_FRAME_NUMBER),
mPreviousFrame( 0 ),
+ mDelayTime(0),
+ mDroppedFrames(0),
mFrameRate( 60.0f ),
+ mNeedDroppedFrames(false),
mEventThreadCallback( new EventThreadCallback( MakeCallback( this, &VectorAnimationRenderer::OnTriggered ) ) )
{
mCount++;
bool Load(const std::string& url)
{
mUrl = url;
- if(mUrl == "invalid.json")
+ if(mUrl == "invalid.json" || mUrl == "invalid.riv")
{
return false;
}
+ else if(mUrl == "framedrop.json")
+ {
+ // Change total frame number for test
+ mTotalFrameNumber = 200;
+ }
return true;
}
bool Render( uint32_t frameNumber )
{
+ if(mDelayTime != 0)
+ {
+ std::this_thread::sleep_for(std::chrono::milliseconds(static_cast<int32_t>(mDelayTime)));
+ mDelayTime = 0;
+ mNeedDroppedFrames = true;
+ }
+ else if(mNeedDroppedFrames)
+ {
+ mDroppedFrames = (frameNumber > mPreviousFrame) ? frameNumber - mPreviousFrame - 1: frameNumber + (mTotalFrameNumber - mPreviousFrame) - 1;
+ mNeedTrigger = true;
+ mNeedDroppedFrames = false;
+ }
+
if( mNeedTrigger )
{
mEventThreadCallback->Trigger();
uint32_t GetTotalFrameNumber() const
{
- return VECTOR_ANIMATION_TOTAL_FRAME_NUMBER;
+ return mTotalFrameNumber;
}
float GetFrameRate() const
Dali::Renderer mRenderer;
uint32_t mWidth;
uint32_t mHeight;
+ uint32_t mTotalFrameNumber;
uint32_t mPreviousFrame;
+ uint32_t mDelayTime;
+ uint32_t mDroppedFrames;
float mFrameRate;
+ bool mNeedDroppedFrames;
Dali::VectorAnimationRenderer::UploadCompletedSignalType mUploadCompletedSignal;
std::unique_ptr< EventThreadCallback > mEventThreadCallback;
};
{
Internal::Adaptor::VectorAnimationRenderer* animationRenderer = new Internal::Adaptor::VectorAnimationRenderer();
+ Internal::Adaptor::gVectorAnimationRenderer = animationRenderer;
+
return VectorAnimationRenderer( animationRenderer );
}
Dali::Internal::Adaptor::VectorAnimationRenderer::mNeedTrigger = true;
}
+void DelayRendering(uint32_t delay)
+{
+ Dali::Internal::Adaptor::gVectorAnimationRenderer->mDelayTime = delay;
+}
+
+uint32_t GetDroppedFrames()
+{
+ return Dali::Internal::Adaptor::gVectorAnimationRenderer->mDroppedFrames;
+}
+
} // VectorAnimationRenderer
} // Test
#define DALI_TOOLKIT_TEST_VECTOR_ANIMATION_RENDERER_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#define VECTOR_ANIMATION_MARKER_END_FRAME_2 3
void RequestTrigger();
+void DelayRendering(uint32_t delay);
+uint32_t GetDroppedFrames();
} // VectorAnimationRenderer
} // Test
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
+const char* TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP = "framedrop.json";
const char* TEST_VECTOR_IMAGE_INVALID_FILE_NAME = "invalid.json";
+const char* TEST_VECTOR_IMAGE_RIVE_FILE_NAME = TEST_RESOURCE_DIR "/juice.riv";
+const char* TEST_VECTOR_IMAGE_INVALID_RIVE_FILE_NAME = "invalid.riv";
+
bool gAnimationFinishedSignalFired = false;
void VisualEventSignal( Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId )
END_TEST;
}
+
+int UtcDaliAnimatedVectorImageVisualFrameDrops(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliAnimatedVectorImageVisualFrameDrops");
+
+ Property::Map propertyMap;
+ propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
+ .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP);
+
+ Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ DummyControl actor = DummyControl::New(true);
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ Vector2 controlSize(20.f, 30.f);
+ actor.SetProperty(Actor::Property::SIZE, controlSize);
+
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ application.Render();
+
+ Property::Map attributes;
+ DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
+
+ application.SendNotification();
+ application.Render();
+
+ // Trigger count is 1 - render the first frame
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ // Make delay to drop frames
+ Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames
+
+ // Check dropped frame
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames();
+ DALI_TEST_CHECK(frames >= 9);
+
+ END_TEST;
+}
+
+int UtcDaliAnimatedVectorImageVisualLoadRiveFileP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliAnimatedVectorImageVisualLoadRiveFile: Request animated vector image visual with a rive url" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual( TEST_VECTOR_IMAGE_RIVE_FILE_NAME, ImageDimensions() );
+ DALI_TEST_CHECK( visual );
+
+ DummyControl actor = DummyControl::New( true );
+ DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) );
+ application.GetScene().Add( actor );
+
+ application.SendNotification();
+ application.Render();
+
+ // renderer is added to actor
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ Renderer renderer = actor.GetRendererAt( 0u );
+ DALI_TEST_CHECK( renderer );
+
+ // Test SetOffScene().
+ actor.Unparent();
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
+
+int UtcDaliAnimatedVectorImageVisualLoadRiveFileN(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("Request loading with invalid rive file - should draw broken image");
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ Property::Map propertyMap;
+ propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
+ .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_RIVE_FILE_NAME);
+
+ Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ DummyControl actor = DummyControl::New(true);
+ DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
+
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ application.Render();
+
+ // Check resource status
+ Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL);
+ DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
+
+ // The broken image should be shown.
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimatedVectorImageVisualPlaybackRiveFile(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliAnimatedVectorImageVisualPlaybackRiveFile" );
+
+ {
+ // request AnimatedVectorImageVisual for Rive with a property map
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual(
+ Property::Map()
+ .Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
+ .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_RIVE_FILE_NAME ) );
+
+ DummyControl dummyControl = DummyControl::New( true );
+ Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummyControl.GetImplementation() );
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+ dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+
+ Property::Map attributes;
+ tet_infoline( "Test Play action" );
+ DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
+
+ application.GetScene().Add( dummyControl );
+ application.SendNotification();
+ application.Render( 16 );
+
+ Property::Map map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING );
+
+ tet_infoline( "Test Pause action" );
+ DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes );
+
+ application.SendNotification();
+ application.Render(16);
+
+ map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PAUSED );
+
+ tet_infoline( "Test Play action" );
+ DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
+
+ application.SendNotification();
+ application.Render(16);
+
+ map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING );
+
+ tet_infoline( "Test Stop action" );
+ DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes );
+
+ application.SendNotification();
+ application.Render(16);
+
+ map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED );
+
+ tet_infoline( "Test Stop action again" );
+ DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes );
+
+ application.SendNotification();
+ application.Render(16);
+
+ map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED );
+
+ tet_infoline( "Test Play action" );
+ DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
+
+ application.SendNotification();
+ application.Render(16);
+
+ map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING );
+
+ tet_infoline( "Off stage" );
+ dummyControl.Unparent();
+
+ application.SendNotification();
+ application.Render(16);
+
+ map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED );
+
+ tet_infoline( "On stage again" );
+ application.GetScene().Add( dummyControl );
+
+ application.SendNotification();
+ application.Render(16);
+
+ map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED );
+
+ tet_infoline( "Test Play action" );
+ DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
+
+ application.SendNotification();
+ application.Render(16);
+
+ map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
+ value = map.Find( DevelImageVisual::Property::PLAY_STATE );
+ DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING );
+
+ // Change Size
+ Vector3 newSize( 100.0f, 100.0f, 0.0f );
+ dummyControl.SetProperty( Actor::Property::SIZE, newSize );
+
+ application.SendNotification();
+ application.Render(16);
+
+ // Size should be changed
+ Vector3 naturalSize = dummyControl.GetNaturalSize();
+ DALI_TEST_CHECK( naturalSize == newSize );
+
+ dummyControl.Unparent();
+ }
+
+ END_TEST;
+}
\ No newline at end of file
END_TEST;
}
+
+
+int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
+
+ int lineCountBefore =0 ;
+ int lineCountAfter =0 ;
+
+ // Create a text editor
+ TextEditor textEditor = TextEditor::New();
+ //Set very large font-size using point-size
+ textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
+ //Specify font-family
+ textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
+ //Specify size
+ textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
+ //Set text longer than width of textEditor
+ textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
+
+ application.GetScene().Add( textEditor );
+
+ application.SendNotification();
+ application.Render();
+
+ //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
+ //GetHeightForWidth is a retrieval method which should not modify object
+ lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
+ textEditor.GetHeightForWidth(200.f);
+
+ //This is to simulate focus into text editor after calling GetHeightForWidth
+ //Create a tap event to touch the text editor.
+ TestGenerateTap( application, 18.0f, 25.0f );
+
+ application.SendNotification();
+ application.Render();
+
+ lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
+
+ //The LineCount must not be changed when calling GetHeightForWidth.
+ DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
+
+ int lineCountBefore =0 ;
+ int lineCountAfter =0 ;
+
+ // Create a text editor
+ TextEditor textEditor = TextEditor::New();
+ //Set very large font-size using point-size
+ textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
+ //Specify font-family
+ textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
+ //Specify size
+ textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
+ //Set text longer than width of textEditor
+ textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
+ //Set line wrap mode Character
+ textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
+
+ application.GetScene().Add( textEditor );
+
+ application.SendNotification();
+ application.Render();
+
+ //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
+ //GetHeightForWidth is a retrieval method which should not modify object
+ lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
+ textEditor.GetHeightForWidth(200.f);
+
+ //This is to simulate focus into text editor after calling GetHeightForWidth
+ //Create a tap event to touch the text editor.
+ TestGenerateTap( application, 18.0f, 25.0f );
+
+ application.SendNotification();
+ application.Render();
+
+ lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
+
+ //The LineCount must not be changed when calling GetHeightForWidth.
+ DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
+
+ int lineCountBefore =0 ;
+ int lineCountAfter =0 ;
+
+ // Create a text editor
+ TextEditor textEditor = TextEditor::New();
+ //Set very large font-size using point-size
+ textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
+ //Specify font-family
+ textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
+ //Specify size
+ textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
+ //Set text longer than width of textEditor
+ textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
+
+ application.GetScene().Add( textEditor );
+
+ application.SendNotification();
+ application.Render();
+
+ //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
+ //GetNaturalSize is a retrieval method which should not modify object
+ lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
+ textEditor.GetNaturalSize();
+
+ //This is to simulate focus into text editor after calling GetNaturalSize
+ //Create a tap event to touch the text editor.
+ TestGenerateTap( application, 18.0f, 25.0f );
+
+ application.SendNotification();
+ application.Render();
+
+ lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
+
+ //The LineCount must not be changed when calling GetNaturalSize.
+ DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
+
+ int lineCountBefore =0 ;
+ int lineCountAfter =0 ;
+
+ // Create a text editor
+ TextEditor textEditor = TextEditor::New();
+ //Set very large font-size using point-size
+ textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
+ //Specify font-family
+ textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
+ //Specify size
+ textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
+ //Set text longer than width of textEditor
+ textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
+ //Set line wrap mode Character
+ textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
+
+ application.GetScene().Add( textEditor );
+
+ application.SendNotification();
+ application.Render();
+
+ //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
+ //GetNaturalSize is a retrieval method which should not modify object
+ lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
+ textEditor.GetNaturalSize( );
+
+ //This is to simulate focus into text editor after calling GetNaturalSize
+ //Create a tap event to touch the text editor.
+ TestGenerateTap( application, 18.0f, 25.0f );
+
+ application.SendNotification();
+ application.Render();
+
+ lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
+
+ //The LineCount must not be changed when calling GetNaturalSize.
+ DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
+
+ // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
+ const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+ const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+
+ // Create a text editor
+ TextEditor textEditor = TextEditor::New();
+
+ //Set size to avoid automatic eliding
+ textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
+ //Set very large font-size using point-size
+ textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000) ;
+ //Specify font-family
+ textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
+ //Set text to check if appear or not
+ textEditor.SetProperty( TextEditor::Property::TEXT, "A");
+
+ application.GetScene().Add( textEditor );
+
+ application.SendNotification();
+ application.Render();
+ //Use GetNaturalSize to verify that size of block does not exceed Atlas size
+ Vector3 naturalSize = textEditor.GetNaturalSize();
+
+ DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
+ DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
+
+ // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
+ const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+ const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+
+ Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
+ // Create a text editor
+ TextEditor textEditor = TextEditor::New();
+ //Set size to avoid automatic eliding
+ textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
+ textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
+ textEditor.SetProperty( TextEditor::Property::TEXT, "A");
+
+ const int numberOfCases = 6;
+ int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
+
+ for (int index=0; index < numberOfCases; index++)
+ {
+ tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
+ textEditor.SetProperty( TextEditor::Property::POINT_SIZE, arrayCases[index]) ;
+ application.GetScene().Add( textEditor );
+ application.SendNotification();
+ application.Render();
+ naturalSize = textEditor.GetNaturalSize();
+ DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
+ DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
+
+ }
+
+ END_TEST;
+}
\ No newline at end of file
DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "123456789", TEST_LOCATION );
END_TEST;
+}
+
+
+
+int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
+
+ // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
+ const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+ const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+
+ // Create a text field
+ TextField textField = TextField::New();
+
+ //Set size to avoid automatic eliding
+ textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
+ //Set very large font-size using point-size
+ textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
+ //Specify font-family
+ textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
+ //Set text to check if appear or not
+ textField.SetProperty( TextField::Property::TEXT, "A");
+
+ application.GetScene().Add( textField );
+
+ application.SendNotification();
+ application.Render();
+ //Use GetNaturalSize to verify that size of block does not exceed Atlas size
+ Vector3 naturalSize = textField.GetNaturalSize();
+
+ DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
+ DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
+
+ // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
+ const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+ const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+
+ Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
+ // Create a text editor
+ TextField textField = TextField::New();
+
+ //Set size to avoid automatic eliding
+ textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
+ textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
+ textField.SetProperty( TextField::Property::TEXT, "A");
+
+ const int numberOfCases = 6;
+ int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
+
+ for (int index=0; index < numberOfCases; index++)
+ {
+ tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
+ textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ;
+ application.GetScene().Add( textField );
+ application.SendNotification();
+ application.Render();
+ naturalSize = textField.GetNaturalSize();
+ DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
+ DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
+
+ }
+
+ END_TEST;
}
\ No newline at end of file
END_TEST;
}
+
+int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
+
+ //TextLabel is not using Atlas but this is to unify font-size on text-controllers
+
+ // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
+ const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+ const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
+
+ // Create a text editor
+ TextLabel textLabel = TextLabel::New();
+ //Set size to avoid automatic eliding
+ textLabel.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
+ //Set very large font-size using point-size
+ textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 1000);
+ //Specify font-family
+ textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
+ //Set text to check if appear or not
+ textLabel.SetProperty( TextLabel::Property::TEXT, "A");
+
+ application.GetScene().Add( textLabel );
+
+ application.SendNotification();
+ application.Render();
+ //Use GetNaturalSize to verify that size of block does not exceed Atlas size
+ Vector3 naturalSize = textLabel.GetNaturalSize();
+
+ DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
+ DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
+
+ END_TEST;
+}
\ No newline at end of file
dali.info
*.dylib
dali2-*-config.cmake
-libdali2-scene-loader.so*
\ No newline at end of file
+libdali2-scene-loader.so*
+dali-shader-generator
# Generate source files for shaders
SET(SHADER_SOURCE_DIR "${ROOT_SRC_DIR}/dali-toolkit/internal/graphics/shaders/")
SET(SHADER_GENERATED_DIR "${ROOT_SRC_DIR}/dali-toolkit/internal/graphics/generated")
-EXECUTE_PROCESS( COMMAND bash -c "${CMAKE_CURRENT_SOURCE_DIR}/shader-generator.sh ${SHADER_SOURCE_DIR} ${SHADER_GENERATED_DIR}" )
SET(GENERATED_SHADER_DIR ${ROOT_SRC_DIR}/dali-toolkit/internal/graphics/)
SET_PROPERTY(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
"${GENERATED_SHADER_DIR}/generated/"
"${GENERATED_SHADER_DIR}/builtin-shader-extern-gen.h")
+SET(SHADER_GENERATOR_NAME dali-shader-generator)
+SET(SHADER_GENERATOR_SOURCES ${ROOT_SRC_DIR}/dali-toolkit/shader-generator/shader-generator.cpp)
+
+IF( WIN32)
+ # When Using VCPKG, the default is always set to Debug if CMAKE_BUILD_TYPE is not set
+ IF( NOT CMAKE_BUILD_TYPE )
+ SET(SHADER_GENERATOR_BINARY ${CMAKE_CURRENT_BINARY_DIR}/Debug/${SHADER_GENERATOR_NAME})
+ ELSE()
+ SET(SHADER_GENERATOR_BINARY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${SHADER_GENERATOR_NAME})
+ ENDIF()
+ELSE()
+ SET(SHADER_GENERATOR_BINARY ${CMAKE_CURRENT_BINARY_DIR}/${SHADER_GENERATOR_NAME})
+ENDIF()
+
+IF(NOT ANDROID)
+ ADD_EXECUTABLE(${SHADER_GENERATOR_NAME} ${SHADER_GENERATOR_SOURCES})
+ INSTALL(TARGETS ${SHADER_GENERATOR_NAME} RUNTIME DESTINATION bin)
+ELSE()
+ # Need to build dali-shader-generator using the host compiler, not the android cross-compiler so
+ # that it can be run on the host machine
+ OPTION(ANDROID_HOST_COMPILER "Provide the host compiler used by Android (Mandatory)")
+ IF(${ANDROID_HOST_COMPILER} STREQUAL "OFF")
+ MESSAGE(FATAL_ERROR "-DANDROID_HOST_COMPILER=\"Compiler\" must be set")
+ ENDIF()
+
+ ADD_CUSTOM_COMMAND(OUTPUT ${SHADER_GENERATOR_NAME}
+ COMMAND ${ANDROID_HOST_COMPILER} -o ${CMAKE_CURRENT_BINARY_DIR}/${SHADER_GENERATOR_NAME} -std=c++17 ${SHADER_GENERATOR_SOURCES})
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SHADER_GENERATOR_NAME}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+ DESTINATION bin)
+ENDIF()
+
+SET(BUILT_IN_SHADER_GEN_CPP "${GENERATED_SHADER_DIR}/generated/builtin-shader-gen.cpp")
+ADD_CUSTOM_COMMAND(OUTPUT ${BUILT_IN_SHADER_GEN_CPP}
+ DEPENDS ${SHADER_GENERATOR_NAME}
+ COMMAND ${SHADER_GENERATOR_BINARY} ${SHADER_SOURCE_DIR} ${SHADER_GENERATED_DIR})
+
+SET(SOURCES ${SOURCES} ${BUILT_IN_SHADER_GEN_CPP})
+
IF( WIN32 OR APPLE )
SET( DALICORE_LDFLAGS
"${DALICORE_LDFLAGS}"
add_definitions("-DDEBUG_ENABLED")
endif()
+ADD_DEFINITIONS( "-DBUILDING_DALI_SCENE_LOADER" )
+
foreach(flag ${PKGS_CFLAGS})
set(extra_flags "${extra_flags} ${flag}")
endforeach(flag)
${prefix_include_dir}
)
+# Generate source files for shaders
+SET(SHADER_SOURCE_DIR "${scene_loader_dir}/internal/graphics/shaders/")
+SET(SHADER_GENERATED_DIR "${scene_loader_dir}/internal/graphics/generated")
+
+SET(GENERATED_SHADER_DIR ${scene_loader_dir}/internal/graphics/)
+SET_PROPERTY(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
+ "${GENERATED_SHADER_DIR}/generated/"
+ "${GENERATED_SHADER_DIR}/builtin-shader-extern-gen.h")
+
+IF( WIN32)
+ # When Using VCPKG, the default is always set to Debug if CMAKE_BUILD_TYPE is not set
+ IF( NOT CMAKE_BUILD_TYPE )
+ SET(SHADER_GENERATOR_BINARY ${CMAKE_CURRENT_BINARY_DIR}/../Debug/${SHADER_GENERATOR_NAME})
+ ELSE()
+ SET(SHADER_GENERATOR_BINARY ${CMAKE_CURRENT_BINARY_DIR}/../${CMAKE_BUILD_TYPE}/${SHADER_GENERATOR_NAME})
+ ENDIF()
+ELSE()
+ SET(SHADER_GENERATOR_BINARY ${CMAKE_CURRENT_BINARY_DIR}/../${SHADER_GENERATOR_NAME})
+ENDIF()
+
+SET( BUILT_IN_SHADER_GEN_CPP "${GENERATED_SHADER_DIR}/generated/builtin-shader-gen.cpp")
+ADD_CUSTOM_COMMAND(OUTPUT ${BUILT_IN_SHADER_GEN_CPP}
+ DEPENDS ${SHADER_GENERATOR_BINARY}
+ COMMAND ${SHADER_GENERATOR_BINARY} ${SHADER_SOURCE_DIR} ${SHADER_GENERATED_DIR})
+
+SET( scene_loader_src_files ${scene_loader_src_files} ${BUILT_IN_SHADER_GEN_CPP} )
+
add_library(${name} SHARED ${scene_loader_src_files})
target_link_libraries(${name} ${DALICORE_LDFLAGS} ${DALIADAPTOR_LDFLAGS}
target_link_libraries(${name} log)
endif()
-# Generate source files for shaders
-SET(SHADER_SOURCE_DIR "${scene_loader_dir}/internal/graphics/shaders/")
-SET(SHADER_GENERATED_DIR "${scene_loader_dir}/internal/graphics/generated")
-EXECUTE_PROCESS( COMMAND bash -c "${repo_root_dir}/build/tizen/shader-generator.sh ${SHADER_SOURCE_DIR} ${SHADER_GENERATED_DIR}" )
-
-SET(GENERATED_SHADER_DIR ${scene_loader_dir}/internal/graphics/)
-SET_PROPERTY(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
- "${GENERATED_SHADER_DIR}/generated/"
- "${GENERATED_SHADER_DIR}/builtin-shader-extern-gen.h")
-
IF( INSTALL_CMAKE_MODULES )
SET_TARGET_PROPERTIES( ${name}
PROPERTIES
+++ /dev/null
-#!/bin/bash
-
-indir=$1
-outdir=$2
-
-mkdir -p $outdir
-
-if [ ! -e $indir ] ; then
- echo "Error! "$indir" not found!"
- exit 0
-fi
-
-cd $indir
-all_shaders=$(ls -1 *.{vert,frag,def})
-cd $OLDPWD
-
-# Generate one header file per shader which is defined as a const std::string_view
-for name in $all_shaders ; do
- echo "Generating header files for $name..."
- varname=$(echo "SHADER_$name" | tr [a-z] [A-Z] | sed -e 's/-/_/g;s/\./_/g;')
-
- newname=$(echo ${name} | sed -e 's/\./-/;')".h"
- echo Writing $newname
-
- shader_fullpath=$(echo ${indir})$name
-
- header_name="${varname}_GEN_H"
- echo "const std::string_view" "$varname""{" > $outdir/$newname
- cat $shader_fullpath | sed -e 's/^..*$/"&\\n"/' >> $outdir/$newname
- echo "};" >> $outdir/$newname
-done
-
-# Generate one cpp file that includes all the previously generated string_views for shaders
-echo "Generating cpp file..."
-echo -e "#include \"../builtin-shader-extern-gen.h\"\n" > $outdir/builtin-shader-gen.cpp
-
-varnames=
-for name in $all_shaders ; do
- varname=$(echo "SHADER_$name" | tr [a-z] [A-Z] | sed -e 's/-/_/g;s/\./_/g;')
- newname=$(echo ${name} | sed -e 's/\./-/;')".h"
- varnames="${varnames} $varname"
- echo "#include \"$newname\"" >> $outdir/builtin-shader-gen.cpp
-done
-
-# Generate one header file that defines all the shader string_views as extern variables
-echo "Generating extern header file ( for external use )..."
-echo "#ifndef GRAPHICS_BUILTIN_SHADER_EXTERN_GEN_H" > $outdir/../builtin-shader-extern-gen.h
-echo -e "#define GRAPHICS_BUILTIN_SHADER_EXTERN_GEN_H\n" >> $outdir/../builtin-shader-extern-gen.h
-
-echo "#include <string_view>" >> $outdir/../builtin-shader-extern-gen.h
-echo "" >> $outdir/../builtin-shader-extern-gen.h
-
-for name in $all_shaders ; do
- varname=$(echo "SHADER_$name" | tr [a-z] [A-Z] | sed -e 's/-/_/g;s/\./_/g;')
- newname=$(echo ${name} | sed -e 's/\./-/;')".h"
- echo "extern const std::string_view $varname;" >> $outdir/../builtin-shader-extern-gen.h
-done
-cat >> $outdir/../builtin-shader-extern-gen.h << EOF
-
-#endif // GRAPHICS_BUILTIN_SHADER_EXTERN_GEN_H
-EOF
-
: (max.empty() ? [](const float* min, const float* max, uint32_t i, float& value) {
value = std::max(min[i], value);
}
- : [](const float* min, const float* max, uint32_t i, float& value) {
+ : static_cast<ClampFn>([](const float* min, const float* max, uint32_t i, float& value) {
value = std::min(std::max(min[i], value), max[i]);
- });
+ }));
if(!clampFn)
{
MarkupProcessData markupProcessData(colorRuns,
fontDescriptionRuns,
textModel->mLogicalModel->mEmbeddedItems,
- textModel->mLogicalModel->mAnchors);
+ textModel->mLogicalModel->mAnchors,
+ textModel->mLogicalModel->mUnderlinedCharacterRuns);
if(textParameters.markupEnabled)
{
mChanged = true;
}
-void CanvasView::Process()
+void CanvasView::Process(bool postProcessor)
{
if(!mCanvasRenderer)
{
/**
* @copydoc Dali::Integration::Processor::Process()
*/
- void Process() override;
+ void Process(bool postProcessor) override;
private:
/**
{
place->Get(value);
}
+ else
+ {
+ Dali::Accessibility::ReadingInfoTypes types;
+ types[Dali::Accessibility::ReadingInfoType::NAME] = true;
+ types[Dali::Accessibility::ReadingInfoType::ROLE] = true;
+ types[Dali::Accessibility::ReadingInfoType::DESCRIPTION] = true;
+ types[Dali::Accessibility::ReadingInfoType::STATE] = true;
+ return types;
+ }
if(value.empty())
{
${toolkit_src_dir}/transition-effects/cube-transition-wave-effect-impl.cpp
${toolkit_src_dir}/text/xhtml-entities.cpp
${toolkit_src_dir}/drag-drop-detector/drag-and-drop-detector-impl.cpp
- ${toolkit_src_dir}/graphics/generated/builtin-shader-gen.cpp
)
SET( SOURCES ${SOURCES}
mColorRuns,
removedColorRuns);
+ // This is needed until now for underline tag in mark-up processor
+ // Process the underlined runs.
+ Vector<UnderlinedCharacterRun> removedUnderlinedCharacterRuns;
+ UpdateCharacterRuns<UnderlinedCharacterRun>(index,
+ numberOfCharacters,
+ totalNumberOfCharacters,
+ mUnderlinedCharacterRuns,
+ removedUnderlinedCharacterRuns);
+
// Process the background color runs.
Vector<ColorRun> removedBackgroundColorRuns;
UpdateCharacterRuns<ColorRun>(index,
#include <dali-toolkit/internal/text/font-run.h>
#include <dali-toolkit/internal/text/paragraph-run.h>
#include <dali-toolkit/internal/text/script-run.h>
+#include <dali-toolkit/internal/text/underlined-character-run.h>
namespace Dali
{
Vector<BidirectionalLineInfoRun> mBidirectionalLineInfo;
Vector<EmbeddedItem> mEmbeddedItems;
Vector<Anchor> mAnchors;
+ Vector<UnderlinedCharacterRun> mUnderlinedCharacterRuns; ///< The underlined character run from markup-processor
BidirectionalLineRunIndex mBidirectionalLineIndex; ///< The last fetched bidirectional line info.
};
}
/**
+ * @brief Initializes a underlined character run to its defaults.
+ *
+ * @param[in,out] underlinedCharacterRun The underelined character run to initialize.
+ */
+void Initialize(UnderlinedCharacterRun& underlinedCharacterRun)
+{
+ underlinedCharacterRun.characterRun.characterIndex = 0u;
+ underlinedCharacterRun.characterRun.numberOfCharacters = 0u;
+}
+
+/**
* @brief Splits the tag string into the tag name and its attributes.
*
* The attributes are stored in a vector in the tag.
}
/**
- * @brief Processes a particular tag for the required run (color-run or font-run).
+ * @brief Processes a particular tag for the required run (color-run, font-run or underlined-character-run).
*
- * @tparam RunType Whether ColorRun or FontDescriptionRun
+ * @tparam RunType Whether ColorRun , FontDescriptionRun or UnderlinedCharacterRun
*
* @param[in/out] runsContainer The container containing all the runs
* @param[in/out] styleStack The style stack
* @param[in/out] markupProcessData The markup process data
* @param[in] fontRunIndex The font run index
* @param[in] colorRunIndex The color run index
+ * @param[in] underlinedCharacterRunIndex The underlined character run index
*/
-void ResizeModelVectors(MarkupProcessData& markupProcessData, const StyleStack::RunIndex fontRunIndex, const StyleStack::RunIndex colorRunIndex)
+void ResizeModelVectors(MarkupProcessData& markupProcessData, const StyleStack::RunIndex fontRunIndex, const StyleStack::RunIndex colorRunIndex, const StyleStack::RunIndex underlinedCharacterRunIndex)
{
markupProcessData.fontRuns.Resize(fontRunIndex);
markupProcessData.colorRuns.Resize(colorRunIndex);
+ markupProcessData.underlinedCharacterRuns.Resize(underlinedCharacterRunIndex);
#ifdef DEBUG_ENABLED
for(unsigned int i = 0; i < colorRunIndex; ++i)
StyleStack styleStack;
// Points the next free position in the vector of runs.
- StyleStack::RunIndex colorRunIndex = 0u;
- StyleStack::RunIndex fontRunIndex = 0u;
+ StyleStack::RunIndex colorRunIndex = 0u;
+ StyleStack::RunIndex fontRunIndex = 0u;
+ StyleStack::RunIndex underlinedCharacterRunIndex = 0u;
// check tag reference
int colorTagReference = 0u;
int fontTagReference = 0u;
int iTagReference = 0u;
int bTagReference = 0u;
+ int uTagReference = 0u;
// Give an initial default value to the model's vectors.
markupProcessData.colorRuns.Reserve(DEFAULT_VECTOR_SIZE);
markupProcessData.fontRuns.Reserve(DEFAULT_VECTOR_SIZE);
+ markupProcessData.underlinedCharacterRuns.Reserve(DEFAULT_VECTOR_SIZE);
// Get the mark-up string buffer.
const char* markupStringBuffer = markupString.c_str();
} // <i></i>
else if(TokenComparison(XHTML_U_TAG, tag.buffer, tag.length))
{
- // TODO: If !tag.isEndTag, then create a new underline run.
- // else Pop the top of the stack and set the number of characters of the run.
- } // <u></u>
+ ProcessTagForRun<UnderlinedCharacterRun>(
+ markupProcessData.underlinedCharacterRuns, styleStack, tag, characterIndex, underlinedCharacterRunIndex, uTagReference, [](const Tag& tag, UnderlinedCharacterRun& run) { });
+ } // <u></u>
else if(TokenComparison(XHTML_B_TAG, tag.buffer, tag.length))
{
ProcessTagForRun<FontDescriptionRun>(
}
// Resize the model's vectors.
- ResizeModelVectors(markupProcessData, fontRunIndex, colorRunIndex);
+ ResizeModelVectors(markupProcessData, fontRunIndex, colorRunIndex, underlinedCharacterRunIndex);
}
} // namespace Text
#include <dali-toolkit/internal/text/color-run.h>
#include <dali-toolkit/internal/text/embedded-item.h>
#include <dali-toolkit/internal/text/font-description-run.h>
+#include <dali-toolkit/internal/text/underlined-character-run.h>
namespace Dali
{
MarkupProcessData(Vector<ColorRun>& colorRuns,
Vector<FontDescriptionRun>& fontRuns,
Vector<EmbeddedItem>& items,
- Vector<Anchor>& anchors)
+ Vector<Anchor>& anchors,
+ Vector<UnderlinedCharacterRun>& underlinedCharacterRuns)
: colorRuns(colorRuns),
fontRuns(fontRuns),
items(items),
anchors(anchors),
+ underlinedCharacterRuns(underlinedCharacterRuns),
markupProcessedText()
{
}
- Vector<ColorRun>& colorRuns; ///< The color runs.
- Vector<FontDescriptionRun>& fontRuns; ///< The font description runs.
- Vector<EmbeddedItem>& items; ///< The embedded items.
- Vector<Anchor>& anchors; ///< The anchors.
- std::string markupProcessedText; ///< The mark-up string.
+ Vector<ColorRun>& colorRuns; ///< The color runs.
+ Vector<FontDescriptionRun>& fontRuns; ///< The font description runs.
+ Vector<EmbeddedItem>& items; ///< The embedded items.
+ Vector<Anchor>& anchors; ///< The anchors.
+ Vector<UnderlinedCharacterRun>& underlinedCharacterRuns; ///< The underlined character runs.
+ std::string markupProcessedText; ///< The mark-up string.
};
/**
const float ZERO(0.0f);
const float HALF(0.5f);
const float ONE(1.0f);
-const uint32_t DEFAULT_ATLAS_WIDTH = 512u;
-const uint32_t DEFAULT_ATLAS_HEIGHT = 512u;
-const uint32_t MAX_ATLAS_WIDTH = 1024u;
-const uint32_t MAX_ATLAS_HEIGHT = 1024u;
const uint32_t DOUBLE_PIXEL_PADDING = 4u;//Padding will be added twice to Atlas
const uint16_t NO_OUTLINE = 0u;
} // namespace
mRight(0.0f),
mUnderlinePosition(0.0f),
mUnderlineThickness(0.0f),
- mMeshRecordIndex(0u)
+ mMeshRecordIndex(0u),
+ mUnderlineChunkId(0u)
{
}
float mUnderlinePosition;
float mUnderlineThickness;
uint32_t mMeshRecordIndex;
+ uint32_t mUnderlineChunkId;
};
struct MaxBlockSize
void CacheGlyph(const GlyphInfo& glyph, FontId lastFontId, const AtlasGlyphManager::GlyphStyle& style, AtlasManager::AtlasSlot& slot)
{
+ const Size& defaultTextAtlasSize = mFontClient.GetDefaultTextAtlasSize(); //Retrieve default size of text-atlas-block from font-client.
+ const Size& maximumTextAtlasSize = mFontClient.GetMaximumTextAtlasSize(); //Retrieve maximum size of text-atlas-block from font-client.
+
const bool glyphNotCached = !mGlyphManager.IsCached(glyph.fontId, glyph.index, style, slot); // Check FontGlyphRecord vector for entry with glyph index and fontId
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "AddGlyphs fontID[%u] glyphIndex[%u] [%s]\n", glyph.fontId, glyph.index, (glyphNotCached) ? "not cached" : "cached");
// If CheckAtlas in AtlasManager::Add can't fit the bitmap in the current atlas it will create a new atlas
// Setting the block size and size of new atlas does not mean a new one will be created. An existing atlas may still surffice.
- uint32_t default_width = DEFAULT_ATLAS_WIDTH;
- uint32_t default_height = DEFAULT_ATLAS_HEIGHT;
+ uint32_t default_width = defaultTextAtlasSize.width;
+ uint32_t default_height = defaultTextAtlasSize.height;
while (
(blockSize.mNeededBlockWidth >= (default_width - (DOUBLE_PIXEL_PADDING + 1u)) ||
blockSize.mNeededBlockHeight >= (default_height - (DOUBLE_PIXEL_PADDING + 1u)))
&&
- (default_width < MAX_ATLAS_WIDTH &&
- default_height < MAX_ATLAS_HEIGHT))
+ (default_width < maximumTextAtlasSize.width &&
+ default_height < maximumTextAtlasSize.height))
{
default_width <<= 1u;
default_height <<= 1u;
float currentUnderlineThickness,
std::vector<MeshRecord>& meshContainer,
Vector<TextCacheEntry>& newTextCache,
- Vector<Extent>& extents)
+ Vector<Extent>& extents,
+ uint32_t underlineChunkId)
{
// Generate mesh data for this quad, plugging in our supplied position
AtlasManager::Mesh2D newMesh;
underlineGlyph,
currentUnderlinePosition,
currentUnderlineThickness,
- slot);
+ slot,
+ underlineChunkId);
}
void CreateActors(const std::vector<MeshRecord>& meshContainer,
const Vector2* const positionsBuffer = positions.Begin();
const Vector2 lineOffsetPosition(minLineOffset, 0.f);
+ //For septated underlined chunks. (this is for Markup case)
+ uint32_t underlineChunkId = 0u; // give id for each chunk.
+ bool isPreUnderlined = false; // status of underlined for previous glyph.
+
for(uint32_t i = 0, glyphSize = glyphs.Size(); i < glyphSize; ++i)
{
const GlyphInfo& glyph = *(glyphsBuffer + i);
}
lastUnderlinedFontId = glyph.fontId;
+
} // underline
AtlasGlyphManager::GlyphStyle style;
currentUnderlineThickness,
meshContainer,
newTextCache,
- extents);
+ extents,
+ underlineChunkId);
lastFontId = glyph.fontId; // Prevents searching for existing blocksizes when string of the same fontId.
}
currentUnderlineThickness,
meshContainerOutline,
newTextCache,
- extents);
+ extents,
+ 0u);
+ }
+
+
+ //The new underlined chunk. Add new id if they are not consecutive indices (this is for Markup case)
+ // Examples: "Hello <u>World</u> Hello <u>World</u>", "<u>World</u> Hello <u>World</u>", "<u> World</u> Hello <u>World</u>"
+ if( isPreUnderlined && (isPreUnderlined != isGlyphUnderlined))
+ {
+ underlineChunkId++;
}
+ //Keep status of underlined for previous glyph to check consecutive indices
+ isPreUnderlined = isGlyphUnderlined;
}
} // glyphs
bool underlineGlyph,
float underlinePosition,
float underlineThickness,
- AtlasManager::AtlasSlot& slot)
+ AtlasManager::AtlasSlot& slot,
+ uint32_t underlineChunkId)
{
if(slot.mImageId)
{
right,
baseLine,
underlinePosition,
- underlineThickness);
+ underlineThickness,
+ underlineChunkId);
}
return;
right,
baseLine,
underlinePosition,
- underlineThickness);
+ underlineThickness,
+ underlineChunkId);
}
}
}
float right,
float baseLine,
float underlinePosition,
- float underlineThickness)
+ float underlineThickness,
+ uint32_t underlineChunkId)
{
bool foundExtent = false;
for(Vector<Extent>::Iterator eIt = extents.Begin(),
eIt != eEndIt;
++eIt)
{
- if(Equals(baseLine, eIt->mBaseLine))
+ if(Equals(baseLine, eIt->mBaseLine) && underlineChunkId == eIt->mUnderlineChunkId)
{
foundExtent = true;
if(left < eIt->mLeft)
extent.mUnderlinePosition = underlinePosition;
extent.mUnderlineThickness = underlineThickness;
extent.mMeshRecordIndex = index;
+ extent.mUnderlineChunkId = underlineChunkId;
extents.PushBack(extent);
}
}
// Combine the two buffers
imageBuffer = CombineImageBuffer(imageBuffer, backgroundImageBuffer, bufferWidth, bufferHeight);
}
+
+ // Markup-Processor
+
+ imageBuffer = ApplyMarkupProcessorOnPixelBuffer(imageBuffer, bufferWidth, bufferHeight, ignoreHorizontalAlignment, pixelFormat, penX, penY);
+
}
// Create the final PixelData for the combined image buffer
return combinedPixelBuffer;
}
+Devel::PixelBuffer Typesetter::ApplyMarkupProcessorOnPixelBuffer(Devel::PixelBuffer topPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, int horizontalOffset, int verticalOffset)
+{
+ // Apply the markup-Processor if enabled
+ const bool markupProcessorEnabled = mModel->IsMarkupProcessorEnabled();
+ if(markupProcessorEnabled)
+ {
+ // Underline-tags (this is for Markup case)
+ // Get the underline runs.
+ const Length numberOfUnderlineRuns = mModel->GetNumberOfUnderlineRuns();
+ Vector<GlyphRun> underlineRuns;
+ underlineRuns.Resize(numberOfUnderlineRuns);
+ mModel->GetUnderlineRuns(underlineRuns.Begin(), 0u, numberOfUnderlineRuns);
+
+ // Iterate on the consecutive underlined glyph run and connect them into one chunk of underlined characters.
+ Vector<GlyphRun>::ConstIterator itGlyphRun = underlineRuns.Begin();
+ Vector<GlyphRun>::ConstIterator endItGlyphRun = underlineRuns.End();
+ GlyphIndex startGlyphIndex, endGlyphIndex;
+
+ //The outer loop to iterate on the separated chunks of underlined glyph runs
+ while(itGlyphRun != endItGlyphRun)
+ {
+ startGlyphIndex = itGlyphRun->glyphIndex;
+ endGlyphIndex = startGlyphIndex;
+ //The inner loop to make a connected underline for the consecutive characters
+ do
+ {
+ endGlyphIndex += itGlyphRun->numberOfGlyphs;
+ itGlyphRun++;
+ } while(itGlyphRun != endItGlyphRun && itGlyphRun->glyphIndex == endGlyphIndex);
+
+ endGlyphIndex--;
+
+ // Create the image buffer for underline
+ Devel::PixelBuffer underlineImageBuffer = CreateImageBuffer(bufferWidth, bufferHeight, Typesetter::STYLE_UNDERLINE, ignoreHorizontalAlignment, pixelFormat, horizontalOffset, verticalOffset, startGlyphIndex, endGlyphIndex);
+ // Combine the two buffers
+ topPixelBuffer = CombineImageBuffer(topPixelBuffer, underlineImageBuffer, bufferWidth, bufferHeight);
+ }
+ }
+
+ return topPixelBuffer;
+}
+
Typesetter::Typesetter(const ModelInterface* const model)
: mModel(new ViewModel(model))
{
*/
Devel::PixelBuffer CombineImageBuffer(Devel::PixelBuffer topPixelBuffer, Devel::PixelBuffer bottomPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeightbool);
+ /**
+ * @brief Apply behaviour of tags if the markup-processor is enabled.
+ *
+ * The properties on TextLabel override the behavior of Markup.
+ * Because the markup will be the bottom layer buffer
+ * - i.e: If you set property UNDERLINE to enabled and blue.
+ * And the TEXT is "<color value='green'>Hello</color> <u>World</u> <i>Hello</i> <b>World</b>".
+ * Then the output of the whole text is underlined by blue line.
+ *
+ * @param[in] topPixelBuffer The top layer buffer.
+ * @param[in] bufferWidth The width of the image buffer.
+ * @param[in] bufferHeight The height of the image buffer.
+ * @param[in] ignoreHorizontalAlignment Whether to ignore the horizontal alignment, not ignored by default.
+ * @param[in] pixelFormat The format of the pixel in the image that the text is rendered as (i.e. either Pixel::BGRA8888 or Pixel::L8).
+ * @param[in] horizontalOffset The horizontal offset to be added to the glyph's position.
+ * @param[in] verticalOffset The vertical offset to be added to the glyph's position.
+ *
+ * @return The image buffer with the markup.
+ */
+ Devel::PixelBuffer ApplyMarkupProcessorOnPixelBuffer(Devel::PixelBuffer topPixelBuffer, const unsigned int bufferWidth, const unsigned int bufferHeight, bool ignoreHorizontalAlignment, Pixel::Format pixelFormat, int horizontalOffset, int verticalOffset);
+
protected:
/**
* @brief A reference counted object may only be deleted by calling Unreference().
return mModel->IsBackgroundEnabled();
}
+bool ViewModel::IsMarkupProcessorEnabled() const
+{
+ return mModel->IsMarkupProcessorEnabled();
+}
+
void ViewModel::ElideGlyphs()
{
mIsTextElided = false;
bool IsBackgroundEnabled() const override;
/**
+ * @copydoc ModelInterface::IsMarkupProcessorEnabled()
+ */
+ bool IsMarkupProcessorEnabled() const override;
+
+ /**
* @brief Does the text elide.
*
* It stores a copy of the visible glyphs and removes as many glyphs as needed
Vector<Character>& srcCharacters = mModel->mLogicalModel->mText;
Vector<Character> displayCharacters;
bool useHiddenText = false;
- if(mHiddenInput && mEventData != NULL && !mEventData->mIsShowingPlaceholderText)
+ if(mHiddenInput && mEventData != nullptr && !mEventData->mIsShowingPlaceholderText)
{
mHiddenInput->Substitute(srcCharacters, displayCharacters);
useHiddenText = true;
TextAbstraction::FontDescription defaultFontDescription;
TextAbstraction::PointSize26Dot6 defaultPointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE * mFontSizeScale;
- if(IsShowingPlaceholderText() && mEventData && (NULL != mEventData->mPlaceholderFont))
+ //Get the number of points per one unit of point-size
+ uint32_t numberOfPointsPerOneUnitOfPointSize = mFontClient.GetNumberOfPointsPerOneUnitOfPointSize();
+
+ if(IsShowingPlaceholderText() && mEventData && (nullptr != mEventData->mPlaceholderFont))
{
// If the placeholder font is set specifically, only placeholder font is changed.
defaultFontDescription = mEventData->mPlaceholderFont->mFontDescription;
if(mEventData->mPlaceholderFont->sizeDefined)
{
- defaultPointSize = mEventData->mPlaceholderFont->mDefaultPointSize * mFontSizeScale * 64u;
+ defaultPointSize = mEventData->mPlaceholderFont->mDefaultPointSize * mFontSizeScale * numberOfPointsPerOneUnitOfPointSize;
}
}
- else if(NULL != mFontDefaults)
+ else if(nullptr != mFontDefaults)
{
// Set the normal font and the placeholder font.
defaultFontDescription = mFontDefaults->mFontDescription;
if(mTextFitEnabled)
{
- defaultPointSize = mFontDefaults->mFitPointSize * 64u;
+ defaultPointSize = mFontDefaults->mFitPointSize * numberOfPointsPerOneUnitOfPointSize;
}
else
{
- defaultPointSize = mFontDefaults->mDefaultPointSize * mFontSizeScale * 64u;
+ defaultPointSize = mFontDefaults->mDefaultPointSize * mFontSizeScale * numberOfPointsPerOneUnitOfPointSize;
}
}
// Create the 'number of glyphs' per character and the glyph to character conversion tables.
mModel->mVisualModel->CreateGlyphsPerCharacterTable(startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters);
mModel->mVisualModel->CreateCharacterToGlyphTable(startIndex, mTextUpdateInfo.mStartGlyphIndex, requestedNumberOfCharacters);
- updated = true;
+
+ updated = true;
}
const Length numberOfGlyphs = glyphs.Count() - currentNumberOfGlyphs;
updated = true;
}
- if((NULL != mEventData) &&
+ if((nullptr != mEventData) &&
mEventData->mPreEditFlag &&
(0u != mModel->mVisualModel->mCharactersToGlyph.Count()))
{
underlineRun.glyphIndex = attrData.startIndex + numberOfCommit;
underlineRun.numberOfGlyphs = numberOfIndices;
mModel->mVisualModel->mUnderlineRuns.PushBack(underlineRun);
+
+ //Mark-up processor case
+ if(mModel->mVisualModel->IsMarkupProcessorEnabled())
+ {
+ CopyUnderlinedFromLogicalToVisualModels(false);
+ }
break;
}
case Dali::InputMethodContext::PreeditStyle::REVERSE:
underlineRun.glyphIndex = attrData.startIndex + numberOfCommit;
underlineRun.numberOfGlyphs = numberOfIndices;
mModel->mVisualModel->mUnderlineRuns.PushBack(underlineRun);
+
+ //Mark-up processor case
+ if(mModel->mVisualModel->IsMarkupProcessorEnabled())
+ {
+ CopyUnderlinedFromLogicalToVisualModels(false);
+ }
break;
}
case Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_2:
underlineRun.glyphIndex = attrData.startIndex + numberOfCommit;
underlineRun.numberOfGlyphs = numberOfIndices;
mModel->mVisualModel->mUnderlineRuns.PushBack(underlineRun);
+
+ //Mark-up processor case
+ if(mModel->mVisualModel->IsMarkupProcessorEnabled())
+ {
+ CopyUnderlinedFromLogicalToVisualModels(false);
+ }
break;
}
case Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_3:
underlineRun.glyphIndex = attrData.startIndex + numberOfCommit;
underlineRun.numberOfGlyphs = numberOfIndices;
mModel->mVisualModel->mUnderlineRuns.PushBack(underlineRun);
+
+ //Mark-up processor case
+ if(mModel->mVisualModel->IsMarkupProcessorEnabled())
+ {
+ CopyUnderlinedFromLogicalToVisualModels(false);
+ }
break;
}
case Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_4:
underlineRun.glyphIndex = attrData.startIndex + numberOfCommit;
underlineRun.numberOfGlyphs = numberOfIndices;
mModel->mVisualModel->mUnderlineRuns.PushBack(underlineRun);
+
+ //Mark-up processor case
+ if(mModel->mVisualModel->IsMarkupProcessorEnabled())
+ {
+ CopyUnderlinedFromLogicalToVisualModels(false);
+ }
break;
}
case Dali::InputMethodContext::PreeditStyle::NONE:
updated = true;
}
+ if((NO_OPERATION != (SHAPE_TEXT & operations)) &&
+ ! ((nullptr != mEventData) &&
+ mEventData->mPreEditFlag &&
+ (0u != mModel->mVisualModel->mCharactersToGlyph.Count())))
+ {
+ //Mark-up processor case
+ if(mModel->mVisualModel->IsMarkupProcessorEnabled())
+ {
+ CopyUnderlinedFromLogicalToVisualModels(true);
+ }
+
+ updated = true;
+ }
+
+
// The estimated number of lines. Used to avoid reallocations when layouting.
mTextUpdateInfo.mEstimatedNumberOfLines = std::max(mModel->mVisualModel->mLines.Count(), mModel->mLogicalModel->mParagraphInfo.Count());
float Controller::Impl::GetDefaultFontLineHeight()
{
FontId defaultFontId = 0u;
- if(NULL == mFontDefaults)
+ if(nullptr == mFontDefaults)
{
TextAbstraction::FontDescription fontDescription;
defaultFontId = mFontClient.GetFontId(fontDescription, TextAbstraction::FontClient::DEFAULT_POINT_SIZE * mFontSizeScale);
void Controller::Impl::ChangeState(EventData::State newState)
{
- if(NULL == mEventData)
+ if(nullptr == mEventData)
{
// Nothing to do if there is no text input.
return;
CharacterIndex Controller::Impl::CalculateNewCursorIndex(CharacterIndex index) const
{
- if(NULL == mEventData)
+ if(nullptr == mEventData)
{
// Nothing to do if there is no text input.
return 0u;
void Controller::Impl::UpdateCursorPosition(const CursorInfo& cursorInfo)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->Controller::UpdateCursorPosition %p\n", this);
- if(NULL == mEventData)
+ if(nullptr == mEventData)
{
// Nothing to do if there is no text input.
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::UpdateCursorPosition no event data\n");
void Controller::Impl::RequestRelayout()
{
- if(NULL != mControlInterface)
+ if(nullptr != mControlInterface)
{
mControlInterface->RequestTextRelayout();
}
return actor;
}
+void Controller::Impl::CopyUnderlinedFromLogicalToVisualModels(bool shouldClearPreUnderlineRuns)
+{
+ //Underlined character runs for markup-processor
+ const Vector<UnderlinedCharacterRun>& underlinedCharacterRuns = mModel->mLogicalModel->mUnderlinedCharacterRuns;
+ const Vector<GlyphIndex>& charactersToGlyph = mModel->mVisualModel->mCharactersToGlyph;
+ const Vector<Length>& glyphsPerCharacter = mModel->mVisualModel->mGlyphsPerCharacter;
+
+ if(shouldClearPreUnderlineRuns)
+ {
+ mModel->mVisualModel->mUnderlineRuns.Clear();
+ }
+
+ for(Vector<UnderlinedCharacterRun>::ConstIterator it = underlinedCharacterRuns.Begin(), endIt = underlinedCharacterRuns.End(); it != endIt; ++it)
+ {
+ CharacterIndex characterIndex = it->characterRun.characterIndex;
+ Length numberOfCharacters = it->characterRun.numberOfCharacters;
+ for(Length index=0u; index<numberOfCharacters; index++)
+ {
+ GlyphRun underlineGlyphRun;
+ underlineGlyphRun.glyphIndex = charactersToGlyph[characterIndex + index];
+ underlineGlyphRun.numberOfGlyphs = glyphsPerCharacter[characterIndex + index];
+ mModel->mVisualModel->mUnderlineRuns.PushBack(underlineGlyphRun);
+ }
+ }
+}
+
} // namespace Text
} // namespace Toolkit
// Declared private and left undefined to avoid copies.
Impl& operator=(const Impl&);
+ /**
+ * @brief Copy Underlined-Character-Runs from Logical-Model to Underlined-Glyph-Runs in Visual-Model
+ *
+ * @param shouldClearPreUnderlineRuns Whether should clear the existing Underlined-Glyph-Runs in Visual-Model
+ */
+ void CopyUnderlinedFromLogicalToVisualModels(bool shouldClearPreUnderlineRuns);
+
public:
ControlInterface* mControlInterface; ///< Reference to the text controller.
EditableControlInterface* mEditableControlInterface; ///< Reference to the editable text controller.
{
namespace Text
{
-Vector3 Controller::Relayouter::GetNaturalSize(Controller& controller)
-{
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->Controller::GetNaturalSize\n");
- Vector3 naturalSize;
- // Make sure the model is up-to-date before layouting
- controller.ProcessModifyEvents();
+Size Controller::Relayouter::CalculateLayoutSizeOnRequiredControllerSize(Controller& controller, const Size& requestedControllerSize, const OperationsMask& requestedOperationsMask, bool restoreLinesAndGlyphPositions)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->CalculateLayoutSizeOnRequiredControllerSize\n");
+ Size calculatedLayoutSize;
Controller::Impl& impl = *controller.mImpl;
ModelPtr& model = impl.mModel;
VisualModelPtr& visualModel = model->mVisualModel;
- if(impl.mRecalculateNaturalSize)
+
+ // Store the pending operations mask so that it can be restored later on with no modifications made on it
+ // while getting the natural size were reflected on the original mask.
+ OperationsMask operationsPendingBackUp = static_cast<OperationsMask>(impl.mOperationsPending);
+
+ // This is a hotfix for side effect on Scrolling, LineWrap and Invalid position of cursor in TextEditor after calling CalculateLayoutSizeOnRequiredControllerSize.
+ // The number of lines and glyph-positions inside visualModel have been changed by calling DoRelayout with requestedControllerSize.
+ // Store the mLines and mGlyphPositions from visualModel so that they can be restored later on with no modifications made on them.
+ //TODO: Refactor "DoRelayout" and extract common code of size calculation without modifying attributes of mVisualModel, and then blah, blah, etc.
+ Vector<LineRun> linesBackup = visualModel->mLines;
+ Vector<Vector2> glyphPositionsBackup = visualModel->mGlyphPositions;
+
+ // Operations that can be done only once until the text changes.
+ const OperationsMask onlyOnceOperations = static_cast<OperationsMask>(CONVERT_TO_UTF32 |
+ GET_SCRIPTS |
+ VALIDATE_FONTS |
+ GET_LINE_BREAKS |
+ BIDI_INFO |
+ SHAPE_TEXT |
+ GET_GLYPH_METRICS);
+
+ // Set the update info to relayout the whole text.
+ TextUpdateInfo& textUpdateInfo = impl.mTextUpdateInfo;
+ textUpdateInfo.mParagraphCharacterIndex = 0u;
+ textUpdateInfo.mRequestedNumberOfCharacters = model->mLogicalModel->mText.Count();
+
+ // Make sure the model is up-to-date before layouting
+ impl.UpdateModel(onlyOnceOperations);
+
+ // Get a reference to the pending operations member
+ OperationsMask& operationsPending = impl.mOperationsPending;
+
+ // Layout the text for the new width.
+ operationsPending = static_cast<OperationsMask>(operationsPending | requestedOperationsMask);
+
+ // Store the actual control's size to restore later.
+ const Size actualControlSize = visualModel->mControlSize;
+
+ DoRelayout(controller,
+ requestedControllerSize,
+ static_cast<OperationsMask>(onlyOnceOperations |
+ requestedOperationsMask),
+ calculatedLayoutSize);
+
+
+ // Clear the update info. This info will be set the next time the text is updated.
+ textUpdateInfo.Clear();
+ textUpdateInfo.mClearAll = true;
+
+ // Restore the actual control's size.
+ visualModel->mControlSize = actualControlSize;
+ // Restore the previously backed-up pending operations' mask without the only once operations.
+ impl.mOperationsPending = static_cast<OperationsMask>(operationsPendingBackUp & ~onlyOnceOperations);
+
+ // Restore the previously backed-up mLines and mGlyphPositions from visualModel.
+ if(restoreLinesAndGlyphPositions)
{
- // Store the pending operations mask so that it can be restored later on with no modifications made on it
- // while getting the natural size were reflected on the original mask.
- OperationsMask operationsPendingBackUp = static_cast<OperationsMask>(impl.mOperationsPending);
- // Operations that can be done only once until the text changes.
- const OperationsMask onlyOnceOperations = static_cast<OperationsMask>(CONVERT_TO_UTF32 |
- GET_SCRIPTS |
- VALIDATE_FONTS |
- GET_LINE_BREAKS |
- BIDI_INFO |
- SHAPE_TEXT |
- GET_GLYPH_METRICS);
+ visualModel->mLines = linesBackup;
+ visualModel->mGlyphPositions = glyphPositionsBackup;
+ }
- // Set the update info to relayout the whole text.
- TextUpdateInfo& textUpdateInfo = impl.mTextUpdateInfo;
- textUpdateInfo.mParagraphCharacterIndex = 0u;
- textUpdateInfo.mRequestedNumberOfCharacters = model->mLogicalModel->mText.Count();
+ return calculatedLayoutSize;
+}
- // Make sure the model is up-to-date before layouting
- impl.UpdateModel(onlyOnceOperations);
- // Get a reference to the pending operations member
- OperationsMask& operationsPending = impl.mOperationsPending;
+Vector3 Controller::Relayouter::GetNaturalSize(Controller& controller)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->Controller::GetNaturalSize\n");
+ Vector3 naturalSizeVec3;
- // Layout the text for the new width.
- operationsPending = static_cast<OperationsMask>(operationsPending | LAYOUT | REORDER);
+ // Make sure the model is up-to-date before layouting
+ controller.ProcessModifyEvents();
+
+ Controller::Impl& impl = *controller.mImpl;
+ ModelPtr& model = impl.mModel;
+ VisualModelPtr& visualModel = model->mVisualModel;
+
+ if(impl.mRecalculateNaturalSize)
+ {
+ Size naturalSize;
- // Store the actual control's size to restore later.
- const Size actualControlSize = visualModel->mControlSize;
+ // Layout the text for the new width.
+ OperationsMask requestedOperationsMask = static_cast<OperationsMask>(LAYOUT | REORDER);
+ Size sizeMaxWidthAndMaxHeight = Size(MAX_FLOAT, MAX_FLOAT);
- DoRelayout(controller,
- Size(MAX_FLOAT, MAX_FLOAT),
- static_cast<OperationsMask>(onlyOnceOperations |
- LAYOUT | REORDER),
- naturalSize.GetVectorXY());
+ naturalSize = CalculateLayoutSizeOnRequiredControllerSize(controller, sizeMaxWidthAndMaxHeight, requestedOperationsMask, true);
// Stores the natural size to avoid recalculate it again
// unless the text/style changes.
- visualModel->SetNaturalSize(naturalSize.GetVectorXY());
+ visualModel->SetNaturalSize(naturalSize);
+ naturalSizeVec3 = naturalSize;
impl.mRecalculateNaturalSize = false;
- // Clear the update info. This info will be set the next time the text is updated.
- textUpdateInfo.Clear();
- textUpdateInfo.mClearAll = true;
-
- // Restore the actual control's size.
- visualModel->mControlSize = actualControlSize;
- // Restore the previously backed-up pending operations' mask without the only once operations.
- impl.mOperationsPending = static_cast<OperationsMask>(operationsPendingBackUp & ~onlyOnceOperations);
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize calculated %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize calculated %f,%f,%f\n", naturalSizeVec3.x, naturalSizeVec3.y, naturalSizeVec3.z);
}
else
{
- naturalSize = visualModel->GetNaturalSize();
+ naturalSizeVec3 = visualModel->GetNaturalSize();
- DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize cached %f,%f,%f\n", naturalSize.x, naturalSize.y, naturalSize.z);
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::GetNaturalSize cached %f,%f,%f\n", naturalSizeVec3.x, naturalSizeVec3.y, naturalSizeVec3.z);
}
- naturalSize.x = ConvertToEven(naturalSize.x);
- naturalSize.y = ConvertToEven(naturalSize.y);
+ naturalSizeVec3.x = ConvertToEven(naturalSizeVec3.x);
+ naturalSizeVec3.y = ConvertToEven(naturalSizeVec3.y);
- return naturalSize;
+ return naturalSizeVec3;
}
bool Controller::Relayouter::CheckForTextFit(Controller& controller, float pointSize, const Size& layoutSize)
float Controller::Relayouter::GetHeightForWidth(Controller& controller, float width)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->Controller::GetHeightForWidth %p width %f\n", &controller, width);
+
// Make sure the model is up-to-date before layouting
controller.ProcessModifyEvents();
TextUpdateInfo& textUpdateInfo = impl.mTextUpdateInfo;
Size layoutSize;
+
if(fabsf(width - visualModel->mControlSize.width) > Math::MACHINE_EPSILON_1000 ||
textUpdateInfo.mFullRelayoutNeeded ||
textUpdateInfo.mClearAll)
{
- // Store the pending operations mask so that it can be restored later on with no modifications made on it
- // while getting the natural size were reflected on the original mask.
- OperationsMask operationsPendingBackUp = static_cast<OperationsMask>(impl.mOperationsPending);
- // Operations that can be done only once until the text changes.
- const OperationsMask onlyOnceOperations = static_cast<OperationsMask>(CONVERT_TO_UTF32 |
- GET_SCRIPTS |
- VALIDATE_FONTS |
- GET_LINE_BREAKS |
- BIDI_INFO |
- SHAPE_TEXT |
- GET_GLYPH_METRICS);
-
- // Set the update info to relayout the whole text.
- textUpdateInfo.mParagraphCharacterIndex = 0u;
- textUpdateInfo.mRequestedNumberOfCharacters = model->mLogicalModel->mText.Count();
-
- // Make sure the model is up-to-date before layouting
- impl.UpdateModel(onlyOnceOperations);
-
- // Get a reference to the pending operations member
- OperationsMask& operationsPending = impl.mOperationsPending;
// Layout the text for the new width.
- operationsPending = static_cast<OperationsMask>(operationsPending | LAYOUT);
+ OperationsMask requestedOperationsMask = static_cast<OperationsMask>(LAYOUT);
+ Size sizeRequestedWidthAndMaxHeight = Size(width, MAX_FLOAT);
- // Store the actual control's width.
- const float actualControlWidth = visualModel->mControlSize.width;
+ // Skip restore, because if GetHeightForWidth called before rendering and layouting then visualModel->mControlSize will be zero which will make LineCount zero.
+ // The implementation of Get LineCount property depends on calling GetHeightForWidth then read mLines.Count() from visualModel direct.
+ // If the LineCount property is requested before rendering and layouting then the value will be zero, which is incorrect.
+ // So we will not restore the previously backed-up mLines and mGlyphPositions from visualModel in such case.
+ bool restoreLinesAndGlyphPositions = visualModel->mControlSize.width>0 && visualModel->mControlSize.height>0;
- DoRelayout(controller,
- Size(width, MAX_FLOAT),
- static_cast<OperationsMask>(onlyOnceOperations |
- LAYOUT),
- layoutSize);
-
- // Clear the update info. This info will be set the next time the text is updated.
- textUpdateInfo.Clear();
- textUpdateInfo.mClearAll = true;
+ layoutSize = CalculateLayoutSizeOnRequiredControllerSize(controller, sizeRequestedWidthAndMaxHeight, requestedOperationsMask, restoreLinesAndGlyphPositions);
- // Restore the actual control's width.
- visualModel->mControlSize.width = actualControlWidth;
- // Restore the previously backed-up pending operations' mask without the only once operations.
- impl.mOperationsPending = static_cast<OperationsMask>(operationsPendingBackUp & ~onlyOnceOperations);
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth calculated %f\n", layoutSize.height);
}
else
* @param[in] controlSize The control size
*/
static void CalculateVerticalOffset(Controller& controller, const Size& controlSize);
+
+ /**
+ * @brief Calculates the layout size of control according to @p requestedControllerSize and @p requestedOperationsMask
+ *
+ * GetNaturalSize() and GetHeightForWidth() calls this method.
+ *
+ * @param[in] controller The controller to calcualte size on it.
+ * @param[in] requestedControllerSize The requested size of controller to calcualte layout size on it.
+ * @param[in] requestedOperationsMask The requested operations-mask to calcualte layout size according to it.
+ * @param[in] restoreLinesAndGlyphPositions whether to restore lines and glyph-positions to status before requesting calculation on size.
+ *
+ * @return The calculated layout-size.
+ */
+ static Size CalculateLayoutSizeOnRequiredControllerSize(Controller& controller, const Size& requestedControllerSize, const OperationsMask& requestedOperationsMask, bool restoreLinesAndGlyphPositions);
+
};
} // namespace Text
MarkupProcessData markupProcessData(logicalModel->mColorRuns,
logicalModel->mFontDescriptionRuns,
logicalModel->mEmbeddedItems,
- logicalModel->mAnchors);
+ logicalModel->mAnchors,
+ logicalModel->mUnderlinedCharacterRuns);
Length textSize = 0u;
const uint8_t* utf8 = NULL;
GetText(text);
SetText(text);
}
+
+ mImpl->mModel->mVisualModel->SetMarkupProcessorEnabled(enable);
}
bool Controller::IsMarkupProcessorEnabled() const
* @return The background state.
*/
virtual bool IsBackgroundEnabled() const = 0;
+
+ /**
+ * @brief Returns whether markup-processor is enabled or not.
+ *
+ * @return The markup-processor state.
+ */
+ virtual bool IsMarkupProcessorEnabled() const = 0;
};
} // namespace Text
return mVisualModel->IsBackgroundEnabled();
}
+bool Model::IsMarkupProcessorEnabled() const
+{
+ return mVisualModel->IsMarkupProcessorEnabled();
+}
+
Model::Model()
: mLogicalModel(),
mVisualModel(),
*/
bool IsBackgroundEnabled() const override;
+ /**
+ * @copydoc ModelInterface::IsMarkupProcessorEnabled()
+ */
+ bool IsMarkupProcessorEnabled() const override;
+
private: // Private contructors & copy operator.
/**
* @brief Private constructor.
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_UNDERLINED_CHARACTER_RUN_H
+#define DALI_TOOLKIT_TEXT_UNDERLINED_CHARACTER_RUN_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/math/vector4.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/character-run.h>
+#include <dali-toolkit/internal/text/glyph-run.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+/**
+ * @brief Run of underlined characters with same properties.
+ */
+struct UnderlinedCharacterRun
+{
+ CharacterRun characterRun; ///< The initial character index and the number of characters of the run.
+ //TODO: add properties like color, height and style
+ //Vector4 color; ///< The color of underline.
+ //float height; ///< The height of underline.
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_UNDERLINED_CHARACTER_RUN_H
mBackgroundEnabled = enabled;
}
+void VisualModel::SetMarkupProcessorEnabled(bool enabled)
+{
+ mMarkupProcessorEnabled = enabled;
+}
+
const Vector4& VisualModel::GetTextColor() const
{
return mTextColor;
return mBackgroundEnabled;
}
+bool VisualModel::IsMarkupProcessorEnabled() const
+{
+ return mMarkupProcessorEnabled;
+}
+
Length VisualModel::GetNumberOfUnderlineRuns() const
{
return mUnderlineRuns.Count();
mCachedLineIndex(0u),
mUnderlineEnabled(false),
mUnderlineColorSet(false),
- mBackgroundEnabled(false)
+ mBackgroundEnabled(false),
+ mMarkupProcessorEnabled(false)
{
}
*/
bool IsBackgroundEnabled() const;
+ /**
+ * @brief Sets whether the text has a markup-processor or not.
+ *
+ * @param[in] enabled true if the text has a markup-processor.
+ */
+ void SetMarkupProcessorEnabled(bool enabled);
+
+ /**
+ * @brief Returns whether the text has a markup-processor or not.
+ *
+ * @return whether the text has a markup-processor or not.
+ */
+ bool IsMarkupProcessorEnabled() const;
+
protected:
/**
* @brief A reference counted object may only be deleted by calling Unreference().
bool mUnderlineEnabled : 1; ///< Underline enabled flag
bool mUnderlineColorSet : 1; ///< Has the underline color been explicitly set?
bool mBackgroundEnabled : 1; ///< Background enabled flag
+ bool mMarkupProcessorEnabled : 1; ///< Markup-processor enabled flag
};
} // namespace Text
}
}
-void VectorAnimationManager::Process()
+void VectorAnimationManager::Process(bool postProcessor)
{
for(auto&& iter : mEventCallbacks)
{
/**
* @copydoc Dali::Integration::Processor::Process()
*/
- void Process() override;
+ void Process(bool postProcessor) override;
private:
// Undefined
namespace
{
constexpr auto LOOP_FOREVER = -1;
-constexpr auto NANOSECONDS_PER_SECOND(1e+9);
+constexpr auto MICROSECONDS_PER_SECOND(1e+6);
#if defined(DEBUG_ENABLED)
Debug::Filter* gVectorAnimationLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_VECTOR_ANIMATION");
mStopBehavior(DevelImageVisual::StopBehavior::CURRENT_FRAME),
mLoopingMode(DevelImageVisual::LoopingMode::RESTART),
mNextFrameStartTime(),
- mFrameDurationNanoSeconds(0),
+ mFrameDurationMicroSeconds(MICROSECONDS_PER_SECOND / 60.0f),
mFrameRate(60.0f),
mCurrentFrame(0),
mTotalFrame(0),
mStartFrame(0),
mEndFrame(0),
+ mDroppedFrames(0),
mWidth(0),
mHeight(0),
mAnimationDataIndex(0),
mEndFrame = mTotalFrame - 1;
- mFrameRate = mVectorRenderer.GetFrameRate();
- mFrameDurationNanoSeconds = NANOSECONDS_PER_SECOND / mFrameRate;
+ mFrameRate = mVectorRenderer.GetFrameRate();
+ mFrameDurationMicroSeconds = MICROSECONDS_PER_SECOND / mFrameRate;
uint32_t width, height;
mVectorRenderer.GetDefaultSize(width, height);
bool VectorAnimationTask::Rasterize()
{
bool stopped = false;
- uint32_t currentFrame;
+ uint32_t currentFrame, droppedFrames = 0;
{
ConditionalWait::ScopedLock lock(mConditionalWait);
// The task will be destroyed. We don't need rasterization.
return false;
}
+ droppedFrames = mDroppedFrames;
}
ApplyAnimationData();
if(mPlayState == PlayState::PLAYING && mUpdateFrameNumber)
{
- mCurrentFrame = mForward ? mCurrentFrame + 1 : mCurrentFrame - 1;
+ mCurrentFrame = mForward ? mCurrentFrame + droppedFrames + 1 : mCurrentFrame - droppedFrames - 1;
Dali::ClampInPlace(mCurrentFrame, mStartFrame, mEndFrame);
}
return frame;
}
-std::chrono::time_point<std::chrono::system_clock> VectorAnimationTask::CalculateNextFrameTime(bool renderNow)
+VectorAnimationTask::TimePoint VectorAnimationTask::CalculateNextFrameTime(bool renderNow)
{
+ uint32_t droppedFrames = 0;
+
// std::chrono::time_point template has second parameter duration which defaults to the std::chrono::system_clock supported
// duration. In some C++11 implementations it is a milliseconds duration, so it fails to compile unless mNextFrameStartTime
// is casted to use the default duration.
- mNextFrameStartTime = std::chrono::time_point_cast<std::chrono::time_point<std::chrono::system_clock>::duration>(
- mNextFrameStartTime + std::chrono::nanoseconds(mFrameDurationNanoSeconds));
- auto current = std::chrono::system_clock::now();
- if(renderNow || mNextFrameStartTime < current)
+ mNextFrameStartTime = std::chrono::time_point_cast<TimePoint::duration>(mNextFrameStartTime + std::chrono::microseconds(mFrameDurationMicroSeconds));
+ auto current = std::chrono::system_clock::now();
+ if(renderNow)
+ {
+ mNextFrameStartTime = current;
+ }
+ else if(mNextFrameStartTime < current)
{
+ while(current > std::chrono::time_point_cast<TimePoint::duration>(mNextFrameStartTime + std::chrono::microseconds(mFrameDurationMicroSeconds)))
+ {
+ droppedFrames++;
+ mNextFrameStartTime = std::chrono::time_point_cast<TimePoint::duration>(mNextFrameStartTime + std::chrono::microseconds(mFrameDurationMicroSeconds));
+ }
+
+ {
+ ConditionalWait::ScopedLock lock(mConditionalWait);
+ mDroppedFrames = droppedFrames;
+ }
+
mNextFrameStartTime = current;
}
+
return mNextFrameStartTime;
}
-std::chrono::time_point<std::chrono::system_clock> VectorAnimationTask::GetNextFrameTime()
+VectorAnimationTask::TimePoint VectorAnimationTask::GetNextFrameTime()
{
return mNextFrameStartTime;
}
public:
using UploadCompletedSignalType = Dali::VectorAnimationRenderer::UploadCompletedSignalType;
+ using TimePoint = std::chrono::time_point<std::chrono::system_clock>;
+
/**
* Flags for re-sending data to the vector animation thread
*/
* @brief Calculates the time for the next frame rasterization.
* @return The time for the next frame rasterization.
*/
- std::chrono::time_point<std::chrono::system_clock> CalculateNextFrameTime(bool renderNow);
+ TimePoint CalculateNextFrameTime(bool renderNow);
/**
* @brief Gets the time for the next frame rasterization.
* @return The time for the next frame rasterization.
*/
- std::chrono::time_point<std::chrono::system_clock> GetNextFrameTime();
+ TimePoint GetNextFrameTime();
private:
/**
PAUSED ///< The animation is paused
};
- std::string mUrl;
- VectorAnimationRenderer mVectorRenderer;
- AnimationData mAnimationData[2];
- VectorAnimationThread& mVectorAnimationThread;
- ConditionalWait mConditionalWait;
- std::unique_ptr<EventThreadCallback> mAnimationFinishedTrigger;
- PlayState mPlayState;
- DevelImageVisual::StopBehavior::Type mStopBehavior;
- DevelImageVisual::LoopingMode::Type mLoopingMode;
- std::chrono::time_point<std::chrono::system_clock> mNextFrameStartTime;
- int64_t mFrameDurationNanoSeconds;
- float mFrameRate;
- uint32_t mCurrentFrame;
- uint32_t mTotalFrame;
- uint32_t mStartFrame;
- uint32_t mEndFrame;
- uint32_t mWidth;
- uint32_t mHeight;
- uint32_t mAnimationDataIndex;
- int32_t mLoopCount;
- int32_t mCurrentLoop;
- bool mForward;
- bool mUpdateFrameNumber;
- bool mNeedAnimationFinishedTrigger;
- bool mAnimationDataUpdated;
- bool mDestroyTask;
+ std::string mUrl;
+ VectorAnimationRenderer mVectorRenderer;
+ AnimationData mAnimationData[2];
+ VectorAnimationThread& mVectorAnimationThread;
+ ConditionalWait mConditionalWait;
+ std::unique_ptr<EventThreadCallback> mAnimationFinishedTrigger;
+ PlayState mPlayState;
+ DevelImageVisual::StopBehavior::Type mStopBehavior;
+ DevelImageVisual::LoopingMode::Type mLoopingMode;
+ TimePoint mNextFrameStartTime;
+ int64_t mFrameDurationMicroSeconds;
+ float mFrameRate;
+ uint32_t mCurrentFrame;
+ uint32_t mTotalFrame;
+ uint32_t mStartFrame;
+ uint32_t mEndFrame;
+ uint32_t mDroppedFrames;
+ uint32_t mWidth;
+ uint32_t mHeight;
+ uint32_t mAnimationDataIndex;
+ int32_t mLoopCount;
+ int32_t mCurrentLoop;
+ bool mForward;
+ bool mUpdateFrameNumber;
+ bool mNeedAnimationFinishedTrigger;
+ bool mAnimationDataUpdated;
+ bool mDestroyTask;
};
} // namespace Internal
UnregisterProcessor();
}
-void SvgRasterizeThread::Process()
+void SvgRasterizeThread::Process(bool postProcessor)
{
ApplyRasterizedSVGToSampler();
}
/**
* @copydoc Dali::Integration::Processor::Process()
*/
- void Process() override;
+ void Process(bool postProcessor) override;
private:
/**
shadowEnabled = true;
}
- const bool underlineEnabled = mController->GetTextModel()->IsUnderlineEnabled();
- const bool outlineEnabled = (mController->GetTextModel()->GetOutlineWidth() > Math::MACHINE_EPSILON_1);
- const bool backgroundEnabled = mController->GetTextModel()->IsBackgroundEnabled();
- ;
+ const bool underlineEnabled = mController->GetTextModel()->IsUnderlineEnabled();
+ const bool outlineEnabled = (mController->GetTextModel()->GetOutlineWidth() > Math::MACHINE_EPSILON_1);
+ const bool backgroundEnabled = mController->GetTextModel()->IsBackgroundEnabled();
+ const bool markupProcessorEnabled = mController->IsMarkupProcessorEnabled();
- const bool styleEnabled = (shadowEnabled || underlineEnabled || outlineEnabled || backgroundEnabled);
+ const bool styleEnabled = (shadowEnabled || underlineEnabled || outlineEnabled || backgroundEnabled || markupProcessorEnabled);
AddRenderer(control, relayoutSize, hasMultipleTextColors, containsColorGlyph, styleEnabled);
break;
}
case VisualUrl::JSON:
+ case VisualUrl::RIVE:
{
visualPtr = AnimatedVectorImageVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), imageUrl, propertyMap);
break;
break;
}
case VisualUrl::JSON:
+ case VisualUrl::RIVE:
{
visualPtr = AnimatedVectorImageVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), visualUrl);
break;
char GIF[4] = {'f', 'i', 'g', '.'};
char WEBP[5] = {'p', 'b', 'e', 'w', '.'};
char JSON[5] = {'n', 'o', 's', 'j', '.'};
+ char RIVE[4] = {'v', 'i', 'r', '.'};
unsigned int svgScore = 0;
unsigned int gifScore = 0;
unsigned int webpScore = 0;
unsigned int jsonScore = 0;
+ unsigned int riveScore = 0;
int index = count;
while(--index >= 0)
{
return VisualUrl::JSON;
}
}
+ if((offsetFromEnd < sizeof(RIVE)) && (currentChar == RIVE[offsetFromEnd]))
+ {
+ // early out if RIVE as can't be used in N patch for now
+ if(++riveScore == sizeof(RIVE))
+ {
+ return VisualUrl::RIVE;
+ }
+ }
switch(state)
{
case SUFFIX:
SVG,
GIF,
WEBP,
- JSON
+ JSON,
+ RIVE
};
enum ProtocolType
{
const unsigned int TOOLKIT_MAJOR_VERSION = 2;
const unsigned int TOOLKIT_MINOR_VERSION = 0;
-const unsigned int TOOLKIT_MICRO_VERSION = 23;
+const unsigned int TOOLKIT_MICRO_VERSION = 24;
const char* const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
--- /dev/null
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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 <algorithm>
+#include <filesystem>
+#include <fstream>
+#include <iostream>
+#include <string>
+#include <string_view>
+#include <vector>
+
+using namespace std;
+namespace fs = filesystem;
+
+namespace
+{
+///////////////////////////////////////////////////////////////////////////////////////////////////
+string PROGRAM_NAME; ///< We set the program name on this global early on for use in Usage.
+string_view VERSION = "1.0.0";
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// Supported extensions for the files in the input directory.
+// clang-format off
+constexpr string_view SHADER_EXTENSIONS[] =
+{
+ ".vert",
+ ".frag",
+ ".def"
+};
+// clang-format on
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// Function & variable to retrieve the size of the extension with the largest string size.
+constexpr auto GetShaderExtensionMaxSize()
+{
+ auto maxSize = 0u;
+ for(const auto& extension : SHADER_EXTENSIONS)
+ {
+ if(extension.size() > maxSize)
+ {
+ maxSize = extension.size();
+ }
+ }
+ return maxSize;
+}
+constexpr const int SHADER_MAX_EXTENSION_SIZE(GetShaderExtensionMaxSize());
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// Prints out the Usage to standard output.
+void Usage()
+{
+ cout << "Usage: " << PROGRAM_NAME << " [OPTIONS] [IN_DIR] [OUT_DIR]" << endl;
+ cout << " IN_DIR: Input Directory which has all the shader files." << endl;
+ cout << " Supported extensions:";
+ string extensions;
+ for(const auto& extension : SHADER_EXTENSIONS)
+ {
+ extensions = extensions + " \"" + string(extension) + "\",";
+ }
+ extensions.pop_back(); // Remove the last comma.
+ cout << extensions << "." << endl;
+ cout << " OUT_DIR: Directory where the generated shader source code will be outputted to." << endl;
+ cout << " This directory will be created if it does not exist." << endl;
+ cout << " Any existing files of the same name in the directory will be overwritten." << endl;
+ cout << " Options: " << endl;
+ cout << " -s|--skip Skips the generation of the built-in header and source files" << endl;
+ cout << " -v|--version Prints out the version" << endl;
+ cout << " -h|--help Help" << endl;
+ cout << " NOTE: The options can be placed after the IN_DIR & OUT_DIR as well" << endl;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// Uses the filename to generate the shader variable name to use in source code.
+/// @param[in] filename The filename of the shader (including the extension)
+/// @return The shader variable name
+string GetShaderVariableName(const string& filename)
+{
+ string shaderVariableName("SHADER_" + filename);
+ for_each(
+ shaderVariableName.begin(),
+ shaderVariableName.end(),
+ [](char& character) {
+ switch(character)
+ {
+ case '-':
+ case '.':
+ {
+ character = '_';
+ break;
+ }
+
+ default:
+ {
+ character = ::toupper(character);
+ break;
+ }
+ }
+ });
+ return shaderVariableName;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// Uses the ourDir & filename to generate the path of the output header file for the shader.
+/// @param[in] outDir The directory where the readable shaders will be outputted to
+/// @param[in] filename The filename of the shader (including the extension)
+/// @return The path to the output file
+fs::path GetShaderOutputFilePath(fs::path& outDir, const string& filename)
+{
+ string outFilename(filename);
+ replace(outFilename.end() - SHADER_MAX_EXTENSION_SIZE, outFilename.end(), '.', '-');
+ outFilename = outDir.string() + "/" + outFilename + ".h";
+ return outFilename;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// Generates the header file from the input shader file.
+/// @param[in] shaderFile The full path of the input shader file
+/// @param[in] shaderVariableName The variable name to use for the string_view
+/// @param[in] outFilePath The full path to the output file
+void GenerateHeaderFile(
+ ifstream& shaderFile,
+ const string& shaderVariableName,
+ const fs::path& outFilePath)
+{
+ cout << " Generating \"" << shaderVariableName << "\" in " << outFilePath.filename();
+ ofstream outFile(outFilePath);
+ if(outFile.is_open())
+ {
+ outFile << "#pragma once" << endl
+ << endl;
+ outFile << "const std::string_view " << shaderVariableName << endl;
+ outFile << "{" << endl;
+ string line;
+ while(getline(shaderFile, line))
+ {
+ outFile << "\"" << line << "\\n\"" << endl;
+ }
+ outFile << "};" << endl;
+ cout << " [OK]" << endl;
+ }
+ else
+ {
+ cout << " [FAIL]" << endl;
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// If required, this accumulates data about all the shaders & generates the built-in cpp & header
+class BuiltInFilesGenerator
+{
+public:
+ /// Constructor
+ /// @param[in] outDir The path to the output directory
+ BuiltInFilesGenerator(const fs::path& outDir)
+ : mHeaderFilePath(outDir.string() + "/../" + string(HEADER_FILE_NAME)),
+ mSourceFilePath(outDir.string() + "/" + string(SOURCE_FILE_NAME))
+ {
+ }
+
+ /// Default destructor
+ ~BuiltInFilesGenerator() = default;
+
+ /// Adds the variable and the header file name to the appropriate vectors.
+ /// @param[in] variableName The string_view variable name used
+ /// @param[in] headerFileName The name of the header used
+ void Add(string&& variableName, const std::string& headerFilename)
+ {
+ mVariableNames.emplace_back(variableName);
+ mHeaderFileNames.emplace_back(headerFilename);
+ }
+
+ // Generates the built in files.
+ void Generate()
+ {
+ GenerateFile(
+ mVariableNames,
+ mHeaderFilePath,
+ "#pragma once\n\n#include <string_view>\n\n",
+ "extern const std::string_view ",
+ ";");
+
+ GenerateFile(
+ mHeaderFileNames,
+ mSourceFilePath,
+ "#include \"../" + string(HEADER_FILE_NAME) + "\"\n\n",
+ "#include \"",
+ "\"");
+ }
+
+private:
+ /// Generates the required file.
+ /// @param[in] strings A reference to the vector to parse
+ /// @param[in] filePath Outputs the data to this file
+ /// @param[in] header Puts this before parsing any of the vector
+ /// @param[in] before For each string, puts this string before it on every line
+ /// @param[in] after For each string, puts this string after it on every line
+ void GenerateFile(
+ vector<string>& strings,
+ const string& filePath,
+ const string_view header,
+ const string_view before,
+ const string_view after)
+ {
+ sort(strings.begin(), strings.end());
+ cout << " Generating \"" << filePath << "\"";
+ ofstream outFile(filePath);
+ if(outFile)
+ {
+ outFile << header;
+ for(auto& current : strings)
+ {
+ outFile << before << current << after << endl;
+ }
+ cout << " [OK]" << endl;
+ }
+ else
+ {
+ cout << " [FAIL]" << endl;
+ }
+ }
+
+ constexpr static string_view HEADER_FILE_NAME = "builtin-shader-extern-gen.h";
+ constexpr static string_view SOURCE_FILE_NAME = "builtin-shader-gen.cpp";
+
+ const string mHeaderFilePath; ///< Path to the header file to generate
+ const string mSourceFilePath; ///< Path to the source file to generate
+ vector<string> mVariableNames; ///< Holds all the variable names added through Add
+ vector<string> mHeaderFileNames; ///< Holds all the header file names added through Add
+};
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// Generates the header files from the shaders in the input directory & built-in files if reqruied.
+///
+/// @param[in] inDir The directory where all the input shader source is
+/// @param[in] outDir The directory where the readable shaders will be outputted to
+/// @param[in] generateBuiltInFiles If true, we generate the built-in files as well
+/// @return 0 if successful, 1 if failure
+int GenerateShaderSources(fs::path inDir, fs::path outDir, const bool generateBuiltInFiles)
+{
+ if(!fs::is_directory(inDir))
+ {
+ cerr << "ERROR: " << inDir << " is not a valid directory" << endl;
+ Usage();
+ return 1;
+ }
+
+ try
+ {
+ fs::create_directories(outDir);
+ }
+ catch(...)
+ {
+ cerr << "ERROR: Unable to create directory " << outDir << endl;
+ return 1;
+ }
+
+ cout << "====================================================================" << endl;
+ cout << "Shader Input Directory: " << inDir << endl;
+ cout << "Shader Output Directory: " << outDir << endl;
+ cout << "====================================================================" << endl;
+
+ BuiltInFilesGenerator generator(outDir);
+
+ for(auto& file : fs::directory_iterator(inDir))
+ {
+ if(file.is_regular_file())
+ {
+ for(const auto& extension : SHADER_EXTENSIONS)
+ {
+ if(file.path().extension() == extension)
+ {
+ const fs::path& path(file.path());
+ const string filename(path.filename().string());
+ string shaderVariableName(GetShaderVariableName(filename));
+ ifstream shaderFile(path);
+ if(shaderFile.is_open())
+ {
+ fs::path outFilePath(GetShaderOutputFilePath(outDir, filename));
+ GenerateHeaderFile(shaderFile, shaderVariableName, outFilePath);
+ generator.Add(std::move(shaderVariableName), outFilePath.filename().string());
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ if(generateBuiltInFiles)
+ {
+ generator.Generate();
+ }
+
+ cout << "====================================================================" << endl;
+ return 0;
+}
+
+} // unnamed namespace
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/// MAIN.
+int main(int argc, char* argv[])
+{
+ PROGRAM_NAME = argv[0];
+
+ bool generateBuiltInFiles = true;
+
+ string inDir;
+ string outDir;
+
+ for(auto i = 1; i < argc; ++i)
+ {
+ string option(argv[i]);
+ if(option == "--skip" || option == "-s")
+ {
+ generateBuiltInFiles = false;
+ }
+ else if(option == "--help" || option == "-h")
+ {
+ cout << "DALi Shader Generator v" << VERSION << endl
+ << endl;
+ Usage();
+ return 0;
+ }
+ else if(option == "--version" || option == "-v")
+ {
+ cout << VERSION << endl;
+ return 0;
+ }
+ else if(*option.begin() == '-')
+ {
+ cerr << "ERROR: " << option << " is not a supported option" << endl;
+ Usage();
+ return 1;
+ }
+ else if(inDir.empty())
+ {
+ inDir = option;
+ }
+ else if(outDir.empty())
+ {
+ outDir = option;
+ }
+ else if(inDir.size() && outDir.size())
+ {
+ cerr << "ERROR: Too many options" << endl;
+ Usage();
+ return 1;
+ }
+ }
+
+ if(inDir.empty() || outDir.empty())
+ {
+ cerr << "ERROR: Both IN_DIR & OUT_DIR not provided" << endl;
+ Usage();
+ return 1;
+ }
+
+ return GenerateShaderSources(inDir, outDir, generateBuiltInFiles);
+}
Name: dali2-toolkit
Summary: Dali 3D engine Toolkit
-Version: 2.0.23
+Version: 2.0.24
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT
%defattr(-,root,root,-)
%{dev_include_path}/dali-toolkit/*
%{_libdir}/pkgconfig/dali2-toolkit.pc
+%{_bindir}/dali-shader-generator
%files resources_360x360
%manifest dali-toolkit-resources.manifest