Title: [169412] trunk/Source/WebCore
Revision
169412
Author
timothy_hor...@apple.com
Date
2014-05-27 21:46:18 -0700 (Tue, 27 May 2014)

Log Message

REGRESSION (Margin tiles): Background gradient on dom.spec.whatwg.org is very slow to render
https://bugs.webkit.org/show_bug.cgi?id=133335
<rdar://problem/17011392>

Reviewed by Simon Fraser.

* platform/graphics/Image.cpp:
(WebCore::Image::drawTiled):
Make cross-platform and use some iOS code which avoids patterned drawing when the pattern buffer
would be very large. Instead, it calls draw() repeatedly over the pattern space, avoiding the allocation
of a huge (in the case of bug 133335, nearly 2GB) buffer.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (169411 => 169412)


--- trunk/Source/WebCore/ChangeLog	2014-05-28 04:44:56 UTC (rev 169411)
+++ trunk/Source/WebCore/ChangeLog	2014-05-28 04:46:18 UTC (rev 169412)
@@ -1,3 +1,17 @@
+2014-05-27  Timothy Horton  <timothy_hor...@apple.com>
+
+        REGRESSION (Margin tiles): Background gradient on dom.spec.whatwg.org is very slow to render
+        https://bugs.webkit.org/show_bug.cgi?id=133335
+        <rdar://problem/17011392>
+
+        Reviewed by Simon Fraser.
+
+        * platform/graphics/Image.cpp:
+        (WebCore::Image::drawTiled):
+        Make cross-platform and use some iOS code which avoids patterned drawing when the pattern buffer
+        would be very large. Instead, it calls draw() repeatedly over the pattern space, avoiding the allocation
+        of a huge (in the case of bug 133335, nearly 2GB) buffer.
+
 2014-05-27  Simon Fraser  <simon.fra...@apple.com>
 
         [iOS WK2] Fix behavior of position:sticky inside accelerated overflow-scroll

Modified: trunk/Source/WebCore/platform/graphics/Image.cpp (169411 => 169412)


--- trunk/Source/WebCore/platform/graphics/Image.cpp	2014-05-28 04:44:56 UTC (rev 169411)
+++ trunk/Source/WebCore/platform/graphics/Image.cpp	2014-05-28 04:46:18 UTC (rev 169412)
@@ -118,7 +118,7 @@
     oneTileRect.setY(destRect.y() + fmodf(fmodf(-srcPoint.y(), actualTileSize.height()) - actualTileSize.height(), actualTileSize.height()));
     oneTileRect.setSize(scaledTileSize);
     
-    // Check and see if a single draw of the image can cover the entire area we are supposed to tile.    
+    // Check and see if a single draw of the image can cover the entire area we are supposed to tile.
     if (oneTileRect.contains(destRect) && !ctxt->drawLuminanceMask()) {
         FloatRect visibleSrcRect;
         visibleSrcRect.setX((destRect.x() - oneTileRect.x()) / scale.width());
@@ -153,22 +153,27 @@
     }
 #endif
 
+
+    // Patterned images and gradients can use lots of memory for caching when the
+    // tile size is large (<rdar://problem/4691859>, <rdar://problem/6239505>).
+    // Memory consumption depends on the transformed tile size which can get
+    // larger than the original tile if user zooms in enough.
 #if PLATFORM(IOS)
-    // CGPattern uses lots of memory got caching when the tile size is large (<rdar://problem/4691859>,
-    // <rdar://problem/6239505>). Memory consumption depends on the transformed tile size which can get
-    // larger than the original tile if user zooms in enough.
     const float maxPatternTilePixels = 512 * 512;
+#else
+    const float maxPatternTilePixels = 2048 * 2048;
+#endif
     FloatRect transformedTileSize = ctxt->getCTM().mapRect(FloatRect(FloatPoint(), scaledTileSize));
     float transformedTileSizePixels = transformedTileSize.width() * transformedTileSize.height();
     if (transformedTileSizePixels > maxPatternTilePixels) {
         float fromY = (destRect.y() - oneTileRect.y()) / scale.height();
         float toY = oneTileRect.y();
-        while (toY < CGRectGetMaxY(destRect)) {
+        while (toY < destRect.maxY()) {
             float fromX = (destRect.x() - oneTileRect.x()) / scale.width();
             float toX = oneTileRect.x();
-            while (toX < CGRectGetMaxX(destRect)) {
-                CGRect toRect = CGRectIntersection(destRect, CGRectMake(toX, toY, oneTileRect.width(), oneTileRect.height()));
-                CGRect fromRect = CGRectMake(fromX, fromY, toRect.size.width / scale.width(), toRect.size.height / scale.height());
+            while (toX < destRect.maxX()) {
+                FloatRect toRect(toX, toY, oneTileRect.width(), oneTileRect.height());
+                FloatRect fromRect(fromX, fromY, oneTileRect.width() / scale.width(), oneTileRect.height() / scale.height());
                 draw(ctxt, toRect, fromRect, styleColorSpace, op, BlendModeNormal, ImageOrientationDescription());
                 toX += oneTileRect.width();
                 fromX = 0;
@@ -178,7 +183,6 @@
         }
         return;
     }
-#endif    
 
     AffineTransform patternTransform = AffineTransform().scaleNonUniform(scale.width(), scale.height());
     FloatRect tileRect(FloatPoint(), intrinsicTileSize);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to