From: David Steele Date: Fri, 20 Aug 2021 11:19:15 +0000 (+0100) Subject: [dali_2.0.40] Merge branch 'devel/master' X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=8f1a6195e212abf3eb7ef598f216601e225babaa;hp=33233fdcb39140e9080eb71087348ae0edcb887d [dali_2.0.40] Merge branch 'devel/master' Change-Id: I298b622cba2a1c91c11fddf74b664d495c0cdb1b --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-canvas-renderer.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-canvas-renderer.cpp index f280f6f..56c0cd8 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-canvas-renderer.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-canvas-renderer.cpp @@ -103,7 +103,7 @@ public: } - bool SetSize(const Vector2& size) + bool SetSize(Vector2 size) { mSize = size; // For negative test @@ -114,10 +114,9 @@ public: return true; } - const Vector2& GetSize() + Vector2 GetSize() const { - mSize = Vector2(200, 200); - return mSize; + return Vector2(200, 200); } bool SetViewBox(const Vector2& viewBox) @@ -221,12 +220,12 @@ bool CanvasRenderer::RemoveAllDrawables() return Internal::Adaptor::GetImplementation(*this).RemoveAllDrawables(); } -bool CanvasRenderer::SetSize(const Vector2& size) +bool CanvasRenderer::SetSize(Vector2 size) { return Internal::Adaptor::GetImplementation(*this).SetSize(size); } -const Vector2& CanvasRenderer::GetSize() +Vector2 CanvasRenderer::GetSize() const { return Internal::Adaptor::GetImplementation(*this).GetSize(); } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index d89428a..d00dc75 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -3221,6 +3221,70 @@ int UtcDaliTextFieldSettingPlaceholder(void) END_TEST; } +int UtcDaliTextFieldPlaceholderCoverage(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextFieldPlaceholderCoverage"); + + // mPlaceholderFont is created only once, so create a new control for coverage. + TextField fieldForCoverage = TextField::New(); + DALI_TEST_CHECK(fieldForCoverage); + application.GetScene().Add(fieldForCoverage); + + // for SetPlaceholderFontFamily() coverage. + Property::Map fontFamilyMap; + fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial"; + fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap); + + // mPlaceholderFont is created only once, so create a new control for coverage. + fieldForCoverage = TextField::New(); + DALI_TEST_CHECK(fieldForCoverage); + application.GetScene().Add(fieldForCoverage); + + // for SetPlaceholderTextFontSize coverage. + Property::Map fontSizeMap; + fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f; + fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap); + + // mPlaceholderFont is created only once, so create a new control for coverage. + fieldForCoverage = TextField::New(); + DALI_TEST_CHECK(fieldForCoverage); + application.GetScene().Add(fieldForCoverage); + + // for SetPlaceholderTextFontWeight coverage. + Property::Map fontStyleWeightMap; + Property::Map fontStyleWeightPropertyMap; + fontStyleWeightPropertyMap.Insert("weight", "bold"); + fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap; + fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap); + + // mPlaceholderFont is created only once, so create a new control for coverage. + fieldForCoverage = TextField::New(); + DALI_TEST_CHECK(fieldForCoverage); + application.GetScene().Add(fieldForCoverage); + + // for SetPlaceholderTextFontWidth coverage. + Property::Map fontStyleWidthMap; + Property::Map fontStyleWidthPropertyMap; + fontStyleWidthPropertyMap.Insert("width", "expanded"); + fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap; + fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap); + + // mPlaceholderFont is created only once, so create a new control for coverage. + fieldForCoverage = TextField::New(); + DALI_TEST_CHECK(fieldForCoverage); + application.GetScene().Add(fieldForCoverage); + + // for SetPlaceholderTextFontSlant coverage. + Property::Map fontStyleSlantMap; + Property::Map fontStyleSlantPropertyMap; + fontStyleSlantPropertyMap.Insert("slant", "italic"); + fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap; + fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap); + + END_TEST; +} + int UtcDaliTextFieldSetPaddingProperty(void) { ToolkitTestApplication application; diff --git a/dali-toolkit/devel-api/focus-manager/focus-finder.cpp b/dali-toolkit/devel-api/focus-manager/focus-finder.cpp index a7324b8..2679dda 100644 --- a/dali-toolkit/devel-api/focus-manager/focus-finder.cpp +++ b/dali-toolkit/devel-api/focus-manager/focus-finder.cpp @@ -188,19 +188,19 @@ static bool IsCandidate(Dali::Rect srcRect, Dali::Rect destRect, D { case Dali::Toolkit::Control::KeyboardFocus::LEFT: { - return (srcRect.right > destRect.right || srcRect.left >= destRect.right); + return (srcRect.right > destRect.right || srcRect.left >= destRect.right) && srcRect.left > destRect.left; } case Dali::Toolkit::Control::KeyboardFocus::RIGHT: { - return (srcRect.left < destRect.left || srcRect.right <= destRect.left); + return (srcRect.left < destRect.left || srcRect.right <= destRect.left) && srcRect.right < destRect.right; } case Dali::Toolkit::Control::KeyboardFocus::UP: { - return (srcRect.bottom > destRect.bottom || srcRect.top >= destRect.bottom); + return (srcRect.bottom > destRect.bottom || srcRect.top >= destRect.bottom) && srcRect.top > destRect.top; } case Dali::Toolkit::Control::KeyboardFocus::DOWN: { - return (srcRect.top < destRect.top || srcRect.bottom <= destRect.top); + return (srcRect.top < destRect.top || srcRect.bottom <= destRect.top) && srcRect.bottom < destRect.bottom; } default: { @@ -344,14 +344,13 @@ bool IsFocusable(Actor& actor) { return (actor.GetProperty(Actor::Property::KEYBOARD_FOCUSABLE) && actor.GetProperty(Actor::Property::VISIBLE) && - actor.GetProperty(Actor::Property::SENSITIVE) && actor.GetProperty(Actor::Property::WORLD_COLOR).a > FULLY_TRANSPARENT); } Actor FindNextFocus(Actor& actor, Actor& focusedActor, Rect& focusedRect, Rect& bestCandidateRect, Toolkit::Control::KeyboardFocus::Direction direction) { Actor nearestActor; - if(actor) + if(actor && actor.GetProperty(Actor::Property::VISIBLE)) { // Recursively children const auto childCount = actor.GetChildCount(); diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index c31fc93..3fe3322 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -85,7 +85,7 @@ namespace Text EventData::EventData(DecoratorPtr decorator, InputMethodContext& inputMethodContext) : mDecorator(decorator), mInputMethodContext(inputMethodContext), - mPlaceholderFont(NULL), + mPlaceholderFont(nullptr), mPlaceholderTextActive(), mPlaceholderTextInactive(), mPlaceholderTextColor(0.8f, 0.8f, 0.8f, 0.8f), // This color has been published in the Public API (placeholder-properties.h). diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index 84d6193..02fbff8 100644 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -116,12 +116,12 @@ struct EventData return (stateToCheck == EDITING || stateToCheck == EDITING_WITH_POPUP || stateToCheck == EDITING_WITH_GRAB_HANDLE || stateToCheck == EDITING_WITH_PASTE_POPUP); } - DecoratorPtr mDecorator; ///< Pointer to the decorator. - InputMethodContext mInputMethodContext; ///< The Input Method Framework Manager. - FontDefaults* mPlaceholderFont; ///< The placeholder default font. - std::string mPlaceholderTextActive; ///< The text to display when the TextField is empty with key-input focus. - std::string mPlaceholderTextInactive; ///< The text to display when the TextField is empty and inactive. - Vector4 mPlaceholderTextColor; ///< The in/active placeholder text color. + DecoratorPtr mDecorator; ///< Pointer to the decorator. + InputMethodContext mInputMethodContext; ///< The Input Method Framework Manager. + std::unique_ptr mPlaceholderFont; ///< The placeholder default font. + std::string mPlaceholderTextActive; ///< The text to display when the TextField is empty with key-input focus. + std::string mPlaceholderTextInactive; ///< The text to display when the TextField is empty and inactive. + Vector4 mPlaceholderTextColor; ///< The in/active placeholder text color. /** * This is used to delay handling events until after the model has been updated. diff --git a/dali-toolkit/internal/text/text-controller-placeholder-handler.cpp b/dali-toolkit/internal/text/text-controller-placeholder-handler.cpp index 81d491a..301dbcb 100644 --- a/dali-toolkit/internal/text/text-controller-placeholder-handler.cpp +++ b/dali-toolkit/internal/text/text-controller-placeholder-handler.cpp @@ -111,10 +111,8 @@ void Controller::PlaceholderHandler::SetPlaceholderFontFamily(Controller& contro { if(NULL != controller.mImpl->mEventData) { - if(NULL == controller.mImpl->mEventData->mPlaceholderFont) - { - controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults(); - } + // if mPlaceholderFont is null, create an instance. + CreatePlaceholderFont(controller); controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.family = placeholderTextFontFamily; DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::SetPlaceholderFontFamily %s\n", placeholderTextFontFamily.c_str()); @@ -138,10 +136,8 @@ void Controller::PlaceholderHandler::SetPlaceholderTextFontWeight(Controller& co { if(NULL != controller.mImpl->mEventData) { - if(NULL == controller.mImpl->mEventData->mPlaceholderFont) - { - controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults(); - } + // if mPlaceholderFont is null, create an instance. + CreatePlaceholderFont(controller); controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.weight = weight; controller.mImpl->mEventData->mPlaceholderFont->weightDefined = true; @@ -173,10 +169,8 @@ void Controller::PlaceholderHandler::SetPlaceholderTextFontWidth(Controller& con { if(NULL != controller.mImpl->mEventData) { - if(NULL == controller.mImpl->mEventData->mPlaceholderFont) - { - controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults(); - } + // if mPlaceholderFont is null, create an instance. + CreatePlaceholderFont(controller); controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.width = width; controller.mImpl->mEventData->mPlaceholderFont->widthDefined = true; @@ -208,10 +202,8 @@ void Controller::PlaceholderHandler::SetPlaceholderTextFontSlant(Controller& con { if(NULL != controller.mImpl->mEventData) { - if(NULL == controller.mImpl->mEventData->mPlaceholderFont) - { - controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults(); - } + // if mPlaceholderFont is null, create an instance. + CreatePlaceholderFont(controller); controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.slant = slant; controller.mImpl->mEventData->mPlaceholderFont->slantDefined = true; @@ -243,10 +235,8 @@ void Controller::PlaceholderHandler::SetPlaceholderTextFontSize(Controller& cont { if(NULL != controller.mImpl->mEventData) { - if(NULL == controller.mImpl->mEventData->mPlaceholderFont) - { - controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults(); - } + // if mPlaceholderFont is null, create an instance. + CreatePlaceholderFont(controller); switch(type) { @@ -533,6 +523,14 @@ void Controller::PlaceholderHandler::ShowPlaceholderText(Controller& controller) } } +void Controller::PlaceholderHandler::CreatePlaceholderFont(Controller& controller) +{ + if(nullptr == controller.mImpl->mEventData->mPlaceholderFont) + { + controller.mImpl->mEventData->mPlaceholderFont = std::unique_ptr(new FontDefaults()); + } +} + } // namespace Text } // namespace Toolkit diff --git a/dali-toolkit/internal/text/text-controller-placeholder-handler.h b/dali-toolkit/internal/text/text-controller-placeholder-handler.h index c69e003..ac2ba1b 100644 --- a/dali-toolkit/internal/text/text-controller-placeholder-handler.h +++ b/dali-toolkit/internal/text/text-controller-placeholder-handler.h @@ -56,6 +56,7 @@ struct Controller::PlaceholderHandler static void SetPlaceholderProperty(Controller& controller, const Property::Map& map); static void GetPlaceholderProperty(Controller& controller, Property::Map& map); static void ShowPlaceholderText(Controller& controller); + static void CreatePlaceholderFont(Controller& controller); }; } // namespace Text diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index 16a4a4a..4ae09f6 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -187,6 +187,23 @@ ImageVisual::~ImageVisual() } } + if(mImageUrl.IsValid()) + { + // Decrease reference count of External Resources : + // EncodedImageBuffer or ExternalTextures. + // Ensure the stage is still valid before accessing texture manager. + if(mImageUrl.GetProtocolType() == VisualUrl::TEXTURE) + { + TextureManager& textureManager = mFactoryCache.GetTextureManager(); + textureManager.RemoveExternalTexture(mImageUrl.GetUrl()); + } + else if(mImageUrl.IsBufferResource()) + { + TextureManager& textureManager = mFactoryCache.GetTextureManager(); + textureManager.RemoveExternalEncodedImageBuffer(mImageUrl.GetUrl()); + } + } + // ImageVisual destroyed so remove texture unless ReleasePolicy is set to never release if((mTextureId != TextureManager::INVALID_TEXTURE_ID) && (mReleasePolicy != Toolkit::ImageVisual::ReleasePolicy::NEVER)) { @@ -530,6 +547,15 @@ void ImageVisual::OnInitialize() } } + // Increase reference count of External Resources : + // EncodedImageBuffer or ExternalTextures. + // Reference count will be decreased at destructor of the visual. + if(mImageUrl.IsValid() && (mImageUrl.IsBufferResource() || mImageUrl.GetProtocolType() == VisualUrl::TEXTURE)) + { + TextureManager& textureManager = mFactoryCache.GetTextureManager(); + textureManager.UseExternalResource(mImageUrl.GetUrl()); + } + Shader shader = GetShader(); // Create the renderer diff --git a/dali-toolkit/internal/visuals/texture-manager-impl.cpp b/dali-toolkit/internal/visuals/texture-manager-impl.cpp index c6fc0c2..093954e 100644 --- a/dali-toolkit/internal/visuals/texture-manager-impl.cpp +++ b/dali-toolkit/internal/visuals/texture-manager-impl.cpp @@ -469,6 +469,10 @@ TextureManager::TextureId TextureManager::RequestLoadInternal( if(encodedImageBuffer) { textureId = targetId; + + // Increase EncodedImageBuffer reference during it contains mTextureInfoContainer. + UseExternalResource(url.GetUrl()); + // Insert this buffer at mTextureInfoContainer. // This buffer will decode at ImageLoaderThread. bool preMultiply = (preMultiplyOnLoad == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD); @@ -604,6 +608,11 @@ void TextureManager::Remove(const TextureManager::TextureId textureId, TextureUp // If the state allows us to remove the TextureInfo data, we do so. if(removeTextureInfo) { + // If url location is BUFFER, decrease reference count of EncodedImageBuffer. + if(textureInfo.url.IsBufferResource()) + { + RemoveExternalEncodedImageBuffer(textureInfo.url.GetUrl()); + } // Permanently remove the textureInfo struct. mTextureInfoContainer.erase(mTextureInfoContainer.begin() + textureInfoIndex); } diff --git a/dali-toolkit/internal/visuals/visual-url.cpp b/dali-toolkit/internal/visuals/visual-url.cpp index 70c6dc2..30d9c02 100644 --- a/dali-toolkit/internal/visuals/visual-url.cpp +++ b/dali-toolkit/internal/visuals/visual-url.cpp @@ -20,10 +20,6 @@ // EXTERNAL HEADERS #include // for toupper() -// INTERNAL HEADERS -#include -#include - namespace Dali { namespace Toolkit @@ -228,14 +224,6 @@ VisualUrl::VisualUrl(const std::string& url) // TEXTURE and BUFFER location url doesn't need type resolving, REGULAR_IMAGE is fine mType = ResolveType(url); } - else - { - Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get(); - if(factory) - { - GetImplementation(factory).GetTextureManager().UseExternalResource(*this); - } - } } } @@ -244,69 +232,19 @@ VisualUrl::VisualUrl(const VisualUrl& url) mType(url.mType), mLocation(url.mLocation) { - if(VisualUrl::TEXTURE == mLocation || VisualUrl::BUFFER == mLocation) - { - Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get(); - if(factory) - { - GetImplementation(factory).GetTextureManager().UseExternalResource(*this); - } - } } VisualUrl::~VisualUrl() { - if(VisualUrl::TEXTURE == mLocation) - { - Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get(); - if(factory) - { - GetImplementation(factory).GetTextureManager().RemoveExternalTexture(mUrl); - } - } - else if(VisualUrl::BUFFER == mLocation) - { - Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get(); - if(factory) - { - GetImplementation(factory).GetTextureManager().RemoveExternalEncodedImageBuffer(mUrl); - } - } } VisualUrl& VisualUrl::operator=(const VisualUrl& url) { if(&url != this) { - if(VisualUrl::TEXTURE == mLocation) - { - Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get(); - if(factory) - { - GetImplementation(factory).GetTextureManager().RemoveExternalTexture(mUrl); - } - } - else if(VisualUrl::BUFFER == mLocation) - { - Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get(); - if(factory) - { - GetImplementation(factory).GetTextureManager().RemoveExternalEncodedImageBuffer(mUrl); - } - } - mUrl = url.mUrl; mType = url.mType; mLocation = url.mLocation; - - if(VisualUrl::TEXTURE == mLocation || VisualUrl::BUFFER == mLocation) - { - Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get(); - if(factory) - { - GetImplementation(factory).GetTextureManager().UseExternalResource(*this); - } - } } return *this; } diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index 71537c6..2f6f7a9 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -29,7 +29,7 @@ namespace Toolkit { const unsigned int TOOLKIT_MAJOR_VERSION = 2; const unsigned int TOOLKIT_MINOR_VERSION = 0; -const unsigned int TOOLKIT_MICRO_VERSION = 39; +const unsigned int TOOLKIT_MICRO_VERSION = 40; const char* const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index a9a7ac0..de44474 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ Name: dali2-toolkit Summary: Dali 3D engine Toolkit -Version: 2.0.39 +Version: 2.0.40 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-3-Clause and MIT