summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authoregraether@chromium.org <egraether@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-06 20:40:59 +0000
committeregraether@chromium.org <egraether@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-06 20:40:59 +0000
commit35c5f13b7a4fee435a9b6ebdf3a1b825adcfd5d5 (patch)
treecbbae78ce4761bc1f4a2ce8fc32d7dc92c445632 /cc
parentf27d2834e3a86b789fee28e287c071c5ffe993f7 (diff)
downloadchromium_src-35c5f13b7a4fee435a9b6ebdf3a1b825adcfd5d5.zip
chromium_src-35c5f13b7a4fee435a9b6ebdf3a1b825adcfd5d5.tar.gz
chromium_src-35c5f13b7a4fee435a9b6ebdf3a1b825adcfd5d5.tar.bz2
cc: Refactoring of HudLayer contents and UI polishing
This change refactors drawing and updating of HudLayer contents and introduces small UI improvements. Refactoring: - Made all drawing methods const. - HeadsUpDisplayLayerImpl::updateHudContents() manages graph value updating now. - Widget drawing methods return the area the widget covers. - Debug rectangle drawing reuses one SkPaint instance. - Added all colors to DebugColors. - Turned Graph helper structure into a class. UI changes: - Synced memory stats updating with graph value updating and increased font size to improve readability. - Memory stats display gets flexible width to adapt to the widget previously drawn. - Removed the 1px gaps in the paint time graph to display more values and increased size of the paint time counter buffer. - Indicator line in the graph is drawn on top of paint time graph and uses additive blending to increase contrast. - Increased saturation of the paint time counter's green. - Removed the 2px top/left offset from the border for widgets. - New drawing order: debug rectangles, platform layer tree, FPS counter | paint time counter, memory stats; Screenshot: https://docs.google.com/file/d/0B8Y78t3tjy1XdXYzelVRdGVnQzg/edit?usp=sharing BUG= Review URL: https://chromiumcodereview.appspot.com/12468003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186495 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/debug_colors.cc9
-rw-r--r--cc/debug_colors.h5
-rw-r--r--cc/heads_up_display_layer_impl.cc158
-rw-r--r--cc/heads_up_display_layer_impl.h30
-rw-r--r--cc/layer_tree_debug_state.cc4
-rw-r--r--cc/layer_tree_debug_state.h1
-rw-r--r--cc/paint_time_counter.h2
7 files changed, 122 insertions, 87 deletions
diff --git a/cc/debug_colors.cc b/cc/debug_colors.cc
index e41435d..01b6667 100644
--- a/cc/debug_colors.cc
+++ b/cc/debug_colors.cc
@@ -124,10 +124,15 @@ SkColor DebugColors::MissingPictureFillColor() { return SK_ColorMAGENTA; }
// ======= HUD widget colors =======
+SkColor DebugColors::HUDBackgroundColor() { return SkColorSetARGB(215, 17, 17, 17); }
+SkColor DebugColors::HUDSeparatorLineColor() { return SkColorSetARGB(255, 130, 130, 130); }
+SkColor DebugColors::HUDIndicatorLineColor() { return SkColorSetARGB(255, 80, 80, 80); }
+
SkColor DebugColors::PlatformLayerTreeTextColor() { return SK_ColorRED; }
SkColor DebugColors::FPSDisplayTextAndGraphColor() { return SK_ColorRED; }
+SkColor DebugColors::MemoryDisplayTextColor() { return SkColorSetARGB(255, 220, 220, 220); }
-// Paint time display has the same green as used for paint time in the WebInspector
-SkColor DebugColors::PaintTimeDisplayTextAndGraphColor() { return SkColorSetRGB(95, 160, 80); }
+// Paint time display in green (similar to paint times in the WebInspector)
+SkColor DebugColors::PaintTimeDisplayTextAndGraphColor() { return SkColorSetRGB(75, 155, 55); }
} // namespace cc
diff --git a/cc/debug_colors.h b/cc/debug_colors.h
index 8a4d480..da9dbd8 100644
--- a/cc/debug_colors.h
+++ b/cc/debug_colors.h
@@ -88,8 +88,13 @@ class DebugColors {
static SkColor NonPaintedFillColor();
static SkColor MissingPictureFillColor();
+ static SkColor HUDBackgroundColor();
+ static SkColor HUDSeparatorLineColor();
+ static SkColor HUDIndicatorLineColor();
+
static SkColor PlatformLayerTreeTextColor();
static SkColor FPSDisplayTextAndGraphColor();
+ static SkColor MemoryDisplayTextColor();
static SkColor PaintTimeDisplayTextAndGraphColor();
DISALLOW_IMPLICIT_CONSTRUCTORS(DebugColors);
diff --git a/cc/heads_up_display_layer_impl.cc b/cc/heads_up_display_layer_impl.cc
index 75b2df1..27f43b5 100644
--- a/cc/heads_up_display_layer_impl.cc
+++ b/cc/heads_up_display_layer_impl.cc
@@ -61,11 +61,11 @@ HeadsUpDisplayLayerImpl::Graph::Graph(double indicatorValue, double startUpperBo
{
}
-double HeadsUpDisplayLayerImpl::Graph::updateUpperBound(Graph* graph)
+double HeadsUpDisplayLayerImpl::Graph::updateUpperBound()
{
- double targetUpperBound = std::max(graph->max, graph->defaultUpperBound);
- graph->currentUpperBound += (targetUpperBound - graph->currentUpperBound) * 0.5;
- return graph->currentUpperBound;
+ double targetUpperBound = std::max(max, defaultUpperBound);
+ currentUpperBound += (targetUpperBound - currentUpperBound) * 0.5;
+ return currentUpperBound;
}
HeadsUpDisplayLayerImpl::HeadsUpDisplayLayerImpl(LayerTreeImpl* treeImpl, int id)
@@ -141,6 +141,8 @@ void HeadsUpDisplayLayerImpl::updateHudTexture(ResourceProvider* resourceProvide
if (canvasSize.fWidth != bounds().width() || canvasSize.fHeight != bounds().height() || !m_hudCanvas)
m_hudCanvas = make_scoped_ptr(skia::CreateBitmapCanvas(bounds().width(), bounds().height(), false /* opaque */));
+ updateHudContents();
+
m_hudCanvas->clear(SkColorSetARGB(0, 0, 0, 0));
drawHudContents(m_hudCanvas.get());
@@ -175,24 +177,25 @@ bool HeadsUpDisplayLayerImpl::layerIsAlwaysDamaged() const
return true;
}
-void HeadsUpDisplayLayerImpl::drawHudContents(SkCanvas* canvas)
+void HeadsUpDisplayLayerImpl::updateHudContents()
{
const LayerTreeDebugState& debugState = layerTreeImpl()->debug_state();
- if (debugState.showPlatformLayerTree)
- drawPlaformLayerTree(canvas);
-
- if (debugState.continuousPainting || debugState.showFPSCounter) {
- FrameRateCounter* fpsCounter = layerTreeImpl()->frame_rate_counter();
- PaintTimeCounter* paintTimeCounter = layerTreeImpl()->paint_time_counter();
+ // Don't update numbers every frame so text is readable.
+ base::TimeTicks now = layerTreeImpl()->CurrentFrameTime();
+ if (base::TimeDelta(now - m_timeOfLastGraphUpdate).InSecondsF() > 0.25f) {
+ m_timeOfLastGraphUpdate = now;
- // Update numbers not every frame so text is readable
- base::TimeTicks now = base::TimeTicks::Now();
- if (base::TimeDelta(now - m_timeOfLastGraphUpdate).InSecondsF() > 0.25) {
+ if (debugState.showFPSCounter) {
+ FrameRateCounter* fpsCounter = layerTreeImpl()->frame_rate_counter();
m_fpsGraph.value = fpsCounter->getAverageFPS();
fpsCounter->getMinAndMaxFPS(m_fpsGraph.min, m_fpsGraph.max);
+ }
+ if (debugState.continuousPainting) {
+ PaintTimeCounter* paintTimeCounter = layerTreeImpl()->paint_time_counter();
base::TimeDelta latest, min, max;
+
if (paintTimeCounter->End())
latest = paintTimeCounter->End()->total_time();
paintTimeCounter->GetMinAndMaxPaintTime(&min, &max);
@@ -200,25 +203,43 @@ void HeadsUpDisplayLayerImpl::drawHudContents(SkCanvas* canvas)
m_paintTimeGraph.value = latest.InMillisecondsF();
m_paintTimeGraph.min = min.InMillisecondsF();
m_paintTimeGraph.max = max.InMillisecondsF();
+ }
- m_timeOfLastGraphUpdate = now;
+ if (debugState.showMemoryStats()) {
+ MemoryHistory* memoryHistory = layerTreeImpl()->memory_history();
+ if (memoryHistory->End())
+ m_memoryEntry = **memoryHistory->End();
+ else
+ m_memoryEntry = MemoryHistory::Entry();
}
+ }
- int top = 2;
- if (debugState.continuousPainting)
- top = drawPaintTimeDisplay(canvas, paintTimeCounter, top);
- // Don't show the FPS display when continuous painting is enabled, because it would show misleading numbers.
- else if (debugState.showFPSCounter)
- top = drawFPSDisplay(canvas, fpsCounter, top);
+ m_fpsGraph.updateUpperBound();
+ m_paintTimeGraph.updateUpperBound();
+}
- drawMemoryDisplay(canvas, layerTreeImpl()->memory_history(), top);
- }
+void HeadsUpDisplayLayerImpl::drawHudContents(SkCanvas* canvas) const
+{
+ const LayerTreeDebugState& debugState = layerTreeImpl()->debug_state();
if (debugState.showHudRects())
drawDebugRects(canvas, layerTreeImpl()->debug_rect_history());
+
+ if (debugState.showPlatformLayerTree)
+ drawPlatformLayerTree(canvas);
+
+ SkRect area = SkRect::MakeEmpty();
+ if (debugState.continuousPainting)
+ area = drawPaintTimeDisplay(canvas, layerTreeImpl()->paint_time_counter(), 0, 0);
+ // Don't show the FPS display when continuous painting is enabled, because it would show misleading numbers.
+ else if (debugState.showFPSCounter)
+ area = drawFPSDisplay(canvas, layerTreeImpl()->frame_rate_counter(), 0, 0);
+
+ if (debugState.showMemoryStats())
+ drawMemoryDisplay(canvas, 0, area.bottom(), SkMaxScalar(area.width(), 150));
}
-void HeadsUpDisplayLayerImpl::drawText(SkCanvas* canvas, SkPaint* paint, const std::string& text, const SkPaint::Align& align, const int& size, const int& x, const int& y)
+void HeadsUpDisplayLayerImpl::drawText(SkCanvas* canvas, SkPaint* paint, const std::string& text, SkPaint::Align align, int size, int x, int y) const
{
const bool antiAlias = paint->isAntiAlias();
paint->setAntiAlias(true);
@@ -231,31 +252,33 @@ void HeadsUpDisplayLayerImpl::drawText(SkCanvas* canvas, SkPaint* paint, const s
paint->setAntiAlias(antiAlias);
}
-void HeadsUpDisplayLayerImpl::drawText(SkCanvas* canvas, SkPaint* paint, const std::string& text, const SkPaint::Align& align, const int& size, const SkPoint& pos)
+void HeadsUpDisplayLayerImpl::drawText(SkCanvas* canvas, SkPaint* paint, const std::string& text, SkPaint::Align align, int size, const SkPoint& pos) const
{
drawText(canvas, paint, text, align, size, pos.x(), pos.y());
}
-void HeadsUpDisplayLayerImpl::drawGraphBackground(SkCanvas* canvas, SkPaint* paint, const SkRect& bounds)
+void HeadsUpDisplayLayerImpl::drawGraphBackground(SkCanvas* canvas, SkPaint* paint, const SkRect& bounds) const
{
- paint->setColor(SkColorSetARGB(215, 17, 17, 17));
+ paint->setColor(DebugColors::HUDBackgroundColor());
canvas->drawRect(bounds, *paint);
}
-void HeadsUpDisplayLayerImpl::drawGraphLines(SkCanvas* canvas, SkPaint* paint, const SkRect& bounds, const Graph& graph)
+void HeadsUpDisplayLayerImpl::drawGraphLines(SkCanvas* canvas, SkPaint* paint, const SkRect& bounds, const Graph& graph) const
{
// Draw top and bottom line.
- paint->setColor(SkColorSetRGB(130, 130, 130));
+ paint->setColor(DebugColors::HUDSeparatorLineColor());
canvas->drawLine(bounds.left(), bounds.top() - 1, bounds.right(), bounds.top() - 1, *paint);
canvas->drawLine(bounds.left(), bounds.bottom(), bounds.right(), bounds.bottom(), *paint);
- // Draw indicator line.
- paint->setColor(SkColorSetRGB(100, 100, 100));
+ // Draw indicator line (additive blend mode to increase contrast when drawn on top of graph).
+ paint->setColor(DebugColors::HUDIndicatorLineColor());
+ paint->setXfermodeMode(SkXfermode::kPlus_Mode);
const double indicatorTop = bounds.height() * (1 - graph.indicator / graph.currentUpperBound) - 1;
canvas->drawLine(bounds.left(), bounds.top() + indicatorTop, bounds.right(), bounds.top() + indicatorTop, *paint);
+ paint->setXfermode(NULL);
}
-void HeadsUpDisplayLayerImpl::drawPlaformLayerTree(SkCanvas* canvas)
+void HeadsUpDisplayLayerImpl::drawPlatformLayerTree(SkCanvas* canvas) const
{
const int fontHeight = 14;
SkPaint paint = createPaint();
@@ -271,7 +294,7 @@ void HeadsUpDisplayLayerImpl::drawPlaformLayerTree(SkCanvas* canvas)
}
}
-int HeadsUpDisplayLayerImpl::drawFPSDisplay(SkCanvas* canvas, FrameRateCounter* fpsCounter, const int& top)
+SkRect HeadsUpDisplayLayerImpl::drawFPSDisplay(SkCanvas* canvas, const FrameRateCounter* fpsCounter, int right, int top) const
{
const int padding = 4;
const int gap = 6;
@@ -285,11 +308,12 @@ int HeadsUpDisplayLayerImpl::drawFPSDisplay(SkCanvas* canvas, FrameRateCounter*
const int width = graphWidth + histogramWidth + 4 * padding;
const int height = fontHeight + graphHeight + 4 * padding + 2;
+ const int left = bounds().width() - width - right;
- const int left = bounds().width() - width - 2;
+ const SkRect area = SkRect::MakeXYWH(left, top, width, height);
SkPaint paint = createPaint();
- drawGraphBackground(canvas, &paint, SkRect::MakeXYWH(left, top, width, height));
+ drawGraphBackground(canvas, &paint, area);
SkRect textBounds = SkRect::MakeXYWH(left + padding, top + padding, graphWidth + histogramWidth + gap + 2, fontHeight);
SkRect graphBounds = SkRect::MakeXYWH(left + padding, textBounds.bottom() + 2 * padding, graphWidth, graphHeight);
@@ -302,7 +326,6 @@ int HeadsUpDisplayLayerImpl::drawFPSDisplay(SkCanvas* canvas, FrameRateCounter*
drawText(canvas, &paint, valueText, SkPaint::kLeft_Align, fontHeight, textBounds.left(), textBounds.bottom());
drawText(canvas, &paint, minMaxText, SkPaint::kRight_Align, fontHeight, textBounds.right(), textBounds.bottom());
- const double upperBound = Graph::updateUpperBound(&m_fpsGraph);
drawGraphLines(canvas, &paint, graphBounds, m_fpsGraph);
// Collect graph and histogram data.
@@ -321,7 +344,7 @@ int HeadsUpDisplayLayerImpl::drawFPSDisplay(SkCanvas* canvas, FrameRateCounter*
double fps = 1.0 / delta.InSecondsF();
// Clamp the FPS to the range we want to plot visually.
- double p = fps / upperBound;
+ double p = fps / m_fpsGraph.currentUpperBound;
if (p > 1)
p = 1;
@@ -342,7 +365,7 @@ int HeadsUpDisplayLayerImpl::drawFPSDisplay(SkCanvas* canvas, FrameRateCounter*
}
// Draw FPS histogram.
- paint.setColor(SkColorSetRGB(130, 130, 130));
+ paint.setColor(DebugColors::HUDSeparatorLineColor());
canvas->drawLine(histogramBounds.left() - 1, histogramBounds.top() - 1, histogramBounds.left() - 1, histogramBounds.bottom() + 1, paint);
canvas->drawLine(histogramBounds.right() + 1, histogramBounds.top() - 1, histogramBounds.right() + 1, histogramBounds.bottom() + 1, paint);
@@ -360,74 +383,69 @@ int HeadsUpDisplayLayerImpl::drawFPSDisplay(SkCanvas* canvas, FrameRateCounter*
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(1);
-
canvas->drawPath(path, paint);
- return top + height + 2;
+ return area;
}
-int HeadsUpDisplayLayerImpl::drawMemoryDisplay(SkCanvas* canvas, MemoryHistory* memoryHistory, const int& initial_top)
+SkRect HeadsUpDisplayLayerImpl::drawMemoryDisplay(SkCanvas* canvas, int right, int top, int width) const
{
- // Don't draw the display if there is no data in it.
- if (!memoryHistory->End())
- return initial_top;
-
- const MemoryHistory::Entry curEntry = **memoryHistory->End();
+ if (!m_memoryEntry.bytes_total())
+ return SkRect::MakeEmpty();
- // Move up by 2 to create no gap between us and previous counter.
- const int top = initial_top - 2;
const int padding = 4;
- const int fontHeight = 11;
+ const int fontHeight = 13;
- const int width = 187;
const int height = 3 * fontHeight + 4 * padding;
+ const int left = bounds().width() - width - right;
+ const SkRect area = SkRect::MakeXYWH(left, top, width, height);
- const int left = bounds().width() - width - 2;
const double megabyte = static_cast<double>(1024*1024);
SkPaint paint = createPaint();
- drawGraphBackground(canvas, &paint, SkRect::MakeXYWH(left, top, width, height));
+ drawGraphBackground(canvas, &paint, area);
SkPoint titlePos = SkPoint::Make(left + padding, top + fontHeight);
SkPoint stat1Pos = SkPoint::Make(left + width - padding - 1, top + padding + 2 * fontHeight);
SkPoint stat2Pos = SkPoint::Make(left + width - padding - 1, top + 2 * padding + 3 * fontHeight);
- paint.setColor(SkColorSetRGB(220, 220, 220));
+ paint.setColor(DebugColors::MemoryDisplayTextColor());
drawText(canvas, &paint, "GPU memory", SkPaint::kLeft_Align, fontHeight, titlePos);
std::string text = base::StringPrintf(
"%6.1f MB used",
- (curEntry.bytes_unreleasable + curEntry.bytes_allocated) / megabyte);
+ (m_memoryEntry.bytes_unreleasable + m_memoryEntry.bytes_allocated) / megabyte);
drawText(canvas, &paint, text, SkPaint::kRight_Align, fontHeight, stat1Pos);
- if (curEntry.bytes_over) {
+ if (m_memoryEntry.bytes_over) {
paint.setColor(SK_ColorRED);
text = base::StringPrintf("%6.1f MB over",
- curEntry.bytes_over / megabyte);
+ m_memoryEntry.bytes_over / megabyte);
} else {
text = base::StringPrintf("%6.1f MB max ",
- curEntry.total_budget_in_bytes / megabyte);
+ m_memoryEntry.total_budget_in_bytes / megabyte);
}
drawText(canvas, &paint, text, SkPaint::kRight_Align, fontHeight, stat2Pos);
- return top + height + 2;
+ return area;
}
-int HeadsUpDisplayLayerImpl::drawPaintTimeDisplay(SkCanvas* canvas, PaintTimeCounter* paintTimeCounter, const int& top)
+SkRect HeadsUpDisplayLayerImpl::drawPaintTimeDisplay(SkCanvas* canvas, const PaintTimeCounter* paintTimeCounter, int right, int top) const
{
const int padding = 4;
const int fontHeight = 15;
- const int graphWidth = paintTimeCounter->HistorySize() * 2 - 1;
+ const int graphWidth = paintTimeCounter->HistorySize();
const int graphHeight = 40;
const int width = graphWidth + 2 * padding;
const int height = fontHeight + graphHeight + 4 * padding + 2 + fontHeight + padding;
+ const int left = bounds().width() - width - right;
- const int left = bounds().width() - width - 2;
+ const SkRect area = SkRect::MakeXYWH(left, top, width, height);
SkPaint paint = createPaint();
- drawGraphBackground(canvas, &paint, SkRect::MakeXYWH(left, top, width, height));
+ drawGraphBackground(canvas, &paint, area);
SkRect textBounds = SkRect::MakeXYWH(left + padding, top + padding, graphWidth, fontHeight);
SkRect textBounds2 = SkRect::MakeXYWH(left + padding, textBounds.bottom() + padding, graphWidth, fontHeight);
@@ -441,9 +459,6 @@ int HeadsUpDisplayLayerImpl::drawPaintTimeDisplay(SkCanvas* canvas, PaintTimeCou
drawText(canvas, &paint, valueText, SkPaint::kLeft_Align, fontHeight, textBounds2.left(), textBounds2.bottom());
drawText(canvas, &paint, minMaxText, SkPaint::kRight_Align, fontHeight, textBounds2.right(), textBounds2.bottom());
- const double upperBound = Graph::updateUpperBound(&m_paintTimeGraph);
- drawGraphLines(canvas, &paint, graphBounds, m_paintTimeGraph);
-
paint.setColor(DebugColors::PaintTimeDisplayTextAndGraphColor());
for (PaintTimeCounter::RingBufferType::Iterator it = paintTimeCounter->End(); it; --it) {
double pt = it->total_time().InMillisecondsF();
@@ -451,20 +466,23 @@ int HeadsUpDisplayLayerImpl::drawPaintTimeDisplay(SkCanvas* canvas, PaintTimeCou
if (pt == 0.0)
continue;
- double p = pt / upperBound;
+ double p = pt / m_paintTimeGraph.currentUpperBound;
if (p > 1)
p = 1;
- canvas->drawRect(SkRect::MakeXYWH(graphBounds.left() + it.index() * 2, graphBounds.bottom() - p * graphBounds.height(), 1, p * graphBounds.height()), paint);
+ canvas->drawRect(SkRect::MakeXYWH(graphBounds.left() + it.index(), graphBounds.bottom() - p * graphBounds.height(), 1, p * graphBounds.height()), paint);
}
- return top + height + 2;
+ drawGraphLines(canvas, &paint, graphBounds, m_paintTimeGraph);
+
+ return area;
}
-void HeadsUpDisplayLayerImpl::drawDebugRects(SkCanvas* canvas, DebugRectHistory* debugRectHistory)
+void HeadsUpDisplayLayerImpl::drawDebugRects(SkCanvas* canvas, DebugRectHistory* debugRectHistory) const
{
const std::vector<DebugRect>& debugRects = debugRectHistory->debugRects();
float rectScale = 1 / layerTreeImpl()->device_scale_factor();
+ SkPaint paint = createPaint();
canvas->save();
canvas->scale(rectScale, rectScale);
@@ -514,8 +532,8 @@ void HeadsUpDisplayLayerImpl::drawDebugRects(SkCanvas* canvas, DebugRectHistory*
const gfx::RectF& rect = debugRects[i].rect;
SkRect skRect = SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height());
- SkPaint paint = createPaint();
paint.setColor(fillColor);
+ paint.setStyle(SkPaint::kFill_Style);
canvas->drawRect(skRect, paint);
paint.setColor(strokeColor);
diff --git a/cc/heads_up_display_layer_impl.h b/cc/heads_up_display_layer_impl.h
index e45cc24..94c3400 100644
--- a/cc/heads_up_display_layer_impl.h
+++ b/cc/heads_up_display_layer_impl.h
@@ -9,6 +9,7 @@
#include "base/time.h"
#include "cc/cc_export.h"
#include "cc/layer_impl.h"
+#include "cc/memory_history.h"
#include "cc/scoped_resource.h"
class SkCanvas;
@@ -20,7 +21,6 @@ namespace cc {
class DebugRectHistory;
class FrameRateCounter;
-class MemoryHistory;
class PaintTimeCounter;
class CC_EXPORT HeadsUpDisplayLayerImpl : public LayerImpl {
@@ -43,12 +43,13 @@ public:
virtual bool layerIsAlwaysDamaged() const OVERRIDE;
private:
- struct Graph {
+ class Graph {
+ public:
Graph(double indicatorValue, double startUpperBound);
// Eases the upper bound, which limits what is currently visible in the graph,
// so that the graph always scales to either it's max or defaultUpperBound.
- static double updateUpperBound(Graph*);
+ double updateUpperBound();
double value;
double min;
@@ -63,19 +64,19 @@ private:
virtual const char* layerTypeAsString() const OVERRIDE;
- void drawHudContents(SkCanvas*);
+ void updateHudContents();
+ void drawHudContents(SkCanvas* canvas) const;
- void drawText(SkCanvas*, SkPaint*, const std::string&, const SkPaint::Align&, const int& size, const int& x, const int& y);
- void drawText(SkCanvas*, SkPaint*, const std::string&, const SkPaint::Align&, const int& size, const SkPoint& pos);
- void drawGraphBackground(SkCanvas*, SkPaint*, const SkRect& bounds);
- void drawGraphLines(SkCanvas*, SkPaint*, const SkRect& bounds, const Graph&);
+ void drawText(SkCanvas* canvas, SkPaint* paint, const std::string& text, SkPaint::Align align, int size, int x, int y) const;
+ void drawText(SkCanvas* canvas, SkPaint* paint, const std::string& text, SkPaint::Align align, int size, const SkPoint& pos) const;
+ void drawGraphBackground(SkCanvas* canvas, SkPaint* paint, const SkRect& bounds) const;
+ void drawGraphLines(SkCanvas* canvas, SkPaint* paint, const SkRect& bounds, const Graph& graph) const;
- void drawPlaformLayerTree(SkCanvas*);
- int drawFPSDisplay(SkCanvas*, FrameRateCounter*, const int& top);
- int drawMemoryDisplay(SkCanvas*, MemoryHistory*, const int& top);
- int drawPaintTimeDisplay(SkCanvas*, PaintTimeCounter*, const int& top);
-
- void drawDebugRects(SkCanvas*, DebugRectHistory*);
+ void drawPlatformLayerTree(SkCanvas* canvas) const;
+ SkRect drawFPSDisplay(SkCanvas* canvas, const FrameRateCounter* fpsCounter, int right, int top) const;
+ SkRect drawMemoryDisplay(SkCanvas* canvas, int top, int right, int width) const;
+ SkRect drawPaintTimeDisplay(SkCanvas* canvas, const PaintTimeCounter* paintTimeCounter, int top, int right) const;
+ void drawDebugRects(SkCanvas* canvas, DebugRectHistory* debugRectHistory) const;
scoped_ptr<ScopedResource> m_hudTexture;
scoped_ptr<SkCanvas> m_hudCanvas;
@@ -84,6 +85,7 @@ private:
Graph m_fpsGraph;
Graph m_paintTimeGraph;
+ MemoryHistory::Entry m_memoryEntry;
base::TimeTicks m_timeOfLastGraphUpdate;
};
diff --git a/cc/layer_tree_debug_state.cc b/cc/layer_tree_debug_state.cc
index abe94bb..9d8dc55 100644
--- a/cc/layer_tree_debug_state.cc
+++ b/cc/layer_tree_debug_state.cc
@@ -44,6 +44,10 @@ bool LayerTreeDebugState::showHudRects() const {
return showPaintRects || showPropertyChangedRects || showSurfaceDamageRects || showScreenSpaceRects || showReplicaScreenSpaceRects || showOccludingRects || showNonOccludingRects;
}
+bool LayerTreeDebugState::showMemoryStats() const {
+ return showFPSCounter || continuousPainting;
+}
+
bool LayerTreeDebugState::equal(const LayerTreeDebugState& a, const LayerTreeDebugState& b) {
return (a.showFPSCounter == b.showFPSCounter &&
a.showPlatformLayerTree == b.showPlatformLayerTree &&
diff --git a/cc/layer_tree_debug_state.h b/cc/layer_tree_debug_state.h
index 0931908..e488558 100644
--- a/cc/layer_tree_debug_state.h
+++ b/cc/layer_tree_debug_state.h
@@ -36,6 +36,7 @@ class CC_EXPORT LayerTreeDebugState {
bool showHudInfo() const;
bool showHudRects() const;
+ bool showMemoryStats() const;
static bool equal(const LayerTreeDebugState& a, const LayerTreeDebugState& b);
static LayerTreeDebugState unite(const LayerTreeDebugState& a, const LayerTreeDebugState& b);
diff --git a/cc/paint_time_counter.h b/cc/paint_time_counter.h
index b9c6a6c..1db6138 100644
--- a/cc/paint_time_counter.h
+++ b/cc/paint_time_counter.h
@@ -44,7 +44,7 @@ class PaintTimeCounter {
void ClearHistory();
- typedef RingBuffer<Entry, 90> RingBufferType;
+ typedef RingBuffer<Entry, 200> RingBufferType;
RingBufferType::Iterator Begin() const { return ring_buffer_.Begin(); }
RingBufferType::Iterator End() const { return ring_buffer_.End(); }