[TextureMapper] [Cairo] Implement repaint counters
authormrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2012 22:08:20 +0000 (22:08 +0000)
committermrobinson@webkit.org <mrobinson@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2012 22:08:20 +0000 (22:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=87062

Reviewed by Gustavo Noronha Silva.

No new tests. This just adds a debugging feature that shouldn't
affect the normal drawing of a page.

* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::updateBackingStore): Now, if repaint counters are
enabled, increment the repaint count and call drawRepaintCounter.
(WebCore::TextureMapperLayer::drawRepaintCounter): Added.
* platform/graphics/texmap/TextureMapperLayer.h:
(TextureMapperLayer): Added declaration for drawRepaintCounter.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@118061 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h

index a0d3496..9e0cedd 100644 (file)
@@ -1,3 +1,20 @@
+2012-05-22  Martin Robinson  <mrobinson@igalia.com>
+
+        [TextureMapper] [Cairo] Implement repaint counters
+        https://bugs.webkit.org/show_bug.cgi?id=87062
+
+        Reviewed by Gustavo Noronha Silva.
+
+        No new tests. This just adds a debugging feature that shouldn't
+        affect the normal drawing of a page.
+
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::updateBackingStore): Now, if repaint counters are
+        enabled, increment the repaint count and call drawRepaintCounter.
+        (WebCore::TextureMapperLayer::drawRepaintCounter): Added.
+        * platform/graphics/texmap/TextureMapperLayer.h:
+        (TextureMapperLayer): Added declaration for drawRepaintCounter.
+
 2012-05-22  Simon Fraser  <simon.fraser@apple.com>
 
         Use the same animation begin time while updating compositing layers
index 40f0c98..96cafac 100644 (file)
 
 #include "GraphicsLayerTextureMapper.h"
 #include "ImageBuffer.h"
-
+#include "NotImplemented.h"
 #include <wtf/MathExtras.h>
 
+#if USE(CAIRO)
+#include "CairoUtilities.h"
+#endif
+
 namespace WebCore {
 
 TextureMapperLayer* toTextureMapperLayer(GraphicsLayer* layer)
@@ -122,8 +126,12 @@ void TextureMapperLayer::updateBackingStore(TextureMapper* textureMapper, Graphi
     context->translate(-dirtyRect.x(), -dirtyRect.y());
     layer->paintGraphicsLayerContents(*context, dirtyRect);
 
-    RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore);
+    if (layer->showRepaintCounter()) {
+        layer->incrementRepaintCount();
+        drawRepaintCounter(context, layer);
+    }
 
+    RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore);
     TextureMapperTiledBackingStore* backingStore = static_cast<TextureMapperTiledBackingStore*>(m_backingStore.get());
     backingStore->updateContents(textureMapper, image.get(), m_size, dirtyRect);
 
@@ -562,5 +570,40 @@ void TextureMapperLayer::setDebugBorder(const Color& color, float width)
     m_debugBorderWidth = width * 2;
 }
 
+#if USE(CAIRO)
+void TextureMapperLayer::drawRepaintCounter(GraphicsContext* context, GraphicsLayer* layer)
+{
+
+    cairo_t* cr = context->platformContext()->cr();
+    cairo_save(cr);
+
+    CString repaintCount = String::format("%i", layer->repaintCount()).utf8();
+    cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
+    cairo_set_font_size(cr, 18);
+
+    cairo_text_extents_t repaintTextExtents;
+    cairo_text_extents(cr, repaintCount.data(), &repaintTextExtents);
+
+    static const int repaintCountBorderWidth = 10;
+    setSourceRGBAFromColor(cr, layer->showDebugBorders() ? m_debugBorderColor : Color(0, 255, 0, 127));
+    cairo_rectangle(cr, 0, 0,
+                    repaintTextExtents.width + (repaintCountBorderWidth * 2),
+                    repaintTextExtents.height + (repaintCountBorderWidth * 2));
+    cairo_fill(cr);
+
+    cairo_set_source_rgb(cr, 1, 1, 1);
+    cairo_move_to(cr, repaintCountBorderWidth, repaintTextExtents.height + repaintCountBorderWidth);
+    cairo_show_text(cr, repaintCount.data());
+
+    cairo_restore(cr);
+}
+#else
+void TextureMapperLayer::drawRepaintCounter(GraphicsContext* context, GraphicsLayer* layer)
+{
+    notImplemented();
+}
+
+#endif
+
 }
 #endif
index da1ac99..64172d1 100644 (file)
@@ -157,6 +157,8 @@ private:
     void paintSelfAndChildrenWithReplica(const TextureMapperPaintOptions&);
     void updateBackingStore(TextureMapper*, GraphicsLayerTextureMapper*);
 
+    void drawRepaintCounter(GraphicsContext*, GraphicsLayer*);
+
     void syncAnimations();
     bool isVisible() const;
     enum ContentsLayerCount {