<!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>[169960] trunk/Source/WebCore</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/169960">169960</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2014-06-13 19:59:00 -0700 (Fri, 13 Jun 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move utility functions from WebLayer to PlatformCALayer
https://bugs.webkit.org/show_bug.cgi?id=133887
<rdar://problem/17309622>
Reviewed by Simon Fraser.
Move some utility functions from WebLayer.h/.mm to PlatformCALayer.
Provide ObjC implementation in PlatformCALayerMac. A future patch will
provide corresponding Windows versions.
* WebCore.exp.in:
* platform/graphics/ca/PlatformCALayer.cpp:
(WebCore::PlatformCALayer::drawRepaintIndicator):
* platform/graphics/ca/PlatformCALayer.h:
* platform/graphics/ca/TileController.cpp:
(WebCore::TileController::blankPixelCountForTiles):
* platform/graphics/ca/TileGrid.cpp:
(WebCore::TileGrid::platformCALayerPaintContents):
* platform/graphics/ca/mac/PlatformCALayerMac.mm:
(PlatformCALayer::collectRectsToPaint):
(PlatformCALayer::drawLayerContents):
(PlatformCALayer::frameForLayer):
* platform/graphics/mac/WebLayer.h:
* platform/graphics/mac/WebLayer.mm:
(-[WebLayer drawInContext:]):
(WebCore::collectRectsToPaint): Deleted.
(WebCore::drawLayerContents): Deleted.
(WebCore::drawRepaintIndicator): Deleted.
(WebCore::frameForLayer): Deleted.</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="#trunkSourceWebCoreplatformgraphicscaPlatformCALayercpp">trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaPlatformCALayerh">trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaTileControllercpp">trunk/Source/WebCore/platform/graphics/ca/TileController.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscaTileGridcpp">trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscamacPlatformCALayerMacmm">trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacWebLayerh">trunk/Source/WebCore/platform/graphics/mac/WebLayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacWebLayermm">trunk/Source/WebCore/platform/graphics/mac/WebLayer.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (169959 => 169960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-06-14 00:35:13 UTC (rev 169959)
+++ trunk/Source/WebCore/ChangeLog        2014-06-14 02:59:00 UTC (rev 169960)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2014-06-13 Brent Fulgham <bfulgham@apple.com>
+
+ Move utility functions from WebLayer to PlatformCALayer
+ https://bugs.webkit.org/show_bug.cgi?id=133887
+ <rdar://problem/17309622>
+
+ Reviewed by Simon Fraser.
+
+ Move some utility functions from WebLayer.h/.mm to PlatformCALayer.
+ Provide ObjC implementation in PlatformCALayerMac. A future patch will
+ provide corresponding Windows versions.
+
+ * WebCore.exp.in:
+ * platform/graphics/ca/PlatformCALayer.cpp:
+ (WebCore::PlatformCALayer::drawRepaintIndicator):
+ * platform/graphics/ca/PlatformCALayer.h:
+ * platform/graphics/ca/TileController.cpp:
+ (WebCore::TileController::blankPixelCountForTiles):
+ * platform/graphics/ca/TileGrid.cpp:
+ (WebCore::TileGrid::platformCALayerPaintContents):
+ * platform/graphics/ca/mac/PlatformCALayerMac.mm:
+ (PlatformCALayer::collectRectsToPaint):
+ (PlatformCALayer::drawLayerContents):
+ (PlatformCALayer::frameForLayer):
+ * platform/graphics/mac/WebLayer.h:
+ * platform/graphics/mac/WebLayer.mm:
+ (-[WebLayer drawInContext:]):
+ (WebCore::collectRectsToPaint): Deleted.
+ (WebCore::drawLayerContents): Deleted.
+ (WebCore::drawRepaintIndicator): Deleted.
+ (WebCore::frameForLayer): Deleted.
+
</ins><span class="cx"> 2014-06-13 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> Unreviewed disabling css jit on armv7. It's not quite ready yet.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (169959 => 169960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-06-14 00:35:13 UTC (rev 169959)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-06-14 02:59:00 UTC (rev 169960)
</span><span class="lines">@@ -600,6 +600,7 @@
</span><span class="cx"> __ZN7WebCore15PasteboardImageC1Ev
</span><span class="cx"> __ZN7WebCore15PasteboardImageD1Ev
</span><span class="cx"> __ZN7WebCore15PlatformCALayer15platformCALayerEPv
</span><ins>+__ZN7WebCore15PlatformCALayer17drawLayerContentsEP9CGContextPS0_RN3WTF6VectorINS_9FloatRectELm5ENS4_15CrashOnOverflowEEE
</ins><span class="cx"> __ZN7WebCore15PlatformCALayerC2ENS0_9LayerTypeEPNS_21PlatformCALayerClientE
</span><span class="cx"> __ZN7WebCore15PlatformCALayerD2Ev
</span><span class="cx"> __ZN7WebCore15ProtectionSpaceC1ERKN3WTF6StringEiNS_25ProtectionSpaceServerTypeES4_NS_35ProtectionSpaceAuthenticationSchemeE
</span><span class="lines">@@ -758,7 +759,6 @@
</span><span class="cx"> __ZN7WebCore17SQLiteTransactionD1Ev
</span><span class="cx"> __ZN7WebCore17SubresourceLoader6createEPNS_5FrameEPNS_14CachedResourceERKNS_15ResourceRequestERKNS_21ResourceLoaderOptionsE
</span><span class="cx"> __ZN7WebCore17cacheDOMStructureEPNS_17JSDOMGlobalObjectEPN3JSC9StructureEPKNS2_9ClassInfoE
</span><del>-__ZN7WebCore17drawLayerContentsEP9CGContextPNS_15PlatformCALayerERN3WTF6VectorINS_9FloatRectELm5ENS4_15CrashOnOverflowEEE
</del><span class="cx"> __ZN7WebCore17encodeForFileNameERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore17jsStringWithCacheEPN3JSC9ExecStateERKN3WTF6StringE
</span><span class="cx"> __ZN7WebCore17languageDidChangeEv
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaPlatformCALayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp (169959 => 169960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp        2014-06-14 00:35:13 UTC (rev 169959)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp        2014-06-14 02:59:00 UTC (rev 169960)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2013-2014 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -50,6 +50,42 @@
</span><span class="cx"> setOwner(nullptr);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void PlatformCALayer::drawRepaintIndicator(CGContextRef context, PlatformCALayer* platformCALayer, int repaintCount, CGColorRef customBackgroundColor)
+{
+ char text[16]; // that's a lot of repaints
+ snprintf(text, sizeof(text), "%d", repaintCount);
+
+ CGRect indicatorBox = platformCALayer->bounds();
+ indicatorBox.size.width = 12 + 10 * strlen(text);
+ indicatorBox.size.height = 27;
+ CGContextSaveGState(context);
+
+ CGContextSetAlpha(context, 0.5f);
+ CGContextBeginTransparencyLayerWithRect(context, indicatorBox, 0);
+
+ if (customBackgroundColor)
+ CGContextSetFillColorWithColor(context, customBackgroundColor);
+ else
+ CGContextSetRGBFillColor(context, 0, 0.5f, 0.25f, 1);
+
+ CGContextFillRect(context, indicatorBox);
+
+ if (platformCALayer->acceleratesDrawing())
+ CGContextSetRGBFillColor(context, 1, 0, 0, 1);
+ else
+ CGContextSetRGBFillColor(context, 1, 1, 1, 1);
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1, -1));
+ CGContextSelectFont(context, "Helvetica", 22, kCGEncodingMacRoman);
+ CGContextShowTextAtPoint(context, indicatorBox.origin.x + 5, indicatorBox.origin.y + 22, text, strlen(text));
+#pragma clang diagnostic pop
+
+ CGContextEndTransparencyLayer(context);
+ CGContextRestoreGState(context);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+}
+
</ins><span class="cx"> #endif // USE(CA)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaPlatformCALayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h (169959 => 169960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h        2014-06-14 00:35:13 UTC (rev 169959)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h        2014-06-14 02:59:00 UTC (rev 169960)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -226,7 +226,18 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx"> virtual void enumerateRectsBeingDrawn(CGContextRef, void (^block)(CGRect)) = 0;
</span><ins>+
+ static const unsigned webLayerMaxRectsToPaint = 5;
+ constexpr static const float webLayerWastedSpaceThreshold = 0.75f;
+
+ typedef Vector<FloatRect, webLayerMaxRectsToPaint> RepaintRectList;
+
+ // Functions allows us to share implementation across WebTiledLayer and WebLayer
+ static RepaintRectList collectRectsToPaint(CGContextRef, PlatformCALayer*);
+ static void drawLayerContents(CGContextRef, PlatformCALayer*, RepaintRectList& dirtyRects);
</ins><span class="cx"> #endif
</span><ins>+ static void drawRepaintIndicator(CGContextRef, PlatformCALayer*, int repaintCount, CGColorRef customBackgroundColor);
+ static CGRect frameForLayer(const PlatformLayer*);
</ins><span class="cx">
</span><span class="cx"> protected:
</span><span class="cx"> PlatformCALayer(LayerType, PlatformCALayerClient* owner);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaTileControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.cpp (169959 => 169960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/TileController.cpp        2014-06-14 00:35:13 UTC (rev 169959)
+++ trunk/Source/WebCore/platform/graphics/ca/TileController.cpp        2014-06-14 02:59:00 UTC (rev 169960)
</span><span class="lines">@@ -383,7 +383,7 @@
</span><span class="cx"> for (PlatformLayerList::const_iterator it = tiles.begin(), end = tiles.end(); it != end; ++it) {
</span><span class="cx"> const PlatformLayer* tileLayer = it->get();
</span><span class="cx">
</span><del>- FloatRect visiblePart(CGRectOffset(frameForLayer(tileLayer), tileTranslation.x(), tileTranslation.y()));
</del><ins>+ FloatRect visiblePart(CGRectOffset(PlatformCALayer::frameForLayer(tileLayer), tileTranslation.x(), tileTranslation.y()));
</ins><span class="cx"> visiblePart.intersect(visibleRect);
</span><span class="cx">
</span><span class="cx"> if (!visiblePart.isEmpty())
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscaTileGridcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp (169959 => 169960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp        2014-06-14 00:35:13 UTC (rev 169959)
+++ trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp        2014-06-14 02:59:00 UTC (rev 169960)
</span><span class="lines">@@ -30,7 +30,6 @@
</span><span class="cx"> #include "LayerPool.h"
</span><span class="cx"> #include "PlatformCALayer.h"
</span><span class="cx"> #include "TileController.h"
</span><del>-#include "WebLayer.h"
</del><span class="cx"> #include <wtf/MainThread.h>
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -651,13 +650,13 @@
</span><span class="cx"> context.translate(-layerOrigin.x(), -layerOrigin.y());
</span><span class="cx"> context.scale(FloatSize(m_scale, m_scale));
</span><span class="cx">
</span><del>- RepaintRectList dirtyRects = collectRectsToPaint(context.platformContext(), platformCALayer);
- drawLayerContents(context.platformContext(), &m_controller.rootLayer(), dirtyRects);
</del><ins>+ PlatformCALayer::RepaintRectList dirtyRects = PlatformCALayer::collectRectsToPaint(context.platformContext(), platformCALayer);
+ PlatformCALayer::drawLayerContents(context.platformContext(), &m_controller.rootLayer(), dirtyRects);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int repaintCount = platformCALayerIncrementRepaintCount(platformCALayer);
</span><span class="cx"> if (m_controller.rootLayer().owner()->platformCALayerShowRepaintCounter(0))
</span><del>- drawRepaintIndicator(context.platformContext(), platformCALayer, repaintCount, cachedCGColor(m_controller.tileDebugBorderColor(), ColorSpaceDeviceRGB));
</del><ins>+ PlatformCALayer::drawRepaintIndicator(context.platformContext(), platformCALayer, repaintCount, cachedCGColor(m_controller.tileDebugBorderColor(), ColorSpaceDeviceRGB));
</ins><span class="cx">
</span><span class="cx"> if (m_controller.scrollingPerformanceLoggingEnabled()) {
</span><span class="cx"> FloatRect visiblePart(platformCALayer->position().x(), platformCALayer->position().y(), platformCALayer->bounds().size().width(), platformCALayer->bounds().size().height());
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscamacPlatformCALayerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm (169959 => 169960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm        2014-06-14 00:35:13 UTC (rev 169959)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm        2014-06-14 02:59:00 UTC (rev 169960)
</span><span class="lines">@@ -51,12 +51,17 @@
</span><span class="cx"> #import <wtf/RetainPtr.h>
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><ins>+#import "WAKWindow.h"
+#import "WKGraphics.h"
</ins><span class="cx"> #import "WebCoreThread.h"
</span><span class="cx"> #import "WebTiledLayer.h"
</span><span class="cx"> #import <Foundation/NSGeometry.h>
</span><span class="cx"> #import <QuartzCore/CATiledLayerPrivate.h>
</span><ins>+#else
+#import "ThemeMac.h"
</ins><span class="cx"> #endif
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
</span><span class="cx"> SOFT_LINK_CLASS(AVFoundation, AVPlayerLayer)
</span><span class="cx">
</span><span class="lines">@@ -843,6 +848,116 @@
</span><span class="cx"> }
</span><span class="cx"> #endif // PLATFORM(IOS)
</span><span class="cx">
</span><ins>+PlatformCALayer::RepaintRectList PlatformCALayer::collectRectsToPaint(CGContextRef context, PlatformCALayer* platformCALayer)
+{
+ __block double totalRectArea = 0;
+ __block unsigned rectCount = 0;
+ __block RepaintRectList dirtyRects;
+
+ platformCALayer->enumerateRectsBeingDrawn(context, ^(CGRect rect) {
+ if (++rectCount > webLayerMaxRectsToPaint)
+ return;
+
+ totalRectArea += rect.size.width * rect.size.height;
+ dirtyRects.append(rect);
+ });
+
+ FloatRect clipBounds = CGContextGetClipBoundingBox(context);
+ double clipArea = clipBounds.width() * clipBounds.height();
+
+ if (rectCount >= webLayerMaxRectsToPaint || totalRectArea >= clipArea * webLayerWastedSpaceThreshold) {
+ dirtyRects.clear();
+ dirtyRects.append(clipBounds);
+ }
+
+ return dirtyRects;
+}
+
+void PlatformCALayer::drawLayerContents(CGContextRef context, WebCore::PlatformCALayer* platformCALayer, RepaintRectList& dirtyRects)
+{
+ WebCore::PlatformCALayerClient* layerContents = platformCALayer->owner();
+ if (!layerContents)
+ return;
+
+#if PLATFORM(IOS)
+ WKSetCurrentGraphicsContext(context);
+#endif
+
+ CGContextSaveGState(context);
+
+ // We never use CompositingCoordinatesBottomUp on Mac.
+ ASSERT(layerContents->platformCALayerContentsOrientation() == GraphicsLayer::CompositingCoordinatesTopDown);
+
+#if PLATFORM(IOS)
+ WKFontAntialiasingStateSaver fontAntialiasingState(context, [platformCALayer->platformLayer() isOpaque]);
+ fontAntialiasingState.setup([WAKWindow hasLandscapeOrientation]);
+#else
+ [NSGraphicsContext saveGraphicsState];
+
+ // Set up an NSGraphicsContext for the context, so that parts of AppKit that rely on
+ // the current NSGraphicsContext (e.g. NSCell drawing) get the right one.
+ NSGraphicsContext* layerContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:YES];
+ [NSGraphicsContext setCurrentContext:layerContext];
+#endif
+
+ GraphicsContext graphicsContext(context);
+ graphicsContext.setIsCALayerContext(true);
+ graphicsContext.setIsAcceleratedContext(platformCALayer->acceleratesDrawing());
+
+ if (!layerContents->platformCALayerContentsOpaque()) {
+ // Turn off font smoothing to improve the appearance of text rendered onto a transparent background.
+ graphicsContext.setShouldSmoothFonts(false);
+ }
+
+#if !PLATFORM(IOS)
+ // It's important to get the clip from the context, because it may be significantly
+ // smaller than the layer bounds (e.g. tiled layers)
+ FloatRect clipBounds = CGContextGetClipBoundingBox(context);
+
+ FloatRect focusRingClipRect = clipBounds;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1090
+ // Set the focus ring clip rect which needs to be in base coordinates.
+ AffineTransform transform = CGContextGetCTM(context);
+ focusRingClipRect = transform.mapRect(clipBounds);
+#endif
+ ThemeMac::setFocusRingClipRect(focusRingClipRect);
+#endif // !PLATFORM(IOS)
+
+ for (const auto& rect : dirtyRects) {
+ GraphicsContextStateSaver stateSaver(graphicsContext);
+ graphicsContext.clip(rect);
+
+ layerContents->platformCALayerPaintContents(platformCALayer, graphicsContext, rect);
+ }
+
+#if PLATFORM(IOS)
+ fontAntialiasingState.restore();
+#else
+ ThemeMac::setFocusRingClipRect(FloatRect());
+
+ [NSGraphicsContext restoreGraphicsState];
+#endif
+
+ // Re-fetch the layer owner, since <rdar://problem/9125151> indicates that it might have been destroyed during painting.
+ layerContents = platformCALayer->owner();
+ ASSERT(layerContents);
+
+ CGContextRestoreGState(context);
+
+ // Always update the repaint count so that it's accurate even if the count itself is not shown. This will be useful
+ // for the Web Inspector feeding this information through the LayerTreeAgent.
+ int repaintCount = layerContents->platformCALayerIncrementRepaintCount(platformCALayer);
+
+ if (!platformCALayer->usesTiledBackingLayer() && layerContents && layerContents->platformCALayerShowRepaintCounter(platformCALayer))
+ drawRepaintIndicator(context, platformCALayer, repaintCount, nullptr);
+}
+
+CGRect PlatformCALayer::frameForLayer(const PlatformLayer* tileLayer)
+{
+ return [tileLayer frame];
+}
+
+
</ins><span class="cx"> PassRefPtr<PlatformCALayer> PlatformCALayerMac::createCompatibleLayer(PlatformCALayer::LayerType layerType, PlatformCALayerClient* client) const
</span><span class="cx"> {
</span><span class="cx"> return PlatformCALayerMac::create(layerType, client);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacWebLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/WebLayer.h (169959 => 169960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/WebLayer.h        2014-06-14 00:35:13 UTC (rev 169959)
+++ trunk/Source/WebCore/platform/graphics/mac/WebLayer.h        2014-06-14 02:59:00 UTC (rev 169960)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2009 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2009, 2014 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -26,14 +26,8 @@
</span><span class="cx"> #ifndef WebLayer_h
</span><span class="cx"> #define WebLayer_h
</span><span class="cx">
</span><del>-#include "FloatRect.h"
-#include "PlatformLayer.h"
</del><span class="cx"> #include <QuartzCore/QuartzCore.h>
</span><del>-#include <wtf/Vector.h>
</del><span class="cx">
</span><del>-const unsigned webLayerMaxRectsToPaint = 5;
-const float webLayerWastedSpaceThreshold = 0.75f;
-
</del><span class="cx"> #ifdef __OBJC__
</span><span class="cx"> @interface WebSimpleLayer : CALayer
</span><span class="cx"> @end
</span><span class="lines">@@ -42,18 +36,4 @@
</span><span class="cx"> @end
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-namespace WebCore {
-class GraphicsLayer;
-class PlatformCALayer;
-class PlatformCALayerClient;
-
-typedef Vector<FloatRect, webLayerMaxRectsToPaint> RepaintRectList;
-
-// Functions allows us to share implementation across WebTiledLayer and WebLayer
-RepaintRectList collectRectsToPaint(CGContextRef, PlatformCALayer*);
-void drawLayerContents(CGContextRef, PlatformCALayer*, RepaintRectList& dirtyRects);
-void drawRepaintIndicator(CGContextRef, PlatformCALayer*, int repaintCount, CGColorRef customBackgroundColor);
-CGRect frameForLayer(const PlatformLayer*);
-}
-
</del><span class="cx"> #endif // WebLayer_h
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacWebLayermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/WebLayer.mm (169959 => 169960)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/WebLayer.mm        2014-06-14 00:35:13 UTC (rev 169959)
+++ trunk/Source/WebCore/platform/graphics/mac/WebLayer.mm        2014-06-14 02:59:00 UTC (rev 169960)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2009 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2009, 2014 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -37,10 +37,6 @@
</span><span class="cx"> #import "WebCoreThread.h"
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if !PLATFORM(IOS)
-#import "ThemeMac.h"
-#endif
-
</del><span class="cx"> @interface CALayer(WebCoreCALayerPrivate)
</span><span class="cx"> - (void)reloadValueForKeyPath:(NSString *)keyPath;
</span><span class="cx"> @end
</span><span class="lines">@@ -53,163 +49,14 @@
</span><span class="cx"> @end
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-namespace WebCore {
-
-RepaintRectList collectRectsToPaint(CGContextRef context, PlatformCALayer* platformCALayer)
-{
- __block double totalRectArea = 0;
- __block unsigned rectCount = 0;
- __block RepaintRectList dirtyRects;
-
- platformCALayer->enumerateRectsBeingDrawn(context, ^(CGRect rect) {
- if (++rectCount > webLayerMaxRectsToPaint)
- return;
-
- totalRectArea += rect.size.width * rect.size.height;
- dirtyRects.append(rect);
- });
-
- FloatRect clipBounds = CGContextGetClipBoundingBox(context);
- double clipArea = clipBounds.width() * clipBounds.height();
-
- if (rectCount >= webLayerMaxRectsToPaint || totalRectArea >= clipArea * webLayerWastedSpaceThreshold) {
- dirtyRects.clear();
- dirtyRects.append(clipBounds);
- }
-
- return dirtyRects;
-}
-
-void drawLayerContents(CGContextRef context, WebCore::PlatformCALayer* platformCALayer, RepaintRectList& dirtyRects)
-{
- WebCore::PlatformCALayerClient* layerContents = platformCALayer->owner();
- if (!layerContents)
- return;
-
-#if PLATFORM(IOS)
- WKSetCurrentGraphicsContext(context);
-#endif
-
- CGContextSaveGState(context);
-
- // We never use CompositingCoordinatesBottomUp on Mac.
- ASSERT(layerContents->platformCALayerContentsOrientation() == GraphicsLayer::CompositingCoordinatesTopDown);
-
-#if PLATFORM(IOS)
- WKFontAntialiasingStateSaver fontAntialiasingState(context, [platformCALayer->platformLayer() isOpaque]);
- fontAntialiasingState.setup([WAKWindow hasLandscapeOrientation]);
-#else
- [NSGraphicsContext saveGraphicsState];
-
- // Set up an NSGraphicsContext for the context, so that parts of AppKit that rely on
- // the current NSGraphicsContext (e.g. NSCell drawing) get the right one.
- NSGraphicsContext* layerContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:YES];
- [NSGraphicsContext setCurrentContext:layerContext];
-#endif
-
- GraphicsContext graphicsContext(context);
- graphicsContext.setIsCALayerContext(true);
- graphicsContext.setIsAcceleratedContext(platformCALayer->acceleratesDrawing());
-
- if (!layerContents->platformCALayerContentsOpaque()) {
- // Turn off font smoothing to improve the appearance of text rendered onto a transparent background.
- graphicsContext.setShouldSmoothFonts(false);
- }
-
-#if !PLATFORM(IOS)
- // It's important to get the clip from the context, because it may be significantly
- // smaller than the layer bounds (e.g. tiled layers)
- FloatRect clipBounds = CGContextGetClipBoundingBox(context);
-
- FloatRect focusRingClipRect = clipBounds;
-#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1090
- // Set the focus ring clip rect which needs to be in base coordinates.
- AffineTransform transform = CGContextGetCTM(context);
- focusRingClipRect = transform.mapRect(clipBounds);
-#endif
- ThemeMac::setFocusRingClipRect(focusRingClipRect);
-#endif // !PLATFORM(IOS)
-
- for (const auto& rect : dirtyRects) {
- GraphicsContextStateSaver stateSaver(graphicsContext);
- graphicsContext.clip(rect);
-
- layerContents->platformCALayerPaintContents(platformCALayer, graphicsContext, rect);
- }
-
-#if PLATFORM(IOS)
- fontAntialiasingState.restore();
-#else
- ThemeMac::setFocusRingClipRect(FloatRect());
-
- [NSGraphicsContext restoreGraphicsState];
-#endif
-
- // Re-fetch the layer owner, since <rdar://problem/9125151> indicates that it might have been destroyed during painting.
- layerContents = platformCALayer->owner();
- ASSERT(layerContents);
-
- CGContextRestoreGState(context);
-
- // Always update the repaint count so that it's accurate even if the count itself is not shown. This will be useful
- // for the Web Inspector feeding this information through the LayerTreeAgent.
- int repaintCount = layerContents->platformCALayerIncrementRepaintCount(platformCALayer);
-
- if (!platformCALayer->usesTiledBackingLayer() && layerContents && layerContents->platformCALayerShowRepaintCounter(platformCALayer))
- drawRepaintIndicator(context, platformCALayer, repaintCount, nullptr);
-}
-
-void drawRepaintIndicator(CGContextRef context, PlatformCALayer* platformCALayer, int repaintCount, CGColorRef customBackgroundColor)
-{
- char text[16]; // that's a lot of repaints
- snprintf(text, sizeof(text), "%d", repaintCount);
-
- CGRect indicatorBox = platformCALayer->bounds();
- indicatorBox.size.width = 12 + 10 * strlen(text);
- indicatorBox.size.height = 27;
- CGContextSaveGState(context);
-
- CGContextSetAlpha(context, 0.5f);
- CGContextBeginTransparencyLayerWithRect(context, indicatorBox, 0);
-
- if (customBackgroundColor)
- CGContextSetFillColorWithColor(context, customBackgroundColor);
- else
- CGContextSetRGBFillColor(context, 0, 0.5f, 0.25f, 1);
-
- CGContextFillRect(context, indicatorBox);
-
- if (platformCALayer->acceleratesDrawing())
- CGContextSetRGBFillColor(context, 1, 0, 0, 1);
- else
- CGContextSetRGBFillColor(context, 1, 1, 1, 1);
-
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1, -1));
- CGContextSelectFont(context, "Helvetica", 22, kCGEncodingMacRoman);
- CGContextShowTextAtPoint(context, indicatorBox.origin.x + 5, indicatorBox.origin.y + 22, text, strlen(text));
-#pragma clang diagnostic pop
-
- CGContextEndTransparencyLayer(context);
- CGContextRestoreGState(context);
-}
-
-CGRect frameForLayer(const PlatformLayer* tileLayer)
-{
- return [tileLayer frame];
-}
-
-}
-
</del><span class="cx"> @implementation WebLayer
</span><span class="cx">
</span><span class="cx"> - (void)drawInContext:(CGContextRef)context
</span><span class="cx"> {
</span><span class="cx"> PlatformCALayer* layer = PlatformCALayer::platformCALayer(self);
</span><span class="cx"> if (layer) {
</span><del>- RepaintRectList rectsToPaint = collectRectsToPaint(context, layer);
- drawLayerContents(context, layer, rectsToPaint);
</del><ins>+ PlatformCALayer::RepaintRectList rectsToPaint = PlatformCALayer::collectRectsToPaint(context, layer);
+ PlatformCALayer::drawLayerContents(context, layer, rectsToPaint);
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>