Changeset 106311 in webkit


Ignore:
Timestamp:
Jan 30, 2012 6:04:09 PM (12 years ago)
Author:
andersca@apple.com
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.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r106310 r106311  
     12012-01-30  Anders Carlsson  <andersca@apple.com>
     2
     3        Show repaint counters in individual tiles
     4        https://bugs.webkit.org/show_bug.cgi?id=77390
     5        <rdar://problem/10767967>
     6
     7        Reviewed by Darin Adler.
     8
     9        * platform/graphics/ca/mac/TileCache.h:
     10        * platform/graphics/ca/mac/TileCache.mm:
     11        (WebCore::TileCache::setNeedsDisplayInRect):
     12        Make sure to invalidate the repaint counter rect if necessary.
     13
     14        (WebCore::TileCache::drawLayer):
     15        Draw the repaint counter.
     16
     17        (WebCore::TileCache::showRepaintCounter):
     18        New function that determines whether we should show repaint counters for the given tile cache.
     19
     20        * platform/graphics/ca/mac/WebTileLayer.h:
     21        * platform/graphics/ca/mac/WebTileLayer.mm:
     22        (-[WebTileLayer incrementRepaintCount]):
     23        Add method for getting the repaint count.
     24
    1252012-01-30  Dan Bernstein  <mitz@apple.com>
    226
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.h

    r106304 r106311  
    7676    RetainPtr<WebTileLayer> createTileLayer();
    7777
     78    bool shouldShowRepaintCounters() const;
     79
    7880    WebTileCacheLayer* m_tileCacheLayer;
    7981    const IntSize m_tileSize;
  • trunk/Source/WebCore/platform/graphics/ca/mac/TileCache.mm

    r106304 r106311  
    9292            CGRect tileRect = [m_tileCacheLayer convertRect:rect toLayer:tileLayer];
    9393
    94             if (!CGRectIsEmpty(tileRect))
     94            if (!CGRectIsEmpty(tileRect)) {
    9595                [tileLayer setNeedsDisplayInRect:tileRect];
     96
     97                if (shouldShowRepaintCounters()) {
     98                    CGRect bounds = [tileLayer bounds];
     99                    CGRect indicatorRect = CGRectMake(bounds.origin.x, bounds.origin.y, 52, 27);
     100                    [tileLayer setNeedsDisplayInRect:indicatorRect];
     101                }
     102            }
    96103        }
    97104    }
     
    110117    drawLayerContents(context, layer, platformLayer);
    111118
     119    CGContextRestoreGState(context);
     120
     121    unsigned repaintCount = [layer incrementRepaintCount];
     122    if (!shouldShowRepaintCounters())
     123        return;
     124
     125    // FIXME: Some of this code could be shared with WebLayer.
     126    char text[16]; // that's a lot of repaints
     127    snprintf(text, sizeof(text), "%d", repaintCount);
     128
     129    CGRect indicatorBox = [layer bounds];
     130    indicatorBox.size.width = 12 + 10 * strlen(text);
     131    indicatorBox.size.height = 27;
     132    CGContextSaveGState(context);
     133
     134    CGContextSetAlpha(context, 0.5f);
     135    CGContextBeginTransparencyLayerWithRect(context, indicatorBox, 0);
     136
     137    CGContextSetFillColorWithColor(context, m_tileDebugBorderColor.get());
     138    CGContextFillRect(context, indicatorBox);
     139
     140    if (platformLayer->acceleratesDrawing())
     141        CGContextSetRGBFillColor(context, 1, 0, 0, 1);
     142    else
     143        CGContextSetRGBFillColor(context, 1, 1, 1, 1);
     144
     145    CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1, -1));
     146    CGContextSelectFont(context, "Helvetica", 22, kCGEncodingMacRoman);
     147    CGContextShowTextAtPoint(context, indicatorBox.origin.x + 5, indicatorBox.origin.y + 22, text, strlen(text));
     148
     149    CGContextEndTransparencyLayer(context);
    112150    CGContextRestoreGState(context);
    113151}
     
    225263}
    226264
     265bool TileCache::shouldShowRepaintCounters() const
     266{
     267    PlatformCALayer* platformLayer = PlatformCALayer::platformCALayer(m_tileCacheLayer);
     268    if (!platformLayer)
     269        return false;
     270
     271    WebCore::PlatformCALayerClient* layerContents = platformLayer->owner();
     272    ASSERT(layerContents);
     273    if (!layerContents)
     274        return false;
     275
     276    return layerContents->platformCALayerShowRepaintCounter();
     277}
     278
    227279} // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.h

    r103114 r106311  
    3333@interface WebTileLayer : CALayer {
    3434    WebCore::TileCache* _tileCache;
     35    unsigned _repaintCount;
    3536}
     37
    3638- (void)setTileCache:(WebCore::TileCache*)tileCache;
     39- (unsigned)incrementRepaintCount;
    3740@end
    3841
  • trunk/Source/WebCore/platform/graphics/ca/mac/WebTileLayer.mm

    r103114 r106311  
    5353}
    5454
     55- (unsigned)incrementRepaintCount
     56{
     57    return ++_repaintCount;
     58}
     59
    5560@end
    5661
Note: See TracChangeset for help on using the changeset viewer.