From eed0cc015ca487bae5767cf108fa7ec7faf11a52 Mon Sep 17 00:00:00 2001 From: "simon.fraser@apple.com" Date: Thu, 31 Mar 2016 02:07:47 +0000 Subject: [PATCH] [iOS WK2] Avoid creating tiles that are too large for rendering https://bugs.webkit.org/show_bug.cgi?id=156050 rdar://problem/25424541 Reviewed by Darin Adler. In the case of a WKWebView which is sized large enough to show an entire document (for example, when enclosed inside a UIScrollView), we would create tiles that were larger than CoreAnimation was willing to deal with. * platform/graphics/ca/TileController.cpp: (WebCore::TileController::tileSize): Take the device scale, and the max IOSurface size into account when computing the max tile size. * platform/graphics/cocoa/IOSurface.mm: (IOSurface::maximumSize): CoreAnimation imposes limits in addition to the size reported by IOSurfaceGetPropertyMaximum(), namely an 8k cap, so mimic that here. (IOSurface::ensurePlatformContext): Typo. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@198875 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 20 +++++++++++++++++++ .../platform/graphics/ca/TileController.cpp | 17 +++++++++++++--- .../platform/graphics/cocoa/IOSurface.mm | 10 ++++++++-- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 80deae047195..39eeead11591 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,23 @@ +2016-03-30 Simon Fraser + + [iOS WK2] Avoid creating tiles that are too large for rendering + https://bugs.webkit.org/show_bug.cgi?id=156050 + rdar://problem/25424541 + + Reviewed by Darin Adler. + + In the case of a WKWebView which is sized large enough to show an entire document + (for example, when enclosed inside a UIScrollView), we would create tiles that were + larger than CoreAnimation was willing to deal with. + + * platform/graphics/ca/TileController.cpp: + (WebCore::TileController::tileSize): Take the device scale, and the max IOSurface size + into account when computing the max tile size. + * platform/graphics/cocoa/IOSurface.mm: + (IOSurface::maximumSize): CoreAnimation imposes limits in addition to the size reported + by IOSurfaceGetPropertyMaximum(), namely an 8k cap, so mimic that here. + (IOSurface::ensurePlatformContext): Typo. + 2016-03-30 Gyuyoung Kim [EFL][CMake] WebKit include path has been added to system include path diff --git a/Source/WebCore/platform/graphics/ca/TileController.cpp b/Source/WebCore/platform/graphics/ca/TileController.cpp index 99b5b620f19c..4df6efbe401c 100644 --- a/Source/WebCore/platform/graphics/ca/TileController.cpp +++ b/Source/WebCore/platform/graphics/ca/TileController.cpp @@ -36,6 +36,10 @@ #include #include +#if USE(IOSURFACE) +#include "IOSurface.h" +#endif + #if PLATFORM(IOS) #include "MemoryPressureHandler.h" #include "TileControllerMemoryHandlerIOS.h" @@ -489,16 +493,23 @@ IntSize TileController::tileSize() const if (m_inLiveResize || m_tileSizeLocked) return tileGrid().tileSize(); + IntSize maxTileSize(kGiantTileSize, kGiantTileSize); +#if USE(IOSURFACE) + IntSize surfaceSizeLimit = IOSurface::maximumSize(); + surfaceSizeLimit.scale(1 / m_deviceScaleFactor); + maxTileSize = maxTileSize.shrunkTo(surfaceSizeLimit); +#endif + if (owningGraphicsLayer()->platformCALayerUseGiantTiles()) - return IntSize(kGiantTileSize, kGiantTileSize); + return maxTileSize; IntSize tileSize(kDefaultTileSize, kDefaultTileSize); if (m_scrollability == NotScrollable) { IntSize scaledSize = expandedIntSize(boundsWithoutMargin().size() * tileGrid().scale()); - tileSize = scaledSize.constrainedBetween(IntSize(kDefaultTileSize, kDefaultTileSize), IntSize(kGiantTileSize, kGiantTileSize)); + tileSize = scaledSize.constrainedBetween(IntSize(kDefaultTileSize, kDefaultTileSize), maxTileSize); } else if (m_scrollability == VerticallyScrollable) - tileSize.setWidth(std::min(std::max(ceilf(boundsWithoutMargin().width() * tileGrid().scale()), kDefaultTileSize), kGiantTileSize)); + tileSize.setWidth(std::min(std::max(ceilf(boundsWithoutMargin().width() * tileGrid().scale()), kDefaultTileSize), maxTileSize.width())); LOG_WITH_STREAM(Scrolling, stream << "TileController::tileSize newSize=" << tileSize); diff --git a/Source/WebCore/platform/graphics/cocoa/IOSurface.mm b/Source/WebCore/platform/graphics/cocoa/IOSurface.mm index 9fa6f2309395..d6d9780d505d 100644 --- a/Source/WebCore/platform/graphics/cocoa/IOSurface.mm +++ b/Source/WebCore/platform/graphics/cocoa/IOSurface.mm @@ -239,7 +239,13 @@ IOSurface::IOSurface(IOSurfaceRef surface, ColorSpace colorSpace) IntSize IOSurface::maximumSize() { - return IntSize(IOSurfaceGetPropertyMaximum(kIOSurfaceWidth), IOSurfaceGetPropertyMaximum(kIOSurfaceHeight)); + IntSize maxSize(IOSurfaceGetPropertyMaximum(kIOSurfaceWidth), IOSurfaceGetPropertyMaximum(kIOSurfaceHeight)); +#if PLATFORM(IOS) + // Match limits imposed by CA. FIXME: should have API for this + const int iOSMaxSurfaceDimension = 8 * 1024; + maxSize = maxSize.shrunkTo({ iOSMaxSurfaceDimension, iOSMaxSurfaceDimension }); +#endif + return maxSize; } MachSendRight IOSurface::createSendRight() const @@ -288,7 +294,7 @@ CGContextRef IOSurface::ensurePlatformContext() case Format::RGB10: case Format::RGB10A8: // A half-float format will be used if CG needs to read back the IOSurface contents, - // but for an IOSurface-to-IOSurface copy, there shoud be no conversion. + // but for an IOSurface-to-IOSurface copy, there should be no conversion. bitsPerComponent = 16; bitsPerPixel = 64; bitmapInfo = kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder16Host | kCGBitmapFloatComponents; -- 2.36.0