Title: [224719] trunk/Source/WebCore
Revision
224719
Author
commit-qu...@webkit.org
Date
2017-11-10 17:43:36 -0800 (Fri, 10 Nov 2017)

Log Message

[CG] PDF document cached image is regenerated every time the destination rectangle changes
https://bugs.webkit.org/show_bug.cgi?id=179516

Patch by Said Abou-Hallawa <sabouhall...@apple.com> on 2017-11-10
Reviewed by Tim Horton.

The PDF document cached image was regenerated if m_cachedImageRect didn't
contain the dirty rectangle. When moving the image, its new rectangle is
invalidated. This will set a new dirty rectangle outside m_cachedImageRect
which may not be fully inside m_cachedImageRect.

The PDF document cached image should be reused if we still draw the same
part of the image (srcRet did not change) and we use the same zooming factor
(dstSize did not change).

* platform/graphics/cg/PDFDocumentImage.cpp:
(WebCore::PDFDocumentImage::cacheParametersMatch const): Remove a check
that was added mainly to force recalculating m_cachedImageRect when the
dirty rectangle changes.

(WebCore::PDFDocumentImage::updateCachedImageIfNeeded): Recalculate
m_cachedImageRect every time this function is called regardless the cached
image will be regenerated or not.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (224718 => 224719)


--- trunk/Source/WebCore/ChangeLog	2017-11-11 01:22:37 UTC (rev 224718)
+++ trunk/Source/WebCore/ChangeLog	2017-11-11 01:43:36 UTC (rev 224719)
@@ -1,3 +1,28 @@
+2017-11-10  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        [CG] PDF document cached image is regenerated every time the destination rectangle changes
+        https://bugs.webkit.org/show_bug.cgi?id=179516
+
+        Reviewed by Tim Horton.
+
+        The PDF document cached image was regenerated if m_cachedImageRect didn't
+        contain the dirty rectangle. When moving the image, its new rectangle is
+        invalidated. This will set a new dirty rectangle outside m_cachedImageRect
+        which may not be fully inside m_cachedImageRect.
+
+        The PDF document cached image should be reused if we still draw the same
+        part of the image (srcRet did not change) and we use the same zooming factor        
+        (dstSize did not change).
+
+        * platform/graphics/cg/PDFDocumentImage.cpp:
+        (WebCore::PDFDocumentImage::cacheParametersMatch const): Remove a check
+        that was added mainly to force recalculating m_cachedImageRect when the
+        dirty rectangle changes. 
+
+        (WebCore::PDFDocumentImage::updateCachedImageIfNeeded): Recalculate
+        m_cachedImageRect every time this function is called regardless the cached
+        image will be regenerated or not.
+
 2017-11-10  Simon Fraser  <simon.fra...@apple.com>
 
         Compositing layers in UIWebView are often missing content after scrolling

Modified: trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp (224718 => 224719)


--- trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp	2017-11-11 01:22:37 UTC (rev 224718)
+++ trunk/Source/WebCore/platform/graphics/cg/PDFDocumentImage.cpp	2017-11-11 01:43:36 UTC (rev 224719)
@@ -116,9 +116,6 @@
     if (srcRect != m_cachedSourceRect)
         return false;
 
-    if (!m_cachedImageRect.contains(context.clipBounds()))
-        return false;
-
     AffineTransform::DecomposedType decomposedTransform;
     context.getCTM(GraphicsContext::DefinitelyIncludeDeviceScale).decompose(decomposedTransform);
 
@@ -207,12 +204,6 @@
     bool repaintIfNecessary = interpolationQuality != InterpolationNone && interpolationQuality != InterpolationLow;
 #endif
 
-    // Clipped option is for testing only. Force recaching the PDF with each draw.
-    if (m_pdfImageCachingPolicy != PDFImageCachingClipBoundsOnly) {
-        if (m_cachedImageBuffer && (!repaintIfNecessary || cacheParametersMatch(context, dstRect, srcRect)))
-            return;
-    }
-
     switch (m_pdfImageCachingPolicy) {
     case PDFImageCachingDisabled:
         return;
@@ -229,6 +220,12 @@
         break;
     }
 
+    // Clipped option is for testing only. Force recaching the PDF with each draw.
+    if (m_pdfImageCachingPolicy != PDFImageCachingClipBoundsOnly) {
+        if (m_cachedImageBuffer && (!repaintIfNecessary || cacheParametersMatch(context, dstRect, srcRect)))
+            return;
+    }
+
     FloatSize cachedImageSize = FloatRect(enclosingIntRect(m_cachedImageRect)).size();
 
     // Cache the PDF image only if the size of the new image won't exceed the cache threshold.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to