Title: [106311] trunk/Source/WebCore
Revision
106311
Author
[email protected]
Date
2012-01-30 18:04:09 -0800 (Mon, 30 Jan 2012)

Log Message

Show repaint counters in individual tiles
https://bugs.webkit.org/show_bug.cgi?id=77390
<rdar://problem/10767967>

Reviewed by Darin Adler.

* platform/graphics/ca/mac/TileCache.h:
* platform/graphics/ca/mac/TileCache.mm:
(WebCore::TileCache::setNeedsDisplayInRect):
Make sure to invalidate the repaint counter rect if necessary.

(WebCore::TileCache::drawLayer):
Draw the repaint counter.

(WebCore::TileCache::showRepaintCounter):
New function that determines whether we should show repaint counters for the given tile cache.

* platform/graphics/ca/mac/WebTileLayer.h:
* platform/graphics/ca/mac/WebTileLayer.mm:
(-[WebTileLayer incrementRepaintCount]):
Add method for getting the repaint count.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (106310 => 106311)


--- trunk/Source/WebCore/ChangeLog	2012-01-31 01:57:37 UTC (rev 106310)
+++ trunk/Source/WebCore/ChangeLog	2012-01-31 02:04:09 UTC (rev 106311)
@@ -1,3 +1,27 @@
+2012-01-30  Anders Carlsson  <[email protected]>
+
+        Show repaint counters in individual tiles
+        https://bugs.webkit.org/show_bug.cgi?id=77390
+        <rdar://problem/10767967>
+
+        Reviewed by Darin Adler.
+
+        * platform/graphics/ca/mac/TileCache.h:
+        * platform/graphics/ca/mac/TileCache.mm:
+        (WebCore::TileCache::setNeedsDisplayInRect):
+        Make sure to invalidate the repaint counter rect if necessary.
+
+        (WebCore::TileCache::drawLayer):
+        Draw the repaint counter.
+
+        (WebCore::TileCache::showRepaintCounter):
+        New function that determines whether we should show repaint counters for the given tile cache.
+
+        * platform/graphics/ca/mac/WebTileLayer.h:
+        * platform/graphics/ca/mac/WebTileLayer.mm:
+        (-[WebTileLayer incrementRepaintCount]):
+        Add method for getting the repaint count.
+
 2012-01-30  Dan Bernstein  <[email protected]>
 
         <rdar://problem/10778045> REGRESSION (r91935): text-combine fails

Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.h (106310 => 106311)


--- trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.h	2012-01-31 01:57:37 UTC (rev 106310)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.h	2012-01-31 02:04:09 UTC (rev 106311)
@@ -75,6 +75,8 @@
     WebTileLayer* tileLayerAtPosition(const IntPoint&) const;
     RetainPtr<WebTileLayer> createTileLayer();
 
+    bool shouldShowRepaintCounters() const;
+
     WebTileCacheLayer* m_tileCacheLayer;
     const IntSize m_tileSize;
 

Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.mm (106310 => 106311)


--- trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.mm	2012-01-31 01:57:37 UTC (rev 106310)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.mm	2012-01-31 02:04:09 UTC (rev 106311)
@@ -91,8 +91,15 @@
 
             CGRect tileRect = [m_tileCacheLayer convertRect:rect toLayer:tileLayer];
 
-            if (!CGRectIsEmpty(tileRect))
+            if (!CGRectIsEmpty(tileRect)) {
                 [tileLayer setNeedsDisplayInRect:tileRect];
+
+                if (shouldShowRepaintCounters()) {
+                    CGRect bounds = [tileLayer bounds];
+                    CGRect indicatorRect = CGRectMake(bounds.origin.x, bounds.origin.y, 52, 27);
+                    [tileLayer setNeedsDisplayInRect:indicatorRect];
+                }
+            }
         }
     }
 }
@@ -110,6 +117,37 @@
     drawLayerContents(context, layer, platformLayer);
 
     CGContextRestoreGState(context);
+
+    unsigned repaintCount = [layer incrementRepaintCount];
+    if (!shouldShowRepaintCounters())
+        return;
+
+    // FIXME: Some of this code could be shared with WebLayer.
+    char text[16]; // that's a lot of repaints
+    snprintf(text, sizeof(text), "%d", repaintCount);
+
+    CGRect indicatorBox = [layer bounds];
+    indicatorBox.size.width = 12 + 10 * strlen(text);
+    indicatorBox.size.height = 27;
+    CGContextSaveGState(context);
+
+    CGContextSetAlpha(context, 0.5f);
+    CGContextBeginTransparencyLayerWithRect(context, indicatorBox, 0);
+
+    CGContextSetFillColorWithColor(context, m_tileDebugBorderColor.get());
+    CGContextFillRect(context, indicatorBox);
+
+    if (platformLayer->acceleratesDrawing())
+        CGContextSetRGBFillColor(context, 1, 0, 0, 1);
+    else
+        CGContextSetRGBFillColor(context, 1, 1, 1, 1);
+
+    CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1, -1));
+    CGContextSelectFont(context, "Helvetica", 22, kCGEncodingMacRoman);
+    CGContextShowTextAtPoint(context, indicatorBox.origin.x + 5, indicatorBox.origin.y + 22, text, strlen(text));
+
+    CGContextEndTransparencyLayer(context);
+    CGContextRestoreGState(context);
 }
 
 void TileCache::setAcceleratesDrawing(bool acceleratesDrawing)
@@ -224,4 +262,18 @@
     return layer;
 }
 
+bool TileCache::shouldShowRepaintCounters() const
+{
+    PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
+    if (!platformLayer)
+        return false;
+
+    WebCore::PlatformCALayerClient* layerContents = platformLayer->owner();
+    ASSERT(layerContents);
+    if (!layerContents)
+        return false;
+
+    return layerContents->platformCALayerShowRepaintCounter();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.h (106310 => 106311)


--- trunk/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.h	2012-01-31 01:57:37 UTC (rev 106310)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.h	2012-01-31 02:04:09 UTC (rev 106311)
@@ -32,8 +32,11 @@
 
 @interface WebTileLayer : CALayer {
     WebCore::TileCache* _tileCache;
+    unsigned _repaintCount;
 }
+
 - (void)setTileCache:(WebCore::TileCache*)tileCache;
+- (unsigned)incrementRepaintCount;
 @end
 
 

Modified: trunk/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.mm (106310 => 106311)


--- trunk/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.mm	2012-01-31 01:57:37 UTC (rev 106310)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.mm	2012-01-31 02:04:09 UTC (rev 106311)
@@ -52,5 +52,10 @@
     _tileCache = tileCache;
 }
 
+- (unsigned)incrementRepaintCount
+{
+    return ++_repaintCount;
+}
+
 @end
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to