(WebView) Change also TransformSize if web view changed 68/316868/4
authorEunki, Hong <eunkiki.hong@samsung.com>
Thu, 19 Dec 2024 02:43:13 +0000 (11:43 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Thu, 19 Dec 2024 04:57:15 +0000 (13:57 +0900)
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 <eunkiki.hong@samsung.com>
dali-toolkit/internal/controls/web-view/web-view-impl.cpp
dali-toolkit/internal/visuals/visual-base-impl.cpp

index 8a78caccb631783b4a2c63b1e02baeeb04ec4746..a4f99a9c99d47731662afc2631304244df99c064 100644 (file)
@@ -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<float>(textureWidth);
   float heightRatio = textureHeight == 0u ? 1.0f : viewSize.height / static_cast<float>(textureHeight);
-  return Vector4(0.0f, 0.0f, widthRatio, heightRatio);
+  return Vector2(widthRatio, heightRatio);
 }
 
 } // namespace
@@ -1080,10 +1081,15 @@ void WebView::SetDisplayArea(const Dali::Rect<int32_t>& 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;
index 1fc041ec74bb3d8360d8dd1b37325288fe043c1b..375024eb6c8907092a1ef1c80c0b55966bdff1ca 100644 (file)
@@ -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;
       }