Title: [199130] trunk/Source
Revision
199130
Author
[email protected]
Date
2016-04-06 18:20:52 -0700 (Wed, 06 Apr 2016)

Log Message

Page tiles are missing when graphics acceleration is unavailable
https://bugs.webkit.org/show_bug.cgi?id=156325
Source/WebCore:

rdar://problem/25587476

Reviewed by Tim Horton.

When graphics acceleration is unavailable on Mac (e.g. in a VM or when running from
the recovery partition), page contents were missing. This is because
IOSurfaceGetPropertyMaximum(kIOSurfaceWidth) and IOSurfaceGetPropertyMaximum(kIOSurfaceHeight)
returned INT_MAX, causing us to compute a tile size of 0x0.

Fix by changing IOSurface::maximumSize() to report a value between 1K x 1K and 32K x 32K.

Rename kGiantTileSize to better describe its purpose.

Add correct clamping in IOSurface::maximumSize().

* platform/graphics/ca/TileController.cpp:
(WebCore::TileController::tileSize):
* platform/graphics/ca/TileController.h:
* platform/graphics/cocoa/IOSurface.mm:
(IOSurface::maximumSize):

Source/WTF:

Reviewed by Tim Horton.

Add clampToInteger(size_t).

* wtf/MathExtras.h:
(clampToInteger):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (199129 => 199130)


--- trunk/Source/WTF/ChangeLog	2016-04-07 01:11:47 UTC (rev 199129)
+++ trunk/Source/WTF/ChangeLog	2016-04-07 01:20:52 UTC (rev 199130)
@@ -1,3 +1,15 @@
+2016-04-06  Simon Fraser  <[email protected]>
+
+        Page tiles are missing when graphics acceleration is unavailable
+        https://bugs.webkit.org/show_bug.cgi?id=156325
+
+        Reviewed by Tim Horton.
+
+        Add clampToInteger(size_t).
+
+        * wtf/MathExtras.h:
+        (clampToInteger):
+
 2016-04-05  Simon Fraser  <[email protected]>
 
         Implement operator== and operator!= for Optional<>

Modified: trunk/Source/WTF/wtf/MathExtras.h (199129 => 199130)


--- trunk/Source/WTF/wtf/MathExtras.h	2016-04-07 01:11:47 UTC (rev 199129)
+++ trunk/Source/WTF/wtf/MathExtras.h	2016-04-07 01:20:52 UTC (rev 199130)
@@ -190,6 +190,15 @@
     return static_cast<int>(x);
 }
 
+inline int clampToInteger(size_t x)
+{
+    const size_t intMax = static_cast<size_t>(std::numeric_limits<int>::max());
+
+    if (x >= intMax)
+        return std::numeric_limits<int>::max();
+    return static_cast<int>(x);
+}
+
 inline bool isWithinIntRange(float x)
 {
     return x > static_cast<float>(std::numeric_limits<int>::min()) && x < static_cast<float>(std::numeric_limits<int>::max());

Modified: trunk/Source/WebCore/ChangeLog (199129 => 199130)


--- trunk/Source/WebCore/ChangeLog	2016-04-07 01:11:47 UTC (rev 199129)
+++ trunk/Source/WebCore/ChangeLog	2016-04-07 01:20:52 UTC (rev 199130)
@@ -1,3 +1,28 @@
+2016-04-06  Simon Fraser  <[email protected]>
+
+        Page tiles are missing when graphics acceleration is unavailable
+        https://bugs.webkit.org/show_bug.cgi?id=156325
+        rdar://problem/25587476
+
+        Reviewed by Tim Horton.
+
+        When graphics acceleration is unavailable on Mac (e.g. in a VM or when running from
+        the recovery partition), page contents were missing. This is because
+        IOSurfaceGetPropertyMaximum(kIOSurfaceWidth) and IOSurfaceGetPropertyMaximum(kIOSurfaceHeight)
+        returned INT_MAX, causing us to compute a tile size of 0x0.
+
+        Fix by changing IOSurface::maximumSize() to report a value between 1K x 1K and 32K x 32K.
+
+        Rename kGiantTileSize to better describe its purpose.
+
+        Add correct clamping in IOSurface::maximumSize().
+
+        * platform/graphics/ca/TileController.cpp:
+        (WebCore::TileController::tileSize):
+        * platform/graphics/ca/TileController.h:
+        * platform/graphics/cocoa/IOSurface.mm:
+        (IOSurface::maximumSize):
+
 2016-03-29  Keith Miller  <[email protected]>
 
         [ES6] Add support for Symbol.isConcatSpreadable.

Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.cpp (199129 => 199130)


--- trunk/Source/WebCore/platform/graphics/ca/TileController.cpp	2016-04-07 01:11:47 UTC (rev 199129)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.cpp	2016-04-07 01:20:52 UTC (rev 199130)
@@ -493,7 +493,9 @@
     if (m_inLiveResize || m_tileSizeLocked)
         return tileGrid().tileSize();
 
-    IntSize maxTileSize(kGiantTileSize, kGiantTileSize);
+    const int kLowestCommonDenominatorMaxTileSize = 4 * 1024;
+    IntSize maxTileSize(kLowestCommonDenominatorMaxTileSize, kLowestCommonDenominatorMaxTileSize);
+
 #if USE(IOSURFACE)
     IntSize surfaceSizeLimit = IOSurface::maximumSize();
     surfaceSizeLimit.scale(1 / m_deviceScaleFactor);

Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.h (199129 => 199130)


--- trunk/Source/WebCore/platform/graphics/ca/TileController.h	2016-04-07 01:11:47 UTC (rev 199129)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.h	2016-04-07 01:20:52 UTC (rev 199130)
@@ -49,9 +49,6 @@
 typedef Vector<RetainPtr<PlatformLayer>> PlatformLayerList;
 
 const int kDefaultTileSize = 512;
-// This is an experimental value for debugging and evaluating the overhead which may be
-// incurred due to a large tile size.
-const int kGiantTileSize = 4096;
 
 class TileController final : public TiledBacking {
     WTF_MAKE_NONCOPYABLE(TileController); WTF_MAKE_FAST_ALLOCATED;

Modified: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm (199129 => 199130)


--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm	2016-04-07 01:11:47 UTC (rev 199129)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm	2016-04-07 01:20:52 UTC (rev 199130)
@@ -36,6 +36,7 @@
 #import "ImageBufferDataCG.h"
 #import "MachSendRight.h"
 #import <wtf/Assertions.h>
+#import <wtf/MathExtras.h>
 
 #if PLATFORM(IOS)
 // Move this into the SPI header once it's possible to put inside the APPLE_INTERNAL_SDK block.
@@ -239,13 +240,20 @@
 
 IntSize IOSurface::maximumSize()
 {
-    IntSize maxSize(IOSurfaceGetPropertyMaximum(kIOSurfaceWidth), IOSurfaceGetPropertyMaximum(kIOSurfaceHeight));
+    IntSize maxSize(clampToInteger(IOSurfaceGetPropertyMaximum(kIOSurfaceWidth)), clampToInteger(IOSurfaceGetPropertyMaximum(kIOSurfaceHeight)));
+
+    // Protect against maxSize being { 0, 0 }.
+    const int iOSMaxSurfaceDimensionLowerBound = 1024;
+
 #if PLATFORM(IOS)
-    // Match limits imposed by CA. FIXME: should have API for this <rdar://problem/25454148>
+    // Match limits imposed by Core Animation. FIXME: should have API for this <rdar://problem/25454148>
     const int iOSMaxSurfaceDimension = 8 * 1024;
-    maxSize = maxSize.shrunkTo({ iOSMaxSurfaceDimension, iOSMaxSurfaceDimension });
+#else
+    // IOSurface::maximumSize() can return { INT_MAX, INT_MAX } when hardware acceleration is unavailable.
+    const int iOSMaxSurfaceDimension = 32 * 1024;
 #endif
-    return maxSize;
+
+    return maxSize.constrainedBetween({ iOSMaxSurfaceDimensionLowerBound, iOSMaxSurfaceDimensionLowerBound }, { iOSMaxSurfaceDimension, iOSMaxSurfaceDimension });
 }
 
 MachSendRight IOSurface::createSendRight() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to