Commit f2826416 authored by andersca@apple.com's avatar andersca@apple.com

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.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106311 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3c1842d0
2012-01-30 Anders Carlsson <andersca@apple.com>
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 <mitz@apple.com>
<rdar://problem/10778045> REGRESSION (r91935): text-combine fails
......@@ -75,6 +75,8 @@ private:
WebTileLayer* tileLayerAtPosition(const IntPoint&) const;
RetainPtr<WebTileLayer> createTileLayer();
bool shouldShowRepaintCounters() const;
WebTileCacheLayer* m_tileCacheLayer;
const IntSize m_tileSize;
......
......@@ -91,8 +91,15 @@ void TileCache::setNeedsDisplayInRect(const IntRect& rect)
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 @@ void TileCache::drawLayer(WebTileLayer* layer, CGContextRef context)
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 @@ RetainPtr<WebTileLayer> TileCache::createTileLayer()
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
......@@ -32,8 +32,11 @@ namespace WebCore {
@interface WebTileLayer : CALayer {
WebCore::TileCache* _tileCache;
unsigned _repaintCount;
}
- (void)setTileCache:(WebCore::TileCache*)tileCache;
- (unsigned)incrementRepaintCount;
@end
......
......@@ -52,5 +52,10 @@ using namespace WebCore;
_tileCache = tileCache;
}
- (unsigned)incrementRepaintCount
{
return ++_repaintCount;
}
@end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment