[M108 Migration][Loading Performance] Apply to prevent incremental image rendering 10/290310/3
authorGajendra N <gajendra.n@samsung.com>
Tue, 21 Mar 2023 08:56:25 +0000 (14:26 +0530)
committerBot Blink <blinkbot@samsung.com>
Thu, 23 Mar 2023 14:23:22 +0000 (14:23 +0000)
Do not request image rendering when image resource is loading for page loading
performance. This patch is written referring to tizen 2.4 webkit's code.

Reference: https://review.tizen.org/gerrit/268835

Change-Id: Ifc46153667dc5af8d782c890335d32ae9ae44035
Signed-off-by: Gajendra N <gajendra.n@samsung.com>
third_party/blink/renderer/core/layout/layout_image.cc
third_party/blink/renderer/core/loader/resource/image_resource_content.cc
third_party/blink/renderer/core/loader/resource/image_resource_content.h

index a5828c003f00f3a564380365535228d149509a1d..a66339732b9c4a710cf9bb5096c597f5b2fcefe0 100644 (file)
 #include "third_party/blink/renderer/platform/runtime_enabled_features.h"
 #include "ui/gfx/geometry/size_conversions.h"
 
+#if BUILDFLAG(IS_TIZEN)
+#include "third_party/blink/renderer/core/paint/paint_info.h"
+#endif
+
 namespace blink {
 
 LayoutImage::LayoutImage(Element* element)
@@ -222,6 +226,16 @@ void LayoutImage::PaintReplaced(const PaintInfo& paint_info,
 
 void LayoutImage::Paint(const PaintInfo& paint_info) const {
   NOT_DESTROYED();
+#if BUILDFLAG(IS_TIZEN)
+  // Do not request image rendering when image resource is loading
+  // for page loading performance.
+  if (paint_info.phase == PaintPhase::kForeground &&
+      !Style()->HasBoxDecorations() && image_resource_ &&
+      image_resource_->CachedImage() &&
+      image_resource_->CachedImage()->IsLoading()) {
+    return;
+  }
+#endif
   ImagePainter(*this).Paint(paint_info);
 }
 
index aa6087be3541211ee1b70d5e51d338c02692bf65..c1b61f023a60f03458d23ad21519d4a9ad331efe 100644 (file)
@@ -456,6 +456,12 @@ ImageResourceContent::UpdateImageResult ImageResourceContent::UpdateImage(
   DCHECK(all_data_received ||
          size_available_ != Image::kSizeAvailableAndLoadingAsynchronously);
 
+#if BUILDFLAG(IS_TIZEN)
+  if (!notified_)
+    notified_ = true;
+  else if (!all_data_received)
+    return UpdateImageResult::kNoDecodeError;
+#endif
   // Notifies the observers.
   // It would be nice to only redraw the decoded band of the image, but with the
   // current design (decoding delayed until painting) that seems hard.
index 834a0dcb01bd9f7dddccc2c1ae53b4da890047f0..c9ae5e563f3407bfc850cfc36187bb51585fd30f 100644 (file)
@@ -268,6 +268,10 @@ class CORE_EXPORT ImageResourceContent final
 
   scoped_refptr<blink::Image> image_;
 
+#if BUILDFLAG(IS_TIZEN)
+  bool notified_ = false;
+#endif
+
   HeapHashCountedSet<WeakMember<ImageResourceObserver>> observers_;
   HeapHashCountedSet<WeakMember<ImageResourceObserver>> finished_observers_;