utc-Dali-Dictionary.cpp
utc-Dali-FeedbackStyle.cpp
utc-Dali-ItemView-internal.cpp
+ utc-Dali-LineHelperFunctions.cpp
utc-Dali-LogicalModel.cpp
utc-Dali-PropertyHelper.cpp
+ utc-Dali-Text-AbstractStyleCharacterRun.cpp
utc-Dali-Text-Characters.cpp
utc-Dali-Text-CharacterSetConversion.cpp
utc-Dali-Text-Circular.cpp
layoutParameters.startLineIndex = 0u;
layoutParameters.estimatedNumberOfLines = logicalModel->mParagraphInfo.Count();
- bool isAutoScroll = false;
+ bool isAutoScroll = false;
+ bool isAutoScrollMaxTextureExceeded = false;
layoutEngine.LayoutText(layoutParameters,
layoutSize,
false,
isAutoScroll,
+ isAutoScrollMaxTextureExceeded,
ellipsisPosition);
if(options.align)
DALI_TEST_EQUALS( text->SetRangeOfSelection( 1, 0, 1 ), false, TEST_LOCATION );
DALI_TEST_EQUALS( text->RemoveSelection( 1 ), false, TEST_LOCATION );
+ // Insert into empty field
+ DALI_TEST_EQUALS(editabletext->SetTextContents(""), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(editabletext->InsertText(1, "xyz"), false, TEST_LOCATION);
+ DALI_TEST_EQUALS(editabletext->InsertText(0, "abc"), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(text->GetText(0, 3), "abc", TEST_LOCATION);
+
+ // Append at end
+ DALI_TEST_EQUALS(editabletext->InsertText(3, "xyz"), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(text->GetText(0, 6), "abcxyz", TEST_LOCATION);
+
DALI_TEST_EQUALS(editabletext->SetTextContents("adef"), true, TEST_LOCATION);
DALI_TEST_EQUALS(editabletext->InsertText(1, "bc"), true, TEST_LOCATION);
DALI_TEST_EQUALS(text->GetText(0, 6), "abcdef", TEST_LOCATION);
DALI_TEST_EQUALS( text->SetRangeOfSelection( 1, 0, 1 ), false, TEST_LOCATION );
DALI_TEST_EQUALS( text->RemoveSelection( 1 ), false, TEST_LOCATION );
+ // Insert into empty field
+ DALI_TEST_EQUALS(editabletext->SetTextContents(""), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(editabletext->InsertText(1, "xyz"), false, TEST_LOCATION);
+ DALI_TEST_EQUALS(editabletext->InsertText(0, "abc"), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(text->GetText(0, 3), "abc", TEST_LOCATION);
+
+ // Append at end
+ DALI_TEST_EQUALS(editabletext->InsertText(3, "xyz"), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(text->GetText(0, 6), "abcxyz", TEST_LOCATION);
+
DALI_TEST_EQUALS(editabletext->SetTextContents("adef"), true, TEST_LOCATION);
DALI_TEST_EQUALS(editabletext->InsertText(1, "bc"), true, TEST_LOCATION);
DALI_TEST_EQUALS(text->GetText(0, 6), "abcdef", TEST_LOCATION);
--- /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 <stdlib.h>
+#include <unistd.h>
+#include <iostream>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/internal/text/line-helper-functions.h>
+#include <dali-toolkit/internal/text/rendering/text-typesetter.h>
+#include <dali-toolkit/internal/text/rendering/view-model.h>
+#include <dali-toolkit/internal/text/text-controller.h>
+#include <toolkit-text-utils.h>
+
+using namespace Dali;
+using namespace Toolkit;
+using namespace Text;
+
+int UtcDaliGetPreOffsetVerticalLineAlignmentWithNegativeLineSpacing(void)
+{
+ tet_infoline(" UtcDaliGetPreOffsetVerticalLineAlignmentWithNegativeLineSpacing ");
+ ToolkitTestApplication application;
+
+ uint32_t expectedNumberOfLines = 2u;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel(controller);
+
+ // Sets the text.
+ controller->SetMarkupProcessorEnabled(true);
+ controller->SetTextElideEnabled(false);
+ controller->SetText("<p rel-line-height=0.5>Line one Line two</p>");
+
+ // Creates the text's model and relais-out the text.
+ const Size relayoutSize(120.f, 100.f);
+ controller->Relayout(relayoutSize);
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK(model);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(model->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
+ DALI_TEST_CHECK(model->GetLines());
+
+ const LineRun& lineOne = *(model->GetLines() + 0u);
+ const LineRun& lineTwo = *(model->GetLines() + 1u);
+
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), 0.0f, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), 0.0f, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliGetPreOffsetVerticalLineAlignmentWithPositiveLineSpacing(void)
+{
+ tet_infoline(" UtcDaliGetPreOffsetVerticalLineAlignmentWithPositiveLineSpacing ");
+ ToolkitTestApplication application;
+
+ uint32_t expectedNumberOfLines = 2u;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel(controller);
+
+ // Sets the text.
+ controller->SetMarkupProcessorEnabled(true);
+ controller->SetTextElideEnabled(false);
+ controller->SetText("<p rel-line-height=2.0>Line one Line two</p>");
+
+ // Creates the text's model and relais-out the text.
+ const Size relayoutSize(120.f, 100.f);
+ controller->Relayout(relayoutSize);
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK(model);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(model->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
+ DALI_TEST_CHECK(model->GetLines());
+
+ const LineRun& lineOne = *(model->GetLines() + 0u);
+ const LineRun& lineTwo = *(model->GetLines() + 1u);
+
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), 9.5f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), 19.0f, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPreOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), 0.0f, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliGetPostOffsetVerticalLineAlignmentWithNegativeLineSpacing(void)
+{
+ tet_infoline(" UtcDaliGetPostOffsetVerticalLineAlignmentWithNegativeLineSpacing ");
+ ToolkitTestApplication application;
+
+ uint32_t expectedNumberOfLines = 2u;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel(controller);
+
+ // Sets the text.
+ controller->SetMarkupProcessorEnabled(true);
+ controller->SetTextElideEnabled(false);
+ controller->SetText("<p rel-line-height=0.5>Line one Line two</p>");
+
+ // Creates the text's model and relais-out the text.
+ const Size relayoutSize(120.f, 100.f);
+ controller->Relayout(relayoutSize);
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK(model);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(model->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
+ DALI_TEST_CHECK(model->GetLines());
+
+ const LineRun& lineOne = *(model->GetLines() + 0u);
+ const LineRun& lineTwo = *(model->GetLines() + 1u);
+
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), -9.5f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), -9.5f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), -9.5f, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), 0.0f, TEST_LOCATION);
+ END_TEST;
+}
+
+int UtcDaliGetPostOffsetVerticalLineAlignmentWithPositiveLineSpacing(void)
+{
+ tet_infoline(" UtcDaliGetPostOffsetVerticalLineAlignmentWithPositiveLineSpacing ");
+ ToolkitTestApplication application;
+
+ uint32_t expectedNumberOfLines = 2u;
+
+ // Creates a text controller.
+ ControllerPtr controller = Controller::New();
+
+ // Configures the text controller similarly to the text-label.
+ ConfigureTextLabel(controller);
+
+ // Sets the text.
+ controller->SetMarkupProcessorEnabled(true);
+ controller->SetTextElideEnabled(false);
+ controller->SetText("<p rel-line-height=2.0>Line one Line two</p>");
+
+ // Creates the text's model and relais-out the text.
+ const Size relayoutSize(120.f, 100.f);
+ controller->Relayout(relayoutSize);
+
+ // Tests the rendering controller has been created.
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
+ DALI_TEST_CHECK(typesetter);
+
+ // Tests the view model has been created.
+ ViewModel* model = typesetter->GetViewModel();
+ DALI_TEST_CHECK(model);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(model->GetNumberOfLines(), expectedNumberOfLines, TEST_LOCATION);
+ DALI_TEST_CHECK(model->GetLines());
+
+ const LineRun& lineOne = *(model->GetLines() + 0u);
+ const LineRun& lineTwo = *(model->GetLines() + 1u);
+
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), 19.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), 9.5f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineOne, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), 0.0f, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::TOP), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::MIDDLE), 0.0f, TEST_LOCATION);
+ DALI_TEST_EQUALS(GetPostOffsetVerticalLineAlignment(lineTwo, Dali::Toolkit::DevelText::VerticalLineAlignment::BOTTOM), 0.0f, TEST_LOCATION);
+ END_TEST;
+}
--- /dev/null
+/*
+ * Copyright (c) 2022 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 <stdlib.h>
+#include <unistd.h>
+#include <iostream>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/internal/text/bounded-paragraph-run.h>
+#include <dali-toolkit/internal/text/character-spacing-character-run.h>
+#include <dali-toolkit/internal/text/color-run.h>
+#include <dali-toolkit/internal/text/font-description-run.h>
+#include <dali-toolkit/internal/text/strikethrough-character-run.h>
+#include <dali-toolkit/internal/text/underlined-character-run.h>
+
+using namespace Dali;
+using namespace Toolkit;
+using namespace Text;
+
+// Tests the following functions for AbstractStyleCharacterRun.
+// CharacterIndex GetStartCharacterIndex() const;
+// Length GetNumberOfCharacters() const;
+// CharacterIndex GetEndCharacterIndex() const;
+
+template<typename TYPE_OF_RUN>
+void TestAbstractStyleCharacterRunEmptyCharacterRun(std::string test_name)
+{
+ tet_infoline(" TestAbstractStyleCharacterRunEmptyCharacterRun ");
+ std::cout << " testing " << test_name << std::endl;
+
+ tet_infoline(" Default Constructor ");
+ TYPE_OF_RUN abstractStyleCharacterRun;
+
+ tet_infoline(" AbstractStyleCharacterRun_GetStartCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetStartCharacterIndex(), 0u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetNumberOfCharacters ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetNumberOfCharacters(), 0u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetEndCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetEndCharacterIndex(), 0u, TEST_LOCATION);
+}
+
+template<typename TYPE_OF_RUN>
+void TestAbstractStyleCharacterRunOneCharacter(std::string test_name)
+{
+ tet_infoline(" TestAbstractStyleCharacterRunOneCharacter ");
+ std::cout << " testing " << test_name << std::endl;
+
+ TYPE_OF_RUN abstractStyleCharacterRun;
+ abstractStyleCharacterRun.characterRun.numberOfCharacters = 1u;
+ tet_infoline(" AbstractStyleCharacterRun_GetStartCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetStartCharacterIndex(), 0u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetNumberOfCharacters ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetNumberOfCharacters(), 1u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetEndCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetEndCharacterIndex(), 0u, TEST_LOCATION);
+
+ abstractStyleCharacterRun.characterRun.characterIndex = 5u;
+ tet_infoline(" AbstractStyleCharacterRun_GetStartCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetStartCharacterIndex(), 5u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetNumberOfCharacters ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetNumberOfCharacters(), 1u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetEndCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetEndCharacterIndex(), 5u, TEST_LOCATION);
+}
+
+template<typename TYPE_OF_RUN>
+void TestAbstractStyleCharacterRunMoreThanOneCharacter(std::string test_name)
+{
+ tet_infoline(" TestAbstractStyleCharacterRunOneCharacter ");
+ std::cout << " testing " << test_name << std::endl;
+
+ TYPE_OF_RUN abstractStyleCharacterRun;
+ abstractStyleCharacterRun.characterRun.numberOfCharacters = 15u;
+ tet_infoline(" AbstractStyleCharacterRun_GetStartCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetStartCharacterIndex(), 0u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetNumberOfCharacters ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetNumberOfCharacters(), 15u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetEndCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetEndCharacterIndex(), 14u, TEST_LOCATION);
+
+ abstractStyleCharacterRun.characterRun.characterIndex = 5u;
+ tet_infoline(" AbstractStyleCharacterRun_GetStartCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetStartCharacterIndex(), 5u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetNumberOfCharacters ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetNumberOfCharacters(), 15u, TEST_LOCATION);
+
+ tet_infoline(" AbstractStyleCharacterRun_GetEndCharacterIndex ");
+ DALI_TEST_EQUALS(abstractStyleCharacterRun.GetEndCharacterIndex(), 19u, TEST_LOCATION);
+}
+
+int UtcDaliTextAbstractStyleCharacterRun(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextAbstractStyleCharacterRun");
+
+ TestAbstractStyleCharacterRunEmptyCharacterRun<Dali::Toolkit::Text::ColorRun>("ColorRun");
+ TestAbstractStyleCharacterRunEmptyCharacterRun<Dali::Toolkit::Text::CharacterSpacingCharacterRun>("CharacterSpacingCharacterRun");
+ TestAbstractStyleCharacterRunEmptyCharacterRun<Dali::Toolkit::Text::FontDescriptionRun>("FontDescriptionRun");
+ TestAbstractStyleCharacterRunEmptyCharacterRun<Dali::Toolkit::Text::UnderlinedCharacterRun>("UnderlinedCharacterRun");
+ TestAbstractStyleCharacterRunEmptyCharacterRun<Dali::Toolkit::Text::StrikethroughCharacterRun>("StrikethroughCharacterRun");
+ TestAbstractStyleCharacterRunEmptyCharacterRun<Dali::Toolkit::Text::BoundedParagraphRun>("BoundedParagraphRun");
+
+ TestAbstractStyleCharacterRunOneCharacter<Dali::Toolkit::Text::ColorRun>("ColorRun");
+ TestAbstractStyleCharacterRunOneCharacter<Dali::Toolkit::Text::CharacterSpacingCharacterRun>("CharacterSpacingCharacterRun");
+ TestAbstractStyleCharacterRunOneCharacter<Dali::Toolkit::Text::FontDescriptionRun>("FontDescriptionRun");
+ TestAbstractStyleCharacterRunOneCharacter<Dali::Toolkit::Text::UnderlinedCharacterRun>("UnderlinedCharacterRun");
+ TestAbstractStyleCharacterRunOneCharacter<Dali::Toolkit::Text::StrikethroughCharacterRun>("StrikethroughCharacterRun");
+ TestAbstractStyleCharacterRunOneCharacter<Dali::Toolkit::Text::BoundedParagraphRun>("BoundedParagraphRun");
+
+ TestAbstractStyleCharacterRunMoreThanOneCharacter<Dali::Toolkit::Text::ColorRun>("ColorRun");
+ TestAbstractStyleCharacterRunMoreThanOneCharacter<Dali::Toolkit::Text::CharacterSpacingCharacterRun>("CharacterSpacingCharacterRun");
+ TestAbstractStyleCharacterRunMoreThanOneCharacter<Dali::Toolkit::Text::FontDescriptionRun>("FontDescriptionRun");
+ TestAbstractStyleCharacterRunMoreThanOneCharacter<Dali::Toolkit::Text::UnderlinedCharacterRun>("UnderlinedCharacterRun");
+ TestAbstractStyleCharacterRunMoreThanOneCharacter<Dali::Toolkit::Text::StrikethroughCharacterRun>("StrikethroughCharacterRun");
+ TestAbstractStyleCharacterRunMoreThanOneCharacter<Dali::Toolkit::Text::BoundedParagraphRun>("BoundedParagraphRun");
+
+ END_TEST;
+}
layoutSize = Vector2::ZERO;
- bool isAutoScroll = false;
- const bool updated = engine.LayoutText(layoutParameters,
+ bool isAutoScroll = false;
+ bool isAutoScrollMaxTextureExceeded = false;
+ const bool updated = engine.LayoutText(layoutParameters,
layoutSize,
data.ellipsis,
isAutoScroll,
+ isAutoScrollMaxTextureExceeded,
DevelText::EllipsisPosition::END);
// 4) Compare the results.
ControllerPtr controller = Controller::New();
// Tests the rendering controller has been created.
- TypesetterPtr typesetter = Typesetter::New( controller->GetTextModel() );
+ TypesetterPtr typesetter = Typesetter::New(controller->GetTextModel());
DALI_TEST_CHECK(typesetter);
// Tests the view model has been created.
controller->SetLineWrapMode( (Text::LineWrap::Mode)(data.lineWrapMode) );
controller->SetEllipsisPosition( data.ellipsisPosition );
- controller->SetText( data.text );
+ controller->SetText(data.text);
controller->Relayout( data.size );
// Elide the glyphs.
Size textSize36( 120.0f, 30.0f );
float positions36[] = { 0.0f, 10.0f, 21.0f, 25.0f, 28.0f, 38.0f, 44.0f, 55.0f };
+ Size textSize37(145.0f, 30.0f);
+ float positions37[] = {131.0f, 126.0f, 121.0f, 116.0f, 108.0f, 103.0f, 93.0f, 88.0f, 20.0f, 29.0f, 34.0f, 42.0f, 48.0f, 57.0f, 67.0f};
+
+ Size textSize38(145.0f, 30.0f);
+ float positions38[] = {51.0f, 66.0f, 71.0f, 79.0f, 85.0f, 94.0f, 103.0f, 109.0f, 119.0f, 51.0f, 37.0f, 32.0f, 27.0f, 23.0f, 14.0f, 10.0f, 0.0f};
+
struct ElideData data[] =
- {
{
- "void text",
- "",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::END,
- false,
- textSize00,
- 0u,
- 0u,
- nullptr
- },
+ {"void text",
+ "",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize00,
+ 0u,
+ 0u,
+ nullptr},
+
+ {"void text",
+ "",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize00,
+ 0u,
+ 0u,
+ nullptr},
+
+ {"void text",
+ "",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize00,
+ 0u,
+ 0u,
+ nullptr},
+
+ //END LTR cases
+ {
+ "EllipsisPosition: TextLabel: Basic case SingleLine LTR END",
+ "A0123456789 B0123456789 C0123456789 D0123456789 ",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize01,
+ 1u,
+ 10u,
+ positions01},
+
+ {"EllipsisPosition: TextLabel: Basic case Mulitlines LineWrap-WORD LTR END",
+ "A0123456789 B0123456789 C0123456789 D0123456789 ",
+ true,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize02,
+ 2u,
+ 22u,
+ positions02},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD LTR END",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Welcome",
+ true,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize03,
+ 3u,
+ 29u,
+ positions03},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER LTR END",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Welcome",
+ true,
+ DevelText::LineWrap::CHARACTER,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize04,
+ 3u,
+ 40u,
+ positions04},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHAN LTR END",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Welcome",
+ true,
+ DevelText::LineWrap::HYPHENATION,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize05,
+ 3u,
+ 32u,
+ positions05},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED LTR END",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Welcome",
+ true,
+ DevelText::LineWrap::MIXED,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize06,
+ 3u,
+ 28u,
+ positions06},
+
+ //START LTR cases
+ {
+ "EllipsisPosition: TextLabel: Basic case SingleLine LTR START",
+ "A0123456789 B0123456789 C0123456789 D0123456789 ",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize07,
+ 1u,
+ 11u,
+ positions07,
+
+ },
+
+ {"EllipsisPosition: TextLabel: Basic case Mulitlines LineWrap-WORD LTR START",
+ "A0123456789 B0123456789 C0123456789 D0123456789 ",
+ true,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize08,
+ 2u,
+ 23u,
+ positions08},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD LTR START",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Welcome",
+ true,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize09,
+ 3u,
+ 33u,
+ positions09},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER LTR START",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Welcome",
+ true,
+ DevelText::LineWrap::CHARACTER,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize10,
+ 3u,
+ 37u,
+ positions10},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHAN LTR START",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Welcome",
+ true,
+ DevelText::LineWrap::HYPHENATION,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize11,
+ 3u,
+ 25u,
+ positions11},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED LTR START",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Welcome",
+ true,
+ DevelText::LineWrap::MIXED,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize12,
+ 3u,
+ 25u,
+ positions12},
+
+ //END RTL cases
+ {
+ "EllipsisPosition: TextLabel: SingleLine RTL END",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize13,
+ 1u,
+ 14u,
+ positions13},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD RTL END",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ true,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize14,
+ 3u,
+ 42u,
+ positions14},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER RTL END",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ true,
+ DevelText::LineWrap::CHARACTER,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize15,
+ 3u,
+ 44u,
+ positions15},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHENATION RTL END",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ true,
+ DevelText::LineWrap::HYPHENATION,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize16,
+ 3u,
+ 39u,
+ positions16},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED RTL END",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ true,
+ DevelText::LineWrap::MIXED,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize17,
+ 3u,
+ 39u,
+ positions17},
+
+ //START RTL cases
+ {
+ "EllipsisPosition: TextLabel: SingleLine RTL START",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize18,
+ 1u,
+ 13u,
+ positions18},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD RTL START",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ true,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize19,
+ 3u,
+ 33u,
+ positions19},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER RTL START",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ true,
+ DevelText::LineWrap::CHARACTER,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize20,
+ 3u,
+ 30u,
+ positions20},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHENATION RTL START",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ true,
+ DevelText::LineWrap::HYPHENATION,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize21,
+ 3u,
+ 33u,
+ positions21},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED RTL START",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ true,
+ DevelText::LineWrap::MIXED,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize22,
+ 3u,
+ 33u,
+ positions22},
+
+ //MIDDLE LTR cases
+ {
+ "EllipsisPosition: TextLabel: Basic case SingleLine LTR MIDDLE",
+ "ABCDEFGHIJKLMNPQRSTUVWXYZ abcdefghijklmnpqrstuvwxyz",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize23,
+ 1u,
+ 10u,
+ positions23},
+
+ {"EllipsisPosition: TextLabel: Basic case Mulitlines LineWrap-WORD LTR MIDDLE",
+ "A0123456789 B0123456789 C0123456789 D0123456789 ",
+ true,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize24,
+ 2u,
+ 22u,
+ positions24},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD LTR MIDDLE",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye",
+ true,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize25,
+ 3u,
+ 24u,
+ positions25},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER LTR MIDDLE",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye",
+ true,
+ DevelText::LineWrap::CHARACTER,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize26,
+ 3u,
+ 36u,
+ positions26},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHAN LTR MIDDLE",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye",
+ true,
+ DevelText::LineWrap::HYPHENATION,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize27,
+ 3u,
+ 27u,
+ positions27},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED LTR MIDDLE",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye",
+ true,
+ DevelText::LineWrap::MIXED,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize28,
+ 3u,
+ 24u,
+ positions28},
+
+ //MIDDLE RTL cases
+ {
+ "EllipsisPosition: TextLabel: SingleLine RTL MIDDLE",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize29,
+ 1u,
+ 13u,
+ positions29},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD RTL MIDDLE",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ true,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize30,
+ 3u,
+ 31u,
+ positions30},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER RTL MIDDLE",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ true,
+ DevelText::LineWrap::CHARACTER,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize31,
+ 3u,
+ 29u,
+ positions31},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHENATION RTL MIDDLE",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ true,
+ DevelText::LineWrap::HYPHENATION,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize32,
+ 3u,
+ 31u,
+ positions32},
+
+ {"EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED RTL MIDDLE",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ true,
+ DevelText::LineWrap::MIXED,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize33,
+ 3u,
+ 31u,
+ positions33},
+
+ {"EllipsisPosition: TextLabel: One-Line for Mulitlines LineWrap-WORD LTR END",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Welcome",
+ true,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize34,
+ 1u,
+ 13u,
+ positions34},
+
+ {"EllipsisPosition: TextLabel: One-Line for Mulitlines LineWrap-WORD LTR START",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Welcome",
+ true,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize35,
+ 1u,
+ 11u,
+ positions35},
+
+ {"EllipsisPosition: TextLabel: One-Line for Mulitlines LineWrap-WORD LTR MIDDLE",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Welcome",
+ true,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize36,
+ 1u,
+ 12u,
+ positions36},
+
+ {"EllipsisPosition: TextLabel: Mixed Directions Languages END",
+ "سیٹنگیں Projector سیٹنگیں",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize37,
+ 1u,
+ 16u,
+ positions37},
+
+ {"EllipsisPosition: TextLabel: Mixed Directions Languages START",
+ "سیٹنگیں Projector سیٹنگیں",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize38,
+ 1u,
+ 17u,
+ positions38},
+
+ };
+ const unsigned int numberOfTests = 41u;
+ for( unsigned int index = 0u; index < numberOfTests; ++index )
+ {
+ ToolkitTestApplication application;
+ if( !ElideTestViewModel( data[index] ) )
{
- "void text",
- "",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::START,
- false,
- textSize00,
- 0u,
- 0u,
- nullptr
- },
+ tet_result(TET_FAIL);
+ }
+ }
- {
- "void text",
- "",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize00,
- 0u,
- 0u,
- nullptr
- },
+ tet_result(TET_PASS);
+ END_TEST;
+}
- //END LTR cases
- {
- "EllipsisPosition: TextLabel: Basic case SingleLine LTR END",
- "A0123456789 B0123456789 C0123456789 D0123456789 ",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::END,
- false,
- textSize01,
- 1u,
- 10u,
- positions01
- },
- {
- "EllipsisPosition: TextLabel: Basic case Mulitlines LineWrap-WORD LTR END",
- "A0123456789 B0123456789 C0123456789 D0123456789 ",
- true,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::END,
- false,
- textSize02,
- 2u,
- 22u,
- positions02
- },
+int UtcDaliTextFieldlElideTextLocation(void)
+{
+ tet_infoline(" UtcDaliTextFieldlElideTextLocation ");
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD LTR END",
- "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" ,
- true,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::END,
- false,
- textSize03,
- 3u,
- 29u,
- positions03
- },
+ Size textSize00( 100.f, 100.f );
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER LTR END",
- "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" ,
- true,
- DevelText::LineWrap::CHARACTER,
- DevelText::EllipsisPosition::END,
- false,
- textSize04,
- 3u,
- 40u,
- positions04
- },
+ Size textSize01( 120.0f, 50.0f );
+ float positions01[] = { 0.0f, 11.0f, 21.0f, 31.0f, 41.0f, 50.0f, 60.0f, 70.0f, 80.0f, 91.0f };
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHAN LTR END",
- "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" ,
- true,
- DevelText::LineWrap::HYPHENATION,
- DevelText::EllipsisPosition::END,
- false,
- textSize05,
- 3u,
- 32u,
- positions05
- },
+ Size textSize02( 120.0f, 50.0f );
+ float positions02[] = { 0.0f, 10.0f, 21.0f, 25.0f, 28.0f, 38.0f, 44.0f, 55.0f, 59.0f, 65.0f, 73.0f, 84.0f, 93.0f };
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED LTR END",
- "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" ,
- true,
- DevelText::LineWrap::MIXED,
- DevelText::EllipsisPosition::END,
- false,
- textSize06,
- 3u,
- 28u,
- positions06
- },
+ Size textSize03( 120.0f, 50.0f );
+ float positions03[] = { 117.0f, 111.0f, 97.0f, 88.0f, 80.0f, 74.0f, 64.0f, 59.0f, 54.0f, 45.0f, 37.0f, 31.0f, 22.0f, 7.0f };
- //START LTR cases
- {
- "EllipsisPosition: TextLabel: Basic case SingleLine LTR START",
- "A0123456789 B0123456789 C0123456789 D0123456789 ",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::START,
- false,
- textSize07,
- 1u,
- 11u,
- positions07
- },
+ Size textSize04( 120.0f, 50.0f );
+ float positions04[] = { 5.0f, 21.0f, 31.0f, 41.0f, 50.0f, 61.0f, 71.0f, 80.0f, 90.0f, 100.0f, 109.0f };
- {
- "EllipsisPosition: TextLabel: Basic case Mulitlines LineWrap-WORD LTR START",
- "A0123456789 B0123456789 C0123456789 D0123456789 ",
- true,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::START,
- false,
- textSize08,
- 2u,
- 23u,
- positions08
- },
+ Size textSize05( 120.0f, 50.0f );
+ float positions05[] = { 8.0f, 24.0f, 35.0f, 44.0f, 49.0f, 63.0f, 74.0f, 77.0f, 85.0f, 96.0f, 110.0f };
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD LTR START",
- "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" ,
- true,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::START,
- false,
- textSize09,
- 3u,
- 33u,
- positions09
- },
+ Size textSize06( 120.0f, 50.0f );
+ float positions06[] = { 90.0f, 79.0f, 70.0f, 68.0f, 62.0f, 56.0f, 51.0f, 42.0f, 29.0f, 26.0f, 15.0f, 7.0f, 0.0f };
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER LTR START",
- "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" ,
- true,
- DevelText::LineWrap::CHARACTER,
- DevelText::EllipsisPosition::START,
- false,
- textSize10,
- 3u,
- 37u,
- positions10
- },
+ Size textSize07( 120.0f, 50.0f );
+ float positions07[] = { 0.0f, 11.0f, 21.0f, 31.0f, 41.0f, 53.0f };
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHAN LTR START",
- "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" ,
- true,
- DevelText::LineWrap::HYPHENATION,
- DevelText::EllipsisPosition::START,
- false,
- textSize11,
- 3u,
- 25u,
- positions11
- },
+ Size textSize08( 120.0f, 50.0f );
+ float positions08[] = { 0.0f, 10.0f, 21.0f, 25.0f, 28.0f, 38.0f, 44.0f, 55.0f };
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED LTR START",
- "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" ,
- true,
- DevelText::LineWrap::MIXED,
- DevelText::EllipsisPosition::START,
- false,
- textSize12,
- 3u,
- 25u,
- positions12
- },
+ Size textSize09( 120.0f, 50.0f );
+ float positions09[] = { 116.0f, 109.0f, 96.0f, 87.0f, 79.0f, 73.0f, 63.0f };
- //END RTL cases
- {
- "EllipsisPosition: TextLabel: SingleLine RTL END",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::END,
- false,
- textSize13,
- 1u,
- 14u,
- positions13
- },
+ Size textSize10( 120.0f, 50.0f );
+ float positions10[] = { 121.0f, 116.0f, 111.0f, 106.0f, 101.0f, 96.0f, 92.0f, 87.0f, 83.0f, 77.0f, 63.0f, 55.0f, 46.0f, 40.0f, 30.0f, 16.0f };
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD RTL END",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- true,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::END,
- false,
- textSize14,
- 3u,
- 42u,
- positions14
- },
+ Size textSize11( 120.0f, 50.0f );
+ float positions11[] = { 93.0f, 77.0f, 74.0f, 63.0f, 56.0f, 49.0f, 44.0f, 39.0f, 34.0f, 29.0f, 24.0f, 19.0f, 14.0f, 9.0f, 5.0f };
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER RTL END",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- true,
- DevelText::LineWrap::CHARACTER,
- DevelText::EllipsisPosition::END,
- false,
- textSize15,
- 3u,
- 44u,
- positions15
- },
+ Size textSize12( 120.0f, 50.0f );
+ float positions12[] = { 117.0f, 112.0f, 107.0f, 102.0f, 97.0f, 92.0f, 87.0f, 82.0f, 79.0f, 72.0f };
+ Size textSize13(145.0f, 30.0f);
+ float positions13[] = {131.0f, 126.0f, 121.0f, 117.0f, 108.0f, 104.0f, 94.0f, 88.0f, 20.0f, 29.0f, 34.0f, 42.0f, 48.0f, 57.0f, 67.0f};
+
+ Size textSize14(145.0f, 30.0f);
+ float positions14[] = {51.0f, 66.0f, 71.0f, 80.0f, 85.0f, 94.0f, 103.0f, 109.0f, 119.0f, 51.0f, 37.0f, 32.0f, 28.0f, 23.0f, 14.0f, 10.0f, 0.0f};
+
+ struct ElideData data[] =
{
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHENATION RTL END",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- true,
- DevelText::LineWrap::HYPHENATION,
- DevelText::EllipsisPosition::END,
- false,
- textSize16,
- 3u,
- 39u,
- positions16
- },
-
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED RTL END",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- true,
- DevelText::LineWrap::MIXED,
- DevelText::EllipsisPosition::END,
- false,
- textSize17,
- 3u,
- 39u,
- positions17
- },
-
- //START RTL cases
- {
- "EllipsisPosition: TextLabel: SingleLine RTL START",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::START,
- false,
- textSize18,
- 1u,
- 13u,
- positions18
- },
-
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD RTL START",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- true,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::START,
- false,
- textSize19,
- 3u,
- 33u,
- positions19
- },
-
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER RTL START",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- true,
- DevelText::LineWrap::CHARACTER,
- DevelText::EllipsisPosition::START,
- false,
- textSize20,
- 3u,
- 30u,
- positions20
- },
-
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHENATION RTL START",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- true,
- DevelText::LineWrap::HYPHENATION,
- DevelText::EllipsisPosition::START,
- false,
- textSize21,
- 3u,
- 33u,
- positions21
- },
-
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED RTL START",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- true,
- DevelText::LineWrap::MIXED,
- DevelText::EllipsisPosition::START,
- false,
- textSize22,
- 3u,
- 33u,
- positions22
- },
-
- //MIDDLE LTR cases
- {
- "EllipsisPosition: TextLabel: Basic case SingleLine LTR MIDDLE",
- "ABCDEFGHIJKLMNPQRSTUVWXYZ abcdefghijklmnpqrstuvwxyz",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize23,
- 1u,
- 10u,
- positions23
- },
-
- {
- "EllipsisPosition: TextLabel: Basic case Mulitlines LineWrap-WORD LTR MIDDLE",
- "A0123456789 B0123456789 C0123456789 D0123456789 ",
- true,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize24,
- 2u,
- 22u,
- positions24
- },
-
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD LTR MIDDLE",
- "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye" ,
- true,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize25,
- 3u,
- 24u,
- positions25
- },
-
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER LTR MIDDLE",
- "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye" ,
- true,
- DevelText::LineWrap::CHARACTER,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize26,
- 3u,
- 36u,
- positions26
- },
-
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHAN LTR MIDDLE",
- "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye" ,
- true,
- DevelText::LineWrap::HYPHENATION,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize27,
- 3u,
- 27u,
- positions27
- },
-
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED LTR MIDDLE",
- "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye" ,
- true,
- DevelText::LineWrap::MIXED,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize28,
- 3u,
- 24u,
- positions28
- },
-
-//MIDDLE RTL cases
- {
- "EllipsisPosition: TextLabel: SingleLine RTL MIDDLE",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize29,
- 1u,
- 13u,
- positions29
- },
-
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-WORD RTL MIDDLE",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- true,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize30,
- 3u,
- 31u,
- positions30
- },
-
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-CHARACTER RTL MIDDLE",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- true,
- DevelText::LineWrap::CHARACTER,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize31,
- 3u,
- 29u,
- positions31
- },
-
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-HYPHENATION RTL MIDDLE",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- true,
- DevelText::LineWrap::HYPHENATION,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize32,
- 3u,
- 31u,
- positions32
- },
-
- {
- "EllipsisPosition: TextLabel: Mulitlines LineWrap-MIXED RTL MIDDLE",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- true,
- DevelText::LineWrap::MIXED,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize33,
- 3u,
- 31u,
- positions33
- },
-
- {
- "EllipsisPosition: TextLabel: One-Line for Mulitlines LineWrap-WORD LTR END",
- "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" ,
- true,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::END,
- false,
- textSize34,
- 1u,
- 13u,
- positions34
- },
-
- {
- "EllipsisPosition: TextLabel: One-Line for Mulitlines LineWrap-WORD LTR START",
- "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" ,
- true,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::START,
- false,
- textSize35,
- 1u,
- 11u,
- positions35
- },
-
- {
- "EllipsisPosition: TextLabel: One-Line for Mulitlines LineWrap-WORD LTR MIDDLE",
- "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" ,
- true,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize36,
- 1u,
- 12u,
- positions36
- },
-
- };
- const unsigned int numberOfTests = 39u;
-
- for( unsigned int index = 0u; index < numberOfTests; ++index )
- {
- ToolkitTestApplication application;
- if( !ElideTestViewModel( data[index] ) )
- {
- tet_result(TET_FAIL);
- }
- }
-
- tet_result(TET_PASS);
- END_TEST;
-}
-
-
-int UtcDaliTextFieldlElideTextLocation(void)
-{
- tet_infoline(" UtcDaliTextFieldlElideTextLocation ");
-
- Size textSize00( 100.f, 100.f );
-
- Size textSize01( 120.0f, 50.0f );
- float positions01[] = { 0.0f, 11.0f, 21.0f, 31.0f, 41.0f, 50.0f, 60.0f, 70.0f, 80.0f, 91.0f };
-
- Size textSize02( 120.0f, 50.0f );
- float positions02[] = { 0.0f, 10.0f, 21.0f, 25.0f, 28.0f, 38.0f, 44.0f, 55.0f, 59.0f, 65.0f, 73.0f, 84.0f, 93.0f };
-
- Size textSize03( 120.0f, 50.0f );
- float positions03[] = { 117.0f, 111.0f, 97.0f, 88.0f, 80.0f, 74.0f, 64.0f, 59.0f, 54.0f, 45.0f, 37.0f, 31.0f, 22.0f, 7.0f };
-
- Size textSize04( 120.0f, 50.0f );
- float positions04[] = { 5.0f, 21.0f, 31.0f, 41.0f, 50.0f, 61.0f, 71.0f, 80.0f, 90.0f, 100.0f, 109.0f };
-
- Size textSize05( 120.0f, 50.0f );
- float positions05[] = { 8.0f, 24.0f, 35.0f, 44.0f, 49.0f, 63.0f, 74.0f, 77.0f, 85.0f, 96.0f, 110.0f };
-
- Size textSize06( 120.0f, 50.0f );
- float positions06[] = { 90.0f, 79.0f, 70.0f, 68.0f, 62.0f, 56.0f, 51.0f, 42.0f, 29.0f, 26.0f, 15.0f, 7.0f, 0.0f };
-
- Size textSize07( 120.0f, 50.0f );
- float positions07[] = { 0.0f, 11.0f, 21.0f, 31.0f, 41.0f, 53.0f };
-
- Size textSize08( 120.0f, 50.0f );
- float positions08[] = { 0.0f, 10.0f, 21.0f, 25.0f, 28.0f, 38.0f, 44.0f, 55.0f };
-
- Size textSize09( 120.0f, 50.0f );
- float positions09[] = { 116.0f, 109.0f, 96.0f, 87.0f, 79.0f, 73.0f, 63.0f };
-
- Size textSize10( 120.0f, 50.0f );
- float positions10[] = { 121.0f, 116.0f, 111.0f, 106.0f, 101.0f, 96.0f, 92.0f, 87.0f, 83.0f, 77.0f, 63.0f, 55.0f, 46.0f, 40.0f, 30.0f, 16.0f };
-
- Size textSize11( 120.0f, 50.0f );
- float positions11[] = { 93.0f, 77.0f, 74.0f, 63.0f, 56.0f, 49.0f, 44.0f, 39.0f, 34.0f, 29.0f, 24.0f, 19.0f, 14.0f, 9.0f, 5.0f };
-
- Size textSize12( 120.0f, 50.0f );
- float positions12[] = { 117.0f, 112.0f, 107.0f, 102.0f, 97.0f, 92.0f, 87.0f, 82.0f, 79.0f, 72.0f };
-
- struct ElideData data[] =
- {
- {
- "void text",
- "",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::END,
- false,
- textSize00,
- 0u,
- 0u,
- nullptr
- },
-
- {
- "void text",
- "",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::START,
- false,
- textSize00,
- 0u,
- 0u,
- nullptr
- },
-
- {
- "void text",
- "",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize00,
- 0u,
- 0u,
- nullptr
- },
-
- {
- "EllipsisPosition: TextField: Basic case SingleLine LTR END",
- "A0123456789 B0123456789 C0123456789 D0123456789 ",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::END,
- false,
- textSize01,
- 1u,
- 10u,
- positions01
- },
-
- {
- "EllipsisPosition: TextField: SingleLine LTR END",
- "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" ,
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::END,
- false,
- textSize02,
- 1u,
- 13u,
- positions02
- },
-
- {
- "EllipsisPosition: TextField: SingleLine RTL END",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::END,
- false,
- textSize03,
- 1u,
- 14u,
- positions03
- },
-
- {
- "EllipsisPosition: TextField: Basic case SingleLine LTR START",
- "A0123456789 B0123456789 C0123456789 D0123456789 ",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::START,
- false,
- textSize04,
- 1u,
- 11u,
- positions04
- },
-
- {
- "EllipsisPosition: TextField: SingleLine LTR START",
- "Hello Hi Experimen Welcome Hello Hi Experimen Welcome" ,
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::START,
- false,
- textSize05,
- 1u,
- 11u,
- positions05
- },
-
- {
- "EllipsisPosition: TextField: SingleLine RTL START",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::START,
- false,
- textSize06,
- 1u,
- 13u,
- positions06
- },
-
- {
- "EllipsisPosition: TextField: Basic case SingleLine LTR MIDDLE",
- "A0123456789 B0123456789 C0123456789 D0123456789 ",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize07,
- 1u,
- 11u,
- positions07
- },
-
- {
- "EllipsisPosition: TextField: SingleLine LTR MIDDLE",
- "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye" ,
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize08,
- 1u,
- 13u,
- positions08
- },
-
- {
- "EllipsisPosition: TextField: SingleLine RTL MIDDLE",
- "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize09,
- 1u,
- 13u,
- positions09
- },
-
- {
- "EllipsisPosition: TextField: Head and Tail whitespaces RTL END",
- " السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة ",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::END,
- false,
- textSize10,
- 1u,
- 16u,
- positions10
- },
-
- {
- "EllipsisPosition: TextField: Head and Tail whitespaces RTL START",
- " السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة ",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::START,
- false,
- textSize11,
- 1u,
- 15u,
- positions11
- },
-
- {
- "EllipsisPosition: TextField: Head and Tail whitespaces RTL MIDDLE",
- " السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة ",
- false,
- DevelText::LineWrap::WORD,
- DevelText::EllipsisPosition::MIDDLE,
- false,
- textSize12,
- 1u,
- 20u,
- positions12
- },
-
- };
-
- const unsigned int numberOfTests = 15u;
+ {"void text",
+ "",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize00,
+ 0u,
+ 0u,
+ nullptr},
+
+ {"void text",
+ "",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize00,
+ 0u,
+ 0u,
+ nullptr},
+
+ {"void text",
+ "",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize00,
+ 0u,
+ 0u,
+ nullptr},
+
+ {"EllipsisPosition: TextField: Basic case SingleLine LTR END",
+ "A0123456789 B0123456789 C0123456789 D0123456789 ",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize01,
+ 1u,
+ 10u,
+ positions01},
+
+ {"EllipsisPosition: TextField: SingleLine LTR END",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Welcome",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize02,
+ 1u,
+ 13u,
+ positions02},
+
+ {"EllipsisPosition: TextField: SingleLine RTL END",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize03,
+ 1u,
+ 14u,
+ positions03},
+
+ {"EllipsisPosition: TextField: Basic case SingleLine LTR START",
+ "A0123456789 B0123456789 C0123456789 D0123456789 ",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize04,
+ 1u,
+ 11u,
+ positions04},
+
+ {"EllipsisPosition: TextField: SingleLine LTR START",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Welcome",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize05,
+ 1u,
+ 11u,
+ positions05},
+
+ {"EllipsisPosition: TextField: SingleLine RTL START",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize06,
+ 1u,
+ 13u,
+ positions06},
+
+ {"EllipsisPosition: TextField: Basic case SingleLine LTR MIDDLE",
+ "A0123456789 B0123456789 C0123456789 D0123456789 ",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize07,
+ 1u,
+ 11u,
+ positions07},
+
+ {"EllipsisPosition: TextField: SingleLine LTR MIDDLE",
+ "Hello Hi Experimen Welcome Hello Hi Experimen Goodbye",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize08,
+ 1u,
+ 13u,
+ positions08},
+
+ {"EllipsisPosition: TextField: SingleLine RTL MIDDLE",
+ "السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize09,
+ 1u,
+ 13u,
+ positions09},
+
+ {"EllipsisPosition: TextField: Head and Tail whitespaces RTL END",
+ " السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة ",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize10,
+ 1u,
+ 16u,
+ positions10},
+
+ {"EllipsisPosition: TextField: Head and Tail whitespaces RTL START",
+ " السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة ",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize11,
+ 1u,
+ 15u,
+ positions11},
+
+ {"EllipsisPosition: TextField: Head and Tail whitespaces RTL MIDDLE",
+ " السلام عليكم Ù…Ø±ØØ¨Ø§ اهلا هذا اختبار شكرا للمساعدة ",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::MIDDLE,
+ false,
+ textSize12,
+ 1u,
+ 20u,
+ positions12},
+
+ {"EllipsisPosition: TextField: Mixed Directions Languages END",
+ "سیٹنگیں Projector سیٹنگیں",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::END,
+ false,
+ textSize13,
+ 1u,
+ 16,
+ positions13},
+
+ {"EllipsisPosition: TextField: Mixed Directions Languages START",
+ "سیٹنگیں Projector سیٹنگیں",
+ false,
+ DevelText::LineWrap::WORD,
+ DevelText::EllipsisPosition::START,
+ false,
+ textSize14,
+ 1u,
+ 17,
+ positions14},
+
+ };
+
+ const unsigned int numberOfTests = 17u;
for( unsigned int index = 0u; index < numberOfTests; ++index )
{
layoutSize = Vector2::ZERO;
- bool isAutoScroll = false;
- const bool updated = engine.LayoutText(layoutParameters,
+ bool isAutoScroll = false;
+ bool isAutoScrollMaxTextureExceeded = false;
+ const bool updated = engine.LayoutText(layoutParameters,
layoutSize,
data.ellipsis,
isAutoScroll,
+ isAutoScrollMaxTextureExceeded,
data.ellipsisPosition);
// 4) Compare the results.
{
return false;
}
- if(fabsf(glyphData.advance - floor(glyph.advance)) > Math::MACHINE_EPSILON_1000)
+ if(glyphData.advance >= 0.0f && fabsf(glyphData.advance - floor(glyph.advance)) > Math::MACHINE_EPSILON_1000)
{
return false;
}
bool sizeDefined = false;
// variation selector 16 (Emoji)
+ // Note : Non-scalable font's advance value is undefined. See https://github.com/harfbuzz/harfbuzz/discussions/3023. 2022-06-03 updated.
struct GlyphInfoData glyphsVS16[] =
{
- {2u, 74u, 0.f, 0.f, 0.f, 0.f, 39.0f, 0.f, false, false},
+ {2u, 74u, 0.f, 0.f, 0.f, 0.f, -1.0f /* Special value that we don't check it */, 0.f, false, false},
};
CharacterIndex characterIndicesVS16[] = {0u, 1u};
Length charactersPerGlyphVS16[] = {2u};
.Add(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME)
.Add(ImageVisual::Property::MASK_CONTENT_SCALE, 1.6f)
.Add(ImageVisual::Property::CROP_TO_MASK, true)
+ .Add(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING)
.Add(DevelVisual::Property::CORNER_RADIUS, 22.2f)
.Add(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE)
.Add(DevelVisual::Property::BORDERLINE_WIDTH, 33.3f)
DALI_TEST_CHECK(value);
DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
+ value = resultMap.Find(DevelImageVisual::Property::MASKING_TYPE, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
+
Vector2 naturalSize;
animatedImageVisual.GetNaturalSize(naturalSize);
DALI_TEST_EQUALS(naturalSize, Vector2(100, 100), TEST_LOCATION);
.Add("alphaMaskUrl", TEST_MASK_IMAGE_FILE_NAME)
.Add("maskContentScale", 1.6f)
.Add("cropToMask", true)
+ .Add(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING)
.Add("cornerRadius", Vector4(50.0f, 25.0f, 12.5f, 33.0f))
.Add("cornerRadiusPolicy", Visual::Transform::Policy::RELATIVE)
.Add("borderlineWidth", 20.0f)
DALI_TEST_CHECK(value);
DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
+ value = resultMap.Find(DevelImageVisual::Property::MASKING_TYPE, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<int>() == DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
+
END_TEST;
}
.Add("alphaMaskUrl", TEST_MASK_IMAGE_FILE_NAME)
.Add("maskContentScale", 1.6f)
.Add("cropToMask", true)
+ .Add(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING)
.Add("cornerRadius", 50.5f));
Property::Map resultMap;
DALI_TEST_CHECK(value);
DALI_TEST_EQUALS(value->Get<bool>(), true, TEST_LOCATION);
+ value = resultMap.Find(DevelImageVisual::Property::MASKING_TYPE, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_CHECK(value->Get<bool>() == DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
+
END_TEST;
}
END_TEST;
}
-int UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask(void)
+int UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask01(void)
{
ToolkitTestApplication application;
- TestGlAbstraction& gl = application.GetGlAbstraction();
+ tet_infoline("UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask01 for CPU Alpha Masking");
+ TestGlAbstraction& gl = application.GetGlAbstraction();
{
Property::Map propertyMap;
END_TEST;
}
+int UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliAnimatedImageVisualSynchronousLoadingWithAlphaMask02 for GPU Alpha Masking");
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ {
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
+ propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 2);
+ propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
+ propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
+ propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS, 0.23f);
+ propertyMap.Insert(DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::ABSOLUTE);
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+
+ Property::Map testMap;
+ visual.CreatePropertyMap(testMap);
+ DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
+
+ 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);
+ application.GetScene().Add(dummyControl);
+
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ application.SendNotification();
+ application.Render(20);
+
+ // The first frame is loaded synchronously and load next batch with masking
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(Test::GetTimerCount(), 1, TEST_LOCATION);
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 4, TEST_LOCATION);
+
+ dummyControl.Unparent();
+ }
+ tet_infoline("Test that removing the visual from stage deletes all textures");
+ application.SendNotification();
+ application.Render(16);
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliAnimatedImageVisualJumpToAction(void)
{
ToolkitTestApplication application;
// Note that we only re-load 0 frame.
DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
- // To do: we need to fix caching bug in animated-visual
- //tet_infoline("Test that we don't try to re-load new image cause it cached");
- //DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
+ tet_infoline("Test that we don't try to re-load new image cause it cached");
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
// Batch 2 frames. Now visual frame 1, 2, 3 cached and visual2 frame 0, 1 cached.
application.SendNotification();
int UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask01(void)
{
ToolkitTestApplication application;
- TestGlAbstraction& gl = application.GetGlAbstraction();
+ tet_infoline("UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask01 for CPU Alpha Masking");
+ TestGlAbstraction& gl = application.GetGlAbstraction();
{
Property::Map propertyMap;
END_TEST;
}
+int UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask02 for GPU Alpha Masking");
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ {
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
+ propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 4);
+ propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
+ propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
+ propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+
+ 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);
+ application.GetScene().Add(dummyControl);
+
+ application.SendNotification();
+ application.Render();
+
+ // load two frame(batch size), load mask image, and request two masking
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(20);
+
+ DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 3, TEST_LOCATION);
+
+ dummyControl.Unparent();
+ }
+ tet_infoline("Test that removing the visual from stage deletes all textures");
+ application.SendNotification();
+ application.Render(20);
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask03(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliAnimatedImageVisualAnimatedImageWithAlphaMask03 for GPU Alpha Masking with broken mask texture");
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ {
+ Property::Map propertyMap;
+ propertyMap.Insert(Visual::Property::TYPE, Visual::ANIMATED_IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_GIF_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::BATCH_SIZE, 2);
+ propertyMap.Insert(ImageVisual::Property::CACHE_SIZE, 4);
+ propertyMap.Insert(ImageVisual::Property::FRAME_DELAY, 20);
+ propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, "");
+ propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+
+ 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);
+ application.GetScene().Add(dummyControl);
+
+ application.SendNotification();
+ application.Render();
+
+ // load two frame(batch size), load mask image, and request two masking
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(20);
+
+ DALI_TEST_EQUALS(gl.GetLastGenTextureId(), 3, TEST_LOCATION);
+
+ dummyControl.Unparent();
+ }
+ tet_infoline("Test that removing the visual from stage deletes all textures");
+ application.SendNotification();
+ application.Render(20);
+ DALI_TEST_EQUALS(gl.GetNumGeneratedTextures(), 0, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliAnimatedImageVisualMultiImage01(void)
{
ToolkitTestApplication application;
application.SendNotification();
application.Render();
- // Wait for rasterization
- DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+ // Wait for loading & rasterization
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
DALI_TEST_EQUALS(control.IsResourceReady(), true, TEST_LOCATION);
DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
END_TEST;
}
-int UtcDaliImageViewSvgLoadingFailure(void)
+int UtcDaliImageViewSvgLoadingFailureLocalFile(void)
{
// Local svg file - invalid file path
{
DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
}
+ END_TEST;
+}
+
+int UtcDaliImageViewSvgLoadingFailureRemoteFile01(void)
+{
// Remote svg file
{
ToolkitTestApplication application;
textureTrace.Enable(true);
gResourceReadySignalFired = false;
- textureTrace.Reset();
ImageView imageView = ImageView::New("https://bar.org/foobar.svg");
imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
}
+ END_TEST;
+}
+
+int UtcDaliImageViewSvgLoadingFailureRemoteFile02(void)
+{
// Remote svg file without size set
{
ToolkitTestApplication application;
textureTrace.Enable(true);
gResourceReadySignalFired = false;
- textureTrace.Reset();
ImageView imageView = ImageView::New("https://bar.org/foobar.svg");
imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
}
}
+void OnResourceReadySignal05(Control control)
+{
+ gResourceReadySignalCounter++;
+
+ // Request load with same image
+ // NOTE : The url must not be same as gImageView1
+ const int viewCount = 4;
+ for(int i = 0; i < viewCount; ++i)
+ {
+ gImageView1.Add(ImageView::New("invalid2.jpg"));
+ }
+}
+
} // namespace
int UtcDaliImageViewSetImageOnResourceReadySignal01(void)
{
tet_infoline("Test signal handler various case.");
- ToolkitTestApplication application;
+ auto TestResourceReadyUrl = [](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
+ ToolkitTestApplication application;
- auto TestResourceReadyUrl = [&application](int eventTriggerCount, bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& mask, const char* location) {
gResourceReadySignalCounter = 0;
Property::Map map;
imageView.Unparent();
};
- auto TestAuxiliaryResourceReadyUrl = [&application](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
+ auto TestAuxiliaryResourceReadyUrl = [](bool isSynchronous, bool loadSuccess, const std::string& url, const std::string& auxiliaryUrl, const char* location) {
+ ToolkitTestApplication application;
+
gResourceReadySignalCounter = 0;
Property::Map map;
END_TEST;
}
+int UtcDaliImageViewSetImageOnResourceReadySignal05(void)
+{
+ tet_infoline("Test multiple views with same image during ResourceReady load the image only 1 times");
+
+ ToolkitTestApplication application;
+
+ gResourceReadySignalCounter = 0;
+
+ gImageView1 = ImageView::New("invalid.jpg"); // request invalid image, to make loading failed fast.
+ gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal05);
+ application.GetScene().Add(gImageView1);
+
+ application.SendNotification();
+ application.Render();
+
+ tet_infoline("Try to load 1 invalid.jpg image");
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION);
+
+ tet_infoline("Try to load 1 invalid2.jpg image");
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ tet_infoline("Now we don't have any image to be loaded. Check event thread trigger failed.");
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 1), false, TEST_LOCATION);
+
+ gImageView1.Unparent();
+ gImageView1.Reset();
+
+ END_TEST;
+}
END_TEST;
}
-int UtcDaliImageVisualAlphaMask(void)
+int UtcDaliImageVisualAlphaMask01(void)
{
ToolkitTestApplication application;
tet_infoline("Request image visual with a Property::Map containing an Alpha mask");
END_TEST;
}
-int UtcDaliImageVisualSynchronousLoadAlphaMask(void)
+int UtcDaliImageVisualAlphaMask02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("Request image visual with a Property::Map containing an Alpha mask for GPU");
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK(factory);
+
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
+ propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
+
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ Property::Map testMap;
+ visual.CreatePropertyMap(testMap);
+ DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
+ DALI_TEST_EQUALS(*testMap.Find(DevelImageVisual::Property::MASKING_TYPE), Property::Value(DevelImageVisual::MaskingType::MASKING_ON_RENDERING), TEST_LOCATION);
+
+ // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
+ // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
+
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
+
+ application.GetScene().Add(actor);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
+ Renderer renderer = actor.GetRendererAt(0u);
+ TextureSet textures = renderer.GetTextures();
+ DALI_TEST_CHECK(textures);
+ DALI_TEST_EQUALS(textures.GetTextureCount(), 2u, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
+
+ dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliImageVisualAlphaMask03(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("Request image visual with a Property::Map containing an Alpha mask for GPU with fail case");
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK(factory);
+
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, "dummy_path");
+ propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
+
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ Property::Map testMap;
+ visual.CreatePropertyMap(testMap);
+
+ // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
+ // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
+
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
+
+ application.GetScene().Add(actor);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
+ Renderer renderer = actor.GetRendererAt(0u);
+ TextureSet textures = renderer.GetTextures();
+ DALI_TEST_CHECK(textures);
+ DALI_TEST_EQUALS(textures.GetTextureCount(), 1u, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
+
+ dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliImageVisualSynchronousLoadAlphaMask01(void)
{
ToolkitTestApplication application;
tet_infoline("Request image visual with a Property::Map containing an Alpha mask with synchronous loading");
END_TEST;
}
+int UtcDaliImageVisualSynchronousLoadAlphaMask02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("Request image visual with a Property::Map containing an Alpha mask for GPU with synchronous loading");
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK(factory);
+
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
+ propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
+ propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
+ propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
+
+ Visual::Base visual = factory.CreateVisual(propertyMap);
+ DALI_TEST_CHECK(visual);
+
+ Property::Map testMap;
+ visual.CreatePropertyMap(testMap);
+ DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
+
+ // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
+ // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
+
+ actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
+
+ application.GetScene().Add(actor);
+
+ // Do not wait for any EventThreadTrigger in synchronous alpha mask.
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
+ Renderer renderer = actor.GetRendererAt(0u);
+ TextureSet textures = renderer.GetTextures();
+ DALI_TEST_CHECK(textures);
+ DALI_TEST_EQUALS(textures.GetTextureCount(), 2u, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
+
+ dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
+ DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliImageVisualRemoteAlphaMask(void)
{
ToolkitTestApplication application;
// Check if the number of renderers is greater than 1.
DALI_TEST_CHECK(label.GetRendererCount() > 1u);
+ // Coverage test for case of layoutSize is bigger than maxTextureSize
+ float max_value = static_cast<float>(std::numeric_limits<uint16_t>::max());
+ label.SetProperty(Actor::Property::SIZE, Vector2(max_value, 30.0f));
+ application.SendNotification();
+ application.Render();
+
+
END_TEST;
}
#include <dali-toolkit/public-api/transition/transition-set.h>
#include <dali-toolkit/public-api/transition/transition.h>
#include <dali/devel-api/actors/actor-devel.h>
+#include <dali/public-api/rendering/decorated-visual-renderer.h> // for Renderer Property Index.
#include <stdlib.h>
#include <iostream>
DALI_TEST_NOT_EQUALS(destinationPosition, control2.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.00001f, TEST_LOCATION);
DALI_TEST_EQUALS(1, control2.GetRendererCount(), TEST_LOCATION);
- Dali::Renderer renderer = control2.GetRendererAt(0);
- Property::Index index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
- cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
+ Dali::Renderer renderer = control2.GetRendererAt(0);
+ cornerRadius = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
DALI_TEST_NOT_EQUALS(destinationRadiusV4, cornerRadius, 0.00001f, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
- borderlineWidth = renderer.GetCurrentProperty<float>(index);
+ borderlineWidth = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
DALI_TEST_NOT_EQUALS(destinationBorderlineWidth, borderlineWidth, 0.00001f, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
- borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
+ borderlineColor = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR);
DALI_TEST_NOT_EQUALS(destinationBorderlineColor, borderlineColor, 0.00001f, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
- borderlineOffset = renderer.GetCurrentProperty<float>(index);
+ borderlineOffset = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET);
DALI_TEST_NOT_EQUALS(destinationBorderlineOffset, borderlineOffset, 0.00001f, TEST_LOCATION);
application.SendNotification();
DALI_TEST_EQUALS(destinationOpacity, control2.GetCurrentProperty<float>(Actor::Property::OPACITY), TEST_LOCATION);
DALI_TEST_EQUALS(1, control2.GetRendererCount(), TEST_LOCATION);
renderer = control2.GetRendererAt(0);
- index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
- cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
+ cornerRadius = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
DALI_TEST_EQUALS(destinationRadiusV4, cornerRadius, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
- borderlineWidth = renderer.GetCurrentProperty<float>(index);
+ borderlineWidth = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
DALI_TEST_EQUALS(destinationBorderlineWidth, borderlineWidth, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
- borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
+ borderlineColor = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR);
DALI_TEST_EQUALS(destinationBorderlineColor, borderlineColor, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
- borderlineOffset = renderer.GetCurrentProperty<float>(index);
+ borderlineOffset = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET);
DALI_TEST_EQUALS(destinationBorderlineOffset, borderlineOffset, TEST_LOCATION);
END_TEST;
DALI_TEST_NOT_EQUALS(destinationPosition, control1.GetCurrentProperty<Vector3>(Actor::Property::POSITION), 0.00001f, TEST_LOCATION);
DALI_TEST_EQUALS(1, control1.GetRendererCount(), TEST_LOCATION);
- Dali::Renderer renderer = control1.GetRendererAt(0);
- Property::Index index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
- cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
+ Dali::Renderer renderer = control1.GetRendererAt(0);
+ cornerRadius = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
DALI_TEST_NOT_EQUALS(destinationRadiusV4, cornerRadius, 0.00001f, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
- borderlineWidth = renderer.GetCurrentProperty<float>(index);
+ borderlineWidth = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
DALI_TEST_NOT_EQUALS(destinationBorderlineWidth, borderlineWidth, 0.00001f, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
- borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
+ borderlineColor = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR);
DALI_TEST_NOT_EQUALS(destinationBorderlineColor, borderlineColor, 0.00001f, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
- borderlineOffset = renderer.GetCurrentProperty<float>(index);
+ borderlineOffset = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET);
DALI_TEST_NOT_EQUALS(destinationBorderlineOffset, borderlineOffset, 0.00001f, TEST_LOCATION);
application.SendNotification();
DALI_TEST_EQUALS(1, control1.GetRendererCount(), TEST_LOCATION);
renderer = control1.GetRendererAt(0);
- index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
- cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
+ cornerRadius = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
DALI_TEST_EQUALS(destinationRadiusV4, cornerRadius, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
- borderlineWidth = renderer.GetCurrentProperty<float>(index);
+ borderlineWidth = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
DALI_TEST_EQUALS(destinationBorderlineWidth, borderlineWidth, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
- borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
+ borderlineColor = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR);
DALI_TEST_EQUALS(destinationBorderlineColor, borderlineColor, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
- borderlineOffset = renderer.GetCurrentProperty<float>(index);
+ borderlineOffset = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET);
DALI_TEST_EQUALS(destinationBorderlineOffset, borderlineOffset, TEST_LOCATION);
// every actor properties of control1 are returned to the source properties.
// after next update, renderer properties are returned to the source properties.
DALI_TEST_EQUALS(1, control1.GetRendererCount(), TEST_LOCATION);
renderer = control1.GetRendererAt(0);
- index = renderer.GetPropertyIndex(DevelVisual::Property::CORNER_RADIUS);
- cornerRadius = renderer.GetCurrentProperty<Vector4>(index);
+ cornerRadius = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::CORNER_RADIUS);
DALI_TEST_EQUALS(sourceRadiusV4, cornerRadius, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_WIDTH);
- borderlineWidth = renderer.GetCurrentProperty<float>(index);
+ borderlineWidth = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_WIDTH);
DALI_TEST_EQUALS(sourceBorderlineWidth, borderlineWidth, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_COLOR);
- borderlineColor = renderer.GetCurrentProperty<Vector4>(index);
+ borderlineColor = renderer.GetCurrentProperty<Vector4>(DecoratedVisualRenderer::Property::BORDERLINE_COLOR);
DALI_TEST_EQUALS(sourceBorderlineColor, borderlineColor, TEST_LOCATION);
- index = renderer.GetPropertyIndex(DevelVisual::Property::BORDERLINE_OFFSET);
- borderlineOffset = renderer.GetCurrentProperty<float>(index);
+ borderlineOffset = renderer.GetCurrentProperty<float>(DecoratedVisualRenderer::Property::BORDERLINE_OFFSET);
DALI_TEST_EQUALS(sourceBorderlineOffset, borderlineOffset, TEST_LOCATION);
END_TEST;
return true;
}
+void TestShaderCodeContainSubstrings(Control control, std::vector<std::pair<std::string, bool>> substringCheckList, const char* location)
+{
+ Renderer renderer = control.GetRendererAt(0);
+ Shader shader = renderer.GetShader();
+ Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
+ Property::Map* map = value.GetMap();
+ DALI_TEST_CHECK(map);
+
+ Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
+ DALI_TEST_CHECK(fragment);
+ std::string fragmentShader;
+ DALI_TEST_CHECK(fragment->Get(fragmentShader));
+ for(const auto& checkPair : substringCheckList)
+ {
+ const auto& keyword = checkPair.first;
+ const auto& expect = checkPair.second;
+ tet_printf("check [%s] %s exist in fragment shader\n", keyword.c_str(), expect ? "is" : "is not");
+ DALI_TEST_EQUALS((fragmentShader.find(keyword.c_str()) != std::string::npos), expect, location);
+ }
+
+ Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
+ std::string vertexShader;
+ DALI_TEST_CHECK(vertex->Get(vertexShader));
+ for(const auto& checkPair : substringCheckList)
+ {
+ const auto& keyword = checkPair.first;
+ const auto& expect = checkPair.second;
+ tet_printf("check [%s] %s exist in vertex shader\n", keyword.c_str(), expect ? "is" : "is not");
+ DALI_TEST_EQUALS((vertexShader.find(keyword.c_str()) != std::string::npos), expect, location);
+ }
+}
+
} //namespace
void dali_visual_startup(void)
application.SendNotification();
application.Render(0);
- DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ // Wait for loading & rasterization
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+
DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
Renderer renderer = actor.GetRendererAt(0);
auto textures = renderer.GetTextures();
value = resultMap.Find(ImageVisual::Property::BORDER, Property::RECTANGLE);
DALI_TEST_CHECK(value);
- DALI_TEST_CHECK(value->Get<Rect<int> >() == border);
+ DALI_TEST_CHECK(value->Get<Rect<int>>() == border);
value = resultMap.Find(DevelImageVisual::Property::AUXILIARY_IMAGE, Property::STRING);
DALI_TEST_CHECK(value);
value = resultMap.Find(ImageVisual::Property::BORDER, Property::RECTANGLE);
DALI_TEST_CHECK(value);
- DALI_TEST_CHECK(value->Get<Rect<int> >() == border);
+ DALI_TEST_CHECK(value->Get<Rect<int>>() == border);
END_TEST;
}
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+ // Wait for loading & rasterization
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
Renderer renderer = dummy.GetRendererAt(0);
Shader shader2 = renderer.GetShader();
int UtcDaliVisualRoundedCorner(void)
{
- ToolkitTestApplication application;
tet_infoline("UtcDaliVisualRoundedCorner");
static std::vector<UniformData> customUniforms =
UniformData("cornerRadiusPolicy", Property::Type::FLOAT),
};
- TestGraphicsController& graphics = application.GetGraphicsController();
- graphics.AddCustomUniforms(customUniforms);
-
// image visual
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
float cornerRadius = 30.0f;
// color visual 1
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
float cornerRadius = 30.0f;
// color visual 2
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
Vector4 cornerRadius(0.5f, 0.5f, 0.5f, 0.3f);
// color visual 3 - invalid value
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
Vector4 cornerRadius(30.0f, 30.0f, 30.0f, 20.0f);
// gradient visual
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
float cornerRadius = 30.0f;
// animated image visual
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
Vector4 cornerRadius(24.0f, 23.0f, 22.0f, 21.0f);
// vector image visual
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
Vector4 cornerRadius(27.0f, 72.0f, 11.0f, 500.5f);
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+ // Wait for loading & rasterization
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
application.SendNotification();
application.Render();
// animated vector image visual
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
float cornerRadius = 1.3f;
int UtcDaliVisualBorderline(void)
{
- ToolkitTestApplication application;
tet_infoline("UtcDaliVisualBorderline");
static std::vector<UniformData> customUniforms =
UniformData("borderlineOffset", Property::Type::FLOAT),
};
- TestGraphicsController& graphics = application.GetGraphicsController();
- graphics.AddCustomUniforms(customUniforms);
-
// image visual
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
float cornerRadius = 5.0f;
// color visual 1
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
Vector4 cornerRadius(23.0f, 2.0f, 3.0f, 2.3f);
// color visual 2, default color, default offset
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
float borderlineWidth = 30.0f;
// color visual 3, offset not [-1.0 ~ 1.0], but uniform value is same anyway
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
float borderlineWidth = 30.0f;
// gradient visual
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
float borderlineWidth = 30.0f;
// animated image visual
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
float borderlineWidth = 24.0f;
// vector image visual
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
Vector4 cornerRadius(54.0f, 43.0f, 32.0f, 21.0f);
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+ // Wait for loading & rasterization
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
application.SendNotification();
application.Render();
// animated vector image visual
{
+ ToolkitTestApplication application;
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ graphics.AddCustomUniforms(customUniforms);
+
VisualFactory factory = VisualFactory::Get();
Property::Map properties;
Vector4 cornerRadius(1.3f, 0.0f, 0.4f, 0.2f);
application.SendNotification();
application.Render();
- // Wait for image loading
- DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+ // Wait for loading & rasterization
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
application.SendNotification();
application.Render();
application.SendNotification();
application.Render();
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", false},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", false},
+ },
+ TEST_LOCATION);
+
callStack.Reset();
callStack.Enable(true);
DALI_TEST_CHECK(cornerRadiusPolicyValue);
DALI_TEST_EQUALS(cornerRadiusPolicyValue->Get<int>(), static_cast<int>(Toolkit::Visual::Transform::Policy::RELATIVE), TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", false},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true},
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
DALI_TEST_CHECK(borderlineOffsetValue);
DALI_TEST_EQUALS(borderlineOffsetValue->Get<float>(), targetBorderlineOffset, TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos);
- // Note : mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos);
- // Note : mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", true},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true}, // Note : mAlwaysUsingCornerRadius is true.
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
DALI_TEST_CHECK(borderlineOffsetValue);
DALI_TEST_EQUALS(borderlineOffsetValue->Get<float>(), 0.0f, TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- // Note : mAlwaysUsingBorderline and mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- // Note : mAlwaysUsingBorderline and mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", true}, // Note : mAlwaysUsingBorderline is true.
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true}, // Note : mAlwaysUsingCornerRadius is true.
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
application.SendNotification();
application.Render();
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", false},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", false},
+ },
+ TEST_LOCATION);
Vector4 targetCornerRadius = Vector4(0.0f, 0.0f, 0.0f, 0.0f);
DALI_TEST_CHECK(cornerRadiusValue);
DALI_TEST_EQUALS(cornerRadiusValue->Get<Vector4>(), targetCornerRadius, TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- // Note : corner radius is zero. so we don't change shader!
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- // Note : corner radius is zero. so we don't change shader!
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", false},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", false}, // Note : corner radius is zero. so we don't change shader!
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
DALI_TEST_CHECK(borderlineOffsetValue);
DALI_TEST_EQUALS(borderlineOffsetValue->Get<float>(), targetBorderlineOffset, TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- // Note : borderline width is zero. so we don't change shader!
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- // Note : borderline width is zero. so we don't change shader!
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", false}, // Note : borderline width is zero. so we don't change shader!
+ {"#define IS_REQUIRED_ROUNDED_CORNER", false},
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
application.SendNotification();
application.Render();
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BLUR 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BLUR 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") == std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BLUR", false},
+ {"#define IS_REQUIRED_BORDERLINE", false},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", false},
+ },
+ TEST_LOCATION);
float targetBlurRadius = 15.0f;
Vector4 targetCornerRadius = Vector4(1.0f, 0.1f, 1.1f, 0.0f);
DALI_TEST_CHECK(cornerRadiusValue);
DALI_TEST_EQUALS(cornerRadiusValue->Get<Vector4>(), targetCornerRadius, TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BLUR 1") != std::string::npos);
- // Note : We ignore borderline when blur radius occured
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BLUR 1") != std::string::npos);
- // Note : We ignore borderline when blur radius occured
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BLUR", true},
+ {"#define IS_REQUIRED_BORDERLINE", false}, // Note : We ignore borderline when blur radius occured
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true},
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
DALI_TEST_CHECK(cornerRadiusValue);
DALI_TEST_EQUALS(cornerRadiusValue->Get<Vector4>(), Vector4::ZERO, TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- // Note : mAlwaysUsingBlurRadius and mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BLUR 1") != std::string::npos);
- // Note : We ignore borderline when blur radius occured
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- // Note : mAlwaysUsingBlurRadius and mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BLUR 1") != std::string::npos);
- // Note : We ignore borderline when blur radius occured
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BLUR", true}, // Note : mAlwaysUsingBlurRadius is true.
+ {"#define IS_REQUIRED_BORDERLINE", false}, // Note : We ignore borderline when blur radius occured
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true}, // Note : mAlwaysUsingCornerRadius is true.
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
application.SendNotification();
application.Render();
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", false},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true},
+ },
+ TEST_LOCATION);
+
callStack.Reset();
callStack.Enable(true);
application.Render();
application.Render(1001u); // End of animation
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- // Note : mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") == std::string::npos);
- // Note : mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", false},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true}, // Note : mAlwaysUsingCornerRadius is true.
+ },
+ TEST_LOCATION);
+
callStack.Enable(false);
// Shader not changed
DALI_TEST_CHECK(!callStack.FindMethod("CreateShader"));
DALI_TEST_CHECK(borderlineWidthValue);
DALI_TEST_EQUALS(borderlineWidthValue->Get<float>(), targetBorderlineWidth, TEST_LOCATION);
- // Get shader
- {
- Renderer renderer = dummyControl.GetRendererAt(0);
- Shader shader = renderer.GetShader();
- Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
- Property::Map* map = value.GetMap();
- DALI_TEST_CHECK(map);
-
- Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
- DALI_TEST_CHECK(fragment);
- std::string fragmentShader;
- DALI_TEST_CHECK(fragment->Get(fragmentShader));
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos);
- // Note : mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(fragmentShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
-
- Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
- std::string vertexShader;
- DALI_TEST_CHECK(vertex->Get(vertexShader));
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_BORDERLINE 1") != std::string::npos);
- // Note : mAlwaysUsingCornerRadius is true.
- DALI_TEST_CHECK(vertexShader.find("#define IS_REQUIRED_ROUNDED_CORNER 1") != std::string::npos);
- }
+ TestShaderCodeContainSubstrings(
+ dummyControl,
+ {
+ {"#define IS_REQUIRED_BORDERLINE", true},
+ {"#define IS_REQUIRED_ROUNDED_CORNER", true}, // Note : mAlwaysUsingCornerRadius is true.
+ },
+ TEST_LOCATION);
// Send shader compile signal
application.SendNotification();
// Either application.SendNotification() or the trigger can now complete the task.
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ // Wait for loading & rasterization
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
// renderer is added to actor
DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
// Either application.SendNotification() or the trigger can now complete the task.
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ // Wait for loading & rasterization
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
// renderer is added to actor
DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ // Wait for loading & rasterization
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
// renderer is added to actor
DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
set(PREFIX ${prefix})
set(EXEC_PREFIX ${CMAKE_INSTALL_PREFIX})
- set(DEV_INCLUDE_PATH ${repo_root_dir})
+ set(DEV_INCLUDE_PATH ${INCLUDE_DIR})
set(core_pkg_cfg_file dali2-scene-loader.pc)
configure_file(${CMAKE_CURRENT_LIST_DIR}/${core_pkg_cfg_file}.in ${core_pkg_cfg_file} @ONLY)
auto& extras = nodeDef.mExtras;
extras.reserve(eExtras->Size());
- NodeDefinition::Extra e;
for(auto i0 = eExtras->CBegin(), i1 = eExtras->CEnd(); i0 != i1; ++i0)
{
+ NodeDefinition::Extra e;
+
auto eExtra = *i0;
e.mKey = eExtra.first;
if(e.mKey.empty())
* @param minorAxisDistance The minorAxisDistance\r
* @return The distance\r
*/\r
-static int GetWeightedDistanceFor(int majorAxisDistance, int minorAxisDistance)\r
+static uint64_t GetWeightedDistanceFor(int majorAxisDistance, int minorAxisDistance)\r
{\r
- return 13 * majorAxisDistance * majorAxisDistance + minorAxisDistance * minorAxisDistance;\r
+ return 13 * static_cast<int64_t>(majorAxisDistance) * static_cast<int64_t>(majorAxisDistance) + static_cast<int64_t>(minorAxisDistance) * static_cast<int64_t>(minorAxisDistance);\r
}\r
\r
/**\r
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
{
namespace DevelStyleManager
{
-const Property::Map GetConfigurations(StyleManager styleManager)
+const Property::Map& GetConfigurations(StyleManager styleManager)
{
return GetImpl(styleManager).GetConfigurations();
}
#define DALI_TOOLKIT_STYLE_MANAGER_DEVEL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
* @param[in] styleManager The instance of StyleManager
* @return A property map to the currently defined configurations
**/
-DALI_TOOLKIT_API const Property::Map GetConfigurations(StyleManager styleManager);
+DALI_TOOLKIT_API const Property::Map& GetConfigurations(StyleManager styleManager);
/**
* @brief Sets an image to be used when a visual has failed to correctly render
// Update the visual model.
Size newLayoutSize;
- bool isAutoScrollEnabled = false;
+ bool isAutoScrollEnabled = false;
+ bool isAutoScrollMaxTextureExceeded = false;
+
layoutEngine.LayoutText(layoutParameters,
newLayoutSize,
textParameters.ellipsisEnabled,
isAutoScrollEnabled,
+ isAutoScrollMaxTextureExceeded,
ellipsisPosition);
return newLayoutSize;
* @details Name "redrawInScalingDown", type Property::BOOLEAN.
* @note It is used in the AnimatedVectorImageVisual. The default is true.
*/
- REDRAW_IN_SCALING_DOWN
+ REDRAW_IN_SCALING_DOWN = ORIENTATION_CORRECTION + 11,
+
+ /**
+ * @brief Whether to apply mask in loading time or rendering time.
+ * @details Name "maskingType", type PlayState::Type (Property::INTEGER).
+ * @note It is used in the ImageVisual and AnimatedImageVisual. The default is MASKING_ON_LOADING.
+ */
+ MASKING_TYPE = ORIENTATION_CORRECTION + 12
};
} //namespace Property
} // namespace LoopingMode
+/**
+ * @brief Enumeration for what masking type is in.
+ */
+namespace MaskingType
+{
+enum Type
+{
+ MASKING_ON_RENDERING, ///< Alpha masking is applied for each rendering time. (On GPU)
+ MASKING_ON_LOADING ///< Alpha masking is applied when the image is loading. (On CPU)
+};
+
+}
+
} // namespace DevelImageVisual
} // namespace Toolkit
{
auto text = GetWholeText();
- if(!ValidateRange(text, startPosition, startPosition + 1))
+ if(!ValidateRange(text, startPosition, startPosition + 1) && !(startPosition == text.size()))
{
return false;
}
alignmentOffset.x = 0.0f;
alignmentOffset.y = (contentSize.y - layoutSize.y) * VERTICAL_ALIGNMENT_TABLE[mController->GetVerticalAlignment()];
+ const int maxTextureSize = Dali::GetMaxTextureSize();
+ if(layoutSize.width > maxTextureSize)
+ {
+ DALI_LOG_WARNING("layoutSize(%f) > maxTextureSize(%d): To guarantee the behavior of Texture::New, layoutSize must not be bigger than maxTextureSize\n", layoutSize.width, maxTextureSize);
+ layoutSize.width = maxTextureSize;
+ }
+
Property::Map visualTransform;
visualTransform.Add(Toolkit::Visual::Transform::Property::SIZE, layoutSize)
.Add(Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE))
if(textNaturalSize.width > maxTextureSize)
{
mController->SetTextElideEnabled(true);
+ mController->SetAutoScrollMaxTextureExceeded(true);
}
GetHeightForWidth(maxTextureSize);
wrapGap = std::max(maxTextureSize - textNaturalSize.width, 0.0f);
Renderer renderer = static_cast<Internal::Visual::Base&>(GetImplementation(mVisual)).GetRenderer();
mTextScroller->SetParameters(Self(), renderer, textureSet, controlSize, verifiedSize, wrapGap, direction, mController->GetHorizontalAlignment(), mController->GetVerticalAlignment());
mController->SetTextElideEnabled(actualellipsis);
+ mController->SetAutoScrollMaxTextureExceeded(false);
}
void TextLabel::ScrollingFinished()
${toolkit_src_dir}/image-loader/image-load-thread.cpp
${toolkit_src_dir}/image-loader/image-url-impl.cpp
${toolkit_src_dir}/styling/style-manager-impl.cpp
+ ${toolkit_src_dir}/text/abstract-style-character-run.cpp
${toolkit_src_dir}/text/bidirectional-support.cpp
${toolkit_src_dir}/text/bounded-paragraph-helper-functions.cpp
${toolkit_src_dir}/text/character-set-conversion.cpp
${toolkit_src_dir}/text/multi-language-support.cpp
${toolkit_src_dir}/text/hidden-text.cpp
${toolkit_src_dir}/text/input-filter.cpp
+ ${toolkit_src_dir}/text/line-helper-functions.cpp
${toolkit_src_dir}/text/property-string-parser.cpp
${toolkit_src_dir}/text/segmentation.cpp
${toolkit_src_dir}/text/shaper.cpp
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
if(styleManager)
{
- Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
- mAlwaysShowIndicator = config["alwaysShowFocus"].Get<bool>() ? ALWAYS_SHOW : NONE;
+ const Property::Map& config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
+ const auto alwaysShowFocusValue = config.Find("alwaysShowFocus", Property::Type::BOOLEAN);
+
+ mAlwaysShowIndicator = (alwaysShowFocusValue && alwaysShowFocusValue->Get<bool>()) ? ALWAYS_SHOW : NONE;
mIsFocusIndicatorShown = (mAlwaysShowIndicator == ALWAYS_SHOW) ? SHOW : HIDE;
mClearFocusOnTouch = (mIsFocusIndicatorShown == SHOW) ? false : true;
}
actor.Add(GetFocusIndicatorActor());
}
- Toolkit::Control currentlyFocusedControl = Toolkit::Control::DownCast(currentFocusedActor);
- if(currentlyFocusedControl)
- {
- // Do we need it to remember if it was previously DISABLED?
- currentlyFocusedControl.SetProperty(DevelControl::Property::STATE, DevelControl::NORMAL);
- currentlyFocusedControl.ClearKeyInputFocus();
- }
-
// Save the current focused actor
mCurrentFocusActor = actor;
mFocusChangedSignal.Emit(currentFocusedActor, actor);
}
+ Toolkit::Control currentlyFocusedControl = Toolkit::Control::DownCast(currentFocusedActor);
+ if(currentlyFocusedControl)
+ {
+ // Do we need it to remember if it was previously DISABLED?
+ currentlyFocusedControl.SetProperty(DevelControl::Property::STATE, DevelControl::NORMAL);
+ currentlyFocusedControl.ClearKeyInputFocus();
+ }
+
Toolkit::Control newlyFocusedControl = Toolkit::Control::DownCast(actor);
if(newlyFocusedControl)
{
nextFocusableActor = mPreFocusChangeSignal.Emit(currentFocusActor, Actor(), direction);
mIsWaitingKeyboardFocusChangeCommit = false;
}
- else if (mEnableDefaultAlgorithm)
+ else if(mEnableDefaultAlgorithm)
{
Actor rootActor = mFocusFinderRootActor.GetHandle();
if(!rootActor)
{
- if (currentFocusActor)
+ if(currentFocusActor)
{
// Find the window of the focused actor.
Integration::SceneHolder window = Integration::SceneHolder::Get(currentFocusActor);
- if (window)
+ if(window)
{
rootActor = window.GetRootLayer();
}
void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
{
- const std::string& keyName = event.GetKeyName();
+ const std::string& keyName = event.GetKeyName();
const std::string& deviceName = event.GetDeviceName();
if(mIsFocusIndicatorShown == UNKNOWN)
actor.Add(GetFocusIndicatorActor());
}
}
- else
+ else if(!mEnableDefaultAlgorithm)
{
// No actor is focused but keyboard focus is activated by the key press
// Let's try to move the initial focus
bool KeyboardFocusManager::OnCustomWheelEvent(const WheelEvent& event)
{
- bool consumed = false;
- Actor actor = GetCurrentFocusActor();
+ bool consumed = false;
+ Actor actor = GetCurrentFocusActor();
if(actor)
{
// Notify the actor about the wheel event
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 );
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy );
+ return vec4( (aPosition + anchorPoint)*visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0 );
}
void main()
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
vPosition = aPosition* visualSize;
- return vec4( vPosition + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );
+ return vec4( vPosition + anchorPoint*visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0 );
}
void main()
vec2 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
- return (aPosition + anchorPoint)*visualSize + (visualOffset + origin)*uSize.xy;
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
+ return (aPosition + anchorPoint)*visualSize + visualOffset + origin * uSize.xy;
}
void main()
-#ifndef IS_REQUIRED_ROUNDED_CORNER
-#define IS_REQUIRED_ROUNDED_CORNER 0
-#endif
-#ifndef IS_REQUIRED_BORDERLINE
-#define IS_REQUIRED_BORDERLINE 0
-#endif
-#ifndef IS_REQUIRED_BLUR
-#define IS_REQUIRED_BLUR 0
-#endif
-
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE || IS_REQUIRED_BLUR
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE) || defined(IS_REQUIRED_BLUR)
INPUT mediump vec2 vPosition;
INPUT mediump vec2 vRectSize;
INPUT mediump vec2 vOptRectSize;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
INPUT mediump vec4 vCornerRadius;
#endif
#endif
uniform lowp vec4 uColor;
uniform lowp vec3 mixColor;
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_BORDERLINE
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
uniform mediump float borderlineWidth;
uniform mediump float borderlineOffset;
uniform lowp vec4 borderlineColor;
uniform lowp vec4 uActorColor;
#endif
-#if IS_REQUIRED_BLUR
+#ifdef IS_REQUIRED_BLUR
uniform mediump float blurRadius;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE || IS_REQUIRED_BLUR
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE) || defined(IS_REQUIRED_BLUR)
// Global values both rounded corner and borderline use
// radius of rounded corner on this quadrant
void calculateCornerRadius()
{
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
gRadius =
mix(
mix(vCornerRadius.x, vCornerRadius.y, sign(vPosition.x) * 0.5 + 0.5),
{
gFragmentPosition = abs(vPosition) - vRectSize;
gCenterPosition = -gRadius;
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_BORDERLINE
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
gCenterPosition += borderlineWidth * (clamp(borderlineOffset, -1.0, 1.0) + 1.0) * 0.5;
#endif
gDiff = gFragmentPosition - gCenterPosition;
gMaxOutlinePotential = gRadius + gPotentialRange;
gMinOutlinePotential = gRadius - gPotentialRange;
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_BORDERLINE
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
gMaxInlinePotential = gMaxOutlinePotential - borderlineWidth;
gMinInlinePotential = gMinOutlinePotential - borderlineWidth;
#else
}
#endif
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_BORDERLINE
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
{
mediump float potential = gPotential;
}
#endif
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_ROUNDED_CORNER
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_ROUNDED_CORNER)
mediump float calculateCornerOpacity()
{
mediump float potential = gPotential;
}
#endif
-#if IS_REQUIRED_BLUR
+#ifdef IS_REQUIRED_BLUR
mediump float calculateBlurOpacity()
{
// Don't use borderline!
mediump float cy = gRadius + blurRadius;
mediump float cr = gRadius + blurRadius;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
// This routine make perfect circle. If corner radius is not exist, we don't consider prefect circle.
cy = min(cy, min(vRectSize.x, vRectSize.y) - gRadius);
#endif
// highest point of that circle is (x, x + r) and potential is x + r
// solve (v.x - x)^2 + (v.y - x)^2 = (cr / cy * x)^2
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
// Note : lowspec HW cannot calculate here. need to reduce numeric error
highp float A = (cr * cr - 2.0 * cy * cy);
highp float B = cy * (v.x + v.y);
{
lowp vec4 targetColor = vec4(mixColor, 1.0) * uColor;
-#if IS_REQUIRED_BLUR || IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_BLUR) || defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
// skip most potential calculate for performance
if(abs(vPosition.x) < vOptRectSize.x && abs(vPosition.y) < vOptRectSize.y)
{
PreprocessPotential();
#endif
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_BORDERLINE
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
targetColor = convertBorderlineColor(targetColor);
#endif
OUT_COLOR = targetColor;
-#if IS_REQUIRED_BLUR
+#ifdef IS_REQUIRED_BLUR
mediump float opacity = calculateBlurOpacity();
OUT_COLOR.a *= opacity;
-#elif IS_REQUIRED_ROUNDED_CORNER
+#elif defined(IS_REQUIRED_ROUNDED_CORNER)
mediump float opacity = calculateCornerOpacity();
OUT_COLOR.a *= opacity;
#endif
-#if IS_REQUIRED_BLUR || IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_BLUR) || defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
}
#endif
}
-#ifndef IS_REQUIRED_ROUNDED_CORNER
-#define IS_REQUIRED_ROUNDED_CORNER 0
-#endif
-#ifndef IS_REQUIRED_BORDERLINE
-#define IS_REQUIRED_BORDERLINE 0
-#endif
-#ifndef IS_REQUIRED_BLUR
-#define IS_REQUIRED_BLUR 0
-#endif
-
INPUT mediump vec2 aPosition;
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE || IS_REQUIRED_BLUR
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE) || defined(IS_REQUIRED_BLUR)
OUTPUT mediump vec2 vPosition;
OUTPUT mediump vec2 vRectSize;
OUTPUT mediump vec2 vOptRectSize;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
OUTPUT mediump vec4 vCornerRadius;
#endif
#endif
uniform mediump vec4 offsetSizeMode;
uniform mediump vec2 origin;
uniform mediump vec2 anchorPoint;
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_BORDERLINE
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
uniform mediump float borderlineWidth;
uniform mediump float borderlineOffset;
#endif
-#if IS_REQUIRED_BLUR
+#ifdef IS_REQUIRED_BLUR
uniform mediump float blurRadius;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
uniform mediump vec4 cornerRadius;
uniform mediump float cornerRadiusPolicy;
#endif
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
- vec2 visualOffset = mix(offset, offset/uSize.xy, offsetSizeMode.xy);
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw ) + extraSize;
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE || IS_REQUIRED_BLUR
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE) || defined(IS_REQUIRED_BLUR)
vRectSize = visualSize * 0.5;
vOptRectSize = vRectSize;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
-#if !IS_REQUIRED_BLUR && IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_ROUNDED_CORNER
+#if !defined(IS_REQUIRED_BLUR) && defined(IS_REQUIRED_BORDERLINE)
mediump float minSize = min(visualSize.x, visualSize.y) + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth;
#else
mediump float minSize = min(visualSize.x, visualSize.y);
vOptRectSize -= 0.2929 * maxRadius + 1.0;
#endif
-#if IS_REQUIRED_BLUR
+#ifdef IS_REQUIRED_BLUR
vPosition = aPosition * (visualSize + 2.0 * blurRadius);
vOptRectSize -= blurRadius + 1.0;
-#elif IS_REQUIRED_BORDERLINE
+#elif defined(IS_REQUIRED_BORDERLINE)
vPosition = aPosition * (visualSize + (1.0 + clamp(borderlineOffset, -1.0, 1.0))* borderlineWidth);
vOptRectSize -= (1.0 - clamp(borderlineOffset, -1.0, 1.0)) * 0.5 * borderlineWidth + 1.0;
-#elif IS_REQUIRED_ROUNDED_CORNER
+#elif defined(IS_REQUIRED_ROUNDED_CORNER)
vPosition = aPosition * visualSize;
#else
mediump vec2 vPosition = aPosition * visualSize;
#endif
- return vec4(vPosition + anchorPoint * visualSize + (visualOffset + origin) * uSize.xy, 0.0, 1.0);
+ return vec4(vPosition + anchorPoint * visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0);
}
void main()
-#ifndef IS_REQUIRED_ROUNDED_CORNER
-#define IS_REQUIRED_ROUNDED_CORNER 0
-#endif
-#ifndef IS_REQUIRED_BORDERLINE
-#define IS_REQUIRED_BORDERLINE 0
-#endif
-#ifndef RADIAL
-#define RADIAL 0
-#endif
-
INPUT mediump vec2 vTexCoord;
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
INPUT mediump vec2 vPosition;
INPUT mediump vec2 vRectSize;
INPUT mediump vec2 vOptRectSize;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
INPUT mediump vec4 vCornerRadius;
#endif
#endif
uniform sampler2D sTexture; // sampler1D?
uniform lowp vec4 uColor;
uniform lowp vec3 mixColor;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
uniform mediump float borderlineWidth;
uniform mediump float borderlineOffset;
uniform lowp vec4 borderlineColor;
uniform lowp vec4 uActorColor;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
// Global values both rounded corner and borderline use
// radius of rounded corner on this quadrant
void calculateCornerRadius()
{
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
gRadius =
mix(
mix(vCornerRadius.x, vCornerRadius.y, sign(vPosition.x) * 0.5 + 0.5),
{
gFragmentPosition = abs(vPosition) - vRectSize;
gCenterPosition = -gRadius;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
gCenterPosition += borderlineWidth * (clamp(borderlineOffset, -1.0, 1.0) + 1.0) * 0.5;
#endif
gDiff = gFragmentPosition - gCenterPosition;
gMaxOutlinePotential = gRadius + gPotentialRange;
gMinOutlinePotential = gRadius - gPotentialRange;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
gMaxInlinePotential = gMaxOutlinePotential - borderlineWidth;
gMinInlinePotential = gMinOutlinePotential - borderlineWidth;
#else
#endif
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
{
mediump float potential = gPotential;
}
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
mediump float calculateCornerOpacity()
{
mediump float potential = gPotential;
void main()
{
-#if RADIAL
+#ifdef RADIAL
lowp vec4 textureColor = TEXTURE(sTexture, vec2(length(vTexCoord), 0.5)) * vec4(mixColor, 1.0) * uColor;
#else
lowp vec4 textureColor = TEXTURE(sTexture, vec2(vTexCoord.y, 0.5)) * vec4(mixColor, 1.0) * uColor;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
// skip most potential calculate for performance
if(abs(vPosition.x) < vOptRectSize.x && abs(vPosition.y) < vOptRectSize.y)
{
PreprocessPotential();
#endif
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
textureColor = convertBorderlineColor(textureColor);
#endif
OUT_COLOR = textureColor;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
mediump float opacity = calculateCornerOpacity();
OUT_COLOR *= opacity;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
}
#endif
}
-#ifndef IS_REQUIRED_ROUNDED_CORNER
-#define IS_REQUIRED_ROUNDED_CORNER 0
-#endif
-#ifndef IS_REQUIRED_BORDERLINE
-#define IS_REQUIRED_BORDERLINE 0
-#endif
-#ifndef USER_SPACE
-#define USER_SPACE 0
-#endif
-
INPUT mediump vec2 aPosition;
OUTPUT mediump vec2 vTexCoord;
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
OUTPUT mediump vec2 vPosition;
OUTPUT mediump vec2 vRectSize;
OUTPUT mediump vec2 vOptRectSize;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
OUTPUT mediump vec4 vCornerRadius;
#endif
#endif
uniform mediump vec4 offsetSizeMode;
uniform mediump vec2 origin;
uniform mediump vec2 anchorPoint;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
uniform mediump float borderlineWidth;
uniform mediump float borderlineOffset;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
uniform mediump vec4 cornerRadius;
uniform mediump float cornerRadiusPolicy;
#endif
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
vRectSize = visualSize * 0.5;
vOptRectSize = vRectSize;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_BORDERLINE
mediump float minSize = min(visualSize.x, visualSize.y) + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth;
#else
mediump float minSize = min(visualSize.x, visualSize.y);
#endif
mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
vPosition = aPosition * (visualSize + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth);
vertexPosition.xy *= (1.0 + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth / visualSize);
vOptRectSize -= (1.0 - clamp(borderlineOffset, -1.0, 1.0)) * 0.5 * borderlineWidth + 1.0;
-#elif IS_REQUIRED_ROUNDED_CORNER
+#elif defined(IS_REQUIRED_ROUNDED_CORNER)
vPosition = aPosition * visualSize;
#else
mediump vec2 vPosition = aPosition * visualSize;
#endif
-#if USER_SPACE
+#ifdef USER_SPACE
vertexPosition.xyz *= uSize;
#endif
vTexCoord = (uAlignmentMatrix*vertexPosition.xyw).xy;
- return vec4(vPosition + anchorPoint * visualSize + (visualOffset + origin) * uSize.xy, 0.0, 1.0);
+ return vec4(vPosition + anchorPoint * visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0);
}
void main()
-#ifndef IS_REQUIRED_ROUNDED_CORNER
-#define IS_REQUIRED_ROUNDED_CORNER 0
-#endif
-#ifndef IS_REQUIRED_BORDERLINE
-#define IS_REQUIRED_BORDERLINE 0
-#endif
-#ifndef ATLAS_DEFAULT_WARP
-#define ATLAS_DEFAULT_WARP 0
-#endif
-#ifndef ATLAS_CUSTOM_WARP
-#define ATLAS_CUSTOM_WARP 0
-#endif
-
INPUT mediump vec2 vTexCoord;
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
INPUT mediump vec2 vPosition;
INPUT mediump vec2 vRectSize;
INPUT mediump vec2 vOptRectSize;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
INPUT mediump vec4 vCornerRadius;
#endif
#endif
uniform sampler2D sTexture;
-#if ATLAS_DEFAULT_WARP
+
+#ifdef IS_REQUIRED_ALPHA_MASKING
+uniform sampler2D sMaskTexture;
+INPUT mediump vec2 vMaskTexCoord;
+#endif
+
+#ifdef ATLAS_DEFAULT_WARP
uniform mediump vec4 uAtlasRect;
-#elif ATLAS_CUSTOM_WARP
+#elif defined(ATLAS_CUSTOM_WARP)
// WrapMode -- 0: CLAMP; 1: REPEAT; 2: REFLECT;
uniform lowp vec2 wrapMode;
#endif
uniform lowp vec4 uColor;
uniform lowp vec3 mixColor;
uniform lowp float preMultipliedAlpha;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
uniform mediump float borderlineWidth;
uniform mediump float borderlineOffset;
uniform lowp vec4 borderlineColor;
uniform lowp vec4 uActorColor;
#endif
-#if ATLAS_CUSTOM_WARP
+#ifdef ATLAS_CUSTOM_WARP
mediump float wrapCoordinate( mediump vec2 range, mediump float coordinate, lowp float wrap )
{
mediump float coord;
}
#endif
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
// Global values both rounded corner and borderline use
// radius of rounded corner on this quadrant
void calculateCornerRadius()
{
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
gRadius =
mix(
mix(vCornerRadius.x, vCornerRadius.y, sign(vPosition.x) * 0.5 + 0.5),
{
gFragmentPosition = abs(vPosition) - vRectSize;
gCenterPosition = -gRadius;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
gCenterPosition += borderlineWidth * (clamp(borderlineOffset, -1.0, 1.0) + 1.0) * 0.5;
#endif
gDiff = gFragmentPosition - gCenterPosition;
gMaxOutlinePotential = gRadius + gPotentialRange;
gMinOutlinePotential = gRadius - gPotentialRange;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
gMaxInlinePotential = gMaxOutlinePotential - borderlineWidth;
gMinInlinePotential = gMinOutlinePotential - borderlineWidth;
#else
}
#endif
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
{
mediump float potential = gPotential;
}
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
mediump float calculateCornerOpacity()
{
mediump float potential = gPotential;
void main()
{
-#if ATLAS_DEFAULT_WARP
+#ifdef ATLAS_DEFAULT_WARP
mediump vec2 texCoord = clamp( mix( uAtlasRect.xy, uAtlasRect.zw, vTexCoord ), uAtlasRect.xy, uAtlasRect.zw );
-#elif ATLAS_CUSTOM_WARP
+#elif defined(ATLAS_CUSTOM_WARP)
mediump vec2 texCoord = vec2( wrapCoordinate( uAtlasRect.xz, vTexCoord.x, wrapMode.x ),
wrapCoordinate( uAtlasRect.yw, vTexCoord.y, wrapMode.y ) );
#else
lowp vec4 textureColor = TEXTURE( sTexture, texCoord ) * vec4( mixColor, 1.0 ) * uColor;
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_ALPHA_MASKING
+ mediump float maskAlpha = TEXTURE(sMaskTexture, vMaskTexCoord).a;
+ textureColor.a *= maskAlpha;
+ textureColor.rgb *= mix(1.0, maskAlpha, preMultipliedAlpha);
+#endif
+
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
// skip most potential calculate for performance
if(abs(vPosition.x) < vOptRectSize.x && abs(vPosition.y) < vOptRectSize.y)
{
PreprocessPotential();
#endif
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
textureColor = convertBorderlineColor(textureColor);
#endif
OUT_COLOR = textureColor;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
mediump float opacity = calculateCornerOpacity();
OUT_COLOR.a *= opacity;
OUT_COLOR.rgb *= mix(1.0, opacity, preMultipliedAlpha);
#endif
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
}
#endif
}
-#ifndef IS_REQUIRED_ROUNDED_CORNER
-#define IS_REQUIRED_ROUNDED_CORNER 0
-#endif
-#ifndef IS_REQUIRED_BORDERLINE
-#define IS_REQUIRED_BORDERLINE 0
-#endif
-
INPUT mediump vec2 aPosition;
OUTPUT mediump vec2 vTexCoord;
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
OUTPUT mediump vec2 vPosition;
OUTPUT mediump vec2 vRectSize;
OUTPUT mediump vec2 vOptRectSize;
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
OUTPUT mediump vec4 vCornerRadius;
#endif
#endif
uniform mediump vec4 offsetSizeMode;
uniform mediump vec2 origin;
uniform mediump vec2 anchorPoint;
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
uniform mediump float borderlineWidth;
uniform mediump float borderlineOffset;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_ROUNDED_CORNER
uniform mediump vec4 cornerRadius;
uniform mediump float cornerRadiusPolicy;
#endif
+#ifdef IS_REQUIRED_ALPHA_MASKING
+OUTPUT mediump vec2 vMaskTexCoord;
+uniform lowp float cropToMask;
+uniform mediump vec2 maskTextureRatio;
+#endif
uniform mediump vec2 extraSize;
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy * size, size, offsetSizeMode.zw) + extraSize;
- vec2 visualOffset = mix(offset, offset/uSize.xy, offsetSizeMode.xy);
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw) + extraSize;
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
-#if IS_REQUIRED_ROUNDED_CORNER || IS_REQUIRED_BORDERLINE
+#if defined(IS_REQUIRED_ROUNDED_CORNER) || defined(IS_REQUIRED_BORDERLINE)
vRectSize = visualSize * 0.5;
vOptRectSize = vRectSize;
#endif
-#if IS_REQUIRED_ROUNDED_CORNER
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_ROUNDED_CORNER
+#ifdef IS_REQUIRED_BORDERLINE
mediump float minSize = min(visualSize.x, visualSize.y) + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth;
#else
mediump float minSize = min(visualSize.x, visualSize.y);
vOptRectSize -= 0.2929 * maxRadius + 1.0;
#endif
-#if IS_REQUIRED_BORDERLINE
+#ifdef IS_REQUIRED_BORDERLINE
vPosition = aPosition * (visualSize + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth);
vOptRectSize -= (1.0 - clamp(borderlineOffset, -1.0, 1.0)) * 0.5 * borderlineWidth + 1.0;
-#elif IS_REQUIRED_ROUNDED_CORNER
+#elif defined(IS_REQUIRED_ROUNDED_CORNER)
vPosition = aPosition * visualSize;
#else
mediump vec2 vPosition = aPosition * visualSize;
#endif
- vTexCoord = pixelArea.xy + pixelArea.zw * (vPosition.xy / max(vec2(1.0), visualSize) + vec2(0.5));
- return vec4(vPosition + anchorPoint * visualSize + (visualOffset + origin) * uSize.xy, 0.0, 1.0);
+ vec4 finalPixelArea = pixelArea;
+#ifdef IS_REQUIRED_ALPHA_MASKING
+ finalPixelArea = mix(pixelArea,
+ vec4(
+ vec2(0.5) + (pixelArea.xy - vec2(0.5)) * maskTextureRatio,
+ pixelArea.zw * maskTextureRatio
+ ),
+ cropToMask);
+ vMaskTexCoord = pixelArea.xy + pixelArea.zw * (vPosition.xy / max(vec2(1.0), visualSize) + vec2(0.5));
+#endif
+ vTexCoord = finalPixelArea.xy + finalPixelArea.zw * (vPosition.xy / max(vec2(1.0), visualSize) + vec2(0.5));
+
+ return vec4(vPosition + anchorPoint * visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0);
}
void main()
vec4 ComputeVertexPosition()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw );
float scaleFactor = min( visualSize.x, visualSize.y );
vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
- vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
- return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+ vec3 visualOffset = vec3( offset * offsetSizeMode.xy + offset * uSize.xy * (1.0 - offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+ return vec4( (aPosition + anchorPointFlipY)*scaleFactor + visualOffset + originFlipY * uSize, 1.0 );
}
void main()
float scaleFactor = min( visualSize.x, visualSize.y );
vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
- vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
- return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+ vec3 visualOffset = vec3( offset * offsetSizeMode.xy + offset * uSize.xy * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+ return vec4( (aPosition + anchorPointFlipY)*scaleFactor + visualOffset + originFlipY * uSize, 1.0 );
}
void main()
float scaleFactor = min( visualSize.x, visualSize.y );
vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
- vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
- return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+ vec3 visualOffset = vec3( offset * offsetSizeMode.xy + offset * uSize.xy * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+ return vec4( (aPosition + anchorPointFlipY)*scaleFactor + visualOffset + originFlipY * uSize, 1.0 );
}
void main()
void main()
{
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw ) + extraSize;
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
mediump vec2 size = visualSize.xy;
mediump vec4 gridPosition = vec4( fixedFactor * fixedScaleDownRate + ( size - fixedTotal * fixedScaleDownRate ) * stretch, 0.0, 1.0 );
mediump vec4 vertexPosition = gridPosition;
vertexPosition.xy -= size * vec2( 0.5, 0.5 );
- vertexPosition.xy += anchorPoint*size + (visualOffset + origin)*uSize.xy;
+ vertexPosition.xy += anchorPoint*size + visualOffset + origin * uSize.xy;
vertexPosition = uMvpMatrix * vertexPosition;
mediump vec2 fixedTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].x, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].x );
mediump vec2 stretchTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].y, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].y );
- vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw ) + extraSize;
- vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw ) + extraSize;
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
// Scale down if fixedTotal is bigger than visualSize
mediump float fixedScaleDownRate = min(1.0, min(visualSize.x / fixedTotal.x, visualSize.y / fixedTotal.y));
mediump vec4 gridPosition = vec4( fixedFactor * fixedScaleDownRate + ( visualSize.xy - fixedTotal * fixedScaleDownRate ) * stretch / stretchTotal, 0.0, 1.0 );
mediump vec4 vertexPosition = gridPosition;
vertexPosition.xy -= visualSize.xy * vec2( 0.5, 0.5 );
- vertexPosition.xy += anchorPoint*visualSize + (visualOffset + origin)*uSize.xy;
+ vertexPosition.xy += anchorPoint*visualSize + visualOffset + origin * uSize.xy;
vertexPosition = uMvpMatrix * vertexPosition;
vTexCoord = ( fixedFactor + stretch ) / ( fixedTotal + stretchTotal );
float scaleFactor = min( visualSize.x / uObjectDimensions.x, visualSize.y / uObjectDimensions.y );
vec3 originFlipY =vec3(origin.x, -origin.y, 0.0);
vec3 anchorPointFlipY = vec3( anchorPoint.x, -anchorPoint.y, 0.0);
- vec3 offset = vec3( ( offset / uSize.xy ) * offsetSizeMode.xy + offset * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
+ vec3 visualOffset = vec3( offset * offsetSizeMode.xy + offset * uSize.xy * (1.0-offsetSizeMode.xy), 0.0) * vec3(1.0,-1.0,1.0);
- return vec4( (aPosition + anchorPointFlipY)*scaleFactor + (offset + originFlipY)*uSize, 1.0 );
+ return vec4( (aPosition + anchorPointFlipY)*scaleFactor + visualOffset + originFlipY * uSize, 1.0 );
}
void main()
attribute mediump vec2 aPosition;
varying highp vec2 vTexCoord;
uniform highp vec3 uSize;
-uniform mediump float uDelta;
+uniform highp float uDelta;
uniform mediump vec2 uTextureSize;
-uniform mediump float uGap;
+uniform highp float uGap;
uniform mediump float uHorizontalAlign;
uniform mediump float uVerticalAlign;
void main()
{
- mediump vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy );
- mediump vec2 visualSize = mix( uSize.xy * size, size, offsetSizeMode.zw );
+ highp vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw);
+ highp vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
- vTexCoord.x = ( uDelta + uHorizontalAlign * ( uTextureSize.x - visualSize.x - uGap ) + floor( aPosition.x * visualSize.x ) + 0.5 - uGap * 0.5 ) / uTextureSize.x + 0.5;
- vTexCoord.y = ( uVerticalAlign * ( uTextureSize.y - visualSize.y ) + floor( aPosition.y * visualSize.y ) + 0.5 ) / ( uTextureSize.y ) + 0.5;
+ vTexCoord.x = ( uDelta + uHorizontalAlign * ( uTextureSize.x - visualSize.x - uGap ) + aPosition.x * visualSize.x - uGap * 0.5 ) / uTextureSize.x + 0.5;
+ vTexCoord.y = ( uVerticalAlign * ( uTextureSize.y - visualSize.y ) + aPosition.y * visualSize.y ) / ( uTextureSize.y ) + 0.5;
- mediump vec4 vertexPosition = vec4( floor( ( aPosition + anchorPoint ) * visualSize + ( visualOffset + origin ) * uSize.xy ), 0.0, 1.0 );
+ highp vec4 vertexPosition = vec4( ( aPosition + anchorPoint ) * visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0 );
gl_Position = uMvpMatrix * vertexPosition;
}
\ No newline at end of file
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 );
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
+ return vec4( (aPosition + anchorPoint) * visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0 );
}
void main()
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 );
+ vec2 visualSize = mix(size * uSize.xy, size, offsetSizeMode.zw );
+ vec2 visualOffset = mix(offset * uSize.xy, offset, offsetSizeMode.xy);
+ return vec4( (aPosition + anchorPoint)*visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0 );
}
void main()
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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 Property::Map StyleManager::GetConfigurations()
+const Property::Map& StyleManager::GetConfigurations()
{
DALI_LOG_STREAM(gLogFilter, Debug::Concise, "GetConfigurations()\n On entry, mThemeBuilder: " << (bool(mThemeBuilder) ? "Created" : "Empty") << " mThemeFile: " << mThemeFile);
- Property::Map result;
- if(mThemeBuilder)
- {
- result = mThemeBuilder.GetConfigurations();
- }
- else
+ if(!mThemeBuilder)
{
DALI_LOG_STREAM(gLogFilter, Debug::Concise, "GetConfigurations() Loading default theme");
- bool themeLoaded = false;
-
mThemeBuilder = CreateBuilder(mThemeBuilderConstants);
// Load default theme because this is first try to load stylesheet.
- themeLoaded = LoadJSON(mThemeBuilder, mDefaultThemeFilePath);
- mThemeFile = mDefaultThemeFilePath;
-
- if(themeLoaded)
- {
- result = mThemeBuilder.GetConfigurations();
- }
+#if defined(DEBUG_ENABLED)
+ bool themeLoaded = LoadJSON(mThemeBuilder, mDefaultThemeFilePath);
DALI_LOG_STREAM(gLogFilter, Debug::Concise, " themeLoaded" << (themeLoaded ? "success" : "failure"));
+#else
+ LoadJSON(mThemeBuilder, mDefaultThemeFilePath);
+#endif
+
+ mThemeFile = mDefaultThemeFilePath;
}
+#if defined(DEBUG_ENABLED)
+ Property::Map result = mThemeBuilder.GetConfigurations();
DALI_LOG_STREAM(gLogFilter, Debug::Concise, "GetConfigurations()\n On exit, result Count: " << (result.Count() != 0));
DALI_LOG_STREAM(gLogFilter, Debug::Verbose, " result: " << result);
+#endif
- return result;
+ return mThemeBuilder.GetConfigurations();
}
void StyleManager::SetBrokenImageUrl(DevelStyleManager::BrokenImageType brokenImageType, const std::string& brokenImageUrl)
{
- int brokenType = static_cast<int>(brokenImageType);
- mBrokenImageUrls[brokenType] = brokenImageUrl;
+ int brokenType = static_cast<int>(brokenImageType);
+ mBrokenImageUrls[brokenType] = brokenImageUrl;
Toolkit::StyleManager styleManager = StyleManager::Get();
mBrokenImageChangedSignal.Emit(styleManager);
}
#define DALI_TOOLKIT_INTERNAL_STYLE_MANAGER_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/builder/builder.h>
+#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
#include <dali-toolkit/internal/builder/style.h>
#include <dali-toolkit/public-api/styling/style-manager.h>
-#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
namespace Dali
{
/**
* @copydoc Toolkit::StyleManager::GetConfigurations
*/
- const Property::Map GetConfigurations();
+ const Property::Map& GetConfigurations();
/**
* @copydoc Toolkit::DevelStyleManager::SetBrokenImageUrl
Toolkit::Internal::FeedbackStyle* mFeedbackStyle; ///< Feedback style
- std::vector<std::string> mBrokenImageUrls; ///< Broken Image Urls received from user
+ std::vector<std::string> mBrokenImageUrls; ///< Broken Image Urls received from user
// Signals
Toolkit::StyleManager::StyleChangedSignalType mControlStyleChangeSignal; ///< Emitted when the style( theme/font ) changes for the controls to style themselves
--- /dev/null
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// FILE HEADER
+#include <dali-toolkit/internal/text/abstract-style-character-run.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+CharacterIndex AbstractStyleCharacterRun::GetStartCharacterIndex() const
+{
+ return characterRun.characterIndex;
+}
+
+Length AbstractStyleCharacterRun::GetNumberOfCharacters() const
+{
+ return characterRun.numberOfCharacters;
+}
+
+CharacterIndex AbstractStyleCharacterRun::GetEndCharacterIndex() const
+{
+ return characterRun.GetEndCharacterIndex();
+}
+
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_ABSTRACT_STYLE_CHARACTER_RUN_H
+#define DALI_TOOLKIT_TEXT_ABSTRACT_STYLE_CHARACTER_RUN_H
+
+/*
+ * Copyright (c) 2022 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/common/type-traits.h>
+#include <dali/public-api/math/vector4.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/character-run.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+/**
+ * @brief Run of characters with the same style.
+ */
+struct AbstractStyleCharacterRun
+{
+ CharacterRun characterRun; ///< The initial character index and the number of characters of the run.
+
+ // Constructors
+
+protected:
+ /**
+ * @brief Constructor.
+ * Default constructor to set the default values
+ */
+ AbstractStyleCharacterRun()
+ : characterRun{}
+ {
+ }
+
+ /**
+ * @brief Constructor.
+ * Default constructor to set the default values
+ *
+ * @param[in] characterRun the character run
+ */
+ AbstractStyleCharacterRun(const CharacterRun& characterRun)
+ : characterRun{characterRun}
+ {
+ }
+
+public:
+ AbstractStyleCharacterRun(const AbstractStyleCharacterRun&) = default;
+
+ AbstractStyleCharacterRun(AbstractStyleCharacterRun&&) noexcept = default;
+
+ // Operators
+
+ AbstractStyleCharacterRun& operator=(const AbstractStyleCharacterRun&) = default;
+
+ AbstractStyleCharacterRun& operator=(AbstractStyleCharacterRun&&) noexcept = default;
+
+ /**
+ * @brief Destructor.
+ */
+ virtual ~AbstractStyleCharacterRun() = default;
+
+ //Methods
+
+ /**
+ * @brief Retrive the first index in run.
+ * @return the end character index in run.
+ */
+ CharacterIndex GetStartCharacterIndex() const;
+
+ /**
+ * @brief Retrive the number of characters in the run.
+ * @return the the number of characters in run.
+ */
+ Length GetNumberOfCharacters() const;
+
+ /**
+ * @brief Calculate the end index in run.
+ * @return the end character index in run.
+ */
+ CharacterIndex GetEndCharacterIndex() const;
+};
+
+} // namespace Text
+
+} // namespace Toolkit
+
+// Allow AbstractStyleCharacterRun to be treated as a POD type
+template<>
+struct TypeTraits<Dali::Toolkit::Text::AbstractStyleCharacterRun> : public Dali::BasicTypes<Dali::Toolkit::Text::AbstractStyleCharacterRun>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_ABSTRACT_STYLE_CHARACTER_RUN_H
#include <dali/public-api/math/vector2.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/text/character-run.h>
+#include <dali-toolkit/internal/text/abstract-style-character-run.h>
#include <dali-toolkit/public-api/text/text-enumerations.h>
namespace Dali
* Bounded-paragraph could contain multi paragraphs that have been breaked by Paragraph Separators or appropriate Newline Functions.
* This will be used to handle information for the attributes of markup tag. Like TextAlign, TextDirection, TextIndent, LineHeight, etc.
*/
-struct BoundedParagraphRun
+struct BoundedParagraphRun : public AbstractStyleCharacterRun
{
/**
* Default constructor to set the default values of bitfields
*/
BoundedParagraphRun()
- : characterRun{},
+ : AbstractStyleCharacterRun(),
horizontalAlignment(Text::HorizontalAlignment::BEGIN),
relativeLineSize(1),
horizontalAlignmentDefined{false},
{
}
- CharacterRun characterRun; ///< The initial character index within the whole text and the number of characters of the run.
Text::HorizontalAlignment::Type horizontalAlignment; ///< The paragraph horizontal alignment. Values "BEGIN" "CENTER" "END".
float relativeLineSize; ///< The relative line height to be used for this paragaraph.
bool horizontalAlignmentDefined : 1; ///< Whether the horizontal alignment is defined.
} // namespace Toolkit
+// Allow BoundedParagraphRun to be treated as a POD type
+template<>
+struct TypeTraits<Dali::Toolkit::Text::BoundedParagraphRun> : public Dali::BasicTypes<Dali::Toolkit::Text::BoundedParagraphRun>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+
} // namespace Dali
#endif // DALI_TOOLKIT_TEXT_BOUNDED_PARAGRAPH_RUN_H
*
*/
-// EXTERNAL INCLUDES
-#include <dali/public-api/math/vector4.h>
-
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/text/character-run.h>
+#include <dali-toolkit/internal/text/abstract-style-character-run.h>
namespace Dali
{
/**
* @brief Run of character-spacing characters with same properties.
*/
-struct CharacterSpacingCharacterRun
+struct CharacterSpacingCharacterRun : public AbstractStyleCharacterRun
{
/**
- * Default constructor to set the default values of bitfields
+ * @brief Constructor.
+ * Default constructor to set the default values
*/
CharacterSpacingCharacterRun()
- : characterRun{},
+ : AbstractStyleCharacterRun(),
value{0.f} //The default value is 0.f which does nothing.
{
}
- CharacterRun characterRun; ///< The initial character index and the number of characters of the run.
- float value; /// The spaces between characters in Pixels. A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
+ float value; /// The spaces between characters in Pixels. A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
//TODO: Add unit property to choose between Pixel or Scale (%)
};
} // namespace Toolkit
+// Allow ColorRun to be treated as a POD type
+template<>
+struct TypeTraits<Dali::Toolkit::Text::CharacterSpacingCharacterRun> : public Dali::BasicTypes<Dali::Toolkit::Text::CharacterSpacingCharacterRun>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+
} // namespace Dali
#endif // DALI_TOOLKIT_TEXT_CHARACTER_SPACING_CHARACTER_RUN_H
#define DALI_TOOLKIT_TEXT_COLOR_RUN_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
*
*/
-// 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>
+#include <dali-toolkit/internal/text/abstract-style-character-run.h>
namespace Dali
{
/**
* @brief Run of characters with the same color.
*/
-struct ColorRun
+struct ColorRun : public AbstractStyleCharacterRun
{
- CharacterRun characterRun; ///< The initial character index and the number of characters of the run.
- Vector4 color; ///< The color of the characters.
+ /**
+ * @brief Constructor.
+ * Default constructor to set the default values
+ */
+ ColorRun()
+ : AbstractStyleCharacterRun()
+ {
+ }
+ Vector4 color; ///< The color of the characters.
};
} // namespace Text
} // namespace Toolkit
+// Allow ColorRun to be treated as a POD type
+template<>
+struct TypeTraits<Dali::Toolkit::Text::ColorRun> : public Dali::BasicTypes<Dali::Toolkit::Text::ColorRun>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+
} // namespace Dali
#endif // DALI_TOOLKIT_TEXT_COLOR_RUN_H
#define DALI_TOOLKIT_TEXT_FONT_DESCRIPTION_RUN_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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 <dali/devel-api/text-abstraction/font-list.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/text/character-run.h>
+#include <dali-toolkit/internal/text/abstract-style-character-run.h>
#include <dali-toolkit/internal/text/text-definitions.h>
namespace Dali
/**
* @brief Run of characters with the same font.
*/
-struct FontDescriptionRun
+struct FontDescriptionRun : public AbstractStyleCharacterRun
{
/**
* Default constructor to set the default values of bitfields
*/
FontDescriptionRun()
- : characterRun{},
+ : AbstractStyleCharacterRun(),
familyName{nullptr},
familyLength{0u},
weight{FontWeight::NONE},
bool widthDefined,
bool slantDefined,
bool sizeDefined)
- : characterRun{characterRun},
+ : AbstractStyleCharacterRun(characterRun),
familyName{familyName},
familyLength{familyLength},
weight{weight},
{
}
- CharacterRun characterRun; ///< The initial character index and the number of characters of the run.
char* familyName; ///< The font's family name.
Length familyLength; ///< The length of the font's family name.
FontWeight weight; ///< The font's weight.
} // namespace Toolkit
+// Allow FontDescriptionRun to be treated as a POD type
+template<>
+struct TypeTraits<Dali::Toolkit::Text::FontDescriptionRun> : public Dali::BasicTypes<Dali::Toolkit::Text::FontDescriptionRun>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+
} // namespace Dali
#endif // DALI_TOOLKIT_TEXT_FONT_DESCRIPTION_RUN_H
Length& numberOfLines,
float penY,
bool& isAutoScrollEnabled,
+ bool isAutoScrollMaxTextureExceeded,
DevelText::EllipsisPosition::Type ellipsisPosition,
bool enforceEllipsisInSingleLine)
{
- const bool ellipsis = enforceEllipsisInSingleLine || (isAutoScrollEnabled ? (penY - layout.descender > layoutParameters.boundingBox.height) : ((penY - layout.descender > layoutParameters.boundingBox.height) || ((mLayout == SINGLE_LINE_BOX) && (layout.length > layoutParameters.boundingBox.width))));
+ const bool ellipsis = enforceEllipsisInSingleLine || (isAutoScrollEnabled ? isAutoScrollMaxTextureExceeded : ((penY - layout.descender > layoutParameters.boundingBox.height) || ((mLayout == SINGLE_LINE_BOX) && (layout.length > layoutParameters.boundingBox.width))));
const bool isMultiline = !enforceEllipsisInSingleLine && (mLayout == MULTI_LINE_BOX);
if(ellipsis && (ellipsisPosition == DevelText::EllipsisPosition::END || !isMultiline))
{
- isAutoScrollEnabled = false;
- // Do not layout more lines if ellipsis is enabled.
+ if(penY - layout.descender > layoutParameters.boundingBox.height)
+ {
+ // Even if auto scroll is enabled and text is bigger than max texture size,
+ // if the the height is small, auto scroll should not work.
+ isAutoScrollEnabled = false;
+ }
+ // Do not layout more lines if ellipsis is enabled.
// The last line needs to be completely filled with characters.
// Part of a word may be used.
Size& layoutSize,
bool elideTextEnabled,
bool& isAutoScrollEnabled,
+ bool isAutoScrollMaxTextureExceeded,
DevelText::EllipsisPosition::Type ellipsisPosition)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->LayoutText\n");
CharacterIndex lastCharacterInParagraph = currentParagraphRun.characterRun.characterIndex + currentParagraphRun.characterRun.numberOfCharacters - 1;
//check if this is the last line in paragraph, if false we should use the default relative line size (the one set using the property)
- if(lastCharacterInParagraph >= layout.characterIndex && lastCharacterInParagraph < layout.characterIndex+layout.numberOfCharacters)
+ if(lastCharacterInParagraph >= layout.characterIndex && lastCharacterInParagraph < layout.characterIndex + layout.numberOfCharacters)
{
layout.relativeLineSize = mRelativeLineSize;
}
numberOfLines,
penY,
isAutoScrollEnabled,
+ isAutoScrollMaxTextureExceeded,
ellipsisPosition,
false);
}
numberOfLines,
penY,
isAutoScrollEnabled,
+ isAutoScrollMaxTextureExceeded,
ellipsisPosition,
true);
}
Size& layoutSize,
bool elideTextEnabled,
bool& isAutoScrollEnabled,
+ bool isAutoScrollMaxTextureExceeded,
DevelText::EllipsisPosition::Type ellipsisPosition)
{
return mImpl->LayoutText(layoutParameters,
layoutSize,
elideTextEnabled,
isAutoScrollEnabled,
+ isAutoScrollMaxTextureExceeded,
ellipsisPosition);
}
* @param[out] layoutSize The size of the text after it has been laid-out.
* @param[in] elideTextEnabled Whether the text elide is enabled.
* @param[in,out] isAutoScrollEnabled If the isAutoScrollEnabled is true and the height of the text exceeds the boundaries of the control the text is elided and the isAutoScrollEnabled is set to false to disable the autoscroll
+ * @param[in] isAutoScrollMaxTextureExceeded If isAutoScrollMaxTextureExceeded is true, enable ellipsis during auro scroll.
* @param[in] ellipsisPosition The location of the text ellipsis
*
* @return \e true if the text has been re-laid-out. \e false means the given width is too small to layout even a single character.
Size& layoutSize,
bool elideTextEnabled,
bool& isAutoScrollEnabled,
+ bool isAutoScrollMaxTextureExceeded,
DevelText::EllipsisPosition::Type ellipsisPosition);
/**
--- /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.
+ *
+ */
+
+// FILE HEADER
+#include <dali-toolkit/internal/text/line-helper-functions.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+float GetPreOffsetVerticalLineAlignment(const LineRun& line, const DevelText::VerticalLineAlignment::Type& verLineAlign)
+{
+ // Calculate vertical line alignment
+ float offset = 0.0f;
+
+ switch(verLineAlign)
+ {
+ case DevelText::VerticalLineAlignment::TOP:
+ {
+ break;
+ }
+ case DevelText::VerticalLineAlignment::MIDDLE:
+ {
+ offset = line.lineSpacing * 0.5f;
+ break;
+ }
+ case DevelText::VerticalLineAlignment::BOTTOM:
+ {
+ offset = line.lineSpacing;
+ break;
+ }
+ }
+
+ // Apply TOP case when the lineSpacing is less than zero.
+ offset = line.lineSpacing < 0.0f ? 0.0f : offset;
+
+ return offset;
+}
+
+float GetPostOffsetVerticalLineAlignment(const LineRun& line, const DevelText::VerticalLineAlignment::Type& verLineAlign)
+{
+ // Calculate vertical line alignment
+ float offset = 0.0f;
+
+ switch(verLineAlign)
+ {
+ case DevelText::VerticalLineAlignment::TOP:
+ {
+ offset = line.lineSpacing;
+ break;
+ }
+ case DevelText::VerticalLineAlignment::MIDDLE:
+ {
+ offset = line.lineSpacing * 0.5f;
+ break;
+ }
+ case DevelText::VerticalLineAlignment::BOTTOM:
+ {
+ break;
+ }
+ }
+
+ // Apply TOP case when the lineSpacing is less than zero.
+ offset = line.lineSpacing < 0.0f ? line.lineSpacing : offset;
+
+ return offset;
+}
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_TEXT_LINE_HELPER_FUNCTIONS_H
+#define DALI_TOOLKIT_TEXT_LINE_HELPER_FUNCTIONS_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.
+ *
+ */
+
+// INTERNAL INCLUDES
+
+#include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
+#include <dali-toolkit/internal/text/line-run.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Text
+{
+/**
+ * @brief Retrieves the vertical offset to shift text inside line to up by negative value and to down by positive value.
+ * The shifting depends on the vertical line alignment @p verLineAlign and lineSpacing when the lineSpacing is poistive.
+ * When the lineSpacing is negative then ignore @p verLineAlign
+ * @param[in] line the line.
+ * @param[in] line the line.
+ *
+ * @return The vertical offset before text.
+ */
+float GetPreOffsetVerticalLineAlignment(const LineRun& line, const Dali::Toolkit::DevelText::VerticalLineAlignment::Type& verLineAlign);
+
+/**
+ * @brief Retrieves the vertical offset to shift the next line to up by negative value and to down by positive value.
+ * The shifting depends on the vertical line alignment @p verLineAlign and lineSpacing when the lineSpacing is poistive.
+ * When the lineSpacing is negative then ignore @p verLineAlign
+ * @param[in] line the line.
+ * @param[in] line the line.
+ *
+ * @return The vertical offset after text.
+ */
+float GetPostOffsetVerticalLineAlignment(const LineRun& line, const Dali::Toolkit::DevelText::VerticalLineAlignment::Type& verLineAlign);
+} // namespace Text
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_TEXT_LINE_HELPER_FUNCTIONS_H
markupProcessData.characterSpacingCharacterRuns.Resize(characterSpacingCharacterRunIndex);
#ifdef DEBUG_ENABLED
- for(unsigned int i = 0; i < colorRunIndex; ++i)
+ for(uint32_t i = 0; gLogFilter->IsEnabledFor(Debug::Verbose) && i < colorRunIndex; ++i)
{
ColorRun& run = markupProcessData.colorRuns[i];
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "run[%d] index: %d, length: %d, color %f,%f,%f,%f\n", i, run.characterRun.characterIndex, run.characterRun.numberOfCharacters, run.color.r, run.color.g, run.color.b, run.color.a);
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
scriptRunEndIt);
#ifdef DEBUG_ENABLED
+ if(gLogFilter->IsEnabledFor(Debug::Verbose))
{
Dali::TextAbstraction::FontDescription description;
fontClient.GetDescription(fontId, description);
}
#ifdef DEBUG_ENABLED
+ if(gLogFilter->IsEnabledFor(Debug::Verbose))
{
Dali::TextAbstraction::FontDescription description;
fontClient.GetDescription(fontId, description);
glyphBufferData.width,
glyphBufferData.height,
glyphBufferData.format,
- PixelData::DELETE_ARRAY);
+ PixelData::FREE);
if(bitmap)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "%s\n", metrics.mVerboseGlyphCounts.c_str());
- for(uint32_t i = 0; i < metrics.mAtlasMetrics.mAtlasCount; ++i)
+ for(uint32_t i = 0; gLogFilter->IsEnabledFor(Debug::Verbose) && i < metrics.mAtlasMetrics.mAtlasCount; ++i)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, " Atlas [%i] %sPixels: %s Size: %ix%i, BlockSize: %ix%i, BlocksUsed: %i/%i\n", i + 1, i > 8 ? "" : " ", metrics.mAtlasMetrics.mAtlasMetrics[i].mPixelFormat == Pixel::L8 ? "L8 " : "BGRA", metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mWidth, metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mHeight, metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mBlockWidth, metrics.mAtlasMetrics.mAtlasMetrics[i].mSize.mBlockHeight, metrics.mAtlasMetrics.mAtlasMetrics[i].mBlocksUsed, metrics.mAtlasMetrics.mAtlasMetrics[i].mTotalBlocks);
}
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
#include <dali-toolkit/internal/text/glyph-metrics-helper.h>
+#include <dali-toolkit/internal/text/line-helper-functions.h>
#include <dali-toolkit/internal/text/rendering/styles/character-spacing-helper-functions.h>
#include <dali-toolkit/internal/text/rendering/styles/strikethrough-helper-functions.h>
#include <dali-toolkit/internal/text/rendering/styles/underline-helper-functions.h>
const int32_t xOffset = data.horizontalOffset + position->x;
// Whether the given glyph is a color one.
- const bool isColorGlyph = data.glyphBitmap.isColorEmoji || data.glyphBitmap.isColorBitmap;
- const uint32_t glyphPixelSize = Pixel::GetBytesPerPixel(data.glyphBitmap.format);
- const uint32_t alphaIndex = glyphPixelSize - 1u;
+ const bool isColorGlyph = data.glyphBitmap.isColorEmoji || data.glyphBitmap.isColorBitmap;
+ const uint32_t glyphPixelSize = Pixel::GetBytesPerPixel(data.glyphBitmap.format);
+ const uint32_t glyphAlphaIndex = glyphPixelSize - 1u;
// Determinate iterator range.
const int32_t lineIndexRangeMin = std::max(0, -yOffset);
if(Pixel::RGBA8888 == pixelFormat)
{
- const bool swapChannelsBR = Pixel::BGRA8888 == data.glyphBitmap.format;
-
uint32_t* bitmapBuffer = reinterpret_cast<uint32_t*>(data.bitmapBuffer.GetBuffer());
+ // Skip basic line.
+ bitmapBuffer += (lineIndexRangeMin + yOffset) * static_cast<int32_t>(data.width);
// Fast-cut if style is MASK or OUTLINE. Outline not shown for color glyph.
// Just overwrite transparent color and return.
{
for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
{
- const int32_t yOffsetIndex = yOffset + lineIndex;
- const int32_t verticalOffset = yOffsetIndex * data.width;
-
// We can use memset here.
- memset(bitmapBuffer + verticalOffset + xOffset + indexRangeMin, 0, (indexRangeMax - indexRangeMin) * sizeof(uint32_t));
+ memset(bitmapBuffer + xOffset + indexRangeMin, 0, (indexRangeMax - indexRangeMin) * sizeof(uint32_t));
+ bitmapBuffer += data.width;
}
return;
}
+ const bool swapChannelsBR = Pixel::BGRA8888 == data.glyphBitmap.format;
+
// Pointer to the color glyph if there is one.
- const uint32_t* const colorGlyphBuffer = isColorGlyph ? reinterpret_cast<uint32_t*>(data.glyphBitmap.buffer) : NULL;
+ const uint8_t* glyphBuffer = data.glyphBitmap.buffer;
// Precalculate input color's packed result.
uint32_t packedInputColor = 0u;
*(packedInputColorBuffer + 1u) = static_cast<uint8_t>(color->g * 255);
*(packedInputColorBuffer) = static_cast<uint8_t>(color->r * 255);
+ // Skip basic line of glyph.
+ glyphBuffer += (lineIndexRangeMin) * static_cast<int32_t>(data.glyphBitmap.width) * glyphPixelSize;
+
// Traverse the pixels of the glyph line per line.
- for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
+ if(isColorGlyph)
{
- const int32_t yOffsetIndex = yOffset + lineIndex;
-
- const int32_t verticalOffset = yOffsetIndex * data.width;
- const int32_t glyphBufferOffset = lineIndex * static_cast<int32_t>(data.glyphBitmap.width);
- for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
+ for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
{
- const int32_t xOffsetIndex = xOffset + index;
-
- if(isColorGlyph)
+ for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
{
+ const int32_t xOffsetIndex = xOffset + index;
+
// Retrieves the color from the color glyph.
- uint32_t packedColorGlyph = *(colorGlyphBuffer + glyphBufferOffset + index);
+ uint32_t packedColorGlyph = *(reinterpret_cast<const uint32_t*>(glyphBuffer + (index << 2)));
uint8_t* packedColorGlyphBuffer = reinterpret_cast<uint8_t*>(&packedColorGlyph);
// Update the alpha channel.
}
// Set the color into the final pixel buffer.
- *(bitmapBuffer + verticalOffset + xOffsetIndex) = packedColorGlyph;
+ *(bitmapBuffer + xOffsetIndex) = packedColorGlyph;
}
- else
+ bitmapBuffer += data.width;
+ glyphBuffer += data.glyphBitmap.width * glyphPixelSize;
+ }
+ }
+ else
+ {
+ for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
+ {
+ for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
{
- // Pack the given color into a 32bit buffer. The alpha channel will be updated later for each pixel.
- // The format is RGBA8888.
- uint32_t packedColor = 0u;
- uint8_t* packedColorBuffer = reinterpret_cast<uint8_t*>(&packedColor);
-
// Update the alpha channel.
- const uint8_t alpha = *(data.glyphBitmap.buffer + glyphPixelSize * (glyphBufferOffset + index) + alphaIndex);
+ const uint8_t alpha = *(glyphBuffer + index * glyphPixelSize + glyphAlphaIndex);
// Copy non-transparent pixels only
if(alpha > 0u)
{
+ const int32_t xOffsetIndex = xOffset + index;
+
// Check alpha of overlapped pixels
- uint32_t& currentColor = *(bitmapBuffer + verticalOffset + xOffsetIndex);
+ uint32_t& currentColor = *(bitmapBuffer + xOffsetIndex);
uint8_t* packedCurrentColorBuffer = reinterpret_cast<uint8_t*>(¤tColor);
// For any pixel overlapped with the pixel in previous glyphs, make sure we don't
}
else
{
+ // Pack the given color into a 32bit buffer. The alpha channel will be updated later for each pixel.
+ // The format is RGBA8888.
+ uint32_t packedColor = 0u;
+ uint8_t* packedColorBuffer = reinterpret_cast<uint8_t*>(&packedColor);
+
// Color is pre-muliplied with its alpha.
*(packedColorBuffer + 3u) = MultiplyAndNormalizeColor(*(packedInputColorBuffer + 3u), currentAlpha);
*(packedColorBuffer + 2u) = MultiplyAndNormalizeColor(*(packedInputColorBuffer + 2u), currentAlpha);
}
}
}
+ bitmapBuffer += data.width;
+ glyphBuffer += data.glyphBitmap.width * glyphPixelSize;
}
}
}
- else
+ else // Pixel::L8
{
// Below codes required only if not color glyph.
if(!isColorGlyph)
{
- uint8_t* bitmapBuffer = reinterpret_cast<uint8_t*>(data.bitmapBuffer.GetBuffer());
+ uint8_t* bitmapBuffer = data.bitmapBuffer.GetBuffer();
+ const uint8_t* glyphBuffer = data.glyphBitmap.buffer;
+
+ // Skip basic line.
+ bitmapBuffer += (lineIndexRangeMin + yOffset) * static_cast<int32_t>(data.width);
+ glyphBuffer += (lineIndexRangeMin) * static_cast<int32_t>(data.glyphBitmap.width) * glyphPixelSize;
// Traverse the pixels of the glyph line per line.
for(int32_t lineIndex = lineIndexRangeMin; lineIndex < lineIndexRangeMax; ++lineIndex)
{
- const int32_t yOffsetIndex = yOffset + lineIndex;
-
- const int32_t verticalOffset = yOffsetIndex * data.width;
- const int32_t glyphBufferOffset = lineIndex * static_cast<int32_t>(data.glyphBitmap.width);
for(int32_t index = indexRangeMin; index < indexRangeMax; ++index)
{
const int32_t xOffsetIndex = xOffset + index;
// Update the alpha channel.
- const uint8_t alpha = *(data.glyphBitmap.buffer + glyphPixelSize * (glyphBufferOffset + index) + alphaIndex);
+ const uint8_t alpha = *(glyphBuffer + index * glyphPixelSize + glyphAlphaIndex);
// Copy non-transparent pixels only
if(alpha > 0u)
{
// Check alpha of overlapped pixels
- uint8_t& currentAlpha = *(bitmapBuffer + verticalOffset + xOffsetIndex);
+ uint8_t& currentAlpha = *(bitmapBuffer + xOffsetIndex);
// For any pixel overlapped with the pixel in previous glyphs, make sure we don't
// overwrite a previous bigger alpha with a smaller alpha (in order to avoid
currentAlpha = std::max(currentAlpha, alpha);
}
}
+
+ bitmapBuffer += data.width;
+ glyphBuffer += data.glyphBitmap.width * glyphPixelSize;
}
}
}
const Vector4* const backgroundColorsBuffer = model->GetBackgroundColors();
const ColorIndex* const backgroundColorIndicesBuffer = model->GetBackgroundColorIndices();
+ const DevelText::VerticalLineAlignment::Type verLineAlign = model->GetVerticalLineAlignment();
+
// Create and initialize the pixel buffer.
GlyphData glyphData;
glyphData.verticalOffset = verticalOffset;
glyphData.horizontalOffset += horizontalOffset;
// Increases the vertical offset with the line's ascender.
- glyphData.verticalOffset += static_cast<int32_t>(line.ascender);
-
- // Include line spacing after first line
- if(lineIndex > 0u)
- {
- glyphData.verticalOffset += static_cast<int32_t>(line.lineSpacing);
- }
+ glyphData.verticalOffset += static_cast<int32_t>(line.ascender + GetPreOffsetVerticalLineAlignment(line, verLineAlign));
float left = bufferWidth;
float right = 0.0f;
}
// Increases the vertical offset with the line's descender.
- glyphData.verticalOffset += static_cast<int32_t>(-line.descender);
+ glyphData.verticalOffset += static_cast<int32_t>(-line.descender + GetPostOffsetVerticalLineAlignment(line, verLineAlign));
}
return glyphData.bitmapBuffer;
}
}
- // Calculate vertical line alignment
- switch(mModel->GetVerticalLineAlignment())
- {
- case DevelText::VerticalLineAlignment::TOP:
- {
- break;
- }
- case DevelText::VerticalLineAlignment::MIDDLE:
- {
- const auto& line = *mModel->GetLines();
- penY -= line.descender;
- penY += static_cast<int32_t>(line.lineSpacing * 0.5f + line.descender);
- break;
- }
- case DevelText::VerticalLineAlignment::BOTTOM:
- {
- const auto& line = *mModel->GetLines();
- const auto lineHeight = line.ascender + (-line.descender) + line.lineSpacing;
- penY += static_cast<int32_t>(lineHeight - (line.ascender - line.descender));
- break;
- }
- }
-
// Generate the image buffers of the text for each different style first,
// then combine all of them together as one final image buffer. We try to
// do all of these in CPU only, so that once the final texture is generated,
const Vector<CharacterIndex>& glyphToCharacterMap = mModel->GetGlyphsToCharacters();
const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin();
+ const DevelText::VerticalLineAlignment::Type verLineAlign = mModel->GetVerticalLineAlignment();
+
// Traverses the lines of the text.
for(LineIndex lineIndex = 0u; lineIndex < modelNumberOfLines; ++lineIndex)
{
glyphData.horizontalOffset += horizontalOffset;
// Increases the vertical offset with the line's ascender.
- glyphData.verticalOffset += static_cast<int32_t>(line.ascender);
+ glyphData.verticalOffset += static_cast<int32_t>(line.ascender + GetPreOffsetVerticalLineAlignment(line, verLineAlign));
// Retrieves the glyph's outline width
float outlineWidth = static_cast<float>(mModel->GetOutlineWidth());
glyphData.verticalOffset += glyphData.glyphBitmap.outlineOffsetY;
}
- // delete the glyphBitmap.buffer as it is now copied into glyphData.bitmapBuffer
- delete[] glyphData.glyphBitmap.buffer;
+ // free the glyphBitmap.buffer as it is now copied into glyphData.bitmapBuffer
+ free(glyphData.glyphBitmap.buffer);
glyphData.glyphBitmap.buffer = NULL;
}
}
// Increases the vertical offset with the line's descender & line spacing.
- glyphData.verticalOffset += static_cast<int32_t>(-line.descender + line.lineSpacing);
+ glyphData.verticalOffset += static_cast<int32_t>(-line.descender + GetPostOffsetVerticalLineAlignment(line, verLineAlign));
}
return glyphData.bitmapBuffer;
// Change the 'x' and 'y' position of the ellipsis glyph.
if(position.x > firstPenX)
{
- position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth;
+ if(isTailMode)
+ {
+ // To handle case of the mixed languages (LTR then RTL) with
+ // EllipsisPosition::END and the LayoutDirection::RIGHT_TO_LEFT
+ float nextXPositions = ellipsisLine->width;
+ if(indexOfEllipsis + 1u < numberOfGlyphs)
+ {
+ Vector2& positionOfNextGlyph = *(elidedPositionsBuffer + indexOfEllipsis + 1u);
+ nextXPositions = positionOfNextGlyph.x;
+ }
+
+ if(position.x > nextXPositions) // RTL language
+ {
+ if((indexOfEllipsis > 0u) && ((position.x - nextXPositions) > removedGlypsWidth))
+ {
+ // To handle mixed directions
+ // Re-calculates the first penX which will be used if rtl text is elided.
+ firstPenX = position.x - glyphToRemove.xBearing;
+ if(firstPenX < -ellipsisGlyph.xBearing)
+ {
+ // Avoids to exceed the bounding box when rtl text is elided.
+ firstPenX = -ellipsisGlyph.xBearing;
+ }
+ //Reset the width of removed glyphs
+ removedGlypsWidth = std::min(calculatedAdvance, (glyphToRemove.xBearing + glyphToRemove.width)) - ellipsisGlyph.xBearing;
+
+ --indexOfEllipsis;
+ continue;
+ }
+ else
+ {
+ // To handle the case of RTL language with EllipsisPosition::END
+ position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth;
+ }
+ }
+ }
+ else
+ {
+ // To handle the case of LTR language with EllipsisPosition::START
+ position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth;
+ }
+ }
+ else
+ {
+ if(!isTailMode)
+ {
+ // To handle case of the mixed languages (RTL then LTR) with
+ // EllipsisPosition::START and the LayoutDirection::RIGHT_TO_LEFT
+ float nextXPositions = ellipsisLine->width;
+ if(indexOfEllipsis + 1u < numberOfGlyphs)
+ {
+ Vector2& positionOfNextGlyph = *(elidedPositionsBuffer + indexOfEllipsis + 1u);
+ nextXPositions = positionOfNextGlyph.x;
+ }
+
+ if(position.x < nextXPositions) // LTR language
+ {
+ position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth;
+
+ if((position.x + ellipsisGlyphWidth + ellipsisGlyph.xBearing) > nextXPositions)
+ {
+ position.x -= (position.x + ellipsisGlyphWidth + ellipsisGlyph.xBearing) - nextXPositions;
+ }
+ }
+ }
}
position.x += ellipsisGlyph.xBearing;
#include <dali/public-api/math/vector4.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/text/character-run.h>
+#include <dali-toolkit/internal/text/abstract-style-character-run.h>
#include <dali-toolkit/internal/text/strikethrough-style-properties.h>
namespace Dali
/**
* @brief Run of strikethrough characters with same properties.
*/
-struct StrikethroughCharacterRun
+struct StrikethroughCharacterRun : public AbstractStyleCharacterRun
{
/**
* Default constructor to set the default values of bitfields
*/
StrikethroughCharacterRun()
- : characterRun{},
+ : AbstractStyleCharacterRun(),
properties{}
{
}
- CharacterRun characterRun; ///< The initial character index and the number of characters of the run.
- StrikethroughStyleProperties properties; /// The properties of strikethrough style
+ StrikethroughStyleProperties properties; /// The properties of strikethrough style
};
} // namespace Text
} // namespace Toolkit
+// Allow StrikethroughCharacterRun to be treated as a POD type
+template<>
+struct TypeTraits<Dali::Toolkit::Text::StrikethroughCharacterRun> : public Dali::BasicTypes<Dali::Toolkit::Text::StrikethroughCharacterRun>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+
} // namespace Dali
#endif // DALI_TOOLKIT_TEXT_STRIKETHROUGH_CHARACTER_RUN_H
{
namespace Text
{
-const float DEFAULT_TEXTFIT_MIN = 10.f;
-const float DEFAULT_TEXTFIT_MAX = 100.f;
-const float DEFAULT_TEXTFIT_STEP = 1.f;
-const float DEFAULT_FONT_SIZE_SCALE = 1.f;
+const float DEFAULT_TEXTFIT_MIN = 10.f;
+const float DEFAULT_TEXTFIT_MAX = 100.f;
+const float DEFAULT_TEXTFIT_STEP = 1.f;
+const float DEFAULT_FONT_SIZE_SCALE = 1.f;
const float DEFAULT_DISABLED_COLOR_OPACITY = 0.3f;
//Forward declarations
mMarkupProcessorEnabled(false),
mClipboardHideEnabled(true),
mIsAutoScrollEnabled(false),
+ mIsAutoScrollMaxTextureExceeded(false),
mUpdateTextDirection(true),
mIsTextDirectionRTL(false),
mUnderlineSetByString(false),
Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
if(styleManager)
{
- bool temp;
- Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
- if(config["clearFocusOnEscape"].Get(temp))
- {
- mShouldClearFocusOnEscape = temp;
- }
+ const Property::Map& config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
+ const auto clearFocusOnEscapeValue = config.Find("clearFocusOnEscape", Property::Type::BOOLEAN);
+
+ // Default is true. If config don't have "clearFocusOnEscape" property, make it true.
+ mShouldClearFocusOnEscape = (!clearFocusOnEscapeValue || clearFocusOnEscapeValue->Get<bool>());
}
}
std::unique_ptr<InputFilter> mInputFilter; ///< Avoid allocating this when the user does not specify input filter mode.
Vector2 mTextFitContentSize; ///< Size of Text fit content
- bool mRecalculateNaturalSize : 1; ///< Whether the natural size needs to be recalculated.
- bool mMarkupProcessorEnabled : 1; ///< Whether the mark-up procesor is enabled.
- bool mClipboardHideEnabled : 1; ///< Whether the ClipboardHide function work or not
- bool mIsAutoScrollEnabled : 1; ///< Whether auto text scrolling is enabled.
- bool mUpdateTextDirection : 1; ///< Whether the text direction needs to be updated.
- CharacterDirection mIsTextDirectionRTL : 1; ///< Whether the text direction is right to left or not
+ bool mRecalculateNaturalSize : 1; ///< Whether the natural size needs to be recalculated.
+ bool mMarkupProcessorEnabled : 1; ///< Whether the mark-up procesor is enabled.
+ bool mClipboardHideEnabled : 1; ///< Whether the ClipboardHide function work or not
+ bool mIsAutoScrollEnabled : 1; ///< Whether auto text scrolling is enabled.
+ bool mIsAutoScrollMaxTextureExceeded : 1; ///< Whether auto text scrolling is exceed max texture size.
+ bool mUpdateTextDirection : 1; ///< Whether the text direction needs to be updated.
+ CharacterDirection mIsTextDirectionRTL : 1; ///< Whether the text direction is right to left or not
bool mUnderlineSetByString : 1; ///< Set when underline is set by string (legacy) instead of map
bool mShadowSetByString : 1; ///< Set when shadow is set by string (legacy) instead of map
SHAPE_TEXT |
GET_GLYPH_METRICS);
- const OperationsMask sizeOperations = static_cast<OperationsMask>(LAYOUT | ALIGN | REORDER);
+ const OperationsMask sizeOperations = static_cast<OperationsMask>(LAYOUT | ALIGN | REORDER);
// Set the update info to relayout the whole text.
TextUpdateInfo& textUpdateInfo = impl.mTextUpdateInfo;
{
impl.UpdateModel(onlyOnceOperations);
+ // Layout the text for the new width.
+ operationsPending = static_cast<OperationsMask>(operationsPending | requestedOperationsMask);
+
DoRelayout(impl,
requestedControllerSize,
static_cast<OperationsMask>(onlyOnceOperations | requestedOperationsMask),
}
// Update the visual model.
- bool isAutoScrollEnabled = impl.mIsAutoScrollEnabled;
+ bool isAutoScrollEnabled = impl.mIsAutoScrollEnabled;
+ bool isAutoScrollMaxTextureExceeded = impl.mIsAutoScrollMaxTextureExceeded;
+
Size newLayoutSize;
viewUpdated = impl.mLayoutEngine.LayoutText(layoutParameters,
newLayoutSize,
elideTextEnabled,
isAutoScrollEnabled,
+ isAutoScrollMaxTextureExceeded,
ellipsisPosition);
impl.mIsAutoScrollEnabled = isAutoScrollEnabled;
void Controller::Relayouter::CalculateVerticalOffset(Controller::Impl& impl, const Size& controlSize)
{
- ModelPtr& model = impl.mModel;
- VisualModelPtr& visualModel = model->mVisualModel;
- Size layoutSize = model->mVisualModel->GetLayoutSize();
- Size oldLayoutSize = layoutSize;
- float offsetY = 0.f;
- bool needRecalc = false;
- float defaultFontLineHeight = impl.GetDefaultFontLineHeight();
+ ModelPtr& model = impl.mModel;
+ VisualModelPtr& visualModel = model->mVisualModel;
+ Size layoutSize = model->mVisualModel->GetLayoutSize();
+ Size oldLayoutSize = layoutSize;
+ float offsetY = 0.f;
+ bool needRecalc = false;
+ float defaultFontLineHeight = impl.GetDefaultFontLineHeight();
if(fabsf(layoutSize.height) < Math::MACHINE_EPSILON_1000)
{
mImpl->SetAutoScrollEnabled(enable);
}
+void Controller::SetAutoScrollMaxTextureExceeded(bool exceed)
+{
+ mImpl->mIsAutoScrollMaxTextureExceeded = exceed;
+}
+
bool Controller::IsAutoScrollEnabled() const
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Controller::IsAutoScrollEnabled[%s]\n", mImpl->mIsAutoScrollEnabled ? "true" : "false");
void SetAutoScrollEnabled(bool enable);
/**
+ * @brief Whether the auto scrolling texture exceed max texture.
+ *
+ * By default is false.
+ *
+ * @param[in] exceed Whether the auto scrolling texture exceed max texture.
+ */
+ void SetAutoScrollMaxTextureExceeded(bool exceed);
+
+ /**
* @brief Retrieves whether auto text scrolling is enabled.
*
* By default is disabled.
glyphInfo = ellipsisGlyph;
// Change the 'x' and 'y' position of the ellipsis glyph.
-
if(position.x > firstPenX)
{
- position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth;
+ if(isTailMode)
+ {
+ // To handle case of the mixed languages (LTR then RTL) with
+ // EllipsisPosition::END and the LayoutDirection::RIGHT_TO_LEFT
+ float nextXPositions = ellipsisLine->width;
+ if(indexOfEllipsis + 1u < numberOfGlyphs)
+ {
+ Vector2& positionOfNextGlyph = *(glyphPositions + indexOfEllipsis + 1u);
+ nextXPositions = positionOfNextGlyph.x;
+ }
+
+ if(position.x > nextXPositions) // RTL language
+ {
+ if((indexOfEllipsis > 0u) && ((position.x - nextXPositions) > removedGlypsWidth))
+ {
+ // To handle mixed directions
+ // Re-calculates the first penX which will be used if rtl text is elided.
+ firstPenX = position.x - glyphToRemove.xBearing;
+ if(firstPenX < -ellipsisGlyph.xBearing)
+ {
+ // Avoids to exceed the bounding box when rtl text is elided.
+ firstPenX = -ellipsisGlyph.xBearing;
+ }
+ //Reset the width of removed glyphs
+ removedGlypsWidth = std::min(calculatedAdvance, (glyphToRemove.xBearing + glyphToRemove.width)) - ellipsisGlyph.xBearing;
+
+ --indexOfEllipsis;
+ continue;
+ }
+ else
+ {
+ // To handle the case of RTL language with EllipsisPosition::END
+ position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth;
+ }
+ }
+ }
+ else
+ {
+ // To handle the case of LTR language with EllipsisPosition::START
+ position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth;
+ }
+ }
+ else
+ {
+ if(!isTailMode)
+ {
+ // To handle case of the mixed languages (RTL then LTR) with
+ // EllipsisPosition::START and the LayoutDirection::RIGHT_TO_LEFT
+ float nextXPositions = ellipsisLine->width;
+ if(indexOfEllipsis + 1u < numberOfGlyphs)
+ {
+ Vector2& positionOfNextGlyph = *(glyphPositions + indexOfEllipsis + 1u);
+ nextXPositions = positionOfNextGlyph.x;
+ }
+
+ if(position.x < nextXPositions) // LTR language
+ {
+ position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth;
+
+ if((position.x + ellipsisGlyphWidth + ellipsisGlyph.xBearing) > nextXPositions)
+ {
+ position.x -= (position.x + ellipsisGlyphWidth + ellipsisGlyph.xBearing) - nextXPositions;
+ }
+ }
+ }
}
position.x += ellipsisGlyph.xBearing;
#include <dali/public-api/math/vector4.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/internal/text/character-run.h>
+#include <dali-toolkit/internal/text/abstract-style-character-run.h>
#include <dali-toolkit/internal/text/underline-style-properties.h>
namespace Dali
/**
* @brief Run of underlined characters with same properties.
*/
-struct UnderlinedCharacterRun
+struct UnderlinedCharacterRun : public AbstractStyleCharacterRun
{
/**
* Default constructor to set the default values of bitfields
*/
UnderlinedCharacterRun()
- : characterRun{},
+ : AbstractStyleCharacterRun(),
properties{}
{
}
- CharacterRun characterRun; ///< The initial character index and the number of characters of the run.
- UnderlineStyleProperties properties; /// The properties of underline style
+ UnderlineStyleProperties properties; /// The properties of underline style
};
} // namespace Text
} // namespace Toolkit
+// Allow UnderlinedCharacterRun to be treated as a POD type
+template<>
+struct TypeTraits<Dali::Toolkit::Text::UnderlinedCharacterRun> : public Dali::BasicTypes<Dali::Toolkit::Text::UnderlinedCharacterRun>
+{
+ enum
+ {
+ IS_TRIVIAL_TYPE = true
+ };
+};
+
} // namespace Dali
#endif // DALI_TOOLKIT_TEXT_UNDERLINED_CHARACTER_RUN_H
const Dali::FittingMode::Type& fittingMode,
const Dali::SamplingMode::Type& samplingMode,
const TextureCacheManager::UseAtlas& useAtlas,
+ const StorageType& storageType,
const TextureCacheManager::TextureId& maskTextureId,
const bool& cropToMask,
const TextureCacheManager::MultiplyOnLoad& preMultiplyOnLoad,
(cropToMask == textureInfo.cropToMask) &&
(size == textureInfo.desiredSize) &&
(isAnimatedImage == textureInfo.isAnimatedImageFormat) &&
+ (storageType == textureInfo.storageType) &&
(frameIndex == textureInfo.frameIndex) &&
((size.GetWidth() == 0 && size.GetHeight() == 0) ||
(fittingMode == textureInfo.fittingMode &&
* @param[in] fittingMode The FittingMode to use
* @param[in] samplingMode The SamplingMode to use
* @param[in] useAtlas True if atlased
+ * @param[in] storageType Whether the pixel data is stored in the cache or uploaded to the GPU
* @param[in] maskTextureId Optional texture ID to use to mask this image
* @param[in] cropToMask True if crop to mask
* @param[in] preMultiplyOnLoad if the image's color should be multiplied by it's alpha. Set to OFF if there is no alpha.
const Dali::FittingMode::Type& fittingMode,
const Dali::SamplingMode::Type& samplingMode,
const TextureCacheManager::UseAtlas& useAtlas,
+ const StorageType& storageType,
const TextureCacheManager::TextureId& maskTextureId,
const bool& cropToMask,
const TextureCacheManager::MultiplyOnLoad& preMultiplyOnLoad,
: mAlphaMaskUrl(),
mAlphaMaskId(INVALID_TEXTURE_ID),
mContentScaleFactor(1.0f),
- mCropToMask(true)
+ mCropToMask(true),
+ mPreappliedMasking(true),
+ mMaskImageLoadingFailed(false)
{
}
}
else
{
+ Texture maskTexture;
if(maskInfo && maskInfo->mAlphaMaskUrl.IsValid())
{
Devel::PixelBuffer maskPixelBuffer = LoadImageFromFile(maskInfo->mAlphaMaskUrl.GetUrl(), ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, true);
if(maskPixelBuffer)
{
- pixelBuffer.ApplyMask(maskPixelBuffer, maskInfo->mContentScaleFactor, maskInfo->mCropToMask);
+ if(!maskInfo->mPreappliedMasking)
+ {
+ PixelData maskPixelData = Devel::PixelBuffer::Convert(maskPixelBuffer); // takes ownership of buffer
+ maskTexture = Texture::New(Dali::TextureType::TEXTURE_2D, maskPixelData.GetPixelFormat(), maskPixelData.GetWidth(), maskPixelData.GetHeight());
+ maskTexture.Upload(maskPixelData);
+ }
+ else
+ {
+ pixelBuffer.ApplyMask(maskPixelBuffer, maskInfo->mContentScaleFactor, maskInfo->mCropToMask);
+ }
}
else
{
texture.Upload(pixelData);
textureSet = TextureSet::New();
textureSet.SetTexture(0u, texture);
+ if(maskTexture)
+ {
+ textureSet.SetTexture(1u, maskTexture);
+ }
}
}
}
bool cropToMask = false;
if(maskInfo && maskInfo->mAlphaMaskUrl.IsValid())
{
- maskInfo->mAlphaMaskId = RequestMaskLoad(maskInfo->mAlphaMaskUrl);
+ maskInfo->mAlphaMaskId = RequestMaskLoad(maskInfo->mAlphaMaskUrl, maskInfo->mPreappliedMasking ? StorageType::KEEP_PIXEL_BUFFER : StorageType::KEEP_TEXTURE);
alphaMaskId = maskInfo->mAlphaMaskId;
- contentScaleFactor = maskInfo->mContentScaleFactor;
- cropToMask = maskInfo->mCropToMask;
+ if(maskInfo->mPreappliedMasking)
+ {
+ contentScaleFactor = maskInfo->mContentScaleFactor;
+ cropToMask = maskInfo->mCropToMask;
+ }
}
- textureId = RequestLoadInternal(url, alphaMaskId, contentScaleFactor, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, UseAtlas::NO_ATLAS, cropToMask, StorageType::UPLOAD_TO_TEXTURE, textureObserver, true, TextureManager::ReloadPolicy::CACHED, preMultiplyOnLoad, animatedImageLoading, frameIndex, false);
+ textureId = RequestLoadInternal(url, alphaMaskId, contentScaleFactor, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::BOX_THEN_LINEAR, UseAtlas::NO_ATLAS, cropToMask, StorageType::UPLOAD_TO_TEXTURE, textureObserver, true, TextureManager::ReloadPolicy::CACHED, preMultiplyOnLoad, animatedImageLoading, frameIndex, false);
TextureManager::LoadState loadState = mTextureCacheManager.GetTextureStateInternal(textureId);
if(loadState == TextureManager::LoadState::UPLOADED)
if(!textureSet) // big image, no atlasing or atlasing failed
{
atlasingStatus = false;
- if(!maskInfo || !maskInfo->mAlphaMaskUrl.IsValid())
- {
- textureId = RequestLoad(
- url,
- desiredSize,
- fittingMode,
- samplingMode,
- UseAtlas::NO_ATLAS,
- textureObserver,
- orientationCorrection,
- reloadPolicy,
- preMultiplyOnLoad,
- synchronousLoading);
- }
- else
+
+ TextureId alphaMaskId = INVALID_TEXTURE_ID;
+ float contentScaleFactor = 1.0f;
+ bool cropToMask = false;
+ if(maskInfo && maskInfo->mAlphaMaskUrl.IsValid())
{
- maskInfo->mAlphaMaskId = RequestMaskLoad(maskInfo->mAlphaMaskUrl, synchronousLoading);
- textureId = RequestLoad(
- url,
- maskInfo->mAlphaMaskId,
- maskInfo->mContentScaleFactor,
- desiredSize,
- fittingMode,
- samplingMode,
- UseAtlas::NO_ATLAS,
- maskInfo->mCropToMask,
- textureObserver,
- orientationCorrection,
- reloadPolicy,
- preMultiplyOnLoad,
- synchronousLoading);
+ maskInfo->mAlphaMaskId = RequestMaskLoad(maskInfo->mAlphaMaskUrl, maskInfo->mPreappliedMasking ? StorageType::KEEP_PIXEL_BUFFER : StorageType::KEEP_TEXTURE, synchronousLoading);
+ alphaMaskId = maskInfo->mAlphaMaskId;
+ if(maskInfo && maskInfo->mPreappliedMasking)
+ {
+ contentScaleFactor = maskInfo->mContentScaleFactor;
+ cropToMask = maskInfo->mCropToMask;
+ }
}
+ textureId = RequestLoad(
+ url,
+ alphaMaskId,
+ contentScaleFactor,
+ desiredSize,
+ fittingMode,
+ samplingMode,
+ UseAtlas::NO_ATLAS,
+ cropToMask,
+ textureObserver,
+ orientationCorrection,
+ reloadPolicy,
+ preMultiplyOnLoad,
+ synchronousLoading);
+
TextureManager::LoadState loadState = mTextureCacheManager.GetTextureStateInternal(textureId);
if(loadState == TextureManager::LoadState::UPLOADED)
{
TextureManager::TextureId TextureManager::RequestMaskLoad(
const VisualUrl& maskUrl,
+ StorageType storageType,
const bool& synchronousLoading)
{
// Use the normal load procedure to get the alpha mask.
auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
- return RequestLoadInternal(maskUrl, INVALID_TEXTURE_ID, 1.0f, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, UseAtlas::NO_ATLAS, false, StorageType::KEEP_PIXEL_BUFFER, NULL, true, TextureManager::ReloadPolicy::CACHED, preMultiply, Dali::AnimatedImageLoading(), 0u, synchronousLoading);
+ return RequestLoadInternal(maskUrl, INVALID_TEXTURE_ID, 1.0f, ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, UseAtlas::NO_ATLAS, false, storageType, NULL, true, TextureManager::ReloadPolicy::CACHED, preMultiply, Dali::AnimatedImageLoading(), 0u, synchronousLoading);
}
TextureManager::TextureId TextureManager::RequestLoadInternal(
{
TextureHash textureHash = INITIAL_HASH_NUMBER;
TextureCacheIndex cacheIndex = INVALID_CACHE_INDEX;
- if(storageType != StorageType::RETURN_PIXEL_BUFFER && frameIndex == 0)
+ if(storageType != StorageType::RETURN_PIXEL_BUFFER)
{
textureHash = mTextureCacheManager.GenerateHash(url, desiredSize, fittingMode, samplingMode, useAtlas, maskTextureId, cropToMask, frameIndex);
// Look up the texture by hash. Note: The extra parameters are used in case of a hash collision.
- cacheIndex = mTextureCacheManager.FindCachedTexture(textureHash, url, desiredSize, fittingMode, samplingMode, useAtlas, maskTextureId, cropToMask, preMultiplyOnLoad, (animatedImageLoading) ? true : false, frameIndex);
+ cacheIndex = mTextureCacheManager.FindCachedTexture(textureHash, url, desiredSize, fittingMode, samplingMode, useAtlas, storageType, maskTextureId, cropToMask, preMultiplyOnLoad, (animatedImageLoading) ? true : false, frameIndex);
}
TextureManager::TextureId textureId = INVALID_TEXTURE_ID;
// Cache new texutre, and get cacheIndex.
cacheIndex = mTextureCacheManager.AppendCache(TextureInfo(textureId, maskTextureId, url, desiredSize, contentScale, fittingMode, samplingMode, false, cropToMask, useAtlas, textureHash, orientationCorrection, preMultiply, animatedImageLoading, frameIndex));
- DALI_LOG_INFO(gTextureManagerLogFilter, Debug::General, "TextureManager::RequestLoad( url=%s observer=%p ) New texture, cacheIndex:%d, textureId=%d, frameindex=%d\n", url.GetUrl().c_str(), observer, cacheIndex.GetIndex(), textureId, frameIndex);
+ DALI_LOG_INFO(gTextureManagerLogFilter, Debug::General, "TextureManager::RequestLoad( url=%s observer=%p ) New texture, cacheIndex:%d, textureId=%d, frameindex=%d premultiply=%d\n", url.GetUrl().c_str(), observer, cacheIndex.GetIndex(), textureId, frameIndex, preMultiply);
}
// The below code path is common whether we are using the cache or not.
}
else // For the image loading.
{
+ Texture maskTexture;
if(maskTextureId != INVALID_TEXTURE_ID)
{
TextureCacheIndex maskCacheIndex = mTextureCacheManager.GetCacheIndexFromId(maskTextureId);
if(maskCacheIndex != INVALID_CACHE_INDEX)
{
- Devel::PixelBuffer maskPixelBuffer = mTextureCacheManager[maskCacheIndex].pixelBuffer;
- if(maskPixelBuffer)
+ if(mTextureCacheManager[maskCacheIndex].storageType == StorageType::KEEP_TEXTURE)
{
- pixelBuffer.ApplyMask(maskPixelBuffer, contentScale, cropToMask);
+ TextureSet maskTextures = mTextureCacheManager[maskCacheIndex].textureSet;
+ if(maskTextures && maskTextures.GetTextureCount())
+ {
+ maskTexture = maskTextures.GetTexture(0u);
+ }
}
- else
+ else if(mTextureCacheManager[maskCacheIndex].storageType == StorageType::KEEP_PIXEL_BUFFER)
{
- DALI_LOG_ERROR("Mask image cached invalid pixel buffer!\n");
+ Devel::PixelBuffer maskPixelBuffer = mTextureCacheManager[maskCacheIndex].pixelBuffer;
+ if(maskPixelBuffer)
+ {
+ pixelBuffer.ApplyMask(maskPixelBuffer, contentScale, cropToMask);
+ }
+ else
+ {
+ DALI_LOG_ERROR("Mask image cached invalid pixel buffer!\n");
+ }
}
}
else
// Upload texture
UploadTexture(pixelBuffer, textureInfo);
+ if(maskTexture && textureInfo.textureSet)
+ {
+ textureInfo.textureSet.SetTexture(1u, maskTexture);
+ }
}
}
}
{
EmitLoadComplete(element.mObserver, textureInfo, true);
}
+ else if(textureInfo.loadState == LoadState::LOADING)
+ {
+ // Note : LOADING state texture cannot be queue.
+ // This case be occured when same texture id are queue in mLoadQueue.
+ ObserveTexture(textureInfo, element.mObserver);
+ }
else
{
LoadTexture(textureInfo, element.mObserver);
{
textureInfo.loadState = LoadState::WAITING_FOR_MASK;
}
- else if(maskLoadState == LoadState::LOAD_FINISHED)
+ else if(maskLoadState == LoadState::LOAD_FINISHED || maskLoadState == LoadState::UPLOADED)
{
// Send New Task to Thread
- ApplyMask(textureInfo, textureInfo.maskTextureId);
+ TextureCacheIndex maskCacheIndex = mTextureCacheManager.GetCacheIndexFromId(textureInfo.maskTextureId);
+ if(maskCacheIndex != INVALID_CACHE_INDEX)
+ {
+ TextureInfo& maskTextureInfo(mTextureCacheManager[maskCacheIndex]);
+ if(maskTextureInfo.storageType == StorageType::KEEP_PIXEL_BUFFER)
+ {
+ // Send New Task to Thread
+ ApplyMask(textureInfo, textureInfo.maskTextureId);
+ }
+ else if(maskTextureInfo.storageType == StorageType::KEEP_TEXTURE)
+ {
+ // Upload image texture. textureInfo.loadState will be UPLOADED.
+ UploadTexture(textureInfo.pixelBuffer, textureInfo);
+ if(maskTextureInfo.textureSet.GetTextureCount() > 0u)
+ {
+ Texture maskTexture = maskTextureInfo.textureSet.GetTexture(0u);
+ textureInfo.textureSet.SetTexture(1u, maskTexture);
+ }
+ // notify mask texture set.
+ NotifyObservers(textureInfo, true);
+ }
+ }
}
else // maskLoadState == LoadState::LOAD_FAILED
{
{
NotifyObservers(textureInfo, true);
}
- else
+ else // for the StorageType::KEEP_PIXEL_BUFFER and StorageType::KEEP_TEXTURE
{
// Check if there was another texture waiting for this load to complete
// (e.g. if this was an image mask, and its load is on a different thread)
else
{
textureInfo.loadState = LoadState::LOAD_FAILED;
- if(textureInfo.storageType != StorageType::KEEP_PIXEL_BUFFER)
- {
- NotifyObservers(textureInfo, false);
- }
- else // if(textureInfo.storageType == StorageType::KEEP_PIXEL_BUFFER) // image mask case
+ if(textureInfo.storageType == StorageType::KEEP_PIXEL_BUFFER || textureInfo.storageType == StorageType::KEEP_TEXTURE)
{
// Check if there was another texture waiting for this load to complete
// (e.g. if this was an image mask, and its load is on a different thread)
CheckForWaitingTexture(textureInfo);
}
+ else
+ {
+ NotifyObservers(textureInfo, false);
+ }
}
}
void TextureManager::CheckForWaitingTexture(TextureManager::TextureInfo& maskTextureInfo)
{
+ if(maskTextureInfo.loadState == LoadState::LOAD_FINISHED &&
+ maskTextureInfo.storageType == StorageType::KEEP_TEXTURE)
+ {
+ // Upload mask texture. textureInfo.loadState will be UPLOADED.
+ UploadTexture(maskTextureInfo.pixelBuffer, maskTextureInfo);
+ }
+
// Search the cache, checking if any texture has this texture id as a
// maskTextureId:
const std::size_t size = mTextureCacheManager.size();
- const bool maskLoadSuccess = maskTextureInfo.loadState == LoadState::LOAD_FINISHED ? true : false;
-
// TODO : Refactorize here to not iterate whole cached image.
for(TextureCacheIndex cacheIndex = TextureCacheIndex(TextureManagerType::TEXTURE_CACHE_INDEX_TYPE_LOCAL, 0u); cacheIndex.GetIndex() < size; ++cacheIndex.detailValue.index)
{
{
TextureInfo& textureInfo(mTextureCacheManager[cacheIndex]);
- if(maskLoadSuccess)
+ if(maskTextureInfo.loadState == LoadState::LOAD_FINISHED)
+ {
+ if(maskTextureInfo.storageType == StorageType::KEEP_PIXEL_BUFFER)
+ {
+ // Send New Task to Thread
+ ApplyMask(textureInfo, maskTextureInfo.textureId);
+ }
+ }
+ else if(maskTextureInfo.loadState == LoadState::UPLOADED)
{
- // Send New Task to Thread
- ApplyMask(textureInfo, maskTextureInfo.textureId);
+ if(maskTextureInfo.storageType == StorageType::KEEP_TEXTURE)
+ {
+ // Upload image texture. textureInfo.loadState will be UPLOADED.
+ UploadTexture(textureInfo.pixelBuffer, textureInfo);
+ if(maskTextureInfo.textureSet.GetTextureCount() > 0u)
+ {
+ Texture maskTexture = maskTextureInfo.textureSet.GetTexture(0u);
+ textureInfo.textureSet.SetTexture(1u, maskTexture);
+ }
+ // notify mask texture set.
+ NotifyObservers(textureInfo, true);
+ }
}
else
{
TextureManager::TextureId mAlphaMaskId;
float mContentScaleFactor;
bool mCropToMask;
+ bool mPreappliedMasking;
+ bool mMaskImageLoadingFailed;
};
using MaskingDataPointer = std::unique_ptr<MaskingData>;
* @brief Requests a masking image to be loaded. This mask is not uploaded to GL,
* instead, it is stored in CPU memory, and can be used for CPU blending.
* @param[in] maskUrl The URL of the mask image to load
+ * @param[in] storageType, Whether the pixel data is stored in the cache or uploaded to the GPU
* @param[in] synchronousLoading True if the frame should be loaded synchronously. If you skip this parameter,
* default is false.
* @return A TextureId to use as a handle to reference this mask Texture
*/
TextureId RequestMaskLoad(
const VisualUrl& maskUrl,
+ StorageType storageType,
const bool& synchronousLoading = false);
private:
KEEP_PIXEL_BUFFER, ///< Keep loaded pixel buffer inside of texture manager without making texture. This could be used for inside pixel process like mask image.
RETURN_PIXEL_BUFFER, ///< Return loaded pixel buffer without making texture.
/// Because a pixel buffer cannot be used multiple texture, this pixel buffer only cached during loading, and is removed after loading is finished.
+ KEEP_TEXTURE, ///< Keep loaded texture inside of texture manager. This could be used for pixel processing like GPU masking.
UPLOAD_TO_TEXTURE ///< Loaded image will be uploaded to texture and the texture will be returned.
};
// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/image-loading.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/rendering/decorated-visual-renderer.h>
#include <memory>
// INTERNAL INCLUDES
{
namespace
{
-const int CUSTOM_PROPERTY_COUNT(3); // ltr, wrap, pixel area,
+const int CUSTOM_PROPERTY_COUNT(5); // ltr, wrap, pixel area, crop to mask, mask texture ratio
// stop behavior
DALI_ENUM_TO_STRING_TABLE_BEGIN(STOP_BEHAVIOR)
static constexpr auto LOOP_FOREVER = -1;
static constexpr auto FIRST_LOOP = 0u;
+constexpr uint32_t TEXTURE_COUNT_FOR_GPU_ALPHA_MASK = 2u;
+
#if defined(DEBUG_ENABLED)
Debug::Filter* gAnimImgLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_ANIMATED_IMAGE");
#endif
if(mAnimatedImageLoading)
{
- mImageCache = new RollingAnimatedImageCache(textureManager, mAnimatedImageLoading, mMaskingData, *this, mCacheSize, mBatchSize, IsSynchronousLoadingRequired(),mFactoryCache.GetPreMultiplyOnLoad());
+ mImageCache = new RollingAnimatedImageCache(textureManager, mAnimatedImageLoading, mMaskingData, *this, mCacheSize, mBatchSize, IsSynchronousLoadingRequired(), mFactoryCache.GetPreMultiplyOnLoad());
}
else if(mImageUrls)
{
map.Insert(Toolkit::ImageVisual::Property::ALPHA_MASK_URL, mMaskingData->mAlphaMaskUrl.GetUrl());
map.Insert(Toolkit::ImageVisual::Property::MASK_CONTENT_SCALE, mMaskingData->mContentScaleFactor);
map.Insert(Toolkit::ImageVisual::Property::CROP_TO_MASK, mMaskingData->mCropToMask);
+ map.Insert(Toolkit::DevelImageVisual::Property::MASKING_TYPE, mMaskingData->mPreappliedMasking ? DevelImageVisual::MaskingType::MASKING_ON_LOADING : DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
}
map.Insert(Toolkit::ImageVisual::Property::LOAD_POLICY, mLoadPolicy);
{
DoSetProperty(Toolkit::ImageVisual::Property::CROP_TO_MASK, keyValue.second);
}
+ else if(keyValue.first == MASKING_TYPE_NAME)
+ {
+ DoSetProperty(Toolkit::DevelImageVisual::Property::MASKING_TYPE, keyValue.second);
+ }
else if(keyValue.first == LOAD_POLICY_NAME)
{
DoSetProperty(Toolkit::ImageVisual::Property::LOAD_POLICY, keyValue.second);
break;
}
+ case Toolkit::DevelImageVisual::Property::MASKING_TYPE:
+ {
+ int maskingType = 0;
+ if(value.Get(maskingType))
+ {
+ AllocateMaskData();
+ mMaskingData->mPreappliedMasking = Toolkit::DevelImageVisual::MaskingType::Type(maskingType) == Toolkit::DevelImageVisual::MaskingType::MASKING_ON_LOADING ? true : false;
+ }
+ break;
+ }
+
case Toolkit::ImageVisual::Property::RELEASE_POLICY:
{
int releasePolicy = 0;
Shader AnimatedImageVisual::GenerateShader() const
{
- bool defaultWrapMode = mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE;
+ bool defaultWrapMode = mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE;
+ bool requiredAlphaMaskingOnRendering = (mMaskingData && !mMaskingData->mMaskImageLoadingFailed) ? !mMaskingData->mPreappliedMasking : false;
Shader shader;
shader = mImageVisualShaderFactory.GetShader(
mFactoryCache,
ImageVisualShaderFeature::FeatureBuilder()
.ApplyDefaultTextureWrapMode(defaultWrapMode)
.EnableRoundedCorner(IsRoundedCornerRequired())
- .EnableBorderline(IsBorderlineRequired()));
+ .EnableBorderline(IsBorderlineRequired())
+ .EnableAlphaMaskingOnRendering(requiredAlphaMaskingOnRendering));
return shader;
}
Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY);
- mImpl->mRenderer = VisualRenderer::New(geometry, shader);
+ mImpl->mRenderer = DecoratedVisualRenderer::New(geometry, shader);
mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT);
// Register transform properties
mImpl->mRenderer.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, mPixelArea);
}
+ if(mMaskingData)
+ {
+ mImpl->mRenderer.RegisterProperty(CROP_TO_MASK_NAME, static_cast<float>(mMaskingData->mCropToMask));
+ }
+
// Enable PreMultipliedAlpha if it need premultiplied
auto preMultiplyOnLoad = IsPreMultipliedAlphaEnabled() && !mImpl->mCustomShader
? TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD
if(mImpl->mRenderer)
{
mImpl->mRenderer.SetTextures(textureSet);
+ CheckMaskTexture();
Actor actor = mPlacementActor.GetHandle();
if(actor)
mImageSize.SetWidth(texture.GetWidth());
mImageSize.SetHeight(texture.GetHeight());
}
+
+ if(textureSet.GetTextureCount() > 1u && mMaskingData && mMaskingData->mCropToMask)
+ {
+ Texture maskTexture = textureSet.GetTexture(1);
+ if(maskTexture)
+ {
+ mImageSize.SetWidth(std::min(static_cast<uint32_t>(mImageSize.GetWidth() * mMaskingData->mContentScaleFactor), maskTexture.GetWidth()));
+ mImageSize.SetHeight(std::min(static_cast<uint32_t>(mImageSize.GetHeight() * mMaskingData->mContentScaleFactor), maskTexture.GetHeight()));
+
+ float textureWidth = std::max(static_cast<float>(texture.GetWidth() * mMaskingData->mContentScaleFactor), Dali::Math::MACHINE_EPSILON_1);
+ float textureHeight = std::max(static_cast<float>(texture.GetHeight() * mMaskingData->mContentScaleFactor), Dali::Math::MACHINE_EPSILON_1);
+ Vector2 textureRatio(std::min(static_cast<float>(maskTexture.GetWidth()), textureWidth) / textureWidth,
+ std::min(static_cast<float>(maskTexture.GetHeight()), textureHeight) / textureHeight);
+ mImpl->mRenderer.RegisterProperty(MASK_TEXTURE_RATIO_NAME, textureRatio);
+ }
+ }
}
}
mFrameDelayTimer.SetInterval(interval);
}
mImpl->mRenderer.SetTextures(textureSet);
+ CheckMaskTexture();
}
}
}
if(mImpl->mRenderer)
{
mImpl->mRenderer.SetTextures(textureSet);
+ CheckMaskTexture();
}
mFrameDelayTimer.SetInterval(mImageCache->GetFrameInterval(frameIndex));