Log Message
[chromium] Use skia directly in CCHeadsUpDisplayLayerImpl https://bugs.webkit.org/show_bug.cgi?id=92810
Reviewed by Adrienne Walker. The chromium compositor HUD doesn't need to use a full GraphicsContext/etc, all it draws are rectangles and a simple stroked path. This draws the HUD with straight skia calls and removes the now unnecessary PlatformCanvas wrapper. * WebCore.gypi: * platform/graphics/chromium/PlatformCanvas.cpp: Removed. * platform/graphics/chromium/PlatformCanvas.h: Removed. * platform/graphics/chromium/cc/CCFontAtlas.cpp: (WebCore::CCFontAtlas::drawText): * platform/graphics/chromium/cc/CCFontAtlas.h: (CCFontAtlas): * platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp: (WebCore::CCHeadsUpDisplayLayerImpl::willDraw): (WebCore::CCHeadsUpDisplayLayerImpl::drawHudContents): (WebCore::CCHeadsUpDisplayLayerImpl::drawFPSCounter): (WebCore::CCHeadsUpDisplayLayerImpl::drawFPSCounterText): (WebCore::CCHeadsUpDisplayLayerImpl::drawDebugRects): * platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h: (WebCore):
Modified Paths
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/WebCore.gypi
- trunk/Source/WebCore/platform/graphics/chromium/cc/CCFontAtlas.cpp
- trunk/Source/WebCore/platform/graphics/chromium/cc/CCFontAtlas.h
- trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp
- trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h
Removed Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (124274 => 124275)
--- trunk/Source/WebCore/ChangeLog 2012-08-01 00:19:37 UTC (rev 124274)
+++ trunk/Source/WebCore/ChangeLog 2012-08-01 00:34:43 UTC (rev 124275)
@@ -1,3 +1,30 @@
+2012-07-31 James Robinson <[email protected]>
+
+ [chromium] Use skia directly in CCHeadsUpDisplayLayerImpl
+ https://bugs.webkit.org/show_bug.cgi?id=92810
+
+ Reviewed by Adrienne Walker.
+
+ The chromium compositor HUD doesn't need to use a full GraphicsContext/etc, all it draws are rectangles and a
+ simple stroked path. This draws the HUD with straight skia calls and removes the now unnecessary PlatformCanvas
+ wrapper.
+
+ * WebCore.gypi:
+ * platform/graphics/chromium/PlatformCanvas.cpp: Removed.
+ * platform/graphics/chromium/PlatformCanvas.h: Removed.
+ * platform/graphics/chromium/cc/CCFontAtlas.cpp:
+ (WebCore::CCFontAtlas::drawText):
+ * platform/graphics/chromium/cc/CCFontAtlas.h:
+ (CCFontAtlas):
+ * platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp:
+ (WebCore::CCHeadsUpDisplayLayerImpl::willDraw):
+ (WebCore::CCHeadsUpDisplayLayerImpl::drawHudContents):
+ (WebCore::CCHeadsUpDisplayLayerImpl::drawFPSCounter):
+ (WebCore::CCHeadsUpDisplayLayerImpl::drawFPSCounterText):
+ (WebCore::CCHeadsUpDisplayLayerImpl::drawDebugRects):
+ * platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h:
+ (WebCore):
+
2012-07-31 Dean Jackson <[email protected]>
ImageCG doesn't initialize m_decodedPropertiesSize in BitmapImage constructor
Modified: trunk/Source/WebCore/WebCore.gypi (124274 => 124275)
--- trunk/Source/WebCore/WebCore.gypi 2012-08-01 00:19:37 UTC (rev 124274)
+++ trunk/Source/WebCore/WebCore.gypi 2012-08-01 00:34:43 UTC (rev 124275)
@@ -8264,8 +8264,6 @@
'platform/graphics/chromium/LayerTextureSubImage.cpp',
'platform/graphics/chromium/LayerTextureSubImage.h',
'platform/graphics/chromium/LayerTextureUpdater.h',
- 'platform/graphics/chromium/PlatformCanvas.cpp',
- 'platform/graphics/chromium/PlatformCanvas.h',
'platform/graphics/chromium/PlatformColor.h',
'platform/graphics/chromium/ProgramBinding.cpp',
'platform/graphics/chromium/ProgramBinding.h',
Deleted: trunk/Source/WebCore/platform/graphics/chromium/PlatformCanvas.cpp (124274 => 124275)
--- trunk/Source/WebCore/platform/graphics/chromium/PlatformCanvas.cpp 2012-08-01 00:19:37 UTC (rev 124274)
+++ trunk/Source/WebCore/platform/graphics/chromium/PlatformCanvas.cpp 2012-08-01 00:34:43 UTC (rev 124275)
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "PlatformCanvas.h"
-
-#include "GraphicsContext.h"
-
-#include "NativeImageSkia.h"
-#include "PlatformContextSkia.h"
-#include "SkColorPriv.h"
-#include "skia/ext/platform_canvas.h"
-
-namespace WebCore {
-
-PlatformCanvas::PlatformCanvas()
- : m_opaque(false)
-{
-}
-
-PlatformCanvas::~PlatformCanvas()
-{
-}
-
-void PlatformCanvas::resize(const IntSize& size)
-{
- if (m_size == size)
- return;
- m_size = size;
- createBackingCanvas();
-}
-
-void PlatformCanvas::setOpaque(bool opaque)
-{
- if (opaque == m_opaque)
- return;
-
- m_opaque = opaque;
- createBackingCanvas();
-}
-
-void PlatformCanvas::createBackingCanvas()
-{
- if (m_size.isEmpty())
- return;
-
- m_skiaCanvas = adoptPtr(skia::CreateBitmapCanvas(m_size.width(), m_size.height(), m_opaque));
-}
-
-PlatformCanvas::AutoLocker::AutoLocker(PlatformCanvas* canvas)
- : m_canvas(canvas)
-{
- if (m_canvas->m_skiaCanvas) {
- m_bitmap = &m_canvas->m_skiaCanvas->getDevice()->accessBitmap(false);
- m_bitmap->lockPixels();
- } else
- m_bitmap = 0;
-}
-
-PlatformCanvas::AutoLocker::~AutoLocker()
-{
- if (m_bitmap)
- m_bitmap->unlockPixels();
-}
-
-const uint8_t* PlatformCanvas::AutoLocker::pixels() const
-{
- if (m_bitmap && m_bitmap->config() == SkBitmap::kARGB_8888_Config)
- return static_cast<const uint8_t*>(m_bitmap->getPixels());
- return 0;
-}
-
-PlatformCanvas::Painter::Painter(PlatformCanvas* canvas, PlatformCanvas::Painter::TextOption option)
-{
- m_skiaContext = adoptPtr(new PlatformContextSkia(canvas->m_skiaCanvas.get()));
-
- m_context = adoptPtr(new GraphicsContext(reinterpret_cast<PlatformGraphicsContext*>(m_skiaContext.get())));
- context()->save();
-}
-
-PlatformCanvas::Painter::~Painter()
-{
- context()->restore();
-}
-
-} // namespace WebCore
Deleted: trunk/Source/WebCore/platform/graphics/chromium/PlatformCanvas.h (124274 => 124275)
--- trunk/Source/WebCore/platform/graphics/chromium/PlatformCanvas.h 2012-08-01 00:19:37 UTC (rev 124274)
+++ trunk/Source/WebCore/platform/graphics/chromium/PlatformCanvas.h 2012-08-01 00:34:43 UTC (rev 124275)
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PlatformCanvas_h
-#define PlatformCanvas_h
-
-#include "IntSize.h"
-#include <stdint.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
-
-class SkBitmap;
-class SkCanvas;
-
-namespace WebCore {
-
-class GraphicsContext;
-class PlatformContextSkia;
-
-// A 2D buffer of pixels with an associated GraphicsContext.
-class PlatformCanvas {
- WTF_MAKE_NONCOPYABLE(PlatformCanvas);
-public:
- PlatformCanvas();
- ~PlatformCanvas();
-
- // Scoped lock class to get temporary access to this canvas's pixels.
- class AutoLocker {
- WTF_MAKE_NONCOPYABLE(AutoLocker);
- public:
- explicit AutoLocker(PlatformCanvas*);
- ~AutoLocker();
-
- const uint8_t* pixels() const;
- private:
- PlatformCanvas* m_canvas;
- const SkBitmap* m_bitmap;
- };
-
- // Scoped lock class to get temporary access to paint into this canvas.
- class Painter {
- WTF_MAKE_NONCOPYABLE(Painter);
- public:
- enum TextOption { GrayscaleText, SubpixelText };
-
- Painter(PlatformCanvas*, TextOption);
- // Destructor restores canvas context to pre-construction state.
- ~Painter();
-
- GraphicsContext* context() const { return m_context.get(); }
- PlatformContextSkia* skiaContext() const { return m_skiaContext.get(); }
- private:
- OwnPtr<GraphicsContext> m_context;
- OwnPtr<PlatformContextSkia> m_skiaContext;
- };
-
- void resize(const IntSize&);
- IntSize size() const { return m_size; }
-
- void setOpaque(bool);
- bool opaque() const { return m_opaque; }
-
-private:
- void createBackingCanvas();
-
- OwnPtr<SkCanvas> m_skiaCanvas;
- IntSize m_size;
- bool m_opaque;
-};
-
-} // namespace WebCore
-
-#endif
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCFontAtlas.cpp (124274 => 124275)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCFontAtlas.cpp 2012-08-01 00:19:37 UTC (rev 124274)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCFontAtlas.cpp 2012-08-01 00:34:43 UTC (rev 124275)
@@ -130,7 +130,7 @@
generateAtlasForFont(atlasContext, fontDescription, Color(255, 0, 0), IntPoint(0, fontDescription.computedPixelSize()), m_asciiToRectTable);
}
-void CCFontAtlas::drawText(GraphicsContext* targetContext, const String& text, const IntPoint& destPosition, const IntSize& clip) const
+void CCFontAtlas::drawText(SkCanvas* canvas, const String& text, const IntPoint& destPosition, const IntSize& clip) const
{
ASSERT(CCProxy::isImplThread());
ASSERT(m_atlas);
@@ -138,9 +138,13 @@
Vector<String> lines;
text.split('\n', lines);
+ PlatformContextSkia platformContext(canvas);
+ platformContext.setDrawingToImageBuffer(true);
+ GraphicsContext context(&platformContext);
+
IntPoint position = destPosition;
for (size_t i = 0; i < lines.size(); ++i) {
- drawOneLineOfTextInternal(targetContext, lines[i], position);
+ drawOneLineOfTextInternal(&context, lines[i], position);
position.setY(position.y() + m_fontHeight);
if (position.y() > clip.height())
return;
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCFontAtlas.h (124274 => 124275)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCFontAtlas.h 2012-08-01 00:19:37 UTC (rev 124274)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCFontAtlas.h 2012-08-01 00:34:43 UTC (rev 124275)
@@ -32,6 +32,8 @@
#include <wtf/PassOwnPtr.h>
#include <wtf/text/WTFString.h>
+class SkCanvas;
+
namespace WebCore {
class Color;
@@ -60,7 +62,7 @@
// - IntSize clip is used to avoid wasting time drawing things that are outside the
// target canvas bounds.
// - Should only be called only on the impl thread.
- void drawText(GraphicsContext*, const String& text, const IntPoint& destPosition, const IntSize& clip) const;
+ void drawText(SkCanvas*, const String& text, const IntPoint& destPosition, const IntSize& clip) const;
// Draws the entire atlas at the specified position, just for debugging purposes.
void drawDebugAtlas(GraphicsContext*, const IntPoint& destPosition) const;
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp (124274 => 124275)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp 2012-08-01 00:19:37 UTC (rev 124274)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.cpp 2012-08-01 00:34:43 UTC (rev 124275)
@@ -30,7 +30,6 @@
#include "Extensions3DChromium.h"
#include "GraphicsContext3D.h"
#include "LayerRendererChromium.h"
-#include "PlatformCanvas.h"
#include "cc/CCDebugRectHistory.h"
#include "cc/CCFontAtlas.h"
#include "cc/CCFrameRateCounter.h"
@@ -69,19 +68,15 @@
return;
// Render pixels into the texture.
- PlatformCanvas canvas;
- canvas.resize(bounds());
- {
- PlatformCanvas::Painter painter(&canvas, PlatformCanvas::Painter::GrayscaleText);
- painter.context()->clearRect(FloatRect(0, 0, bounds().width(), bounds().height()));
- drawHudContents(painter.context());
- }
+ OwnPtr<SkCanvas> canvas = adoptPtr(skia::CreateBitmapCanvas(bounds().width(), bounds().height(), false /* opaque */));
+ drawHudContents(canvas.get());
- {
- PlatformCanvas::AutoLocker locker(&canvas);
- IntRect layerRect(IntPoint(), bounds());
- resourceProvider->upload(m_hudTexture->id(), locker.pixels(), layerRect, layerRect, layerRect);
- }
+ const SkBitmap* bitmap = &canvas->getDevice()->accessBitmap(false);
+ SkAutoLockPixels locker(*bitmap);
+
+ IntRect layerRect(IntPoint(), bounds());
+ ASSERT(bitmap->config() == SkBitmap::kARGB_8888_Config);
+ resourceProvider->upload(m_hudTexture->id(), static_cast<const uint8_t*>(bitmap->getPixels()), layerRect, layerRect, layerRect);
}
void CCHeadsUpDisplayLayerImpl::appendQuads(CCQuadSink& quadList, const CCSharedQuadState* sharedQuadState, bool&)
@@ -114,13 +109,14 @@
m_hudTexture->leak();
}
-void CCHeadsUpDisplayLayerImpl::drawHudContents(GraphicsContext* context)
+void CCHeadsUpDisplayLayerImpl::drawHudContents(SkCanvas* canvas)
{
const CCLayerTreeSettings& settings = layerTreeHostImpl()->settings();
if (settings.showPlatformLayerTree) {
- context->setFillColor(Color(0, 0, 0, 192), ColorSpaceDeviceRGB);
- context->fillRect(FloatRect(0, 0, bounds().width(), bounds().height()));
+ SkPaint paint;
+ paint.setColor(SkColorSetARGB(192, 0, 0, 0));
+ canvas->drawRect(SkRect::MakeXYWH(0, 0, bounds().width(), bounds().height()), paint);
}
int fpsCounterHeight = 40;
@@ -133,40 +129,39 @@
platformLayerTreeTop = 0;
if (settings.showFPSCounter)
- drawFPSCounter(context, layerTreeHostImpl()->fpsCounter(), fpsCounterTop, fpsCounterHeight);
+ drawFPSCounter(canvas, layerTreeHostImpl()->fpsCounter(), fpsCounterTop, fpsCounterHeight);
if (settings.showPlatformLayerTree && m_fontAtlas) {
String layerTree = layerTreeHostImpl()->layerTreeAsText();
- m_fontAtlas->drawText(context, layerTree, IntPoint(2, platformLayerTreeTop), bounds());
+ m_fontAtlas->drawText(canvas, layerTree, IntPoint(2, platformLayerTreeTop), bounds());
}
if (settings.showDebugRects())
- drawDebugRects(context, layerTreeHostImpl()->debugRectHistory());
+ drawDebugRects(canvas, layerTreeHostImpl()->debugRectHistory());
}
-void CCHeadsUpDisplayLayerImpl::drawFPSCounter(GraphicsContext* context, CCFrameRateCounter* fpsCounter, int top, int height)
+void CCHeadsUpDisplayLayerImpl::drawFPSCounter(SkCanvas* canvas, CCFrameRateCounter* fpsCounter, int top, int height)
{
float textWidth = 170; // so text fits on linux.
float graphWidth = fpsCounter->timeStampHistorySize();
// Draw the FPS text.
- drawFPSCounterText(context, fpsCounter, top, textWidth, height);
+ drawFPSCounterText(canvas, fpsCounter, top, textWidth, height);
// Draw FPS graph.
const double loFPS = 0;
const double hiFPS = 80;
- context->setStrokeStyle(SolidStroke);
- context->setFillColor(Color(154, 205, 50), ColorSpaceDeviceRGB);
- context->fillRect(FloatRect(2 + textWidth, top, graphWidth, height / 2));
- context->setFillColor(Color(255, 250, 205), ColorSpaceDeviceRGB);
- context->fillRect(FloatRect(2 + textWidth, top + height / 2, graphWidth, height / 2));
- context->setStrokeColor(Color(255, 0, 0), ColorSpaceDeviceRGB);
- context->setFillColor(Color(255, 0, 0), ColorSpaceDeviceRGB);
+ SkPaint paint;
+ paint.setColor(SkColorSetRGB(154, 205, 50));
+ canvas->drawRect(SkRect::MakeXYWH(2 + textWidth, top, graphWidth, height / 2), paint);
+ paint.setColor(SkColorSetRGB(255, 250, 205));
+ canvas->drawRect(SkRect::MakeXYWH(2 + textWidth, top + height / 2, graphWidth, height / 2), paint);
+
int graphLeft = static_cast<int>(textWidth + 3);
- IntPoint prev(-1, 0);
int x = 0;
double h = static_cast<double>(height - 2);
+ SkPath path;
for (int i = 0; i < fpsCounter->timeStampHistorySize() - 1; ++i) {
int j = i + 1;
double delta = fpsCounter->timeStampOfRecentFrame(j) - fpsCounter->timeStampOfRecentFrame(i);
@@ -188,73 +183,84 @@
// Plot this data point.
IntPoint cur(graphLeft + x, 1 + top + p*h);
- if (prev.x() != -1)
- context->drawLine(prev, cur);
- prev = cur;
+ if (path.isEmpty())
+ path.moveTo(cur);
+ else
+ path.lineTo(cur);
x += 1;
}
+ paint.setColor(SK_ColorRED);
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStrokeWidth(1);
+ paint.setAntiAlias(true);
+ canvas->drawPath(path, paint);
}
-void CCHeadsUpDisplayLayerImpl::drawFPSCounterText(GraphicsContext* context, CCFrameRateCounter* fpsCounter, int top, int width, int height)
+void CCHeadsUpDisplayLayerImpl::drawFPSCounterText(SkCanvas* canvas, CCFrameRateCounter* fpsCounter, int top, int width, int height)
{
double averageFPS, stdDeviation;
fpsCounter->getAverageFPSAndStandardDeviation(averageFPS, stdDeviation);
// Draw background.
- context->setFillColor(Color(0, 0, 0, 255), ColorSpaceDeviceRGB);
- context->fillRect(FloatRect(2, top, width, height));
+ SkPaint paint;
+ paint.setColor(SK_ColorBLACK);
+ canvas->drawRect(SkRect::MakeXYWH(2, top, width, height), paint);
// Draw FPS text.
if (m_fontAtlas)
- m_fontAtlas->drawText(context, String::format("FPS: %4.1f +/- %3.1f", averageFPS, stdDeviation), IntPoint(10, height / 3), IntSize(width, height));
+ m_fontAtlas->drawText(canvas, String::format("FPS: %4.1f +/- %3.1f", averageFPS, stdDeviation), IntPoint(10, height / 3), IntSize(width, height));
}
-void CCHeadsUpDisplayLayerImpl::drawDebugRects(GraphicsContext* context, CCDebugRectHistory* debugRectHistory)
+void CCHeadsUpDisplayLayerImpl::drawDebugRects(SkCanvas* canvas, CCDebugRectHistory* debugRectHistory)
{
const Vector<CCDebugRect>& debugRects = debugRectHistory->debugRects();
+
for (size_t i = 0; i < debugRects.size(); ++i) {
+ SkColor strokeColor = 0;
+ SkColor fillColor = 0;
- if (debugRects[i].type == PaintRectType) {
+ switch (debugRects[i].type) {
+ case PaintRectType:
// Paint rects in red
- context->setStrokeColor(Color(255, 0, 0, 255), ColorSpaceDeviceRGB);
- context->fillRect(debugRects[i].rect, Color(255, 0, 0, 30), ColorSpaceDeviceRGB);
- context->strokeRect(debugRects[i].rect, 2.0);
- }
-
- if (debugRects[i].type == PropertyChangedRectType) {
+ strokeColor = SkColorSetARGB(255, 255, 0, 0);
+ fillColor = SkColorSetARGB(30, 255, 0, 0);
+ break;
+ case PropertyChangedRectType:
// Property-changed rects in blue
- context->setStrokeColor(Color(0, 0, 255, 255), ColorSpaceDeviceRGB);
- context->fillRect(debugRects[i].rect, Color(0, 0, 255, 30), ColorSpaceDeviceRGB);
- context->strokeRect(debugRects[i].rect, 2.0);
- }
-
- if (debugRects[i].type == SurfaceDamageRectType) {
+ strokeColor = SkColorSetARGB(255, 255, 0, 0);
+ fillColor = SkColorSetARGB(30, 0, 0, 255);
+ break;
+ case SurfaceDamageRectType:
// Surface damage rects in yellow-orange
- context->setStrokeColor(Color(200, 100, 0, 255), ColorSpaceDeviceRGB);
- context->fillRect(debugRects[i].rect, Color(200, 100, 0, 30), ColorSpaceDeviceRGB);
- context->strokeRect(debugRects[i].rect, 2.0);
- }
-
- if (debugRects[i].type == ReplicaScreenSpaceRectType) {
+ strokeColor = SkColorSetARGB(255, 200, 100, 0);
+ fillColor = SkColorSetARGB(30, 200, 100, 0);
+ break;
+ case ReplicaScreenSpaceRectType:
// Screen space rects in green.
- context->setStrokeColor(Color(100, 200, 0, 255), ColorSpaceDeviceRGB);
- context->fillRect(debugRects[i].rect, Color(100, 200, 0, 30), ColorSpaceDeviceRGB);
- context->strokeRect(debugRects[i].rect, 2.0);
- }
-
- if (debugRects[i].type == ScreenSpaceRectType) {
+ strokeColor = SkColorSetARGB(255, 100, 200, 0);
+ fillColor = SkColorSetARGB(30, 100, 200, 0);
+ break;
+ case ScreenSpaceRectType:
// Screen space rects in purple.
- context->setStrokeColor(Color(100, 0, 200, 255), ColorSpaceDeviceRGB);
- context->fillRect(debugRects[i].rect, Color(100, 0, 200, 10), ColorSpaceDeviceRGB);
- context->strokeRect(debugRects[i].rect, 2.0);
+ strokeColor = SkColorSetARGB(255, 100, 0, 200);
+ fillColor = SkColorSetARGB(10, 100, 0, 200);
+ break;
+ case OccludingRectType:
+ // Occluding rects in a reddish color.
+ strokeColor = SkColorSetARGB(255, 200, 0, 100);
+ fillColor = SkColorSetARGB(10, 200, 0, 100);
+ break;
}
- if (debugRects[i].type == OccludingRectType) {
- // Occluding rects in a reddish color.
- context->setStrokeColor(Color(200, 0, 100, 255), ColorSpaceDeviceRGB);
- context->fillRect(debugRects[i].rect, Color(200, 0, 100, 10), ColorSpaceDeviceRGB);
- context->strokeRect(debugRects[i].rect, 2.0);
- }
+ SkRect rect = debugRects[i].rect;
+ SkPaint paint;
+ paint.setColor(fillColor);
+ canvas->drawRect(rect, paint);
+
+ paint.setColor(strokeColor);
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStrokeWidth(2);
+ canvas->drawRect(rect, paint);
}
}
Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h (124274 => 124275)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h 2012-08-01 00:19:37 UTC (rev 124274)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCHeadsUpDisplayLayerImpl.h 2012-08-01 00:34:43 UTC (rev 124275)
@@ -29,12 +29,13 @@
#include "cc/CCLayerImpl.h"
#include "cc/CCScopedTexture.h"
+class SkCanvas;
+
namespace WebCore {
class CCDebugRectHistory;
class CCFontAtlas;
class CCFrameRateCounter;
-class GraphicsContext;
class CCHeadsUpDisplayLayerImpl : public CCLayerImpl {
public:
@@ -57,10 +58,10 @@
virtual const char* layerTypeAsString() const OVERRIDE { return "HeadsUpDisplayLayer"; }
- void drawHudContents(GraphicsContext*);
- void drawFPSCounter(GraphicsContext*, CCFrameRateCounter*, int top, int height);
- void drawFPSCounterText(GraphicsContext*, CCFrameRateCounter*, int top, int width, int height);
- void drawDebugRects(GraphicsContext*, CCDebugRectHistory*);
+ void drawHudContents(SkCanvas*);
+ void drawFPSCounter(SkCanvas*, CCFrameRateCounter*, int top, int height);
+ void drawFPSCounterText(SkCanvas*, CCFrameRateCounter*, int top, int width, int height);
+ void drawDebugRects(SkCanvas*, CCDebugRectHistory*);
OwnPtr<CCFontAtlas> m_fontAtlas;
OwnPtr<CCScopedTexture> m_hudTexture;
_______________________________________________ webkit-changes mailing list [email protected] http://lists.webkit.org/mailman/listinfo/webkit-changes
