Introduce HAVE(IOSURFACE_ACCELERATOR)
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Feb 2018 01:32:26 +0000 (01:32 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Feb 2018 01:32:26 +0000 (01:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182955
<rdar://problem/37699510>

Reviewed by Sam Weinig.

Source/WebCore:

No new tests, no change in behavior.

Introduce HAVE(IOSURFACE_ACCELERATOR) and guard all uses of
IOSurfaceAccelerator behind it.

Rename USE(IOSURFACE) to HAVE(IOSURFACE) for accuracy.

* page/cocoa/MemoryReleaseCocoa.mm:
* platform/graphics/ca/TileController.cpp:
* platform/graphics/cg/IOSurfacePool.cpp:
* platform/graphics/cg/IOSurfacePool.h:
* platform/graphics/cg/ImageBufferCG.cpp:
* platform/graphics/cocoa/IOSurface.h:
* platform/graphics/cocoa/IOSurface.mm:
* platform/graphics/cocoa/IOSurfacePoolCocoa.mm:
* platform/graphics/cv/VideoTextureCopierCV.cpp:
* platform/graphics/cv/VideoTextureCopierCV.h:

Source/WebCore/PAL:

* pal/spi/cg/CoreGraphicsSPI.h:
* pal/spi/cocoa/IOSurfaceSPI.h:
* pal/spi/cocoa/QuartzCoreSPI.h:

Source/WebKit:

* Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
* Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
* Shared/cg/ShareableBitmapCG.cpp:
* UIProcess/API/Cocoa/WKWebView.mm:
* UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
* UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
* UIProcess/mac/ViewSnapshotStore.h:
* UIProcess/mac/ViewSnapshotStore.mm:

Source/WTF:

* wtf/Platform.h:

Tools:

* DumpRenderTree/ios/PixelDumpSupportIOS.mm:
(createBitmapContextFromWebView):
* WebKitTestRunner/ios/PlatformWebViewIOS.mm:
(WTR::PlatformWebView::windowSnapshotImage):

WebKitLibraries:

* WebKitPrivateFrameworkStubs/iOS/10/IOSurface.framework/IOSurface.tbd:
* WebKitPrivateFrameworkStubs/iOS/10/IOSurfaceAccelerator.framework/IOSurfaceAccelerator.tbd: Added.
* WebKitPrivateFrameworkStubs/iOS/11/IOSurfaceAccelerator.framework/IOSurfaceAccelerator.tbd: Added.
Switch IOSurfaceAccelerator symbols over to the still-private IOSurfaceAccelerator framework.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228853 268f45cc-cd09-0410-ab3c-d52691b4dbfc

34 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/Configurations/WebCore.xcconfig
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h
Source/WebCore/PAL/pal/spi/cocoa/IOSurfaceSPI.h
Source/WebCore/PAL/pal/spi/cocoa/QuartzCoreSPI.h
Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm
Source/WebCore/platform/graphics/ca/TileController.cpp
Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp
Source/WebCore/platform/graphics/cg/IOSurfacePool.h
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
Source/WebCore/platform/graphics/cocoa/IOSurface.h
Source/WebCore/platform/graphics/cocoa/IOSurface.mm
Source/WebCore/platform/graphics/cocoa/IOSurfacePoolCocoa.mm
Source/WebCore/platform/graphics/cv/VideoTextureCopierCV.cpp
Source/WebCore/platform/graphics/cv/VideoTextureCopierCV.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.mm
Source/WebKit/Shared/cg/ShareableBitmapCG.cpp
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm
Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm
Source/WebKit/UIProcess/mac/ViewSnapshotStore.h
Source/WebKit/UIProcess/mac/ViewSnapshotStore.mm
Tools/ChangeLog
Tools/DumpRenderTree/ios/PixelDumpSupportIOS.mm
Tools/WebKitTestRunner/ios/PlatformWebViewIOS.mm
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/10/IOSurface.framework/IOSurface.tbd
WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/10/IOSurfaceAccelerator.framework/IOSurfaceAccelerator.tbd [new file with mode: 0644]
WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/11/IOSurfaceAccelerator.framework/IOSurfaceAccelerator.tbd [new file with mode: 0644]

index 5dfdf25..236fe1a 100644 (file)
@@ -1,3 +1,13 @@
+2018-02-20  Tim Horton  <timothy_horton@apple.com>
+
+        Introduce HAVE(IOSURFACE_ACCELERATOR)
+        https://bugs.webkit.org/show_bug.cgi?id=182955
+        <rdar://problem/37699510>
+
+        Reviewed by Sam Weinig.
+
+        * wtf/Platform.h:
+
 2018-02-20  Chris Dumez  <cdumez@apple.com>
 
         Provisional load may get committed before receiving the decidePolicyForNavigationResponse response
index ea79a15..c02b66d 100644 (file)
 #endif
 
 #if PLATFORM(COCOA) && !PLATFORM(IOS_SIMULATOR)
-#define USE_IOSURFACE 1
+#define HAVE_IOSURFACE 1
+#endif
+
+#if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR)
+#define HAVE_IOSURFACE_ACCELERATOR 1
 #endif
 
 #if PLATFORM(COCOA)
index f437c75..6b52ffc 100644 (file)
@@ -1,3 +1,29 @@
+2018-02-20  Tim Horton  <timothy_horton@apple.com>
+
+        Introduce HAVE(IOSURFACE_ACCELERATOR)
+        https://bugs.webkit.org/show_bug.cgi?id=182955
+        <rdar://problem/37699510>
+
+        Reviewed by Sam Weinig.
+
+        No new tests, no change in behavior.
+
+        Introduce HAVE(IOSURFACE_ACCELERATOR) and guard all uses of
+        IOSurfaceAccelerator behind it.
+
+        Rename USE(IOSURFACE) to HAVE(IOSURFACE) for accuracy.
+
+        * page/cocoa/MemoryReleaseCocoa.mm:
+        * platform/graphics/ca/TileController.cpp:
+        * platform/graphics/cg/IOSurfacePool.cpp:
+        * platform/graphics/cg/IOSurfacePool.h:
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        * platform/graphics/cocoa/IOSurface.h:
+        * platform/graphics/cocoa/IOSurface.mm:
+        * platform/graphics/cocoa/IOSurfacePoolCocoa.mm:
+        * platform/graphics/cv/VideoTextureCopierCV.cpp:
+        * platform/graphics/cv/VideoTextureCopierCV.h:
+
 2018-02-20  Chris Dumez  <cdumez@apple.com>
 
         Provisional load may get committed before receiving the decidePolicyForNavigationResponse response
index bdee7e4..7491e43 100644 (file)
@@ -80,7 +80,7 @@ OTHER_LDFLAGS = $(inherited) $(WK_RELOCATABLE_FRAMEWORK_LDFLAGS) $(WK_UNDEFINED_
 OTHER_LDFLAGS_BASE = -lsqlite3 -lobjc -lANGLE -framework CoreAudio -framework Metal -allowable_client WebCoreTestSupport -allowable_client WebKitLegacy -force_load $(BUILT_PRODUCTS_DIR)/libPAL.a;
 // FIXME: Reduce the number of allowable_client <rdar://problem/31823969>
 OTHER_LDFLAGS_BASE_ios = $(OTHER_LDFLAGS_BASE) -framework CFNetwork -framework CoreGraphics -framework CoreText -framework Foundation -framework ImageIO -framework MobileCoreServices -framework OpenGLES -lMobileGestalt $(WK_IOS_BINCOMPAT_LDFLAGS) -allowable_client WebKit -allowable_client iTunesU -allowable_client Casablanca -allowable_client Remote -allowable_client TVBooks -allowable_client DumpRenderTree -allowable_client WebKitTestRunner -allowable_client TestWebKitAPI;
-OTHER_LDFLAGS_PLATFORM[sdk=iphoneos*] = $(OTHER_LDFLAGS_BASE_ios) -framework IOSurface -framework GraphicsServices $(LIBWEBRTC_LDFLAGS);
+OTHER_LDFLAGS_PLATFORM[sdk=iphoneos*] = $(OTHER_LDFLAGS_BASE_ios) -framework IOSurface -framework IOSurfaceAccelerator -framework GraphicsServices $(LIBWEBRTC_LDFLAGS);
 OTHER_LDFLAGS_PLATFORM[sdk=iphonesimulator*] = $(OTHER_LDFLAGS_BASE_ios) $(LIBWEBRTC_LDFLAGS);
 OTHER_LDFLAGS_PLATFORM[sdk=macosx*] = $(OTHER_LDFLAGS_BASE) -sub_library libobjc -umbrella WebKit -framework ApplicationServices -framework AudioUnit -framework Carbon -framework Cocoa -framework DataDetectorsCore -framework IOSurface -framework OpenGL -framework SystemConfiguration $(LIBWEBRTC_LDFLAGS);
 
index 9dd46eb..b30476f 100644 (file)
@@ -1,3 +1,15 @@
+2018-02-20  Tim Horton  <timothy_horton@apple.com>
+
+        Introduce HAVE(IOSURFACE_ACCELERATOR)
+        https://bugs.webkit.org/show_bug.cgi?id=182955
+        <rdar://problem/37699510>
+
+        Reviewed by Sam Weinig.
+
+        * pal/spi/cg/CoreGraphicsSPI.h:
+        * pal/spi/cocoa/IOSurfaceSPI.h:
+        * pal/spi/cocoa/QuartzCoreSPI.h:
+
 2018-02-15  Tim Horton  <timothy_horton@apple.com>
 
         Stop using EXCLUDED_SOURCE_FILE_NAMES for actual source files in WebCore
index 847f459..769bc39 100644 (file)
@@ -28,7 +28,7 @@
 #include <CoreFoundation/CoreFoundation.h>
 #include <CoreGraphics/CoreGraphics.h>
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 #include <pal/spi/cocoa/IOSurfaceSPI.h>
 #endif
 
@@ -249,7 +249,7 @@ bool CGContextGetAllowsFontSubpixelPositioning(CGContextRef);
 bool CGContextDrawsWithCorrectShadowOffsets(CGContextRef);
 CGPatternRef CGPatternCreateWithImage2(CGImageRef, CGAffineTransform, CGPatternTiling);
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 CGContextRef CGIOSurfaceContextCreate(IOSurfaceRef, size_t, size_t, size_t, size_t, CGColorSpaceRef, CGBitmapInfo);
 CGImageRef CGIOSurfaceContextCreateImage(CGContextRef);
 CGImageRef CGIOSurfaceContextCreateImageReference(CGContextRef);
index e72f4d2..82a3d62 100644 (file)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#if !PLATFORM(IOS_SIMULATOR)
+#if HAVE(IOSURFACE)
 
 #if PLATFORM(MAC) || USE(APPLE_INTERNAL_SDK)
 
@@ -113,7 +113,7 @@ IOReturn IOSurfaceSetPurgeable(IOSurfaceRef buffer, uint32_t newState, uint32_t
 
 WTF_EXTERN_C_END
 
-#if PLATFORM(IOS)
+#if HAVE(IOSURFACE_ACCELERATOR)
 #if USE(APPLE_INTERNAL_SDK)
 
 #import <IOSurfaceAccelerator/IOSurfaceAccelerator.h>
@@ -128,6 +128,8 @@ typedef struct __IOSurfaceAccelerator *IOSurfaceAcceleratorRef;
 
 WTF_EXTERN_C_BEGIN
 
+extern const CFStringRef kIOSurfaceAcceleratorUnwireSurfaceKey;
+
 IOReturn IOSurfaceAcceleratorCreate(CFAllocatorRef, CFDictionaryRef properties, IOSurfaceAcceleratorRef* acceleratorOut);
 CFRunLoopSourceRef IOSurfaceAcceleratorGetRunLoopSource(IOSurfaceAcceleratorRef);
 
@@ -144,6 +146,6 @@ IOReturn IOSurfaceAcceleratorTransformSurface(IOSurfaceAcceleratorRef, IOSurface
 WTF_EXTERN_C_END
 
 #endif // USE(APPLE_INTERNAL_SDK)
-#endif // PLATFORM(IOS)
+#endif // HAVE(IOSURFACE_ACCELERATOR)
 
-#endif // !PLATFORM(IOS_SIMULATOR)
+#endif // HAVE(IOSURFACE)
index ff96c0b..971d0bc 100644 (file)
@@ -170,7 +170,7 @@ WTF_EXTERN_C_BEGIN
 #if !USE(APPLE_INTERNAL_SDK)
 void CARenderServerCaptureLayerWithTransform(mach_port_t, uint32_t clientId, uint64_t layerId, uint32_t slotId, int32_t ox, int32_t oy, const CATransform3D*);
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 void CARenderServerRenderLayerWithTransform(mach_port_t server_port, uint32_t client_id, uint64_t layer_id, IOSurfaceRef, int32_t ox, int32_t oy, const CATransform3D*);
 void CARenderServerRenderDisplayLayerWithTransformAndTimeOffset(mach_port_t, CFStringRef display_name, uint32_t client_id, uint64_t layer_id, IOSurfaceRef, int32_t ox, int32_t oy, const CATransform3D*, CFTimeInterval);
 #else
index b37b5cb..206eafa 100644 (file)
@@ -56,7 +56,7 @@ void platformReleaseMemory(Critical)
     tileControllerMemoryHandler().trimUnparentedTilesToTarget(0);
 #endif
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     IOSurfacePool::sharedPool().discardAllSurfaces();
 #endif
 }
index a3302a9..ec3ae4f 100644 (file)
@@ -38,7 +38,7 @@
 #include <wtf/MainThread.h>
 #include <wtf/text/TextStream.h>
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 #include "IOSurface.h"
 #endif
 
@@ -534,7 +534,7 @@ IntSize TileController::tileSize() const
     const int kLowestCommonDenominatorMaxTileSize = 4 * 1024;
     IntSize maxTileSize(kLowestCommonDenominatorMaxTileSize, kLowestCommonDenominatorMaxTileSize);
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     IntSize surfaceSizeLimit = IOSurface::maximumSize();
     surfaceSizeLimit.scale(1 / m_deviceScaleFactor);
     maxTileSize = maxTileSize.shrunkTo(surfaceSizeLimit);
index e3f073e..1b0e1b6 100644 (file)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "IOSurfacePool.h"
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 
 #include "GraphicsContextCG.h"
 #include <CoreGraphics/CoreGraphics.h>
@@ -383,4 +383,4 @@ void IOSurfacePool::showPoolStatistics(const char* reason)
 }
 
 }
-#endif // USE(IOSURFACE)
+#endif // HAVE(IOSURFACE)
index df4bec7..92b8db9 100644 (file)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 
 #include "IOSurface.h"
 #include "IntSize.h"
@@ -103,4 +103,4 @@ private:
 };
 
 }
-#endif // USE(IOSURFACE)
+#endif // HAVE(IOSURFACE)
index 824f9f7..f485a34 100644 (file)
@@ -79,7 +79,7 @@ std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const FloatSize
     case kCGContextTypeBitmap:
         colorSpace = CGBitmapContextGetColorSpace(cgContext);
         break;
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     case kCGContextTypeIOSurface:
         colorSpace = CGIOSurfaceContextGetColorSpace(cgContext);
         break;
index b57ae97..e2b4a18 100644 (file)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 
 #include <objc/objc.h>
 #include "GraphicsContext.h"
@@ -134,10 +134,10 @@ public:
     // an accurate result from isInUse(), it needs to be released.
     WEBCORE_EXPORT void releaseGraphicsContext();
 
-#if PLATFORM(IOS)
+#if HAVE(IOSURFACE_ACCELERATOR)
     WEBCORE_EXPORT static bool allowConversionFromFormatToFormat(Format, Format);
     WEBCORE_EXPORT static void convertToFormat(std::unique_ptr<WebCore::IOSurface>&& inSurface, Format, WTF::Function<void(std::unique_ptr<WebCore::IOSurface>)>&&);
-#endif
+#endif // HAVE(IOSURFACE_ACCELERATOR)
 
     void migrateColorSpaceToProperties();
 
@@ -164,5 +164,5 @@ WEBCORE_EXPORT WTF::TextStream& operator<<(WTF::TextStream&, const WebCore::IOSu
 
 } // namespace WebCore
 
-#endif // USE(IOSURFACE)
+#endif // HAVE(IOSURFACE)
 
index 542ae04..8c8adfe 100644 (file)
@@ -26,7 +26,7 @@
 #import "config.h"
 #import "IOSurface.h"
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 
 #import "GraphicsContextCG.h"
 #import "IOSurfacePool.h"
 #import <wtf/MathExtras.h>
 #import <wtf/text/TextStream.h>
 
-#if PLATFORM(IOS)
-// Move this into the SPI header once it's possible to put inside the APPLE_INTERNAL_SDK block.
-NSString * const WebIOSurfaceAcceleratorUnwireSurfaceKey = @"UnwireSurface";
-#endif
-
 namespace WebCore {
 
 inline std::unique_ptr<IOSurface> IOSurface::surfaceFromPool(IntSize size, IntSize contextSize, CGColorSpaceRef colorSpace, Format pixelFormat)
@@ -388,7 +383,8 @@ void IOSurface::releaseGraphicsContext()
     m_cgContext = nullptr;
 }
 
-#if PLATFORM(IOS)
+#if HAVE(IOSURFACE_ACCELERATOR)
+
 bool IOSurface::allowConversionFromFormatToFormat(Format sourceFormat, Format destFormat)
 {
     if ((sourceFormat == Format::RGB10 || sourceFormat == Format::RGB10A8) && destFormat == Format::YUV422)
@@ -430,12 +426,13 @@ void IOSurface::convertToFormat(std::unique_ptr<IOSurface>&& inSurface, Format f
         delete callback;
     };
 
-    NSDictionary *options = @{ WebIOSurfaceAcceleratorUnwireSurfaceKey : @YES };
+    NSDictionary *options = @{ (id)kIOSurfaceAcceleratorUnwireSurfaceKey : @YES };
 
     IOReturn ret = IOSurfaceAcceleratorTransformSurface(accelerator, inSurface->surface(), destinationIOSurfaceRef, (CFDictionaryRef)options, nullptr, &completion, nullptr, nullptr);
     ASSERT_UNUSED(ret, ret == kIOReturnSuccess);
 }
-#endif // PLATFORM(IOS)
+
+#endif // HAVE(IOSURFACE_ACCELERATOR)
 
 void IOSurface::migrateColorSpaceToProperties()
 {
@@ -482,4 +479,4 @@ TextStream& operator<<(TextStream& ts, const IOSurface& surface)
 
 } // namespace WebCore
 
-#endif // USE(IOSURFACE)
+#endif // HAVE(IOSURFACE)
index 4ad5d2e..fb13f1c 100644 (file)
@@ -26,7 +26,7 @@
 #import "config.h"
 #import "IOSurfacePool.h"
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 
 #include <QuartzCore/QuartzCore.h>
 
@@ -40,4 +40,4 @@ void IOSurfacePool::platformGarbageCollectNow()
 
 }
 
-#endif // USE(IOSURFACE)
+#endif // HAVE(IOSURFACE)
index 7b9cb64..3316b47 100644 (file)
@@ -41,7 +41,7 @@
 
 namespace WebCore {
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 enum class PixelRange {
     Unknown,
     Video,
@@ -368,7 +368,7 @@ static const Vector<GLfloat> YCbCrToRGBMatrixForRangeAndTransferFunction(PixelRa
     ASSERT(iterator != matrices.get().end());
     return iterator->second;
 }
-#endif // USE(IOSURFACE)
+#endif // HAVE(IOSURFACE)
 
 VideoTextureCopierCV::VideoTextureCopierCV(GraphicsContext3D& context)
     : m_sharedContext(context)
@@ -728,7 +728,7 @@ bool VideoTextureCopierCV::copyImageToPlatformTexture(CVPixelBufferRef image, si
         return copyVideoTextureToPlatformTexture(texture.get(), width, height, outputTexture, outputTarget, level, internalFormat, format, type, premultiplyAlpha, flipY, swapColorChannels);
     }
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     // FIXME: This currently only supports '420v' and '420f' pixel formats. Investigate supporting more pixel formats.
     OSType pixelFormat = CVPixelBufferGetPixelFormatType(image);
     if (pixelFormat != kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange && pixelFormat != kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) {
@@ -846,7 +846,7 @@ bool VideoTextureCopierCV::copyImageToPlatformTexture(CVPixelBufferRef image, si
     return true;
 #else
     return false;
-#endif // USE(IOSURFACE)
+#endif // HAVE(IOSURFACE)
 }
 
 bool VideoTextureCopierCV::copyVideoTextureToPlatformTexture(TextureType inputVideoTexture, size_t width, size_t height, Platform3DObject outputTexture, GC3Denum outputTarget, GC3Dint level, GC3Denum internalFormat, GC3Denum format, GC3Denum type, bool premultiplyAlpha, bool flipY, bool swapColorChannels)
index c3541aa..472f9f1 100644 (file)
@@ -60,7 +60,7 @@ private:
     bool initializeContextObjects();
     bool initializeUVContextObjects();
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     unsigned lastTextureSeed(GC3Duint texture)
     {
         auto iterator = m_lastTextureSeed.find(texture);
@@ -90,7 +90,7 @@ private:
     GC3Dint m_yTextureSizeUniformLocation { -1 };
     GC3Dint m_uvTextureSizeUniformLocation { -1 };
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     bool m_lastFlipY { false };
     UnsafePointer<IOSurfaceRef> m_lastSurface;
     uint32_t m_lastSurfaceSeed { 0 };
index 6aba890..77f3c61 100644 (file)
@@ -1,3 +1,20 @@
+2018-02-20  Tim Horton  <timothy_horton@apple.com>
+
+        Introduce HAVE(IOSURFACE_ACCELERATOR)
+        https://bugs.webkit.org/show_bug.cgi?id=182955
+        <rdar://problem/37699510>
+
+        Reviewed by Sam Weinig.
+
+        * Shared/RemoteLayerTree/RemoteLayerBackingStore.h:
+        * Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
+        * Shared/cg/ShareableBitmapCG.cpp:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
+        * UIProcess/mac/ViewSnapshotStore.h:
+        * UIProcess/mac/ViewSnapshotStore.mm:
+
 2018-02-20  Chris Dumez  <cdumez@apple.com>
 
         Provisional load may get committed before receiving the decidePolicyForNavigationResponse response
index 28a4980..885b06c 100644 (file)
@@ -75,7 +75,7 @@ public:
 
     bool hasFrontBuffer() const
     {
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
         if (m_acceleratesDrawing)
             return !!m_frontBuffer.surface;
 #endif
@@ -99,7 +99,7 @@ private:
     void clearBackingStore();
     void swapToValidFrontBuffer();
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     WebCore::IOSurface::Format surfaceBufferFormat() const;
 #endif
 
@@ -115,14 +115,14 @@ private:
 
     struct Buffer {
         RefPtr<ShareableBitmap> bitmap;
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
         std::unique_ptr<WebCore::IOSurface> surface;
         bool isVolatile = false;
 #endif
 
         explicit operator bool() const
         {
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
             if (surface)
                 return true;
 #endif
@@ -137,7 +137,7 @@ private:
 
     Buffer m_frontBuffer;
     Buffer m_backBuffer;
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     Buffer m_secondaryBackBuffer;
     WebCore::MachSendRight m_frontBufferSendRight;
 #endif
index 407f756..04ebcd6 100644 (file)
@@ -40,7 +40,7 @@
 #import <WebCore/WebLayer.h>
 #import <pal/spi/cocoa/QuartzCoreSPI.h>
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 #import <mach/mach_port.h>
 #endif
 
@@ -72,7 +72,7 @@ RemoteLayerBackingStore::~RemoteLayerBackingStore()
 
 void RemoteLayerBackingStore::ensureBackingStore(FloatSize size, float scale, bool acceleratesDrawing, bool deepColor, bool isOpaque)
 {
-#if !USE(IOSURFACE)
+#if !HAVE(IOSURFACE)
     acceleratesDrawing = false;
 #endif
     if (m_size == size && m_scale == scale && m_deepColor == deepColor && m_acceleratesDrawing == acceleratesDrawing && m_isOpaque == isOpaque)
@@ -97,7 +97,7 @@ void RemoteLayerBackingStore::clearBackingStore()
 {
     m_frontBuffer.discard();
     m_backBuffer.discard();
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     m_secondaryBackBuffer.discard();
 #endif
 }
@@ -109,7 +109,7 @@ void RemoteLayerBackingStore::encode(IPC::Encoder& encoder) const
     encoder << m_acceleratesDrawing;
     encoder << m_isOpaque;
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     if (m_acceleratesDrawing) {
         if (m_frontBuffer.surface)
             encoder << m_frontBuffer.surface->createSendRight();
@@ -140,7 +140,7 @@ bool RemoteLayerBackingStore::decode(IPC::Decoder& decoder, RemoteLayerBackingSt
     if (!decoder.decode(result.m_isOpaque))
         return false;
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     if (result.m_acceleratesDrawing) {
         MachSendRight sendRight;
         if (!decoder.decode(sendRight))
@@ -179,7 +179,7 @@ IntSize RemoteLayerBackingStore::backingStoreSize() const
 
 unsigned RemoteLayerBackingStore::bytesPerPixel() const
 {
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     switch (surfaceBufferFormat()) {
     case WebCore::IOSurface::Format::RGBA: return 4;
     case WebCore::IOSurface::Format::YUV422: return 2;
@@ -194,7 +194,7 @@ void RemoteLayerBackingStore::swapToValidFrontBuffer()
 {
     IntSize expandedScaledSize = backingStoreSize();
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     if (m_acceleratesDrawing) {
         if (!m_backBuffer.surface || m_backBuffer.surface->isInUse()) {
             std::swap(m_backBuffer, m_secondaryBackBuffer);
@@ -254,7 +254,7 @@ bool RemoteLayerBackingStore::display()
 
     swapToValidFrontBuffer();
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     if (m_acceleratesDrawing) {
         RetainPtr<CGImageRef> backImage;
         if (m_backBuffer.surface && !willPaintEntireBackingStore)
@@ -399,7 +399,7 @@ void RemoteLayerBackingStore::applyBackingStoreToLayer(CALayer *layer, LayerCont
 {
     layer.contentsOpaque = m_isOpaque;
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     if (acceleratesDrawing()) {
         switch (contentsType) {
         case LayerContentsType::IOSurface:
@@ -427,7 +427,7 @@ RetainPtr<CGContextRef> RemoteLayerBackingStore::takeFrontContextPendingFlush()
     return WTFMove(m_frontContextPendingFlush);
 }
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 bool RemoteLayerBackingStore::setBufferVolatility(BufferType type, bool isVolatile)
 {
     switch (type) {
@@ -480,7 +480,7 @@ bool RemoteLayerBackingStore::setBufferVolatility(BufferType, bool)
 
 void RemoteLayerBackingStore::Buffer::discard()
 {
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     if (surface)
         WebCore::IOSurface::moveToPool(WTFMove(surface));
     isVolatile = false;
@@ -488,7 +488,7 @@ void RemoteLayerBackingStore::Buffer::discard()
     bitmap = nullptr;
 }
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 WebCore::IOSurface::Format RemoteLayerBackingStore::surfaceBufferFormat() const
 {
     if (m_deepColor)
@@ -496,6 +496,6 @@ WebCore::IOSurface::Format RemoteLayerBackingStore::surfaceBufferFormat() const
 
     return WebCore::IOSurface::Format::RGBA;
 }
-#endif // USE(IOSURFACE)
+#endif // HAVE(IOSURFACE)
 
 } // namespace WebKit
index 3806217..41b2fea 100644 (file)
@@ -73,7 +73,7 @@ static CGBitmapInfo bitmapInfo(const ShareableBitmap::Configuration& configurati
 Checked<unsigned, RecordOverflow> ShareableBitmap::calculateBytesPerRow(WebCore::IntSize size, const Configuration& configuration)
 {
     unsigned bytesPerRow = calculateBytesPerPixel(configuration) * size.width();
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     return IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, bytesPerRow);
 #else
     return bytesPerRow;
index 20e4cf4..8c153db 100644 (file)
@@ -1871,13 +1871,14 @@ static inline bool areEssentiallyEqualAsFloat(float a, float b)
 
     CATransform3D transform = CATransform3DMakeScale(deviceScale, deviceScale, 1);
 
-#if USE(IOSURFACE)
+#if HAVE(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);
 
+#if HAVE(IOSURFACE_ACCELERATOR)
     WebCore::IOSurface::Format compressedFormat = WebCore::IOSurface::Format::YUV422;
     if (WebCore::IOSurface::allowConversionFromFormatToFormat(snapshotFormat, compressedFormat)) {
         RefPtr<WebKit::ViewSnapshot> viewSnapshot = WebKit::ViewSnapshot::create(nullptr);
@@ -1888,9 +1889,10 @@ static inline bool areEssentiallyEqualAsFloat(float a, float b)
 
         return viewSnapshot;
     }
+#endif // HAVE(IOSURFACE_ACCELERATOR)
 
     return WebKit::ViewSnapshot::create(WTFMove(surface));
-#else
+#else // HAVE(IOSURFACE)
     uint32_t slotID = [WebKit::ViewSnapshotStore::snapshottingContext() createImageSlot:snapshotSize hasAlpha:YES];
 
     if (!slotID)
@@ -1899,7 +1901,7 @@ static inline bool areEssentiallyEqualAsFloat(float a, float b)
     CARenderServerCaptureLayerWithTransform(MACH_PORT_NULL, self.layer.context.contextId, (uint64_t)self.layer, slotID, 0, 0, &transform);
     WebCore::IntSize imageSize = WebCore::expandedIntSize(WebCore::FloatSize(snapshotSize));
     return WebKit::ViewSnapshot::create(slotID, imageSize, (imageSize.area() * 4).unsafeGet());
-#endif
+#endif // HAVE(IOSURFACE)
 }
 
 - (void)_zoomToPoint:(WebCore::FloatPoint)point atScale:(double)scale animated:(BOOL)animated
@@ -5261,7 +5263,7 @@ static inline WebKit::FindOptions toFindOptions(_WKFindOptions wkFindOptions)
     CGFloat imageHeight = imageScale * snapshotRectInContentCoordinates.size.height;
     CGSize imageSize = CGSizeMake(imageWidth, imageHeight);
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     // If we are parented and thus won't incur a significant penalty from paging in tiles, snapshot the view hierarchy directly.
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
index e23c9ee..8093677 100644 (file)
@@ -110,7 +110,7 @@ RemoteLayerTreeDrawingAreaProxy::RemoteLayerTreeDrawingAreaProxy(WebPageProxy& w
     : DrawingAreaProxy(DrawingAreaTypeRemoteLayerTree, webPageProxy)
     , m_remoteLayerTreeHost(*this)
 {
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     // We don't want to pool surfaces in the UI process.
     // FIXME: We should do this somewhere else.
     IOSurfacePool::sharedPool().setPoolSize(0);
index c87d752..9df1dcf 100644 (file)
@@ -289,7 +289,7 @@ void RemoteLayerTreeHost::detachRootLayer()
     m_rootLayer = nullptr;
 }
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 static void recursivelyMapIOSurfaceBackingStore(CALayer *layer)
 {
     if (layer.contents && CFGetTypeID(layer.contents) == CAMachPortGetTypeID()) {
@@ -305,7 +305,7 @@ static void recursivelyMapIOSurfaceBackingStore(CALayer *layer)
 
 void RemoteLayerTreeHost::mapAllIOSurfaceBackingStore()
 {
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     recursivelyMapIOSurfaceBackingStore(asLayer(m_rootLayer));
 #endif
 }
index 70b5879..afed332 100644 (file)
@@ -53,7 +53,7 @@ class WebPageProxy;
 
 class ViewSnapshot : public RefCounted<ViewSnapshot> {
 public:
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     static Ref<ViewSnapshot> create(std::unique_ptr<WebCore::IOSurface>);
 #else
     static Ref<ViewSnapshot> create(uint32_t slotID, WebCore::IntSize, size_t imageSizeInBytes);
@@ -78,7 +78,7 @@ public:
     void setDeviceScaleFactor(float deviceScaleFactor) { m_deviceScaleFactor = deviceScaleFactor; }
     float deviceScaleFactor() const { return m_deviceScaleFactor; }
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     WebCore::IOSurface* surface() const { return m_surface.get(); }
 
     size_t imageSizeInBytes() const { return m_surface ? m_surface->totalBytes() : 0; }
@@ -93,7 +93,7 @@ public:
 #endif
 
 private:
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     explicit ViewSnapshot(std::unique_ptr<WebCore::IOSurface>);
 
     std::unique_ptr<WebCore::IOSurface> m_surface;
@@ -127,7 +127,7 @@ public:
     void setDisableSnapshotVolatilityForTesting(bool disable) { m_disableSnapshotVolatility = disable; }
     bool disableSnapshotVolatilityForTesting() const { return m_disableSnapshotVolatility; }
 
-#if !USE(IOSURFACE)
+#if !HAVE(IOSURFACE)
     static CAContext *snapshottingContext();
 #endif
 
index aef7c33..86dae5f 100644 (file)
@@ -60,7 +60,7 @@ ViewSnapshotStore& ViewSnapshotStore::singleton()
     return store;
 }
 
-#if !USE(IOSURFACE)
+#if !HAVE(IOSURFACE)
 CAContext *ViewSnapshotStore::snapshottingContext()
 {
     static CAContext *context;
@@ -131,7 +131,7 @@ void ViewSnapshotStore::discardSnapshotImages()
         m_snapshotsWithImages.first()->clearImage();
 }
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 Ref<ViewSnapshot> ViewSnapshot::create(std::unique_ptr<WebCore::IOSurface> surface)
 {
     return adoptRef(*new ViewSnapshot(WTFMove(surface)));
@@ -143,7 +143,7 @@ Ref<ViewSnapshot> ViewSnapshot::create(uint32_t slotID, IntSize size, size_t ima
 }
 #endif
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 ViewSnapshot::ViewSnapshot(std::unique_ptr<WebCore::IOSurface> surface)
     : m_surface(WTFMove(surface))
 #else
@@ -162,7 +162,7 @@ ViewSnapshot::~ViewSnapshot()
     clearImage();
 }
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 void ViewSnapshot::setSurface(std::unique_ptr<WebCore::IOSurface> surface)
 {
     ASSERT(!m_surface);
@@ -178,7 +178,7 @@ void ViewSnapshot::setSurface(std::unique_ptr<WebCore::IOSurface> surface)
 
 bool ViewSnapshot::hasImage() const
 {
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     return !!m_surface;
 #else
     return m_slotID;
@@ -192,7 +192,7 @@ void ViewSnapshot::clearImage()
 
     ViewSnapshotStore::singleton().willRemoveImageFromSnapshot(*this);
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     m_surface = nullptr;
 #else
     [ViewSnapshotStore::snapshottingContext() deleteSlot:m_slotID];
@@ -201,7 +201,7 @@ void ViewSnapshot::clearImage()
 #endif
 }
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
 WebCore::IOSurface::SurfaceState ViewSnapshot::setVolatile(bool becomeVolatile)
 {
     if (ViewSnapshotStore::singleton().disableSnapshotVolatilityForTesting())
@@ -216,7 +216,7 @@ WebCore::IOSurface::SurfaceState ViewSnapshot::setVolatile(bool becomeVolatile)
 
 id ViewSnapshot::asLayerContents()
 {
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     if (!m_surface)
         return nullptr;
 
@@ -233,7 +233,7 @@ id ViewSnapshot::asLayerContents()
 
 RetainPtr<CGImageRef> ViewSnapshot::asImageForTesting()
 {
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     if (!m_surface)
         return nullptr;
 
index 1ba80a0..bb7231c 100644 (file)
@@ -1,3 +1,16 @@
+2018-02-20  Tim Horton  <timothy_horton@apple.com>
+
+        Introduce HAVE(IOSURFACE_ACCELERATOR)
+        https://bugs.webkit.org/show_bug.cgi?id=182955
+        <rdar://problem/37699510>
+
+        Reviewed by Sam Weinig.
+
+        * DumpRenderTree/ios/PixelDumpSupportIOS.mm:
+        (createBitmapContextFromWebView):
+        * WebKitTestRunner/ios/PlatformWebViewIOS.mm:
+        (WTR::PlatformWebView::windowSnapshotImage):
+
 2018-02-20  Chris Dumez  <cdumez@apple.com>
 
         Provisional load may get committed before receiving the decidePolicyForNavigationResponse response
index 48f7cce..5e1a243 100644 (file)
@@ -66,7 +66,7 @@ RefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool increme
     int bufferWidth = ceil(viewSize.width * deviceScaleFactor);
     int bufferHeight = ceil(viewSize.height * deviceScaleFactor);
 
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     WebCore::FloatSize snapshotSize(viewSize);
     snapshotSize.scale(deviceScaleFactor);
 
index 2472b3e..e852292 100644 (file)
@@ -294,7 +294,7 @@ void PlatformWebView::changeWindowScaleIfNeeded(float)
     // Retina only surface.
 }
 
-#if !USE(IOSURFACE)
+#if !HAVE(IOSURFACE)
 static void releaseDataProviderData(void* info, const void*, size_t)
 {
     CARenderServerDestroyBuffer(static_cast<CARenderServerBufferRef>(info));
@@ -304,7 +304,7 @@ static void releaseDataProviderData(void* info, const void*, size_t)
 RetainPtr<CGImageRef> PlatformWebView::windowSnapshotImage()
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
-#if USE(IOSURFACE)
+#if HAVE(IOSURFACE)
     __block bool isDone = false;
     __block RetainPtr<CGImageRef> result;
     
index 30694df..db75753 100644 (file)
@@ -1,3 +1,16 @@
+2018-02-20  Tim Horton  <timothy_horton@apple.com>
+
+        Introduce HAVE(IOSURFACE_ACCELERATOR)
+        https://bugs.webkit.org/show_bug.cgi?id=182955
+        <rdar://problem/37699510>
+
+        Reviewed by Sam Weinig.
+
+        * WebKitPrivateFrameworkStubs/iOS/10/IOSurface.framework/IOSurface.tbd:
+        * WebKitPrivateFrameworkStubs/iOS/10/IOSurfaceAccelerator.framework/IOSurfaceAccelerator.tbd: Added.
+        * WebKitPrivateFrameworkStubs/iOS/11/IOSurfaceAccelerator.framework/IOSurfaceAccelerator.tbd: Added.
+        Switch IOSurfaceAccelerator symbols over to the still-private IOSurfaceAccelerator framework.
+
 2018-01-19  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r227211.
index 57b9b97..c7bff4f 100644 (file)
@@ -14,9 +14,6 @@ exports:
       - i386
       - x86_64
     symbols:
-      - _IOSurfaceAcceleratorCreate
-      - _IOSurfaceAcceleratorGetRunLoopSource
-      - _IOSurfaceAcceleratorTransformSurface
       - _IOSurfaceAlignProperty
       - _IOSurfaceCreate
       - _IOSurfaceCreateMachPort
diff --git a/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/10/IOSurfaceAccelerator.framework/IOSurfaceAccelerator.tbd b/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/10/IOSurfaceAccelerator.framework/IOSurfaceAccelerator.tbd
new file mode 100644 (file)
index 0000000..23d3bce
--- /dev/null
@@ -0,0 +1,24 @@
+--- !tapi-tbd-v2
+archs:
+  - armv7
+  - armv7s
+  - arm64
+  - i386
+  - x86_64
+exports:
+  -
+    archs:
+      - armv7
+      - armv7s
+      - arm64
+      - i386
+      - x86_64
+    symbols:
+      - _IOSurfaceAcceleratorCreate
+      - _IOSurfaceAcceleratorGetRunLoopSource
+      - _IOSurfaceAcceleratorTransformSurface
+      - _kIOSurfaceAcceleratorUnwireSurfaceKey
+install-name: /System/Library/PrivateFrameworks/IOSurfaceAccelerator.framework/IOSurfaceAccelerator
+objc-constraint: none
+platform: ios
+...
diff --git a/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/11/IOSurfaceAccelerator.framework/IOSurfaceAccelerator.tbd b/WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/11/IOSurfaceAccelerator.framework/IOSurfaceAccelerator.tbd
new file mode 100644 (file)
index 0000000..23d3bce
--- /dev/null
@@ -0,0 +1,24 @@
+--- !tapi-tbd-v2
+archs:
+  - armv7
+  - armv7s
+  - arm64
+  - i386
+  - x86_64
+exports:
+  -
+    archs:
+      - armv7
+      - armv7s
+      - arm64
+      - i386
+      - x86_64
+    symbols:
+      - _IOSurfaceAcceleratorCreate
+      - _IOSurfaceAcceleratorGetRunLoopSource
+      - _IOSurfaceAcceleratorTransformSurface
+      - _kIOSurfaceAcceleratorUnwireSurfaceKey
+install-name: /System/Library/PrivateFrameworks/IOSurfaceAccelerator.framework/IOSurfaceAccelerator
+objc-constraint: none
+platform: ios
+...