Diff
Modified: branches/safari-602-branch/Source/WebCore/ChangeLog (203861 => 203862)
--- branches/safari-602-branch/Source/WebCore/ChangeLog 2016-07-29 07:11:10 UTC (rev 203861)
+++ branches/safari-602-branch/Source/WebCore/ChangeLog 2016-07-29 07:11:14 UTC (rev 203862)
@@ -1,5 +1,30 @@
2016-07-28 Babak Shafiei <bshaf...@apple.com>
+ Merge r203631. rdar://problem/24606557
+
+ 2016-07-22 Zalan Bujtas <za...@apple.com>
+
+ Handle cases when IOSurface initialization fails.
+ https://bugs.webkit.org/show_bug.cgi?id=160006
+ <rdar://problem/27495102>
+
+ Reviewed by Tim Horton and Simon Fraser.
+
+ This is an additional fix to r203514 to check if IOSurface initialization was successful.
+
+ Unable to test.
+
+ * platform/graphics/cg/ImageBufferCG.cpp:
+ (WebCore::ImageBuffer::ImageBuffer):
+ * platform/graphics/cocoa/IOSurface.h: Merge 2 c'tors.
+ * platform/graphics/cocoa/IOSurface.mm: Remove redundant IOSurface::create() code.
+ (WebCore::IOSurface::create):
+ (WebCore::IOSurface::createFromImage):
+ (WebCore::IOSurface::IOSurface):
+ (WebCore::IOSurface::convertToFormat):
+
+2016-07-28 Babak Shafiei <bshaf...@apple.com>
+
Merge r203629. rdar://problem/27438936
2016-07-22 Wenson Hsieh <wenson_hs...@apple.com>
Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (203861 => 203862)
--- branches/safari-602-branch/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp 2016-07-29 07:11:10 UTC (rev 203861)
+++ branches/safari-602-branch/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp 2016-07-29 07:11:14 UTC (rev 203862)
@@ -154,13 +154,14 @@
#if USE(IOSURFACE_CANVAS_BACKING_STORE)
FloatSize userBounds = sizeForDestinationSize(FloatSize(width.unsafeGet(), height.unsafeGet()));
m_data.surface = IOSurface::create(m_data.backingStoreSize, IntSize(userBounds), colorSpace);
- cgContext = m_data.surface->ensurePlatformContext();
- if (cgContext)
- CGContextClearRect(cgContext.get(), FloatRect(FloatPoint(), userBounds));
- else
- m_data.surface = nullptr;
+ if (m_data.surface) {
+ cgContext = m_data.surface->ensurePlatformContext();
+ if (cgContext)
+ CGContextClearRect(cgContext.get(), FloatRect(FloatPoint(), userBounds));
+ else
+ m_data.surface = nullptr;
+ }
#endif
-
if (!cgContext)
accelerateRendering = false; // If allocation fails, fall back to non-accelerated path.
}
Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/cocoa/IOSurface.h (203861 => 203862)
--- branches/safari-602-branch/Source/WebCore/platform/graphics/cocoa/IOSurface.h 2016-07-29 07:11:10 UTC (rev 203861)
+++ branches/safari-602-branch/Source/WebCore/platform/graphics/cocoa/IOSurface.h 2016-07-29 07:11:14 UTC (rev 203862)
@@ -100,8 +100,7 @@
#endif
private:
- IOSurface(IntSize, CGColorSpaceRef, Format);
- IOSurface(IntSize, IntSize contextSize, CGColorSpaceRef, Format);
+ IOSurface(IntSize, IntSize contextSize, CGColorSpaceRef, Format, bool& success);
IOSurface(IOSurfaceRef, CGColorSpaceRef);
static std::unique_ptr<IOSurface> surfaceFromPool(IntSize, IntSize contextSize, CGColorSpaceRef, Format);
Modified: branches/safari-602-branch/Source/WebCore/platform/graphics/cocoa/IOSurface.mm (203861 => 203862)
--- branches/safari-602-branch/Source/WebCore/platform/graphics/cocoa/IOSurface.mm 2016-07-29 07:11:10 UTC (rev 203861)
+++ branches/safari-602-branch/Source/WebCore/platform/graphics/cocoa/IOSurface.mm 2016-07-29 07:11:14 UTC (rev 203862)
@@ -57,10 +57,7 @@
std::unique_ptr<WebCore::IOSurface> WebCore::IOSurface::create(IntSize size, CGColorSpaceRef colorSpace, Format pixelFormat)
{
- if (auto cachedSurface = surfaceFromPool(size, size, colorSpace, pixelFormat))
- return cachedSurface;
-
- return std::unique_ptr<IOSurface>(new IOSurface(size, colorSpace, pixelFormat));
+ return IOSurface::create(size, size, colorSpace, pixelFormat);
}
std::unique_ptr<WebCore::IOSurface> WebCore::IOSurface::create(IntSize size, IntSize contextSize, CGColorSpaceRef colorSpace, Format pixelFormat)
@@ -67,7 +64,11 @@
{
if (auto cachedSurface = surfaceFromPool(size, contextSize, colorSpace, pixelFormat))
return cachedSurface;
- return std::unique_ptr<IOSurface>(new IOSurface(size, contextSize, colorSpace, pixelFormat));
+ bool success = false;
+ auto surface = std::unique_ptr<IOSurface>(new IOSurface(size, contextSize, colorSpace, pixelFormat, success));
+ if (!success)
+ return nullptr;
+ return surface;
}
std::unique_ptr<WebCore::IOSurface> WebCore::IOSurface::createFromSendRight(const MachSendRight& sendRight, CGColorSpaceRef colorSpace)
@@ -90,10 +91,11 @@
size_t height = CGImageGetHeight(image);
auto surface = IOSurface::create(IntSize(width, height), sRGBColorSpaceRef());
+ if (!surface)
+ return nullptr;
auto surfaceContext = surface->ensurePlatformContext();
CGContextDrawImage(surfaceContext, CGRectMake(0, 0, width, height), image);
CGContextFlush(surfaceContext);
-
return surface;
}
@@ -179,11 +181,15 @@
}
-WebCore::IOSurface::IOSurface(IntSize size, CGColorSpaceRef colorSpace, Format format)
+WebCore::IOSurface::IOSurface(IntSize size, IntSize contextSize, CGColorSpaceRef colorSpace, Format format, bool& success)
: m_colorSpace(colorSpace)
, m_size(size)
- , m_contextSize(size)
+ , m_contextSize(contextSize)
{
+ ASSERT(!success);
+ ASSERT(contextSize.width() <= size.width());
+ ASSERT(contextSize.height() <= size.height());
+
NSDictionary *options;
switch (format) {
@@ -200,21 +206,14 @@
options = optionsForBiplanarSurface(size, '422f', 1, 1);
break;
}
-
m_surface = adoptCF(IOSurfaceCreate((CFDictionaryRef)options));
- m_totalBytes = IOSurfaceGetAllocSize(m_surface.get());
- if (!m_surface)
- NSLog(@"Surface creation failed for options %@", options);
+ success = !!m_surface;
+ if (success)
+ m_totalBytes = IOSurfaceGetAllocSize(m_surface.get());
+ else
+ LOG_ALWAYS_ERROR(true, "Surface creation failed for size: (%d %d) and format: (%d)", size.width(), size.height(), format);
}
-WebCore::IOSurface::IOSurface(IntSize size, IntSize contextSize, CGColorSpaceRef colorSpace, Format pixelFormat)
- : IOSurface(size, colorSpace, pixelFormat)
-{
- ASSERT(contextSize.width() <= size.width());
- ASSERT(contextSize.height() <= size.height());
- m_contextSize = contextSize;
-}
-
WebCore::IOSurface::IOSurface(IOSurfaceRef surface, CGColorSpaceRef colorSpace)
: m_colorSpace(colorSpace)
, m_surface(surface)
@@ -396,8 +395,12 @@
}
auto destinationSurface = IOSurface::create(inSurface->size(), inSurface->colorSpace(), format);
+ if (!destinationSurface) {
+ callback(nullptr);
+ return;
+ }
+
IOSurfaceRef destinationIOSurfaceRef = destinationSurface->surface();
-
IOSurfaceAcceleratorCompletion completion;
completion.completionRefCon = new std::function<void(std::unique_ptr<WebCore::IOSurface>)> (WTFMove(callback));
completion.completionRefCon2 = destinationSurface.release();
Modified: branches/safari-602-branch/Source/WebKit2/ChangeLog (203861 => 203862)
--- branches/safari-602-branch/Source/WebKit2/ChangeLog 2016-07-29 07:11:10 UTC (rev 203861)
+++ branches/safari-602-branch/Source/WebKit2/ChangeLog 2016-07-29 07:11:14 UTC (rev 203862)
@@ -1,5 +1,29 @@
2016-07-28 Babak Shafiei <bshaf...@apple.com>
+ Merge r203631. rdar://problem/24606557
+
+ 2016-07-22 Zalan Bujtas <za...@apple.com>
+
+ Handle cases when IOSurface initialization fails.
+ https://bugs.webkit.org/show_bug.cgi?id=160006
+ <rdar://problem/27495102>
+
+ Reviewed by Tim Horton and Simon Fraser.
+
+ This is an additional fix to r203514 to check if IOSurface initialization was successful.
+
+ Unable to test.
+
+ * Shared/mac/RemoteLayerBackingStore.mm:
+ (WebKit::RemoteLayerBackingStore::encode):
+ (WebKit::RemoteLayerBackingStore::display):
+ (WebKit::RemoteLayerBackingStore::applyBackingStoreToLayer):
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _takeViewSnapshot]):
+ (-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]):
+
+2016-07-28 Babak Shafiei <bshaf...@apple.com>
+
Merge r203630. rdar://problem/27504958
2016-07-22 Chelsea Pugh <cp...@apple.com>
Modified: branches/safari-602-branch/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm (203861 => 203862)
--- branches/safari-602-branch/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm 2016-07-29 07:11:10 UTC (rev 203861)
+++ branches/safari-602-branch/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm 2016-07-29 07:11:14 UTC (rev 203862)
@@ -119,7 +119,10 @@
#if USE(IOSURFACE)
if (m_acceleratesDrawing) {
- encoder << m_frontBuffer.surface->createSendRight();
+ if (m_frontBuffer.surface)
+ encoder << m_frontBuffer.surface->createSendRight();
+ else
+ encoder << WebCore::MachSendRight();
return;
}
#endif
@@ -262,13 +265,15 @@
if (m_backBuffer.surface && !willPaintEntireBackingStore)
backImage = m_backBuffer.surface->createImage();
- GraphicsContext& context = m_frontBuffer.surface->ensureGraphicsContext();
+ if (m_frontBuffer.surface) {
+ GraphicsContext& context = m_frontBuffer.surface->ensureGraphicsContext();
- context.scale(FloatSize(1, -1));
- context.translate(0, -expandedScaledSize.height());
- drawInContext(context, backImage.get());
+ context.scale(FloatSize(1, -1));
+ context.translate(0, -expandedScaledSize.height());
+ drawInContext(context, backImage.get());
- m_frontBuffer.surface->releaseGraphicsContext();
+ m_frontBuffer.surface->releaseGraphicsContext();
+ }
} else
#endif
{
@@ -400,7 +405,7 @@
#if USE(IOSURFACE)
if (acceleratesDrawing()) {
- layer.contents = m_frontBuffer.surface->asLayerContents();
+ layer.contents = m_frontBuffer.surface ? m_frontBuffer.surface->asLayerContents() : nil;
return;
}
#endif
Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (203861 => 203862)
--- branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2016-07-29 07:11:10 UTC (rev 203861)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2016-07-29 07:11:14 UTC (rev 203862)
@@ -1388,6 +1388,8 @@
#if USE(IOSURFACE)
WebCore::IOSurface::Format snapshotFormat = WebCore::screenSupportsExtendedColor() ? WebCore::IOSurface::Format::RGB10 : WebCore::IOSurface::Format::RGBA;
auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(snapshotSize), WebCore::sRGBColorSpaceRef(), snapshotFormat);
+ if (!surface)
+ return nullptr;
CARenderServerRenderLayerWithTransform(MACH_PORT_NULL, self.layer.context.contextId, reinterpret_cast<uint64_t>(self.layer), surface->surface(), 0, 0, &transform);
WebCore::IOSurface::Format compressedFormat = WebCore::IOSurface::Format::YUV422;
@@ -1394,7 +1396,8 @@
if (WebCore::IOSurface::allowConversionFromFormatToFormat(snapshotFormat, compressedFormat)) {
RefPtr<WebKit::ViewSnapshot> viewSnapshot = WebKit::ViewSnapshot::create(nullptr);
WebCore::IOSurface::convertToFormat(WTFMove(surface), WebCore::IOSurface::Format::YUV422, [viewSnapshot](std::unique_ptr<WebCore::IOSurface> convertedSurface) {
- viewSnapshot->setSurface(WTFMove(convertedSurface));
+ if (convertedSurface)
+ viewSnapshot->setSurface(WTFMove(convertedSurface));
});
return viewSnapshot;
@@ -4235,6 +4238,10 @@
// If we are parented and thus won't incur a significant penalty from paging in tiles, snapshot the view hierarchy directly.
if (CADisplay *display = self.window.screen._display) {
auto surface = WebCore::IOSurface::create(WebCore::expandedIntSize(WebCore::FloatSize(imageSize)), WebCore::sRGBColorSpaceRef());
+ if (!surface) {
+ completionHandler(nullptr);
+ return;
+ }
CGFloat imageScaleInViewCoordinates = imageWidth / rectInViewCoordinates.size.width;
CATransform3D transform = CATransform3DMakeScale(imageScaleInViewCoordinates, imageScaleInViewCoordinates, 1);
transform = CATransform3DTranslate(transform, -rectInViewCoordinates.origin.x, -rectInViewCoordinates.origin.y, 0);