[Texmap] Refactor code related to debug border and repaint count.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Jan 2013 13:50:58 +0000 (13:50 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Jan 2013 13:50:58 +0000 (13:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105787

Patch by Huang Dongsung <luxtella@company100.net> on 2013-01-25
Reviewed by Noam Rosenthal.

Currently, TextureMapperBackingStore, CoordinatedBackingStore and
GraphicsLayerTextureMapper have duplicated code to draw debug border or
repaint count. This patch refactors that all platform layers draw debug
border and repaint count in the consistent way:
TextureMapper::drawBorder() and TextureMapper::drawRepaintCounter().

There are three big changes:
1. TextureMapperLayer has the debug visuals like GraphicsLayer.
Both debug border and repaint count are called as the debug visuals.
2. We use the same color and width to Mac port because we get that info using
GraphicsLayer::updateDebugIndicators().
3. Draw borders for background color, backing store and contents layer,
while drawing repaint count only for backing store.

No new tests. This functionality is for debugging, so we cannot test using DRT.

* platform/graphics/cairo/GraphicsContext3DPrivate.h:
* platform/graphics/qt/GraphicsContext3DQt.cpp:
* platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore::GraphicsLayerTextureMapper::setShowDebugBorder):
(WebCore):
(WebCore::GraphicsLayerTextureMapper::setShowRepaintCounter):
(WebCore::GraphicsLayerTextureMapper::flushCompositingStateForThisLayerOnly):
(WebCore::GraphicsLayerTextureMapper::updateDebugBorderAndRepaintCountIfNeeded):
(WebCore::GraphicsLayerTextureMapper::setDebugBorder):
(WebCore::GraphicsLayerTextureMapper::updateBackingStoreIfNeeded):
(WebCore::GraphicsLayerTextureMapper::prepareBackingStore):
(WebCore::GraphicsLayerTextureMapper::setRepaintCount):
* platform/graphics/texmap/GraphicsLayerTextureMapper.h:
(GraphicsLayerTextureMapper):
(WebCore::GraphicsLayerTextureMapper::debugBorderColor):
(WebCore::GraphicsLayerTextureMapper::debugBorderWidth):
* platform/graphics/texmap/TextureMapper.h:
* platform/graphics/texmap/TextureMapperBackingStore.cpp:
(WebCore::TextureMapperTiledBackingStore::adjustedTransformForRect):
(WebCore):
(WebCore::TextureMapperTiledBackingStore::paintToTextureMapper):
(WebCore::TextureMapperTiledBackingStore::drawBorder):
    Override TextureMapperPlatformLayer::drawBorder() to draw the border
    for each tile.
(WebCore::TextureMapperTiledBackingStore::drawRepaintCounter):
* platform/graphics/texmap/TextureMapperBackingStore.h:
(WebCore::TextureMapperBackingStore::drawRepaintCounter):
(TextureMapperBackingStore):
(TextureMapperTiledBackingStore):
* platform/graphics/texmap/TextureMapperGL.cpp:
(WebCore::TextureMapperGL::drawRepaintCounter):
* platform/graphics/texmap/TextureMapperGL.h:
* platform/graphics/texmap/TextureMapperImageBuffer.cpp:
(WebCore::TextureMapperImageBuffer::drawBorder):
(WebCore):
(WebCore::TextureMapperImageBuffer::drawRepaintCounter):
* platform/graphics/texmap/TextureMapperImageBuffer.h:
(TextureMapperImageBuffer):
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::paintSelf):
(WebCore::TextureMapperLayer::flushCompositingStateForThisLayerOnly):
* platform/graphics/texmap/TextureMapperLayer.h:
(State):
(WebCore::TextureMapperLayer::State::State):
* platform/graphics/texmap/TextureMapperPlatformLayer.h:
(WebCore::TextureMapperPlatformLayer::drawBorder):

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cairo/GraphicsContext3DPrivate.h
Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h
Source/WebCore/platform/graphics/texmap/TextureMapper.h
Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperBackingStore.h
Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h
Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayer.h

index ee339f1f80dbb05855bbc5a0517097338d8afb7c..828a2242d0859a5f65072dd79c92221bcad1f98d 100644 (file)
@@ -1,3 +1,73 @@
+2013-01-25  Huang Dongsung  <luxtella@company100.net>
+
+        [Texmap] Refactor code related to debug border and repaint count.
+        https://bugs.webkit.org/show_bug.cgi?id=105787
+
+        Reviewed by Noam Rosenthal.
+
+        Currently, TextureMapperBackingStore, CoordinatedBackingStore and
+        GraphicsLayerTextureMapper have duplicated code to draw debug border or
+        repaint count. This patch refactors that all platform layers draw debug
+        border and repaint count in the consistent way:
+        TextureMapper::drawBorder() and TextureMapper::drawRepaintCounter().
+
+        There are three big changes:
+        1. TextureMapperLayer has the debug visuals like GraphicsLayer.
+        Both debug border and repaint count are called as the debug visuals.
+        2. We use the same color and width to Mac port because we get that info using
+        GraphicsLayer::updateDebugIndicators().
+        3. Draw borders for background color, backing store and contents layer,
+        while drawing repaint count only for backing store.
+
+        No new tests. This functionality is for debugging, so we cannot test using DRT.
+
+        * platform/graphics/cairo/GraphicsContext3DPrivate.h:
+        * platform/graphics/qt/GraphicsContext3DQt.cpp:
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
+        (WebCore::GraphicsLayerTextureMapper::setShowDebugBorder):
+        (WebCore):
+        (WebCore::GraphicsLayerTextureMapper::setShowRepaintCounter):
+        (WebCore::GraphicsLayerTextureMapper::flushCompositingStateForThisLayerOnly):
+        (WebCore::GraphicsLayerTextureMapper::updateDebugBorderAndRepaintCountIfNeeded):
+        (WebCore::GraphicsLayerTextureMapper::setDebugBorder):
+        (WebCore::GraphicsLayerTextureMapper::updateBackingStoreIfNeeded):
+        (WebCore::GraphicsLayerTextureMapper::prepareBackingStore):
+        (WebCore::GraphicsLayerTextureMapper::setRepaintCount):
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.h:
+        (GraphicsLayerTextureMapper):
+        (WebCore::GraphicsLayerTextureMapper::debugBorderColor):
+        (WebCore::GraphicsLayerTextureMapper::debugBorderWidth):
+        * platform/graphics/texmap/TextureMapper.h:
+        * platform/graphics/texmap/TextureMapperBackingStore.cpp:
+        (WebCore::TextureMapperTiledBackingStore::adjustedTransformForRect):
+        (WebCore):
+        (WebCore::TextureMapperTiledBackingStore::paintToTextureMapper):
+        (WebCore::TextureMapperTiledBackingStore::drawBorder):
+            Override TextureMapperPlatformLayer::drawBorder() to draw the border
+            for each tile.
+        (WebCore::TextureMapperTiledBackingStore::drawRepaintCounter):
+        * platform/graphics/texmap/TextureMapperBackingStore.h:
+        (WebCore::TextureMapperBackingStore::drawRepaintCounter):
+        (TextureMapperBackingStore):
+        (TextureMapperTiledBackingStore):
+        * platform/graphics/texmap/TextureMapperGL.cpp:
+        (WebCore::TextureMapperGL::drawRepaintCounter):
+        * platform/graphics/texmap/TextureMapperGL.h:
+        * platform/graphics/texmap/TextureMapperImageBuffer.cpp:
+        (WebCore::TextureMapperImageBuffer::drawBorder):
+        (WebCore):
+        (WebCore::TextureMapperImageBuffer::drawRepaintCounter):
+        * platform/graphics/texmap/TextureMapperImageBuffer.h:
+        (TextureMapperImageBuffer):
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::paintSelf):
+        (WebCore::TextureMapperLayer::flushCompositingStateForThisLayerOnly):
+        * platform/graphics/texmap/TextureMapperLayer.h:
+        (State):
+        (WebCore::TextureMapperLayer::State::State):
+        * platform/graphics/texmap/TextureMapperPlatformLayer.h:
+        (WebCore::TextureMapperPlatformLayer::drawBorder):
+
 2013-01-24  Patrick Gansterer  <paroga@webkit.org>
 
         Build fix for !ENABLE(DRAG_SUPPORT) after r140286.
index 69dad6754722ac7a882ca87615ab8854979afbc6..d0dd23fe7dbd41d6af81f907aad9da032c01b4db 100644 (file)
@@ -25,7 +25,7 @@
 #include <wtf/PassOwnPtr.h>
 
 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
-#include "TextureMapper.h"
+#include "TextureMapperPlatformLayer.h"
 #endif
 
 namespace WebCore {
index 584640a8dc212452eee755e9269010ade36b1cc0..66bdeaed185a54ee393530ad9a09fa6c4a30f7ea 100644 (file)
@@ -34,6 +34,7 @@
 #include "OpenGLShims.h"
 #include "QWebPageClient.h"
 #include "SharedBuffer.h"
+#include "TextureMapperPlatformLayer.h"
 #include <QWindow>
 #include <qpa/qplatformpixmap.h>
 #include <wtf/UnusedParam.h>
index 1ef78cc8748896466326619360fd0c64c27b8310..a678ccf7e814b5f267de28d0e24b6de4c4bf41ca 100644 (file)
 #include "GraphicsLayerAnimation.h"
 #include "GraphicsLayerFactory.h"
 #include "ImageBuffer.h"
-#include "NotImplemented.h"
 #include <wtf/CurrentTime.h>
 
-#if USE(CAIRO)
-#include "CairoUtilities.h"
-#include <wtf/text/CString.h>
-#endif
-
 namespace WebCore {
 
 PassOwnPtr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient* client)
@@ -386,15 +380,57 @@ void GraphicsLayerTextureMapper::setContentsToMedia(TextureMapperPlatformLayer*
     m_contentsLayer = media;
 }
 
+void GraphicsLayerTextureMapper::setShowDebugBorder(bool show)
+{
+    if (isShowingDebugBorder() == show)
+        return;
+
+    GraphicsLayer::setShowDebugBorder(show);
+    notifyChange(TextureMapperLayer::DebugVisualsChange);
+}
+
+void GraphicsLayerTextureMapper::setShowRepaintCounter(bool show)
+{
+    if (isShowingRepaintCounter() == show)
+        return;
+
+    GraphicsLayer::setShowRepaintCounter(show);
+    notifyChange(TextureMapperLayer::DebugVisualsChange);
+}
+
 /* \reimp (GraphicsLayer.h)
 */
 void GraphicsLayerTextureMapper::flushCompositingStateForThisLayerOnly()
 {
+    updateDebugBorderAndRepaintCountIfNeeded();
     m_layer->flushCompositingStateForThisLayerOnly(this);
-    updateBackingStore();
+    updateBackingStoreIfNeeded();
     didFlushCompositingState();
 }
 
+void GraphicsLayerTextureMapper::updateDebugBorderAndRepaintCountIfNeeded()
+{
+    if (!m_hasOwnBackingStore)
+        return;
+
+    m_usingTiledLayer = shouldHaveBackingStore();
+    updateDebugIndicators();
+
+    // When this has its own backing store (e.g. Qt WK1), update the repaint count before calling TextureMapperLayer::flushCompositingStateForThisLayerOnly().
+    bool needsToRepaint = shouldHaveBackingStore() && (m_needsDisplay || !m_needsDisplayRect.isEmpty());
+    if (isShowingRepaintCounter() && needsToRepaint) {
+        incrementRepaintCount();
+        m_changeMask |= TextureMapperLayer::RepaintCountChange;
+    }
+}
+
+void GraphicsLayerTextureMapper::setDebugBorder(const Color& color, float width)
+{
+    m_debugBorderColor = color;
+    m_debugBorderWidth = width;
+    m_changeMask |= TextureMapperLayer::DebugVisualsChange;
+}
+
 /* \reimp (GraphicsLayer.h)
 */
 void GraphicsLayerTextureMapper::flushCompositingState(const FloatRect& rect)
@@ -417,11 +453,10 @@ void GraphicsLayerTextureMapper::didFlushCompositingState()
     m_changeMask = 0;
 }
 
-void GraphicsLayerTextureMapper::updateBackingStore()
+void GraphicsLayerTextureMapper::updateBackingStoreIfNeeded()
 {
     if (!m_hasOwnBackingStore)
         return;
-
     prepareBackingStore();
     m_layer->setBackingStore(m_backingStore);
 }
@@ -451,34 +486,7 @@ void GraphicsLayerTextureMapper::prepareBackingStore()
 #endif
     TextureMapperTiledBackingStore* backingStore = static_cast<TextureMapperTiledBackingStore*>(m_backingStore.get());
 
-    if (isShowingRepaintCounter())
-        incrementRepaintCount();
-
-    // Paint into an intermediate buffer to avoid painting content more than once.
-    bool paintOnce = true;
-    const IntSize maxTextureSize = textureMapper->maxTextureSize();
-    // We need to paint directly if the dirty rect exceeds one of the maximum dimensions.
-    if (dirtyRect.width() > maxTextureSize.width() || dirtyRect.height() > maxTextureSize.height())
-        paintOnce = false;
-
-    if (paintOnce) {
-        OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(dirtyRect.size());
-        GraphicsContext* context = imageBuffer->context();
-        context->setImageInterpolationQuality(textureMapper->imageInterpolationQuality());
-        context->setTextDrawingMode(textureMapper->textDrawingMode());
-        context->translate(-dirtyRect.x(), -dirtyRect.y());
-        paintGraphicsLayerContents(*context, dirtyRect);
-
-        if (isShowingRepaintCounter())
-            drawRepaintCounter(context);
-
-        RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore);
-        backingStore->updateContents(textureMapper, image.get(), m_size, dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData);
-    } else
-        backingStore->updateContents(textureMapper, this, m_size, dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData);
-
-    backingStore->setShowDebugBorders(isShowingDebugBorder());
-    backingStore->setDebugBorder(m_debugBorderColor, m_debugBorderWidth);
+    backingStore->updateContents(textureMapper, this, m_size, dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData);
 
     m_needsDisplay = false;
     m_needsDisplayRect = IntRect();
@@ -489,40 +497,6 @@ bool GraphicsLayerTextureMapper::shouldHaveBackingStore() const
     return drawsContent() && contentsAreVisible() && !m_size.isEmpty();
 }
 
-#if USE(CAIRO)
-void GraphicsLayerTextureMapper::drawRepaintCounter(GraphicsContext* context)
-{
-    cairo_t* cr = context->platformContext()->cr();
-    cairo_save(cr);
-
-    CString repaintCount = String::format("%i", this->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, isShowingDebugBorder() ? 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 GraphicsLayerTextureMapper::drawRepaintCounter(GraphicsContext* context)
-{
-    notImplemented();
-}
-
-#endif
-
 bool GraphicsLayerTextureMapper::addAnimation(const KeyframeValueList& valueList, const IntSize& boxSize, const Animation* anim, const String& keyframesName, double timeOffset)
 {
     ASSERT(!keyframesName.isEmpty());
@@ -564,14 +538,6 @@ void GraphicsLayerTextureMapper::animationStartedTimerFired(Timer<GraphicsLayerT
     client()->notifyAnimationStarted(this, /* DOM time */ WTF::currentTime());
 }
 
-void GraphicsLayerTextureMapper::setDebugBorder(const Color& color, float width)
-{
-    // The default values for GraphicsLayer debug borders are a little
-    // hard to see (some less than one pixel wide), so we double their size here.
-    m_debugBorderColor = color;
-    m_debugBorderWidth = width * 2;
-}
-
 #if ENABLE(CSS_FILTERS)
 bool GraphicsLayerTextureMapper::setFilters(const FilterOperations& filters)
 {
@@ -580,4 +546,10 @@ bool GraphicsLayerTextureMapper::setFilters(const FilterOperations& filters)
 }
 #endif
 
+void GraphicsLayerTextureMapper::setRepaintCount(int repaintCount)
+{
+    m_repaintCount = repaintCount;
+    notifyChange(TextureMapperLayer::RepaintCountChange);
+}
+
 }
index 12c319591b726c7c9f0ba2bdfdf4384e7dea1713..49b504b63bcd2e133c15f103d20bdee43dcb86d4 100644 (file)
@@ -20,7 +20,6 @@
 #ifndef GraphicsLayerTextureMapper_h
 #define GraphicsLayerTextureMapper_h
 
-#include "GraphicsContext.h"
 #include "GraphicsLayer.h"
 #include "GraphicsLayerClient.h"
 #include "Image.h"
@@ -66,6 +65,9 @@ public:
     Color solidColor() const { return m_solidColor; }
     virtual void setContentsToMedia(PlatformLayer*);
     virtual void setContentsToCanvas(PlatformLayer* canvas) { setContentsToMedia(canvas); }
+    virtual void setShowDebugBorder(bool) OVERRIDE;
+    virtual void setDebugBorder(const Color&, float width) OVERRIDE;
+    virtual void setShowRepaintCounter(bool) OVERRIDE;
     virtual void flushCompositingState(const FloatRect&);
     virtual void flushCompositingStateForThisLayerOnly();
     virtual void setName(const String& name);
@@ -81,8 +83,6 @@ public:
 
     TextureMapperLayer* layer() const { return m_layer.get(); }
 
-    virtual void setDebugBorder(const Color&, float width);
-
 #if ENABLE(CSS_FILTERS)
     virtual bool setFilters(const FilterOperations&);
 #endif
@@ -93,11 +93,15 @@ public:
     void setFixedToViewport(bool fixed) { m_fixedToViewport = fixed; }
     bool fixedToViewport() const { return m_fixedToViewport; }
 
-    void drawRepaintCounter(GraphicsContext*);
+    Color debugBorderColor() const { return m_debugBorderColor; }
+    float debugBorderWidth() const { return m_debugBorderWidth; }
+    void setRepaintCount(int);
+
 private:
     virtual void willBeDestroyed();
     void didFlushCompositingState();
-    void updateBackingStore();
+    void updateDebugBorderAndRepaintCountIfNeeded();
+    void updateBackingStoreIfNeeded();
     void prepareBackingStore();
     bool shouldHaveBackingStore() const;
     void animationStartedTimerFired(Timer<GraphicsLayerTextureMapper>*);
index c7241a6c9a722a6452f7c18c9d6697127669366b..d96116b7099368ad4455996c1b732016270deec2 100644 (file)
@@ -36,7 +36,6 @@
 #include "GraphicsContext.h"
 #include "IntRect.h"
 #include "IntSize.h"
-#include "TextureMapperPlatformLayer.h"
 #include "TransformationMatrix.h"
 #include <wtf/UnusedParam.h>
 
@@ -130,8 +129,9 @@ public:
         AllEdges = LeftEdge | RightEdge | TopEdge | BottomEdge,
     };
 
-    virtual void drawBorder(const Color&, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) = 0;
-    virtual void drawRepaintCounter(int value, int pointSize, const FloatPoint&, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) = 0;
+    virtual void drawBorder(const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) = 0;
+    virtual void drawRepaintCounter(int repaintCount, const Color&, const FloatPoint&, const TransformationMatrix&) = 0;
+
     virtual void drawTexture(const BitmapTexture&, const FloatRect& target, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0f, const BitmapTexture* maskTexture = 0, unsigned exposedEdges = AllEdges) = 0;
     virtual void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) = 0;
 
index e8992531b287c5b59779e6476e801b8b6995c2c7..3106df22e2ee0e4d467bb877cb211a3742f75632 100644 (file)
@@ -106,7 +106,6 @@ void TextureMapperTile::paint(TextureMapper* textureMapper, const Transformation
 }
 
 TextureMapperTiledBackingStore::TextureMapperTiledBackingStore()
-    : m_drawsDebugBorders(false)
 {
 }
 
@@ -133,16 +132,31 @@ unsigned TextureMapperBackingStore::calculateExposedTileEdges(const FloatRect& t
     return exposedEdges;
 }
 
+TransformationMatrix TextureMapperTiledBackingStore::adjustedTransformForRect(const FloatRect& targetRect)
+{
+    return TransformationMatrix::rectToRect(rect(), targetRect);
+}
+
 void TextureMapperTiledBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 {
     updateContentsFromImageIfNeeded(textureMapper);
-    TransformationMatrix adjustedTransform = transform;
-    adjustedTransform.multiply(TransformationMatrix::rectToRect(rect(), targetRect));
-    for (size_t i = 0; i < m_tiles.size(); ++i) {
+    TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+    for (size_t i = 0; i < m_tiles.size(); ++i)
         m_tiles[i].paint(textureMapper, adjustedTransform, opacity, mask, calculateExposedTileEdges(rect(), m_tiles[i].rect()));
-        if (m_drawsDebugBorders)
-            textureMapper->drawBorder(m_debugBorderColor, m_debugBorderWidth, m_tiles[i].rect(), adjustedTransform);
-    }
+}
+
+void TextureMapperTiledBackingStore::drawBorder(TextureMapper* textureMapper, const Color& borderColor, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& transform)
+{
+    TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+    for (size_t i = 0; i < m_tiles.size(); ++i)
+        textureMapper->drawBorder(borderColor, borderWidth, m_tiles[i].rect(), adjustedTransform);
+}
+
+void TextureMapperTiledBackingStore::drawRepaintCounter(TextureMapper* textureMapper, int repaintCount, const Color& borderColor, const FloatRect& targetRect, const TransformationMatrix& transform)
+{
+    TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+    for (size_t i = 0; i < m_tiles.size(); ++i)
+        textureMapper->drawRepaintCounter(repaintCount, borderColor, m_tiles[i].rect().location(), adjustedTransform);
 }
 
 void TextureMapperTiledBackingStore::createOrDestroyTilesIfNeeded(const FloatSize& size, const IntSize& tileSize, bool hasAlpha)
@@ -234,11 +248,5 @@ PassRefPtr<BitmapTexture> TextureMapperTiledBackingStore::texture() const
     return PassRefPtr<BitmapTexture>();
 }
 
-void TextureMapperTiledBackingStore::setDebugBorder(const Color& color, float width)
-{
-    m_debugBorderColor = color;
-    m_debugBorderWidth = width;
-}
-
 }
 #endif
index 0dd2df4b198bd311fd41c55a33772184cd14b34a..b61d2d833cd014af7e1e46c95744306ea87f3ace 100644 (file)
@@ -40,8 +40,10 @@ class TextureMapperBackingStore : public TextureMapperPlatformLayer, public RefC
 public:
     virtual PassRefPtr<BitmapTexture> texture() const = 0;
     virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*) = 0;
+    virtual void drawRepaintCounter(TextureMapper*, int /* repaintCount */, const Color&, const FloatRect&, const TransformationMatrix&) { }
     virtual ~TextureMapperBackingStore() { }
 
+
 protected:
     static unsigned calculateExposedTileEdges(const FloatRect& totalRect, const FloatRect& tileRect);
 };
@@ -94,26 +96,23 @@ public:
 
     virtual PassRefPtr<BitmapTexture> texture() const OVERRIDE;
     virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float, BitmapTexture*) OVERRIDE;
+    virtual void drawBorder(TextureMapper*, const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) OVERRIDE;
+    virtual void drawRepaintCounter(TextureMapper*, int repaintCount, const Color&, const FloatRect&, const TransformationMatrix&) OVERRIDE;
     void updateContents(TextureMapper*, Image*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag);
     void updateContents(TextureMapper*, GraphicsLayer*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag);
 
     void setContentsToImage(Image* image) { m_image = image; }
-    void setShowDebugBorders(bool drawsDebugBorders) { m_drawsDebugBorders = drawsDebugBorders; }
-    void setDebugBorder(const Color&, float width);
 
 private:
     TextureMapperTiledBackingStore();
     void createOrDestroyTilesIfNeeded(const FloatSize& backingStoreSize, const IntSize& tileSize, bool hasAlpha);
     void updateContentsFromImageIfNeeded(TextureMapper*);
+    TransformationMatrix adjustedTransformForRect(const FloatRect&);
     inline FloatRect rect() const { return FloatRect(FloatPoint::zero(), m_size); }
 
     Vector<TextureMapperTile> m_tiles;
     FloatSize m_size;
     RefPtr<Image> m_image;
-
-    bool m_drawsDebugBorders;
-    Color m_debugBorderColor;
-    float m_debugBorderWidth;
 };
 
 }
index a9011888a2b199a3dffbde296214dadfe6e9766d..378e732cedd49e09ef3e73ede9151c38a4b9f40d 100644 (file)
@@ -321,10 +321,11 @@ void TextureMapperGL::drawBorder(const Color& color, float width, const FloatRec
     draw(targetRect, modelViewMatrix, program.get(), GraphicsContext3D::LINE_LOOP, color.hasAlpha() ? ShouldBlend : 0);
 }
 
-void TextureMapperGL::drawRepaintCounter(int value, int pointSize, const FloatPoint& targetPoint, const TransformationMatrix& modelViewMatrix)
+void TextureMapperGL::drawRepaintCounter(int repaintCount, const Color& color, const FloatPoint& targetPoint, const TransformationMatrix& modelViewMatrix)
 {
+    int pointSize = 8;
 #if PLATFORM(QT)
-    QString counterString = QString::number(value);
+    QString counterString = QString::number(repaintCount);
 
     QFont font(QString::fromLatin1("Monospace"), pointSize, QFont::Bold);
     font.setStyleHint(QFont::TypeWriter);
@@ -339,7 +340,7 @@ void TextureMapperGL::drawRepaintCounter(int value, int pointSize, const FloatPo
 
     QImage image(size, NativeImageQt::defaultFormatForAlphaEnabledImages());
     QPainter painter(&image);
-    painter.fillRect(sourceRect, Qt::blue); // Since we won't swap R+B for speed, this will paint red.
+    painter.fillRect(sourceRect, Color::createUnchecked(color.blue(), color.green(), color.red())); // Since we won't swap R+B when uploading a texture, paint with the swapped R+B color.
     painter.setFont(font);
     painter.setPen(Qt::white);
     painter.drawText(2, height * 0.85, counterString);
@@ -350,7 +351,7 @@ void TextureMapperGL::drawRepaintCounter(int value, int pointSize, const FloatPo
     drawTexture(*texture, targetRect, modelViewMatrix, 1.0f, 0, AllEdges);
 
 #elif USE(CAIRO)
-    CString counterString = String::number(value).ascii();
+    CString counterString = String::number(repaintCount).ascii();
     // cairo_text_extents() requires a cairo_t, so dimensions need to be guesstimated.
     int width = counterString.length() * pointSize * 1.2;
     int height = pointSize * 1.5;
@@ -358,7 +359,9 @@ void TextureMapperGL::drawRepaintCounter(int value, int pointSize, const FloatPo
     cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
     cairo_t* cr = cairo_create(surface);
 
-    cairo_set_source_rgb(cr, 0, 0, 1); // Since we won't swap R+B for speed, this will paint red.
+    float r, g, b, a;
+    color.getRGBA(r, g, b, a);
+    cairo_set_source_rgba(cr, b, g, r, a); // Since we won't swap R+B when uploading a texture, paint with the swapped R+B color.
     cairo_rectangle(cr, 0, 0, width, height);
     cairo_fill(cr);
 
@@ -382,7 +385,7 @@ void TextureMapperGL::drawRepaintCounter(int value, int pointSize, const FloatPo
     cairo_destroy(cr);
 
 #else
-    UNUSED_PARAM(value);
+    UNUSED_PARAM(repaintCount);
     UNUSED_PARAM(pointSize);
     UNUSED_PARAM(targetPoint);
     UNUSED_PARAM(modelViewMatrix);
index 160507c6068fefc3548430fbedaaf35063d97416..983e2a06c3c43d63aa9eba1af6c1a1d8df593ddd 100644 (file)
@@ -52,8 +52,8 @@ public:
     typedef int Flags;
 
     // TextureMapper implementation
-    virtual void drawBorder(const Color&, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE;
-    virtual void drawRepaintCounter(int value, int pointSize, const FloatPoint&, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE;
+    virtual void drawBorder(const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) OVERRIDE;
+    virtual void drawRepaintCounter(int repaintCount, const Color&, const FloatPoint&, const TransformationMatrix&) OVERRIDE;
     virtual void drawTexture(const BitmapTexture&, const FloatRect&, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges) OVERRIDE;
     virtual void drawTexture(Platform3DObject texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges = AllEdges);
     virtual void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) OVERRIDE;
index d9dbc80e6d2cd4971dac0a750f34b8292c721566..b4e122d2cd8da09705f79c4becdcc63f0aa8322a 100644 (file)
@@ -25,6 +25,7 @@
 #if PLATFORM(QT)
 #include "NativeImageQt.h"
 #endif
+#include "NotImplemented.h"
 
 
 #if USE(TEXTURE_MAPPER)
@@ -164,6 +165,16 @@ void TextureMapperImageBuffer::drawSolidColor(const FloatRect& rect, const Trans
     context->restore();
 }
 
+void TextureMapperImageBuffer::drawBorder(const Color&, float /* borderWidth */, const FloatRect&, const TransformationMatrix&)
+{
+    notImplemented();
+}
+
+void TextureMapperImageBuffer::drawRepaintCounter(int /* repaintCount */, const Color&, const FloatPoint&, const TransformationMatrix&)
+{
+    notImplemented();
+}
+
 #if ENABLE(CSS_FILTERS)
 PassRefPtr<BitmapTexture> BitmapTextureImageBuffer::applyFilters(TextureMapper*, const BitmapTexture& contentTexture, const FilterOperations& filters)
 {
index 9de6d4cbd5eb17e93488018a62a7131d897384eb..5b2e9783d69c058639272a2b631c76ae10573d3c 100644 (file)
@@ -53,14 +53,8 @@ public:
     static PassOwnPtr<TextureMapper> create() { return adoptPtr(new TextureMapperImageBuffer); }
 
     // TextureMapper implementation
-    virtual void drawBorder(const Color&, float /* borderWidth */, const FloatRect& /* targetRect */, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE
-    {
-        UNUSED_PARAM(modelViewMatrix);
-    };
-    virtual void drawRepaintCounter(int /* value */, int /* pointSize */, const FloatPoint&, const TransformationMatrix& modelViewMatrix = TransformationMatrix()) OVERRIDE
-    {
-        UNUSED_PARAM(modelViewMatrix);
-    };
+    virtual void drawBorder(const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) OVERRIDE;
+    virtual void drawRepaintCounter(int repaintCount, const Color&, const FloatPoint&, const TransformationMatrix&) OVERRIDE;
     virtual void drawTexture(const BitmapTexture&, const FloatRect& targetRect, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture, unsigned exposedEdges) OVERRIDE;
     virtual void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) OVERRIDE;
     virtual void beginClip(const TransformationMatrix&, const FloatRect&) OVERRIDE;
index 5dfa1838ed4b4c21847504346eef036439b51a9b..8e80b1942359fbc8ca60d813fb97316f33915642 100644 (file)
@@ -129,6 +129,8 @@ void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
 
     if (m_state.solidColor.isValid() && !m_state.contentsRect.isEmpty()) {
         options.textureMapper->drawSolidColor(m_state.contentsRect, transform, blendWithOpacity(m_state.solidColor, opacity));
+        if (m_state.showDebugBorders)
+            options.textureMapper->drawBorder(m_state.debugBorderColor, m_state.debugBorderWidth, layerRect(), transform);
         return;
     }
 
@@ -136,11 +138,18 @@ void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
         ASSERT(m_state.drawsContent && m_state.contentsVisible && !m_state.size.isEmpty());
         ASSERT(!layerRect().isEmpty());
         m_backingStore->paintToTextureMapper(options.textureMapper, layerRect(), transform, opacity, mask.get());
+        if (m_state.showDebugBorders)
+            m_backingStore->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, layerRect(), transform);
+        // Only draw repaint count for the main backing store.
+        if (m_state.showRepaintCounter)
+            m_backingStore->drawRepaintCounter(options.textureMapper, m_state.repaintCount, m_state.debugBorderColor, layerRect(), transform);
     }
 
     if (m_contentsLayer) {
         ASSERT(!layerRect().isEmpty());
         m_contentsLayer->paintToTextureMapper(options.textureMapper, m_state.contentsRect, transform, opacity, mask.get());
+        if (m_state.showDebugBorders)
+            m_contentsLayer->drawBorder(options.textureMapper, m_state.debugBorderColor, m_state.debugBorderWidth, m_state.contentsRect, transform);
     }
 }
 
@@ -383,8 +392,6 @@ void TextureMapperLayer::flushCompositingStateForThisLayerOnly(GraphicsLayerText
     if (changeMask == NoChanges && graphicsLayer->m_animations.isEmpty())
         return;
 
-    graphicsLayer->updateDebugIndicators();
-
     if (changeMask & ChildrenChange)
         setChildren(graphicsLayer->children());
 
@@ -401,6 +408,9 @@ void TextureMapperLayer::flushCompositingStateForThisLayerOnly(GraphicsLayerText
     if (changeMask & AnimationChange)
         m_animations = graphicsLayer->m_animations;
 
+    if (changeMask & RepaintCountChange)
+        m_state.repaintCount = graphicsLayer->repaintCount();
+
     m_state.maskLayer = toTextureMapperLayer(graphicsLayer->maskLayer());
     m_state.replicaLayer = toTextureMapperLayer(graphicsLayer->replicaLayer());
     m_state.pos = graphicsLayer->position();
@@ -423,6 +433,11 @@ void TextureMapperLayer::flushCompositingStateForThisLayerOnly(GraphicsLayerText
 #endif
     m_fixedToViewport = graphicsLayer->fixedToViewport();
 
+    m_state.showDebugBorders = graphicsLayer->isShowingDebugBorder();
+    m_state.debugBorderColor = toGraphicsLayerTextureMapper(graphicsLayer)->debugBorderColor();
+    m_state.debugBorderWidth = toGraphicsLayerTextureMapper(graphicsLayer)->debugBorderWidth();
+    m_state.showRepaintCounter = graphicsLayer->isShowingRepaintCounter();
+
     m_contentsLayer = graphicsLayer->platformLayer();
 
     m_currentTransform.setPosition(adjustedPosition());
index f41e52a97c4b328c44cf650aee34cd300a46539a..575bb27eb7a874c184b581ed2bd435d1015a83b1 100644 (file)
@@ -71,7 +71,10 @@ public:
 
         ReplicaLayerChange =        (1L << 21),
         AnimationChange =           (1L << 22),
-        FilterChange =              (1L << 23)
+        FilterChange =              (1L << 23),
+
+        DebugVisualsChange =        (1L << 24),
+        RepaintCountChange =        (1L << 25)
     };
 
     TextureMapperLayer()
@@ -172,6 +175,9 @@ private:
 #if ENABLE(CSS_FILTERS)
         FilterOperations filters;
 #endif
+        Color debugBorderColor;
+        float debugBorderWidth;
+        int repaintCount;
 
         bool preserves3D : 1;
         bool masksToBounds : 1;
@@ -180,11 +186,15 @@ private:
         bool contentsOpaque : 1;
         bool backfaceVisibility : 1;
         bool visible : 1;
+        bool showDebugBorders : 1;
+        bool showRepaintCounter : 1;
 
         State()
             : opacity(1)
             , maskLayer(0)
             , replicaLayer(0)
+            , debugBorderWidth(0)
+            , repaintCount(0)
             , preserves3D(false)
             , masksToBounds(false)
             , drawsContent(false)
@@ -192,6 +202,8 @@ private:
             , contentsOpaque(false)
             , backfaceVisibility(false)
             , visible(true)
+            , showDebugBorders(false)
+            , showRepaintCounter(false)
         {
         }
     };
index 38af03e89b62481abaf32098c3a817ab4d000c1e..f4879526768019085cbdef89e66ee47def810115 100644 (file)
 #include "GraphicsSurface.h"
 #endif
 
+#include "TextureMapper.h"
 #include "TransformationMatrix.h"
 
 namespace WebCore {
 
-class TextureMapper;
-class BitmapTexture;
-
 class TextureMapperPlatformLayer {
 public:
     virtual ~TextureMapperPlatformLayer() { }
     virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0, BitmapTexture* mask = 0) = 0;
     virtual void swapBuffers() { }
+    virtual void drawBorder(TextureMapper* textureMapper, const Color& color, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& transform)
+    {
+        textureMapper->drawBorder(color, borderWidth, targetRect, transform);
+    }
 #if USE(GRAPHICS_SURFACE)
     virtual IntSize platformLayerSize() const { return IntSize(); }
     virtual uint32_t copyToGraphicsSurface() { return 0; }