Title: [125445] trunk/Source/WebCore
Revision
125445
Author
[email protected]
Date
2012-08-13 13:48:35 -0700 (Mon, 13 Aug 2012)

Log Message

[chromium] Clear HUD canvas contents before drawing into it.
https://bugs.webkit.org/show_bug.cgi?id=93759

Reviewed by Adrienne Walker.

Not clearing the bitmaps before drawing into it results into
random noise. This patch also caches the SkCanvas used by the HUD
to avoid reallocating it every frame.

* platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp:
(WebCore::CCHeadsUpDisplayLayerImpl::willDraw):
* platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125444 => 125445)


--- trunk/Source/WebCore/ChangeLog	2012-08-13 20:44:33 UTC (rev 125444)
+++ trunk/Source/WebCore/ChangeLog	2012-08-13 20:48:35 UTC (rev 125445)
@@ -1,3 +1,18 @@
+2012-08-13  Vangelis Kokkevis  <[email protected]>
+
+        [chromium] Clear HUD canvas contents before drawing into it.
+        https://bugs.webkit.org/show_bug.cgi?id=93759
+
+        Reviewed by Adrienne Walker.
+
+        Not clearing the bitmaps before drawing into it results into
+        random noise. This patch also caches the SkCanvas used by the HUD
+        to avoid reallocating it every frame.
+
+        * platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp:
+        (WebCore::CCHeadsUpDisplayLayerImpl::willDraw):
+        * platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h:
+
 2012-08-13  Simon Hausmann  <[email protected]>
 
         [Qt] Replace use of internal Weak smart pointer with JSWeakObjectMap

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp (125444 => 125445)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp	2012-08-13 20:44:33 UTC (rev 125444)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp	2012-08-13 20:48:35 UTC (rev 125445)
@@ -90,11 +90,19 @@
     if (!m_hudTexture->id() && !m_hudTexture->allocate(CCRenderer::ImplPool, bounds(), GraphicsContext3D::RGBA, CCResourceProvider::TextureUsageAny))
         return;
 
-    // Render pixels into the texture.
-    OwnPtr<SkCanvas> canvas = adoptPtr(skia::CreateBitmapCanvas(bounds().width(), bounds().height(), false /* opaque */));
-    drawHudContents(canvas.get());
+    SkISize canvasSize;
+    if (m_hudCanvas)
+        canvasSize = m_hudCanvas->getDeviceSize();
+    else
+        canvasSize.set(0, 0);
 
-    const SkBitmap* bitmap = &canvas->getDevice()->accessBitmap(false);
+    if (canvasSize.fWidth != bounds().width() || canvasSize.fHeight != bounds().height() || !m_hudCanvas)
+        m_hudCanvas = adoptPtr(skia::CreateBitmapCanvas(bounds().width(), bounds().height(), false /* opaque */));
+
+    m_hudCanvas->clear(SkColorSetARGB(0, 0, 0, 0));
+    drawHudContents(m_hudCanvas.get());
+
+    const SkBitmap* bitmap = &m_hudCanvas->getDevice()->accessBitmap(false);
     SkAutoLockPixels locker(*bitmap);
 
     IntRect layerRect(IntPoint(), bounds());

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h (125444 => 125445)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h	2012-08-13 20:44:33 UTC (rev 125444)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h	2012-08-13 20:48:35 UTC (rev 125445)
@@ -68,6 +68,7 @@
 
     OwnPtr<CCFontAtlas> m_fontAtlas;
     OwnPtr<CCScopedTexture> m_hudTexture;
+    OwnPtr<SkCanvas> m_hudCanvas;
 };
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to