Title: [169960] trunk/Source/WebCore
Revision
169960
Author
bfulg...@apple.com
Date
2014-06-13 19:59:00 -0700 (Fri, 13 Jun 2014)

Log Message

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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (169959 => 169960)


--- 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)
@@ -1,3 +1,35 @@
+2014-06-13  Brent Fulgham  <bfulg...@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.
+
 2014-06-13  Alex Christensen  <achristen...@webkit.org>
 
         Unreviewed disabling css jit on armv7.  It's not quite ready yet.

Modified: trunk/Source/WebCore/WebCore.exp.in (169959 => 169960)


--- 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)
@@ -600,6 +600,7 @@
 __ZN7WebCore15PasteboardImageC1Ev
 __ZN7WebCore15PasteboardImageD1Ev
 __ZN7WebCore15PlatformCALayer15platformCALayerEPv
+__ZN7WebCore15PlatformCALayer17drawLayerContentsEP9CGContextPS0_RN3WTF6VectorINS_9FloatRectELm5ENS4_15CrashOnOverflowEEE
 __ZN7WebCore15PlatformCALayerC2ENS0_9LayerTypeEPNS_21PlatformCALayerClientE
 __ZN7WebCore15PlatformCALayerD2Ev
 __ZN7WebCore15ProtectionSpaceC1ERKN3WTF6StringEiNS_25ProtectionSpaceServerTypeES4_NS_35ProtectionSpaceAuthenticationSchemeE
@@ -758,7 +759,6 @@
 __ZN7WebCore17SQLiteTransactionD1Ev
 __ZN7WebCore17SubresourceLoader6createEPNS_5FrameEPNS_14CachedResourceERKNS_15ResourceRequestERKNS_21ResourceLoaderOptionsE
 __ZN7WebCore17cacheDOMStructureEPNS_17JSDOMGlobalObjectEPN3JSC9StructureEPKNS2_9ClassInfoE
-__ZN7WebCore17drawLayerContentsEP9CGContextPNS_15PlatformCALayerERN3WTF6VectorINS_9FloatRectELm5ENS4_15CrashOnOverflowEEE
 __ZN7WebCore17encodeForFileNameERKN3WTF6StringE
 __ZN7WebCore17jsStringWithCacheEPN3JSC9ExecStateERKN3WTF6StringE
 __ZN7WebCore17languageDidChangeEv

Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp (169959 => 169960)


--- 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)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-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
@@ -50,6 +50,42 @@
     setOwner(nullptr);
 }
 
+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);
 }
 
+}
+
 #endif // USE(CA)

Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h (169959 => 169960)


--- 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)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 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
@@ -226,7 +226,18 @@
 
 #if PLATFORM(COCOA)
     virtual void enumerateRectsBeingDrawn(CGContextRef, void (^block)(CGRect)) = 0;
+
+    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);
 #endif
+    static void drawRepaintIndicator(CGContextRef, PlatformCALayer*, int repaintCount, CGColorRef customBackgroundColor);
+    static CGRect frameForLayer(const PlatformLayer*);
 
 protected:
     PlatformCALayer(LayerType, PlatformCALayerClient* owner);

Modified: trunk/Source/WebCore/platform/graphics/ca/TileController.cpp (169959 => 169960)


--- 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)
@@ -383,7 +383,7 @@
     for (PlatformLayerList::const_iterator it = tiles.begin(), end = tiles.end(); it != end; ++it) {
         const PlatformLayer* tileLayer = it->get();
 
-        FloatRect visiblePart(CGRectOffset(frameForLayer(tileLayer), tileTranslation.x(), tileTranslation.y()));
+        FloatRect visiblePart(CGRectOffset(PlatformCALayer::frameForLayer(tileLayer), tileTranslation.x(), tileTranslation.y()));
         visiblePart.intersect(visibleRect);
 
         if (!visiblePart.isEmpty())

Modified: trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp (169959 => 169960)


--- 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)
@@ -30,7 +30,6 @@
 #include "LayerPool.h"
 #include "PlatformCALayer.h"
 #include "TileController.h"
-#include "WebLayer.h"
 #include <wtf/MainThread.h>
 
 #if PLATFORM(IOS)
@@ -651,13 +650,13 @@
         context.translate(-layerOrigin.x(), -layerOrigin.y());
         context.scale(FloatSize(m_scale, m_scale));
 
-        RepaintRectList dirtyRects = collectRectsToPaint(context.platformContext(), platformCALayer);
-        drawLayerContents(context.platformContext(), &m_controller.rootLayer(), dirtyRects);
+        PlatformCALayer::RepaintRectList dirtyRects = PlatformCALayer::collectRectsToPaint(context.platformContext(), platformCALayer);
+        PlatformCALayer::drawLayerContents(context.platformContext(), &m_controller.rootLayer(), dirtyRects);
     }
 
     int repaintCount = platformCALayerIncrementRepaintCount(platformCALayer);
     if (m_controller.rootLayer().owner()->platformCALayerShowRepaintCounter(0))
-        drawRepaintIndicator(context.platformContext(), platformCALayer, repaintCount, cachedCGColor(m_controller.tileDebugBorderColor(), ColorSpaceDeviceRGB));
+        PlatformCALayer::drawRepaintIndicator(context.platformContext(), platformCALayer, repaintCount, cachedCGColor(m_controller.tileDebugBorderColor(), ColorSpaceDeviceRGB));
 
     if (m_controller.scrollingPerformanceLoggingEnabled()) {
         FloatRect visiblePart(platformCALayer->position().x(), platformCALayer->position().y(), platformCALayer->bounds().size().width(), platformCALayer->bounds().size().height());

Modified: trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm (169959 => 169960)


--- 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)
@@ -51,12 +51,17 @@
 #import <wtf/RetainPtr.h>
 
 #if PLATFORM(IOS)
+#import "WAKWindow.h"
+#import "WKGraphics.h"
 #import "WebCoreThread.h"
 #import "WebTiledLayer.h"
 #import <Foundation/NSGeometry.h>
 #import <QuartzCore/CATiledLayerPrivate.h>
+#else
+#import "ThemeMac.h"
 #endif
 
+
 SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
 SOFT_LINK_CLASS(AVFoundation, AVPlayerLayer)
 
@@ -843,6 +848,116 @@
 }
 #endif // PLATFORM(IOS)
 
+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];
+}
+
+
 PassRefPtr<PlatformCALayer> PlatformCALayerMac::createCompatibleLayer(PlatformCALayer::LayerType layerType, PlatformCALayerClient* client) const
 {
     return PlatformCALayerMac::create(layerType, client);

Modified: trunk/Source/WebCore/platform/graphics/mac/WebLayer.h (169959 => 169960)


--- 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)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 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
@@ -26,14 +26,8 @@
 #ifndef WebLayer_h
 #define WebLayer_h
 
-#include "FloatRect.h"
-#include "PlatformLayer.h"
 #include <QuartzCore/QuartzCore.h>
-#include <wtf/Vector.h>
 
-const unsigned webLayerMaxRectsToPaint = 5;
-const float webLayerWastedSpaceThreshold = 0.75f;
-
 #ifdef __OBJC__
 @interface WebSimpleLayer : CALayer
 @end
@@ -42,18 +36,4 @@
 @end
 #endif
 
-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*);
-}
-
 #endif // WebLayer_h

Modified: trunk/Source/WebCore/platform/graphics/mac/WebLayer.mm (169959 => 169960)


--- 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)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 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
@@ -37,10 +37,6 @@
 #import "WebCoreThread.h"
 #endif
 
-#if !PLATFORM(IOS)
-#import "ThemeMac.h"
-#endif
-
 @interface CALayer(WebCoreCALayerPrivate)
 - (void)reloadValueForKeyPath:(NSString *)keyPath;
 @end
@@ -53,163 +49,14 @@
 @end
 #endif
 
-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];
-}
-
-}
-
 @implementation WebLayer
 
 - (void)drawInContext:(CGContextRef)context
 {
     PlatformCALayer* layer = PlatformCALayer::platformCALayer(self);
     if (layer) {
-        RepaintRectList rectsToPaint = collectRectsToPaint(context, layer);
-        drawLayerContents(context, layer, rectsToPaint);
+        PlatformCALayer::RepaintRectList rectsToPaint = PlatformCALayer::collectRectsToPaint(context, layer);
+        PlatformCALayer::drawLayerContents(context, layer, rectsToPaint);
     }
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to