From: Eunki, Hong Date: Thu, 19 Dec 2024 02:43:13 +0000 (+0900) Subject: [Tizen] (WebView) Change also TransformSize if web view changed X-Git-Tag: accepted/tizen/9.0/unified/20241223.115340^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2bd5758185f6bc12e88b09dee82421c8961529d4;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git [Tizen] (WebView) Change also TransformSize if web view changed Until now, we only change PixelArea value to control web contents size if webView size changed and source not applied. For scale-down case, it works well. But for scale-up case, it will not works well. To avoid this issue, let we allow to change transfrom size will not over the original content size. Also, we need to support to change transform data without create new visual. Change-Id: I4fe1066fd744600ab56968e4efc8fe643a8af7e6 Signed-off-by: Eunki, Hong --- diff --git a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp index b0fe2e78d6..549423f975 100644 --- a/dali-toolkit/internal/controls/web-view/web-view-impl.cpp +++ b/dali-toolkit/internal/controls/web-view/web-view-impl.cpp @@ -151,22 +151,23 @@ const Property::Map DEFAULT_WEB_IMAGE_VISUAL_PROPERTIES{ {Dali::Toolkit::DevelVisual::Property::CORNER_RADIUS, Vector4::ZERO}, {Dali::Toolkit::DevelVisual::Property::CORNER_SQUARENESS, Vector4::ZERO}, {Dali::Toolkit::DevelVisual::Property::CORNER_RADIUS_POLICY, Dali::Toolkit::Visual::Transform::Policy::ABSOLUTE}, + {Dali::Toolkit::Visual::Property::TRANSFORM, {{Dali::Toolkit::Visual::Transform::Property::SIZE, Vector2::ONE}}}, }; /** - * @brief Helper function to calculate exact pixel area value by view and texture size. + * @brief Helper function to calculate exact texture ratio value by view and texture size. * It will be useful when view size is not integer value, or view size is not matched with texture size. * * @param[in] viewSize The size of view. * @param[in] textureWidth The width of texture, that must be integer type. * @param[in] textureHeight The height of texture, that must be integer type. - * @return PixelArea value that image visual can use. + * @return Ratio value for each width and height that image visual can use. */ -Vector4 CalculatePixelArea(const Size& viewSize, const uint32_t textureWidth, const uint32_t textureHeight) +Vector2 CalculateTextureRatio(const Size& viewSize, const uint32_t textureWidth, const uint32_t textureHeight) { float widthRatio = textureWidth == 0u ? 1.0f : viewSize.width / static_cast(textureWidth); float heightRatio = textureHeight == 0u ? 1.0f : viewSize.height / static_cast(textureHeight); - return Vector4(0.0f, 0.0f, widthRatio, heightRatio); + return Vector2(widthRatio, heightRatio); } } // namespace @@ -1101,10 +1102,15 @@ void WebView::SetDisplayArea(const Dali::Rect& displayArea) // Change old visual's pixel area matched as changed web view size if(mVisual) { - auto pixelArea = CalculatePixelArea(mWebViewSize, mLastRenderedNativeImageWidth, mLastRenderedNativeImageHeight); + const Vector2 textureRatio = CalculateTextureRatio(mWebViewSize, mLastRenderedNativeImageWidth, mLastRenderedNativeImageHeight); + + const Vector4 pixelArea(0.0f, 0.0f, std::min(1.0f, textureRatio.x), std::min(1.0f, textureRatio.y)); + const Vector2 transformSize(DALI_UNLIKELY(Dali::EqualsZero(textureRatio.x)) ? 1.0f : std::min(1.0f, 1.0f / textureRatio.x), DALI_UNLIKELY(Dali::EqualsZero(textureRatio.y)) ? 1.0f : std::min(1.0f, 1.0f / textureRatio.y)); mVisualPropertyMap[Toolkit::ImageVisual::Property::PIXEL_AREA] = pixelArea; - Toolkit::GetImplementation(mVisual).DoAction(Toolkit::DevelVisual::Action::UPDATE_PROPERTY, {{Toolkit::ImageVisual::Property::PIXEL_AREA, pixelArea}}); + mVisualPropertyMap[Toolkit::Visual::Property::TRANSFORM] = {{Dali::Toolkit::Visual::Transform::Property::SIZE, transformSize}}; + + Toolkit::GetImplementation(mVisual).DoAction(Toolkit::DevelVisual::Action::UPDATE_PROPERTY, {{Toolkit::ImageVisual::Property::PIXEL_AREA, pixelArea}, {Toolkit::Visual::Property::TRANSFORM, {{Dali::Toolkit::Visual::Transform::Property::SIZE, transformSize}}}}); } mWebViewArea = displayArea; diff --git a/dali-toolkit/internal/visuals/visual-base-impl.cpp b/dali-toolkit/internal/visuals/visual-base-impl.cpp index 1fc041ec74..375024eb6c 100644 --- a/dali-toolkit/internal/visuals/visual-base-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-base-impl.cpp @@ -242,7 +242,19 @@ void Visual::Base::SetProperties(const Property::Map& propertyMap) Property::Map map; if(value.Get(map)) { - mImpl->mTransform.SetPropertyMap(map); + if(DALI_UNLIKELY(mImpl->mRenderer)) + { + // Unusual case. SetProperty called after OnInitialize(). + // Assume that DoAction call UPDATE_PROPERTY. + mImpl->mTransform.UpdatePropertyMap(map); + + // Set Renderer uniforms, and change logics for subclasses. + OnSetTransform(); + } + else + { + mImpl->mTransform.SetPropertyMap(map); + } } break; }