<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[166005] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/166005">166005</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2014-03-20 15:06:38 -0700 (Thu, 20 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add WebCore::IOSurface wrapper
https://bugs.webkit.org/show_bug.cgi?id=130529
Reviewed by Simon Fraser.
* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/cg/ColorCG.cpp:
* platform/graphics/cg/GraphicsContextCG.h:
(WebCore::cachedCGColorSpace):
Move cachedCGColorSpace out so that other clients of GraphicsContextCG
can use its mapping from WebCore::ColorSpace -> CGColorSpaceRef.
* platform/graphics/cg/ImageBufferBackingStoreCache.cpp:
* platform/graphics/cg/ImageBufferCG.cpp:
Add FIXMEs for ImageBuffer to adopt WebCore::IOSurface.
* platform/graphics/cocoa/IOSurface.h: Added.
* platform/graphics/cocoa/IOSurface.mm: Added.
(IOSurface::create):
(IOSurface::createFromMachPort):
(IOSurface::createFromSurface):
(IOSurface::IOSurface):
(IOSurface::maximumSize):
(IOSurface::createMachPort):
(IOSurface::createImage):
(IOSurface::ensurePlatformContext):
(IOSurface::ensureGraphicsContext):
(IOSurface::state):
(IOSurface::isPurgeable):
(IOSurface::setIsPurgeable):
(IOSurface::inUse):
Add WebCore::IOSurface.
* Shared/mac/RemoteLayerBackingStore.h:
* Shared/mac/RemoteLayerBackingStore.mm:
(RemoteLayerBackingStore::encode):
(RemoteLayerBackingStore::decode):
(RemoteLayerBackingStore::display):
(RemoteLayerBackingStore::applyBackingStoreToLayer):
* UIProcess/ios/ViewGestureControllerIOS.mm:
(WebKit::ViewGestureController::beginSwipeGesture):
(WebKit::ViewGestureController::removeSwipeSnapshot):
* UIProcess/mac/ViewGestureController.h:
* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::beginSwipeGesture):
(WebKit::ViewGestureController::removeSwipeSnapshot):
* UIProcess/mac/ViewSnapshotStore.h:
* UIProcess/mac/ViewSnapshotStore.mm:
(WebKit::createIOSurfaceFromImage):
(WebKit::ViewSnapshotStore::recordSnapshot):
Adopt WebCore::IOSurface.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgColorCGcpp">trunk/Source/WebCore/platform/graphics/cg/ColorCG.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgGraphicsContextCGh">trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgImageBufferBackingStoreCachecpp">trunk/Source/WebCore/platform/graphics/cg/ImageBufferBackingStoreCache.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgImageBufferCGcpp">trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerBackingStoreh">trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h</a></li>
<li><a href="#trunkSourceWebKit2SharedmacRemoteLayerBackingStoremm">trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosViewGestureControllerIOSmm">trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllerh">trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllerMacmm">trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewSnapshotStoreh">trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewSnapshotStoremm">trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaIOSurfaceh">trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaIOSurfacemm">trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166004 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-20 21:53:03 UTC (rev 166004)
+++ trunk/Source/WebCore/ChangeLog        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -1,3 +1,39 @@
</span><ins>+2014-03-20 Tim Horton <timothy_horton@apple.com>
+
+ Add WebCore::IOSurface wrapper
+ https://bugs.webkit.org/show_bug.cgi?id=130529
+
+ Reviewed by Simon Fraser.
+
+ * WebCore.exp.in:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/cg/ColorCG.cpp:
+ * platform/graphics/cg/GraphicsContextCG.h:
+ (WebCore::cachedCGColorSpace):
+ Move cachedCGColorSpace out so that other clients of GraphicsContextCG
+ can use its mapping from WebCore::ColorSpace -> CGColorSpaceRef.
+
+ * platform/graphics/cg/ImageBufferBackingStoreCache.cpp:
+ * platform/graphics/cg/ImageBufferCG.cpp:
+ Add FIXMEs for ImageBuffer to adopt WebCore::IOSurface.
+
+ * platform/graphics/cocoa/IOSurface.h: Added.
+ * platform/graphics/cocoa/IOSurface.mm: Added.
+ (IOSurface::create):
+ (IOSurface::createFromMachPort):
+ (IOSurface::createFromSurface):
+ (IOSurface::IOSurface):
+ (IOSurface::maximumSize):
+ (IOSurface::createMachPort):
+ (IOSurface::createImage):
+ (IOSurface::ensurePlatformContext):
+ (IOSurface::ensureGraphicsContext):
+ (IOSurface::state):
+ (IOSurface::isPurgeable):
+ (IOSurface::setIsPurgeable):
+ (IOSurface::inUse):
+ Add WebCore::IOSurface.
+
</ins><span class="cx"> 2014-03-20 Pratik Solanki <psolanki@apple.com>
</span><span class="cx">
</span><span class="cx"> iOS build fix after r165992.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (166004 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-03-20 21:53:03 UTC (rev 166004)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -2711,11 +2711,6 @@
</span><span class="cx"> _wkCTFontTransformGlyphs
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if !PLATFORM(IOS_SIMULATOR)
-_wkIOSurfaceContextCreate
-_wkIOSurfaceContextCreateImage
-#endif
-
</del><span class="cx"> #if ENABLE(3D_RENDERING)
</span><span class="cx"> _WebCoreHas3DRendering
</span><span class="cx"> #endif
</span><span class="lines">@@ -3055,6 +3050,18 @@
</span><span class="cx"> __ZNK7WebCore9FloatQuad13containsPointERKNS_10FloatPointE
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if USE(IOSURFACE)
+__ZN7WebCore9IOSurface14setIsPurgeableEb
+__ZN7WebCore9IOSurface18createFromMachPortEjNS_10ColorSpaceE
+__ZN7WebCore9IOSurface21ensureGraphicsContextEv
+__ZN7WebCore9IOSurface21ensurePlatformContextEv
+__ZN7WebCore9IOSurface6createENS_7IntSizeENS_10ColorSpaceE
+__ZNK7WebCore9IOSurface11createImageEv
+__ZNK7WebCore9IOSurface14createMachPortEv
+_wkIOSurfaceContextCreate
+_wkIOSurfaceContextCreateImage
+#endif
+
</ins><span class="cx"> #if ENABLE(IOS_TEXT_AUTOSIZING)
</span><span class="cx"> __ZN7WebCore12RenderObject19resetTextAutosizingEv
</span><span class="cx"> __ZN7WebCore5Frame22setTextAutosizingWidthEf
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (166004 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-03-20 21:53:03 UTC (rev 166004)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -1038,6 +1038,8 @@
</span><span class="cx">                 2B365C841525119E0091D27B /* RenderSVGEllipse.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B4235A015250F6000DBBCD8 /* RenderSVGEllipse.h */; };
</span><span class="cx">                 2BE8E2C712A589EC00FAD550 /* HTMLMetaCharsetParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */; };
</span><span class="cx">                 2BE8E2C912A58A0100FAD550 /* HTMLMetaCharsetParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */; };
</span><ins>+                2D0B4AAB18DA1CCD00434DE1 /* IOSurface.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D0B4AA918DA1CCD00434DE1 /* IOSurface.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                2D0B4AAC18DA1CCD00434DE1 /* IOSurface.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D0B4AAA18DA1CCD00434DE1 /* IOSurface.mm */; };
</ins><span class="cx">                 2D25396218CE7F6200270222 /* ImageControlsButtonElementMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D25396018CE7F6200270222 /* ImageControlsButtonElementMac.cpp */; };
</span><span class="cx">                 2D25396318CE7F6200270222 /* ImageControlsButtonElementMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D25396118CE7F6200270222 /* ImageControlsButtonElementMac.h */; };
</span><span class="cx">                 2D3A0E3613A7D76100E85AF0 /* SVGParsingError.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -7901,6 +7903,8 @@
</span><span class="cx">                 2B4235A015250F6000DBBCD8 /* RenderSVGEllipse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGEllipse.h; sourceTree = "<group>"; };
</span><span class="cx">                 2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLMetaCharsetParser.h; path = parser/HTMLMetaCharsetParser.h; sourceTree = "<group>"; };
</span><span class="cx">                 2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HTMLMetaCharsetParser.cpp; path = parser/HTMLMetaCharsetParser.cpp; sourceTree = "<group>"; };
</span><ins>+                2D0B4AA918DA1CCD00434DE1 /* IOSurface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IOSurface.h; sourceTree = "<group>"; };
+                2D0B4AAA18DA1CCD00434DE1 /* IOSurface.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IOSurface.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 2D25396018CE7F6200270222 /* ImageControlsButtonElementMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageControlsButtonElementMac.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 2D25396118CE7F6200270222 /* ImageControlsButtonElementMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageControlsButtonElementMac.h; sourceTree = "<group>"; };
</span><span class="cx">                 2D2FC0541460CD6F00263633 /* CrossfadeGeneratedImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CrossfadeGeneratedImage.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -20243,6 +20247,8 @@
</span><span class="cx">                 B5320D68122A24E9002D1440 /* cocoa */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                2D0B4AA918DA1CCD00434DE1 /* IOSurface.h */,
+                                2D0B4AAA18DA1CCD00434DE1 /* IOSurface.mm */,
</ins><span class="cx">                                 B5320D6A122A24E9002D1440 /* FontPlatformDataCocoa.mm */,
</span><span class="cx">                         );
</span><span class="cx">                         path = cocoa;
</span><span class="lines">@@ -23016,6 +23022,7 @@
</span><span class="cx">                                 B2C3DA2A0D006C1D00EF6F26 /* CharsetData.h in Headers */,
</span><span class="cx">                                 F55B3DB21251F12D003EF269 /* CheckboxInputType.h in Headers */,
</span><span class="cx">                                 93F925430F7EF5B8007E37C9 /* CheckedRadioButtons.h in Headers */,
</span><ins>+                                2D0B4AAB18DA1CCD00434DE1 /* IOSurface.h in Headers */,
</ins><span class="cx">                                 D619A308144E00BE004BC302 /* ChildListMutationScope.h in Headers */,
</span><span class="cx">                                 A81872200977D3C0005826D9 /* ChildNodeList.h in Headers */,
</span><span class="cx">                                 14D823520AF92A790004F057 /* Chrome.h in Headers */,
</span><span class="lines">@@ -27081,6 +27088,7 @@
</span><span class="cx">                                 BC53DA481143134D000D817E /* DOMWrapperWorld.cpp in Sources */,
</span><span class="cx">                                 1A1D13810A5325520064BF5F /* DOMXPath.mm in Sources */,
</span><span class="cx">                                 85E9E0A20AB3A0C700069CD0 /* DOMXPathExpression.mm in Sources */,
</span><ins>+                                2D0B4AAC18DA1CCD00434DE1 /* IOSurface.mm in Sources */,
</ins><span class="cx">                                 85E9E0A60AB3A0C700069CD0 /* DOMXPathResult.mm in Sources */,
</span><span class="cx">                                 FD1762E3176686EA00D836A8 /* DownSampler.cpp in Sources */,
</span><span class="cx">                                 A7CA595E0B27BD9E00FA021D /* DragController.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgColorCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/ColorCG.cpp (166004 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/ColorCG.cpp        2014-03-20 21:53:03 UTC (rev 166004)
+++ trunk/Source/WebCore/platform/graphics/cg/ColorCG.cpp        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -107,20 +107,6 @@
</span><span class="cx"> m_valid = true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static inline CGColorSpaceRef cachedCGColorSpace(ColorSpace colorSpace)
-{
- switch (colorSpace) {
- case ColorSpaceDeviceRGB:
- return deviceRGBColorSpaceRef();
- case ColorSpaceSRGB:
- return sRGBColorSpaceRef();
- case ColorSpaceLinearRGB:
- return linearRGBColorSpaceRef();
- }
- ASSERT_NOT_REACHED();
- return deviceRGBColorSpaceRef();
-}
-
</del><span class="cx"> static CGColorRef leakCGColor(const Color& color, ColorSpace colorSpace)
</span><span class="cx"> {
</span><span class="cx"> CGFloat components[4];
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgGraphicsContextCGh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.h (166004 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.h        2014-03-20 21:53:03 UTC (rev 166004)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.h        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -36,6 +36,20 @@
</span><span class="cx"> CGColorSpaceRef sRGBColorSpaceRef();
</span><span class="cx"> CGColorSpaceRef linearRGBColorSpaceRef();
</span><span class="cx">
</span><ins>+static inline CGColorSpaceRef cachedCGColorSpace(ColorSpace colorSpace)
+{
+ switch (colorSpace) {
+ case ColorSpaceDeviceRGB:
+ return deviceRGBColorSpaceRef();
+ case ColorSpaceSRGB:
+ return sRGBColorSpaceRef();
+ case ColorSpaceLinearRGB:
+ return linearRGBColorSpaceRef();
+ }
+ ASSERT_NOT_REACHED();
+ return deviceRGBColorSpaceRef();
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgImageBufferBackingStoreCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferBackingStoreCache.cpp (166004 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferBackingStoreCache.cpp        2014-03-20 21:53:03 UTC (rev 166004)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferBackingStoreCache.cpp        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+// FIXME: Adopt WebCore::IOSurface.
</ins><span class="cx"> static RetainPtr<IOSurfaceRef> createIOSurface(const IntSize& size)
</span><span class="cx"> {
</span><span class="cx"> unsigned pixelFormat = 'BGRA';
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgImageBufferCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (166004 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp        2014-03-20 21:53:03 UTC (rev 166004)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -63,6 +63,7 @@
</span><span class="cx"> static const int maxIOSurfaceDimension = 4096;
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+// FIXME: Adopt WebCore::IOSurface.
</ins><span class="cx"> static RetainPtr<IOSurfaceRef> createIOSurface(const IntSize& size)
</span><span class="cx"> {
</span><span class="cx"> unsigned pixelFormat = 'BGRA';
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaIOSurfaceh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h (0 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.h        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -0,0 +1,94 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IOSurface_h
+#define IOSurface_h
+
+#if USE(IOSURFACE)
+
+#include "GraphicsContext.h"
+#include "IntSize.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class IOSurface final : public RefCounted<IOSurface> {
+public:
+ static PassRefPtr<IOSurface> create(IntSize, ColorSpace);
+ static PassRefPtr<IOSurface> createFromMachPort(mach_port_t, ColorSpace);
+ static PassRefPtr<IOSurface> createFromSurface(IOSurfaceRef, ColorSpace);
+
+ static IntSize maximumSize();
+
+ mach_port_t createMachPort() const;
+
+ // Any images created from a surface need to be released before releasing
+ // the surface, or an expensive GPU readback can result.
+ RetainPtr<CGImageRef> createImage() const;
+
+ IOSurfaceRef surface() const { return m_surface.get(); }
+ GraphicsContext& ensureGraphicsContext();
+ CGContextRef ensurePlatformContext();
+
+ enum class SurfaceState {
+ Valid,
+ Empty
+ };
+
+ // Querying purgeability state can be expensive, so in cases where the surface is
+ // going to be used immediately, use the return value of setIsPurgeable to
+ // determine whether the data was purged, instead of first calling state() or isPurgeable().
+ SurfaceState state() const;
+ bool isPurgeable() const;
+
+ // setIsPurgeable only has an effect on iOS and OS 10.9 and above.
+ SurfaceState setIsPurgeable(bool);
+
+ IntSize size() const { return m_size; }
+ size_t totalBytes() const { return m_totalBytes; }
+ ColorSpace colorSpace() const { return m_colorSpace; }
+
+ bool inUse() const;
+
+private:
+ IOSurface(IntSize, ColorSpace);
+ IOSurface(IOSurfaceRef, ColorSpace);
+
+ ColorSpace m_colorSpace;
+ IntSize m_size;
+ size_t m_totalBytes;
+
+ OwnPtr<GraphicsContext> m_graphicsContext;
+ RetainPtr<CGContextRef> m_cgContext;
+
+ RetainPtr<IOSurfaceRef> m_surface;
+};
+
+} // namespace WebCore
+
+#endif // USE(IOSURFACE)
+
+#endif // IOSurface_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaIOSurfacemm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm (0 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/IOSurface.mm        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -0,0 +1,189 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "IOSurface.h"
+
+#if USE(IOSURFACE)
+
+#import "GraphicsContextCG.h"
+#import <IOSurface/IOSurface.h>
+#import <wtf/Assertions.h>
+
+#if __has_include(<IOSurface/IOSurfacePrivate.h>)
+#import <IOSurface/IOSurfacePrivate.h>
+#else
+enum {
+ kIOSurfacePurgeableNonVolatile = 0,
+ kIOSurfacePurgeableVolatile = 1,
+ kIOSurfacePurgeableEmpty = 2,
+ kIOSurfacePurgeableKeepCurrent = 3,
+};
+#endif
+
+extern "C" {
+CGContextRef CGIOSurfaceContextCreate(IOSurfaceRef, size_t, size_t, size_t, size_t, CGColorSpaceRef, CGBitmapInfo);
+CGImageRef CGIOSurfaceContextCreateImage(CGContextRef);
+IOReturn IOSurfaceSetPurgeable(IOSurfaceRef, uint32_t, uint32_t *);
+}
+
+using namespace WebCore;
+
+PassRefPtr<IOSurface> IOSurface::create(IntSize size, ColorSpace colorSpace)
+{
+ return adoptRef(new IOSurface(size, colorSpace));
+}
+
+PassRefPtr<IOSurface> IOSurface::createFromMachPort(mach_port_t machPort, ColorSpace colorSpace)
+{
+ RetainPtr<IOSurfaceRef> surface = adoptCF(IOSurfaceLookupFromMachPort(machPort));
+ return IOSurface::createFromSurface(surface.get(), colorSpace);
+}
+
+PassRefPtr<IOSurface> IOSurface::createFromSurface(IOSurfaceRef surface, ColorSpace colorSpace)
+{
+ return adoptRef(new IOSurface(surface, colorSpace));
+}
+
+IOSurface::IOSurface(IntSize size, ColorSpace colorSpace)
+ : m_colorSpace(colorSpace)
+ , m_size(size)
+{
+ unsigned pixelFormat = 'BGRA';
+ unsigned bytesPerElement = 4;
+ int width = size.width();
+ int height = size.height();
+
+ size_t bytesPerRow = IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, width * bytesPerElement);
+ ASSERT(bytesPerRow);
+
+ m_totalBytes = IOSurfaceAlignProperty(kIOSurfaceAllocSize, height * bytesPerRow);
+ ASSERT(m_totalBytes);
+
+ NSDictionary *options = @{
+ (id)kIOSurfaceWidth: @(width),
+ (id)kIOSurfaceHeight: @(height),
+ (id)kIOSurfacePixelFormat: @(pixelFormat),
+ (id)kIOSurfaceBytesPerElement: @(bytesPerElement),
+ (id)kIOSurfaceBytesPerRow: @(bytesPerRow),
+ (id)kIOSurfaceAllocSize: @(m_totalBytes)
+ };
+
+ m_surface = adoptCF(IOSurfaceCreate((CFDictionaryRef)options));
+}
+
+IOSurface::IOSurface(IOSurfaceRef surface, ColorSpace colorSpace)
+ : m_colorSpace(colorSpace)
+ , m_surface(surface)
+{
+ m_size = IntSize(IOSurfaceGetWidth(surface), IOSurfaceGetHeight(surface));
+ m_totalBytes = IOSurfaceGetAllocSize(surface);
+}
+
+IntSize IOSurface::maximumSize()
+{
+ return IntSize(IOSurfaceGetPropertyMaximum(kIOSurfaceWidth), IOSurfaceGetPropertyMaximum(kIOSurfaceHeight));
+}
+
+mach_port_t IOSurface::createMachPort() const
+{
+ return IOSurfaceCreateMachPort(m_surface.get());
+}
+
+RetainPtr<CGImageRef> IOSurface::createImage() const
+{
+ if (!m_cgContext)
+ return nullptr;
+
+ return adoptCF(CGIOSurfaceContextCreateImage(m_cgContext.get()));
+}
+
+CGContextRef IOSurface::ensurePlatformContext()
+{
+ if (m_cgContext)
+ return m_cgContext.get();
+
+ CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host;
+ size_t bitsPerComponent = 8;
+ size_t bitsPerPixel = 32;
+ m_cgContext = adoptCF(CGIOSurfaceContextCreate(m_surface.get(), m_size.width(), m_size.height(), bitsPerComponent, bitsPerPixel, cachedCGColorSpace(m_colorSpace), bitmapInfo));
+
+ return m_cgContext.get();
+}
+
+GraphicsContext& IOSurface::ensureGraphicsContext()
+{
+ if (m_graphicsContext)
+ return *m_graphicsContext;
+
+ m_graphicsContext = adoptPtr(new GraphicsContext(ensurePlatformContext()));
+
+ return *m_graphicsContext;
+}
+
+IOSurface::SurfaceState IOSurface::state() const
+{
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ uint32_t previousState = 0;
+ IOReturn ret = IOSurfaceSetPurgeable(m_surface.get(), kIOSurfacePurgeableKeepCurrent, &previousState);
+ ASSERT_UNUSED(ret, ret == kIOReturnSuccess);
+ return previousState == kIOSurfacePurgeableEmpty ? IOSurface::SurfaceState::Empty : IOSurface::SurfaceState::Valid;
+#else
+ return SurfaceState::Valid;
+#endif
+}
+
+bool IOSurface::isPurgeable() const
+{
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ uint32_t previousState = 0;
+ IOReturn ret = IOSurfaceSetPurgeable(m_surface.get(), kIOSurfacePurgeableKeepCurrent, &previousState);
+ ASSERT_UNUSED(ret, ret == kIOReturnSuccess);
+ return previousState != kIOSurfacePurgeableNonVolatile;
+#else
+ return false;
+#endif
+}
+
+IOSurface::SurfaceState IOSurface::setIsPurgeable(bool isPurgeable)
+{
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ uint32_t previousState = 0;
+ IOReturn ret = IOSurfaceSetPurgeable(m_surface.get(), isPurgeable ? kIOSurfacePurgeableVolatile : kIOSurfacePurgeableNonVolatile, &previousState);
+ ASSERT_UNUSED(ret, ret == kIOReturnSuccess);
+
+ if (previousState == kIOSurfacePurgeableEmpty)
+ return IOSurface::SurfaceState::Empty;
+#endif
+
+ return IOSurface::SurfaceState::Valid;
+}
+
+bool IOSurface::inUse() const
+{
+ return IOSurfaceIsInUse(m_surface.get());
+}
+
+#endif // USE(IOSURFACE)
</ins></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (166004 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-03-20 21:53:03 UTC (rev 166004)
+++ trunk/Source/WebKit2/ChangeLog        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2014-03-20 Tim Horton <timothy_horton@apple.com>
+
+ Add WebCore::IOSurface wrapper
+ https://bugs.webkit.org/show_bug.cgi?id=130529
+
+ Reviewed by Simon Fraser.
+
+ * Shared/mac/RemoteLayerBackingStore.h:
+ * Shared/mac/RemoteLayerBackingStore.mm:
+ (RemoteLayerBackingStore::encode):
+ (RemoteLayerBackingStore::decode):
+ (RemoteLayerBackingStore::display):
+ (RemoteLayerBackingStore::applyBackingStoreToLayer):
+ * UIProcess/ios/ViewGestureControllerIOS.mm:
+ (WebKit::ViewGestureController::beginSwipeGesture):
+ (WebKit::ViewGestureController::removeSwipeSnapshot):
+ * UIProcess/mac/ViewGestureController.h:
+ * UIProcess/mac/ViewGestureControllerMac.mm:
+ (WebKit::ViewGestureController::beginSwipeGesture):
+ (WebKit::ViewGestureController::removeSwipeSnapshot):
+ * UIProcess/mac/ViewSnapshotStore.h:
+ * UIProcess/mac/ViewSnapshotStore.mm:
+ (WebKit::createIOSurfaceFromImage):
+ (WebKit::ViewSnapshotStore::recordSnapshot):
+ Adopt WebCore::IOSurface.
+
</ins><span class="cx"> 2014-03-20 Alexey Proskuryakov <ap@apple.com>
</span><span class="cx">
</span><span class="cx"> Update iOS input method code to use new cross-platform async functions
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerBackingStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h (166004 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h        2014-03-20 21:53:03 UTC (rev 166004)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.h        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -28,12 +28,9 @@
</span><span class="cx">
</span><span class="cx"> #include "ShareableBitmap.h"
</span><span class="cx"> #include <WebCore/FloatRect.h>
</span><ins>+#include <WebCore/IOSurface.h>
</ins><span class="cx"> #include <WebCore/Region.h>
</span><span class="cx">
</span><del>-#if USE(IOSURFACE)
-#include <IOSurface/IOSurface.h>
-#endif
-
</del><span class="cx"> OBJC_CLASS CALayer;
</span><span class="cx">
</span><span class="cx"> // FIXME: Make PlatformCALayerRemote.cpp Objective-C so we can include WebLayer.h here and share the typedef.
</span><span class="lines">@@ -93,7 +90,7 @@
</span><span class="cx">
</span><span class="cx"> RefPtr<ShareableBitmap> m_frontBuffer;
</span><span class="cx"> #if USE(IOSURFACE)
</span><del>- RetainPtr<IOSurfaceRef> m_frontSurface;
</del><ins>+ RefPtr<WebCore::IOSurface> m_frontSurface;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> bool m_acceleratesDrawing;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacRemoteLayerBackingStoremm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm (166004 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm        2014-03-20 21:53:03 UTC (rev 166004)
+++ trunk/Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -33,23 +33,13 @@
</span><span class="cx"> #import "WebCoreArgumentCoders.h"
</span><span class="cx"> #import <QuartzCore/QuartzCore.h>
</span><span class="cx"> #import <WebCore/GraphicsContextCG.h>
</span><ins>+#import <WebCore/IOSurface.h>
</ins><span class="cx"> #import <WebCore/WebLayer.h>
</span><span class="cx">
</span><span class="cx"> #if USE(IOSURFACE)
</span><span class="cx"> #import <mach/mach_port.h>
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if __has_include(<ApplicationServices/ApplicationServicesPriv.h>)
-#import <ApplicationServices/ApplicationServicesPriv.h>
-#endif
-
-extern "C" {
-#if USE(IOSURFACE)
-CGContextRef CGIOSurfaceContextCreate(IOSurfaceRef, size_t, size_t, size_t, size_t, CGColorSpaceRef, CGBitmapInfo);
-#endif
-CGImageRef CGIOSurfaceContextCreateImage(CGContextRef);
-}
-
</del><span class="cx"> #if __has_include(<QuartzCore/CALayerPrivate.h>)
</span><span class="cx"> #import <QuartzCore/CALayerPrivate.h>
</span><span class="cx"> #endif
</span><span class="lines">@@ -93,7 +83,7 @@
</span><span class="cx">
</span><span class="cx"> #if USE(IOSURFACE)
</span><span class="cx"> if (m_acceleratesDrawing) {
</span><del>- mach_port_t port = IOSurfaceCreateMachPort(m_frontSurface.get());
</del><ins>+ mach_port_t port = m_frontSurface->createMachPort();
</ins><span class="cx"> encoder << IPC::MachPort(port, MACH_MSG_TYPE_MOVE_SEND);
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="lines">@@ -125,7 +115,7 @@
</span><span class="cx"> IPC::MachPort machPort;
</span><span class="cx"> if (!decoder.decode(machPort))
</span><span class="cx"> return false;
</span><del>- result.m_frontSurface = adoptCF(IOSurfaceLookupFromMachPort(machPort.port()));
</del><ins>+ result.m_frontSurface = IOSurface::createFromMachPort(machPort.port(), ColorSpaceDeviceRGB);
</ins><span class="cx"> mach_port_deallocate(mach_task_self(), machPort.port());
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -151,44 +141,6 @@
</span><span class="cx"> setNeedsDisplay(IntRect(IntPoint(), m_size));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#if USE(IOSURFACE)
-static RetainPtr<CGContextRef> createIOSurfaceContext(IOSurfaceRef surface, IntSize size, CGColorSpaceRef colorSpace)
-{
- if (!surface)
- return nullptr;
-
- CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host;
- size_t bitsPerComponent = 8;
- size_t bitsPerPixel = 32;
- return adoptCF(CGIOSurfaceContextCreate(surface, size.width(), size.height(), bitsPerComponent, bitsPerPixel, colorSpace, bitmapInfo));
-}
-
-static RetainPtr<IOSurfaceRef> createIOSurface(IntSize size)
-{
- unsigned pixelFormat = 'BGRA';
- unsigned bytesPerElement = 4;
- int width = size.width();
- int height = size.height();
-
- size_t bytesPerRow = IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, width * bytesPerElement);
- ASSERT(bytesPerRow);
-
- size_t allocSize = IOSurfaceAlignProperty(kIOSurfaceAllocSize, height * bytesPerRow);
- ASSERT(allocSize);
-
- NSDictionary *dict = @{
- (id)kIOSurfaceWidth: @(width),
- (id)kIOSurfaceHeight: @(height),
- (id)kIOSurfacePixelFormat: @(pixelFormat),
- (id)kIOSurfaceBytesPerElement: @(bytesPerElement),
- (id)kIOSurfaceBytesPerRow: @(bytesPerRow),
- (id)kIOSurfaceAllocSize: @(allocSize)
- };
-
- return adoptCF(IOSurfaceCreate((CFDictionaryRef)dict));
-}
-#endif // USE(IOSURFACE)
-
</del><span class="cx"> RetainPtr<CGImageRef> RemoteLayerBackingStore::createImageForFrontBuffer() const
</span><span class="cx"> {
</span><span class="cx"> if (!m_frontBuffer || m_acceleratesDrawing)
</span><span class="lines">@@ -233,30 +185,22 @@
</span><span class="cx">
</span><span class="cx"> #if USE(IOSURFACE)
</span><span class="cx"> if (m_acceleratesDrawing) {
</span><del>- RetainPtr<IOSurfaceRef> backSurface = createIOSurface(expandedScaledSize);
- RetainPtr<CGContextRef> cgContext = createIOSurfaceContext(backSurface.get(), expandedScaledSize, sRGBColorSpaceRef());
- GraphicsContext context(cgContext.get());
</del><ins>+ RefPtr<IOSurface> backSurface = IOSurface::create(expandedScaledSize, ColorSpaceDeviceRGB);
+ GraphicsContext& context = backSurface->ensureGraphicsContext();
</ins><span class="cx"> context.clearRect(FloatRect(FloatPoint(), expandedScaledSize));
</span><span class="cx"> context.scale(FloatSize(1, -1));
</span><span class="cx"> context.translate(0, -expandedScaledSize.height());
</span><span class="cx">
</span><del>- RetainPtr<CGContextRef> frontContext;
</del><span class="cx"> RetainPtr<CGImageRef> frontImage;
</span><del>- if (m_frontSurface) {
- frontContext = createIOSurfaceContext(m_frontSurface.get(), expandedIntSize(m_size * m_scale), sRGBColorSpaceRef());
- frontImage = adoptCF(CGIOSurfaceContextCreateImage(frontContext.get()));
- }
-
</del><ins>+ if (m_frontSurface)
+ frontImage = m_frontSurface->createImage();
</ins><span class="cx"> drawInContext(context, frontImage.get());
</span><del>- m_frontSurface = backSurface;
</del><span class="cx">
</span><span class="cx"> // If our frontImage is derived from an IOSurface, we need to
</span><span class="cx"> // destroy the image before the CGContext it's derived from,
</span><span class="cx"> // so that the context doesn't make a CPU copy of the surface data.
</span><del>- if (frontImage) {
- frontImage = nullptr;
- ASSERT(frontContext);
- }
</del><ins>+ frontImage = nullptr;
+ m_frontSurface = backSurface;
</ins><span class="cx">
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -367,7 +311,7 @@
</span><span class="cx"> {
</span><span class="cx"> #if USE(IOSURFACE)
</span><span class="cx"> if (acceleratesDrawing())
</span><del>- layer.contents = (id)m_frontSurface.get();
</del><ins>+ layer.contents = (id)m_frontSurface->surface();
</ins><span class="cx"> else
</span><span class="cx"> layer.contents = (id)createImageForFrontBuffer().get();
</span><span class="cx"> #else
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosViewGestureControllerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm (166004 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm        2014-03-20 21:53:03 UTC (rev 166004)
+++ trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #import "WebPageMessages.h"
</span><span class="cx"> #import "WebPageProxy.h"
</span><span class="cx"> #import "WebProcessProxy.h"
</span><ins>+#import <WebCore/IOSurface.h>
</ins><span class="cx"> #import <QuartzCore/QuartzCore.h>
</span><span class="cx"> #import <UIKit/UIScreenEdgePanGestureRecognizer.h>
</span><span class="cx"> #import <UIKit/UIViewControllerTransitioning_Private.h>
</span><span class="lines">@@ -43,11 +44,6 @@
</span><span class="cx"> #import <UIKit/_UINavigationInteractiveTransition.h>
</span><span class="cx"> #import <UIKit/_UINavigationParallaxTransition.h>
</span><span class="cx">
</span><del>-#if USE(IOSURFACE)
-#import <IOSurface/IOSurface.h>
-#import <IOSurface/IOSurfacePrivate.h>
-#endif
-
</del><span class="cx"> using namespace WebCore;
</span><span class="cx">
</span><span class="cx"> @interface WKSwipeTransitionController : NSObject <_UINavigationInteractiveTransitionBaseDelegate>
</span><span class="lines">@@ -161,11 +157,10 @@
</span><span class="cx"> m_snapshotView = adoptNS([[UIView alloc] initWithFrame:[m_liveSwipeView frame]]);
</span><span class="cx"> if (snapshot) {
</span><span class="cx"> #if USE(IOSURFACE)
</span><del>- uint32_t purgeabilityState = kIOSurfacePurgeableNonVolatile;
- IOSurfaceSetPurgeable(snapshot.get(), kIOSurfacePurgeableNonVolatile, &purgeabilityState);
-
- if (purgeabilityState != kIOSurfacePurgeableEmpty)
</del><ins>+ if (snapshot->setIsPurgeable(false) == IOSurface::SurfaceState::Valid) {
</ins><span class="cx"> [m_snapshotView layer].contents = (id)snapshot.get();
</span><ins>+ m_currentSwipeSnapshotSurface = snapshot;
+ }
</ins><span class="cx"> #else
</span><span class="cx"> [m_snapshotView layer].contents = (id)snapshot.get();
</span><span class="cx"> #endif
</span><span class="lines">@@ -268,9 +263,9 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> #if USE(IOSURFACE)
</span><del>- IOSurfaceRef snapshotSurface = (IOSurfaceRef)[m_snapshotView layer].contents;
- if (snapshotSurface)
- IOSurfaceSetPurgeable(snapshotSurface, kIOSurfacePurgeableVolatile, nullptr);
</del><ins>+ if (m_currentSwipeSnapshotSurface)
+ m_currentSwipeSnapshotSurface->setIsPurgeable(true);
+ m_currentSwipeSnapshotSurface = nullptr;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> [m_snapshotView removeFromSuperview];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h (166004 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h        2014-03-20 21:53:03 UTC (rev 166004)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -43,6 +43,10 @@
</span><span class="cx"> OBJC_CLASS NSView;
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+namespace WebCore {
+class IOSurface;
+}
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><span class="cx"> class WebBackForwardListItem;
</span><span class="lines">@@ -121,6 +125,10 @@
</span><span class="cx">
</span><span class="cx"> WebCore::Timer<ViewGestureController> m_swipeWatchdogTimer;
</span><span class="cx">
</span><ins>+#if USE(IOSURFACE)
+ RefPtr<WebCore::IOSurface> m_currentSwipeSnapshotSurface;
+#endif
+
</ins><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx"> double m_magnification;
</span><span class="cx"> WebCore::FloatPoint m_magnificationOrigin;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm (166004 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm        2014-03-20 21:53:03 UTC (rev 166004)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -40,22 +40,9 @@
</span><span class="cx"> #import "WebProcessProxy.h"
</span><span class="cx"> #import <Cocoa/Cocoa.h>
</span><span class="cx"> #import <QuartzCore/QuartzCore.h>
</span><ins>+#import <WebCore/IOSurface.h>
</ins><span class="cx"> #import <WebCore/WebCoreCALayerExtras.h>
</span><span class="cx">
</span><del>-#if defined(__has_include) && __has_include(<IOSurface/IOSurfacePrivate.h>)
-#import <IOSurface/IOSurfacePrivate.h>
-#else
-enum {
- kIOSurfacePurgeableNonVolatile = 0,
- kIOSurfacePurgeableVolatile = 1,
- kIOSurfacePurgeableEmpty = 2,
-};
-#endif
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
-extern "C" IOReturn IOSurfaceSetPurgeable(IOSurfaceRef buffer, uint32_t newState, uint32_t *oldState);
-#endif
-
</del><span class="cx"> #if defined(__has_include) && __has_include(<QuartzCore/QuartzCorePrivate.h>)
</span><span class="cx"> #import <QuartzCore/QuartzCorePrivate.h>
</span><span class="cx"> #else
</span><span class="lines">@@ -373,18 +360,11 @@
</span><span class="cx"> m_swipeSnapshotLayer = adoptNS([[CALayer alloc] init]);
</span><span class="cx"> [m_swipeSnapshotLayer setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)];
</span><span class="cx">
</span><del>- RetainPtr<IOSurfaceRef> snapshot = ViewSnapshotStore::shared().snapshotAndRenderTreeSize(targetItem).first;
</del><ins>+ RefPtr<IOSurface> snapshot = ViewSnapshotStore::shared().snapshotAndRenderTreeSize(targetItem).first;
</ins><span class="cx">
</span><del>- if (snapshot) {
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- uint32_t purgeabilityState = kIOSurfacePurgeableNonVolatile;
- IOSurfaceSetPurgeable(snapshot.get(), kIOSurfacePurgeableNonVolatile, &purgeabilityState);
-
- if (purgeabilityState != kIOSurfacePurgeableEmpty)
- [m_swipeSnapshotLayer setContents:(id)snapshot.get()];
-#else
- [m_swipeSnapshotLayer setContents:(id)snapshot.get()];
-#endif
</del><ins>+ if (snapshot && snapshot->setIsPurgeable(false) == IOSurface::SurfaceState::Valid) {
+ m_currentSwipeSnapshotSurface = snapshot;
+ [m_swipeSnapshotLayer setContents:(id)snapshot->surface()];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> m_currentSwipeCustomViewBounds = windowRelativeBoundsForCustomSwipeViews();
</span><span class="lines">@@ -530,11 +510,9 @@
</span><span class="cx"> if (m_activeGestureType != ViewGestureType::Swipe)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- IOSurfaceRef snapshotSurface = (IOSurfaceRef)[m_swipeSnapshotLayer contents];
- if (snapshotSurface)
- IOSurfaceSetPurgeable(snapshotSurface, kIOSurfacePurgeableVolatile, nullptr);
-#endif
</del><ins>+ if (m_currentSwipeSnapshotSurface)
+ m_currentSwipeSnapshotSurface->setIsPurgeable(true);
+ m_currentSwipeSnapshotSurface = nullptr;
</ins><span class="cx">
</span><span class="cx"> for (const auto& layer : m_currentSwipeLiveLayers)
</span><span class="cx"> [layer setTransform:CATransform3DIdentity];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewSnapshotStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h (166004 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h        2014-03-20 21:53:03 UTC (rev 166004)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -26,16 +26,13 @@
</span><span class="cx"> #ifndef ViewSnapshotStore_h
</span><span class="cx"> #define ViewSnapshotStore_h
</span><span class="cx">
</span><ins>+#include <WebCore/IOSurface.h>
</ins><span class="cx"> #include <chrono>
</span><span class="cx"> #include <wtf/HashMap.h>
</span><span class="cx"> #include <wtf/Noncopyable.h>
</span><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="cx">
</span><del>-#if USE(IOSURFACE)
-#include <IOSurface/IOSurface.h>
-#endif
-
</del><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><span class="cx"> class WebBackForwardListItem;
</span><span class="lines">@@ -51,7 +48,7 @@
</span><span class="cx">
</span><span class="cx"> void recordSnapshot(WebPageProxy&);
</span><span class="cx"> #if USE(IOSURFACE)
</span><del>- std::pair<RetainPtr<IOSurfaceRef>, uint64_t> snapshotAndRenderTreeSize(WebBackForwardListItem*);
</del><ins>+ std::pair<RefPtr<WebCore::IOSurface>, uint64_t> snapshotAndRenderTreeSize(WebBackForwardListItem*);
</ins><span class="cx"> #else
</span><span class="cx"> std::pair<RetainPtr<CGImageRef>, uint64_t> snapshotAndRenderTreeSize(WebBackForwardListItem*);
</span><span class="cx"> #endif
</span><span class="lines">@@ -64,8 +61,7 @@
</span><span class="cx">
</span><span class="cx"> struct Snapshot {
</span><span class="cx"> #if USE(IOSURFACE)
</span><del>- RetainPtr<IOSurfaceRef> surface;
- RetainPtr<CGContextRef> surfaceContext;
</del><ins>+ RefPtr<WebCore::IOSurface> surface;
</ins><span class="cx"> #else
</span><span class="cx"> RetainPtr<CGImageRef> image;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewSnapshotStoremm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm (166004 => 166005)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm        2014-03-20 21:53:03 UTC (rev 166004)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.mm        2014-03-20 22:06:38 UTC (rev 166005)
</span><span class="lines">@@ -29,29 +29,9 @@
</span><span class="cx"> #import "WebBackForwardList.h"
</span><span class="cx"> #import "WebPageProxy.h"
</span><span class="cx"> #import <CoreGraphics/CoreGraphics.h>
</span><ins>+#import <WebCore/IOSurface.h>
</ins><span class="cx"> #import <WebCore/UUID.h>
</span><span class="cx">
</span><del>-#if defined(__has_include) && __has_include(<CoreGraphics/CoreGraphicsPrivate.h>)
-#import <CoreGraphics/CoreGraphicsPrivate.h>
-#endif
-
-#if USE(IOSURFACE)
-#import <IOSurface/IOSurface.h>
-extern "C" CGContextRef CGIOSurfaceContextCreate(IOSurfaceRef surface, size_t width, size_t height, size_t bitsPerComponent, size_t bitsPerPixel, CGColorSpaceRef space, CGBitmapInfo bitmapInfo);
-
-#if defined(__has_include) && __has_include(<IOSurface/IOSurfacePrivate.h>)
-#import <IOSurface/IOSurfacePrivate.h>
-#else
-enum {
- kIOSurfacePurgeableVolatile = 1,
-};
-#endif
-
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
-extern "C" IOReturn IOSurfaceSetPurgeable(IOSurfaceRef buffer, uint32_t newState, uint32_t *oldState);
-#endif
-#endif
-
</del><span class="cx"> using namespace WebCore;
</span><span class="cx">
</span><span class="cx"> static const int maximumSnapshotCount = 20;
</span><span class="lines">@@ -119,36 +99,17 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if USE(IOSURFACE)
</span><del>-static std::pair<RetainPtr<IOSurfaceRef>, RetainPtr<CGContextRef>> createIOSurfaceFromImage(CGImageRef image)
</del><ins>+static RefPtr<IOSurface> createIOSurfaceFromImage(CGImageRef image)
</ins><span class="cx"> {
</span><del>- unsigned pixelFormat = 'BGRA';
- size_t bitsPerComponent = 8;
- size_t bitsPerPixel = 32;
- size_t bytesPerElement = 4;
</del><span class="cx"> size_t width = CGImageGetWidth(image);
</span><span class="cx"> size_t height = CGImageGetHeight(image);
</span><del>- size_t bytesPerRow = IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, width * bytesPerElement);
- ASSERT(bytesPerRow);
</del><span class="cx">
</span><del>- size_t allocSize = IOSurfaceAlignProperty(kIOSurfaceAllocSize, height * bytesPerRow);
- ASSERT(allocSize);
-
- NSDictionary *properties = @{
- (id)kIOSurfaceWidth: @(width),
- (id)kIOSurfaceHeight: @(height),
- (id)kIOSurfacePixelFormat: @(pixelFormat),
- (id)kIOSurfaceBytesPerElement: @(bytesPerElement),
- (id)kIOSurfaceBytesPerRow: @(bytesPerRow),
- (id)kIOSurfaceAllocSize: @(allocSize)
- };
-
- RetainPtr<IOSurfaceRef> surface = adoptCF(IOSurfaceCreate((CFDictionaryRef)properties));
- CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host;
- RetainPtr<CGContextRef> surfaceContext = adoptCF(CGIOSurfaceContextCreate(surface.get(), width, height, bitsPerComponent, bitsPerPixel, CGImageGetColorSpace(image), bitmapInfo));
</del><ins>+ RefPtr<IOSurface> surface = IOSurface::create(IntSize(width, height), ColorSpaceDeviceRGB);
+ RetainPtr<CGContextRef> surfaceContext = surface->ensurePlatformContext();
</ins><span class="cx"> CGContextDrawImage(surfaceContext.get(), CGRectMake(0, 0, width, height), image);
</span><span class="cx"> CGContextFlush(surfaceContext.get());
</span><span class="cx">
</span><del>- return std::make_pair(surface, surfaceContext);
</del><ins>+ return surface;
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -180,12 +141,8 @@
</span><span class="cx"> snapshot.creationTime = std::chrono::steady_clock::now();
</span><span class="cx">
</span><span class="cx"> #if USE(IOSURFACE)
</span><del>- auto surfaceAndContext = createIOSurfaceFromImage(snapshotImage.get());
- snapshot.surface = surfaceAndContext.first;
- snapshot.surfaceContext = surfaceAndContext.second;
-#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- IOSurfaceSetPurgeable(snapshot.surface.get(), kIOSurfacePurgeableVolatile, nullptr);
-#endif
</del><ins>+ snapshot.surface = createIOSurfaceFromImage(snapshotImage.get());
+ snapshot.surface->setIsPurgeable(true);
</ins><span class="cx"> #else
</span><span class="cx"> snapshot.image = snapshotImage;
</span><span class="cx"> #endif
</span><span class="lines">@@ -195,7 +152,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if USE(IOSURFACE)
</span><del>-std::pair<RetainPtr<IOSurfaceRef>, uint64_t> ViewSnapshotStore::snapshotAndRenderTreeSize(WebBackForwardListItem* item)
</del><ins>+std::pair<RefPtr<IOSurface>, uint64_t> ViewSnapshotStore::snapshotAndRenderTreeSize(WebBackForwardListItem* item)
</ins><span class="cx"> #else
</span><span class="cx"> std::pair<RetainPtr<CGImageRef>, uint64_t> ViewSnapshotStore::snapshotAndRenderTreeSize(WebBackForwardListItem* item)
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>
</body>
</html>