1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/layers/heads_up_display_layer_impl.h"
10 #include "base/debug/trace_event.h"
11 #include "base/debug/trace_event_argument.h"
12 #include "base/strings/stringprintf.h"
13 #include "cc/debug/debug_colors.h"
14 #include "cc/debug/frame_rate_counter.h"
15 #include "cc/debug/paint_time_counter.h"
16 #include "cc/output/begin_frame_args.h"
17 #include "cc/output/renderer.h"
18 #include "cc/quads/texture_draw_quad.h"
19 #include "cc/resources/memory_history.h"
20 #include "cc/trees/layer_tree_impl.h"
21 #include "skia/ext/platform_canvas.h"
22 #include "third_party/khronos/GLES2/gl2.h"
23 #include "third_party/khronos/GLES2/gl2ext.h"
24 #include "third_party/skia/include/core/SkBitmap.h"
25 #include "third_party/skia/include/core/SkPaint.h"
26 #include "third_party/skia/include/core/SkTypeface.h"
27 #include "third_party/skia/include/effects/SkColorMatrixFilter.h"
28 #include "ui/gfx/point.h"
29 #include "ui/gfx/size.h"
33 static inline SkPaint
CreatePaint() {
35 #if (SK_R32_SHIFT || SK_B32_SHIFT != 16)
36 // The SkCanvas is in RGBA but the shader is expecting BGRA, so we need to
37 // swizzle our colors when drawing to the SkCanvas.
38 SkColorMatrix swizzle_matrix
;
39 for (int i
= 0; i
< 20; ++i
)
40 swizzle_matrix
.fMat
[i
] = 0;
41 swizzle_matrix
.fMat
[0 + 5 * 2] = 1;
42 swizzle_matrix
.fMat
[1 + 5 * 1] = 1;
43 swizzle_matrix
.fMat
[2 + 5 * 0] = 1;
44 swizzle_matrix
.fMat
[3 + 5 * 3] = 1;
46 skia::RefPtr
<SkColorMatrixFilter
> filter
=
47 skia::AdoptRef(SkColorMatrixFilter::Create(swizzle_matrix
));
48 paint
.setColorFilter(filter
.get());
53 HeadsUpDisplayLayerImpl::Graph::Graph(double indicator_value
,
54 double start_upper_bound
)
58 current_upper_bound(start_upper_bound
),
59 default_upper_bound(start_upper_bound
),
60 indicator(indicator_value
) {}
62 double HeadsUpDisplayLayerImpl::Graph::UpdateUpperBound() {
63 double target_upper_bound
= std::max(max
, default_upper_bound
);
64 current_upper_bound
+= (target_upper_bound
- current_upper_bound
) * 0.5;
65 return current_upper_bound
;
68 HeadsUpDisplayLayerImpl::HeadsUpDisplayLayerImpl(LayerTreeImpl
* tree_impl
,
70 : LayerImpl(tree_impl
, id
),
71 typeface_(skia::AdoptRef(
72 SkTypeface::CreateFromName("monospace", SkTypeface::kBold
))),
73 fps_graph_(60.0, 80.0),
74 paint_time_graph_(16.0, 48.0),
77 HeadsUpDisplayLayerImpl::~HeadsUpDisplayLayerImpl() {}
79 scoped_ptr
<LayerImpl
> HeadsUpDisplayLayerImpl::CreateLayerImpl(
80 LayerTreeImpl
* tree_impl
) {
81 return HeadsUpDisplayLayerImpl::Create(tree_impl
, id()).PassAs
<LayerImpl
>();
84 void HeadsUpDisplayLayerImpl::AcquireResource(
85 ResourceProvider
* resource_provider
) {
86 for (ScopedPtrVector
<ScopedResource
>::iterator it
= resources_
.begin();
87 it
!= resources_
.end();
89 if (!resource_provider
->InUseByConsumer((*it
)->id())) {
90 resources_
.swap(it
, resources_
.end() - 1);
95 scoped_ptr
<ScopedResource
> resource
=
96 ScopedResource::Create(resource_provider
);
98 content_bounds(), ResourceProvider::TextureHintImmutable
, RGBA_8888
);
99 resources_
.push_back(resource
.Pass());
102 class ResourceSizeIsEqualTo
{
104 explicit ResourceSizeIsEqualTo(const gfx::Size
& size_
)
105 : compare_size_(size_
) {}
107 bool operator()(const ScopedResource
* resource
) {
108 return resource
->size() == compare_size_
;
112 const gfx::Size compare_size_
;
115 void HeadsUpDisplayLayerImpl::ReleaseUnmatchedSizeResources(
116 ResourceProvider
* resource_provider
) {
117 ScopedPtrVector
<ScopedResource
>::iterator it_erase
=
118 resources_
.partition(ResourceSizeIsEqualTo(content_bounds()));
119 resources_
.erase(it_erase
, resources_
.end());
122 bool HeadsUpDisplayLayerImpl::WillDraw(DrawMode draw_mode
,
123 ResourceProvider
* resource_provider
) {
124 if (draw_mode
== DRAW_MODE_RESOURCELESS_SOFTWARE
)
127 ReleaseUnmatchedSizeResources(resource_provider
);
128 AcquireResource(resource_provider
);
129 return LayerImpl::WillDraw(draw_mode
, resource_provider
);
132 void HeadsUpDisplayLayerImpl::AppendQuads(
133 RenderPass
* render_pass
,
134 const OcclusionTracker
<LayerImpl
>& occlusion_tracker
,
135 AppendQuadsData
* append_quads_data
) {
136 if (!resources_
.back()->id())
139 SharedQuadState
* shared_quad_state
=
140 render_pass
->CreateAndAppendSharedQuadState();
141 PopulateSharedQuadState(shared_quad_state
);
143 gfx::Rect
quad_rect(content_bounds());
144 gfx::Rect
opaque_rect(contents_opaque() ? quad_rect
: gfx::Rect());
145 gfx::Rect
visible_quad_rect(quad_rect
);
146 bool premultiplied_alpha
= true;
147 gfx::PointF
uv_top_left(0.f
, 0.f
);
148 gfx::PointF
uv_bottom_right(1.f
, 1.f
);
149 const float vertex_opacity
[] = { 1.f
, 1.f
, 1.f
, 1.f
};
150 bool flipped
= false;
151 TextureDrawQuad
* quad
=
152 render_pass
->CreateAndAppendDrawQuad
<TextureDrawQuad
>();
153 quad
->SetNew(shared_quad_state
,
157 resources_
.back()->id(),
166 void HeadsUpDisplayLayerImpl::UpdateHudTexture(
168 ResourceProvider
* resource_provider
) {
169 if (draw_mode
== DRAW_MODE_RESOURCELESS_SOFTWARE
|| !resources_
.back()->id())
174 canvas_size
= hud_canvas_
->getDeviceSize();
176 canvas_size
.set(0, 0);
178 if (canvas_size
.width() != content_bounds().width() ||
179 canvas_size
.height() != content_bounds().height() || !hud_canvas_
) {
180 TRACE_EVENT0("cc", "ResizeHudCanvas");
182 hud_canvas_
= make_scoped_ptr(skia::CreateBitmapCanvas(
183 content_bounds().width(), content_bounds().height(), opaque
));
189 TRACE_EVENT0("cc", "DrawHudContents");
190 hud_canvas_
->clear(SkColorSetARGB(0, 0, 0, 0));
192 hud_canvas_
->scale(contents_scale_x(), contents_scale_y());
194 DrawHudContents(hud_canvas_
.get());
196 hud_canvas_
->restore();
199 TRACE_EVENT0("cc", "UploadHudTexture");
201 size_t row_bytes
= 0;
202 const void* pixels
= hud_canvas_
->peekPixels(&info
, &row_bytes
);
204 gfx::Rect
content_rect(content_bounds());
205 DCHECK(info
.colorType() == kN32_SkColorType
);
206 resource_provider
->SetPixels(resources_
.back()->id(),
207 static_cast<const uint8_t*>(pixels
),
213 void HeadsUpDisplayLayerImpl::ReleaseResources() {
217 void HeadsUpDisplayLayerImpl::UpdateHudContents() {
218 const LayerTreeDebugState
& debug_state
= layer_tree_impl()->debug_state();
220 // Don't update numbers every frame so text is readable.
221 base::TimeTicks now
= layer_tree_impl()->CurrentBeginFrameArgs().frame_time
;
222 if (base::TimeDelta(now
- time_of_last_graph_update_
).InSecondsF() > 0.25f
) {
223 time_of_last_graph_update_
= now
;
225 if (debug_state
.show_fps_counter
) {
226 FrameRateCounter
* fps_counter
= layer_tree_impl()->frame_rate_counter();
227 fps_graph_
.value
= fps_counter
->GetAverageFPS();
228 fps_counter
->GetMinAndMaxFPS(&fps_graph_
.min
, &fps_graph_
.max
);
231 if (debug_state
.continuous_painting
) {
232 PaintTimeCounter
* paint_time_counter
=
233 layer_tree_impl()->paint_time_counter();
234 base::TimeDelta latest
, min
, max
;
236 if (paint_time_counter
->End())
237 latest
= **paint_time_counter
->End();
238 paint_time_counter
->GetMinAndMaxPaintTime(&min
, &max
);
240 paint_time_graph_
.value
= latest
.InMillisecondsF();
241 paint_time_graph_
.min
= min
.InMillisecondsF();
242 paint_time_graph_
.max
= max
.InMillisecondsF();
245 if (debug_state
.ShowMemoryStats()) {
246 MemoryHistory
* memory_history
= layer_tree_impl()->memory_history();
247 if (memory_history
->End())
248 memory_entry_
= **memory_history
->End();
250 memory_entry_
= MemoryHistory::Entry();
254 fps_graph_
.UpdateUpperBound();
255 paint_time_graph_
.UpdateUpperBound();
258 void HeadsUpDisplayLayerImpl::DrawHudContents(SkCanvas
* canvas
) {
259 const LayerTreeDebugState
& debug_state
= layer_tree_impl()->debug_state();
261 if (debug_state
.ShowHudRects()) {
262 DrawDebugRects(canvas
, layer_tree_impl()->debug_rect_history());
263 if (IsAnimatingHUDContents()) {
264 layer_tree_impl()->SetNeedsRedraw();
268 SkRect area
= SkRect::MakeEmpty();
269 if (debug_state
.continuous_painting
) {
270 area
= DrawPaintTimeDisplay(
271 canvas
, layer_tree_impl()->paint_time_counter(), 0, 0);
272 } else if (debug_state
.show_fps_counter
) {
273 // Don't show the FPS display when continuous painting is enabled, because
274 // it would show misleading numbers.
276 DrawFPSDisplay(canvas
, layer_tree_impl()->frame_rate_counter(), 0, 0);
279 if (debug_state
.ShowMemoryStats())
280 DrawMemoryDisplay(canvas
, 0, area
.bottom(), SkMaxScalar(area
.width(), 150));
283 void HeadsUpDisplayLayerImpl::DrawText(SkCanvas
* canvas
,
285 const std::string
& text
,
286 SkPaint::Align align
,
290 const bool anti_alias
= paint
->isAntiAlias();
291 paint
->setAntiAlias(true);
293 paint
->setTextSize(size
);
294 paint
->setTextAlign(align
);
295 paint
->setTypeface(typeface_
.get());
296 canvas
->drawText(text
.c_str(), text
.length(), x
, y
, *paint
);
298 paint
->setAntiAlias(anti_alias
);
301 void HeadsUpDisplayLayerImpl::DrawText(SkCanvas
* canvas
,
303 const std::string
& text
,
304 SkPaint::Align align
,
306 const SkPoint
& pos
) const {
307 DrawText(canvas
, paint
, text
, align
, size
, pos
.x(), pos
.y());
310 void HeadsUpDisplayLayerImpl::DrawGraphBackground(SkCanvas
* canvas
,
312 const SkRect
& bounds
) const {
313 paint
->setColor(DebugColors::HUDBackgroundColor());
314 canvas
->drawRect(bounds
, *paint
);
317 void HeadsUpDisplayLayerImpl::DrawGraphLines(SkCanvas
* canvas
,
319 const SkRect
& bounds
,
320 const Graph
& graph
) const {
321 // Draw top and bottom line.
322 paint
->setColor(DebugColors::HUDSeparatorLineColor());
323 canvas
->drawLine(bounds
.left(),
329 bounds
.left(), bounds
.bottom(), bounds
.right(), bounds
.bottom(), *paint
);
331 // Draw indicator line (additive blend mode to increase contrast when drawn on
333 paint
->setColor(DebugColors::HUDIndicatorLineColor());
334 paint
->setXfermodeMode(SkXfermode::kPlus_Mode
);
335 const double indicator_top
=
336 bounds
.height() * (1.0 - graph
.indicator
/ graph
.current_upper_bound
) -
338 canvas
->drawLine(bounds
.left(),
339 bounds
.top() + indicator_top
,
341 bounds
.top() + indicator_top
,
343 paint
->setXfermode(NULL
);
346 SkRect
HeadsUpDisplayLayerImpl::DrawFPSDisplay(
348 const FrameRateCounter
* fps_counter
,
351 const int kPadding
= 4;
354 const int kFontHeight
= 15;
356 const int kGraphWidth
= fps_counter
->time_stamp_history_size() - 2;
357 const int kGraphHeight
= 40;
359 const int kHistogramWidth
= 37;
361 int width
= kGraphWidth
+ kHistogramWidth
+ 4 * kPadding
;
362 int height
= kFontHeight
+ kGraphHeight
+ 4 * kPadding
+ 2;
363 int left
= bounds().width() - width
- right
;
364 SkRect area
= SkRect::MakeXYWH(left
, top
, width
, height
);
366 SkPaint paint
= CreatePaint();
367 DrawGraphBackground(canvas
, &paint
, area
);
370 SkRect::MakeXYWH(left
+ kPadding
,
372 kGraphWidth
+ kHistogramWidth
+ kGap
+ 2,
374 SkRect graph_bounds
= SkRect::MakeXYWH(left
+ kPadding
,
375 text_bounds
.bottom() + 2 * kPadding
,
378 SkRect histogram_bounds
= SkRect::MakeXYWH(graph_bounds
.right() + kGap
,
383 const std::string value_text
=
384 base::StringPrintf("FPS:%5.1f", fps_graph_
.value
);
385 const std::string min_max_text
=
386 base::StringPrintf("%.0f-%.0f", fps_graph_
.min
, fps_graph_
.max
);
388 paint
.setColor(DebugColors::FPSDisplayTextAndGraphColor());
392 SkPaint::kLeft_Align
,
395 text_bounds
.bottom());
399 SkPaint::kRight_Align
,
402 text_bounds
.bottom());
404 DrawGraphLines(canvas
, &paint
, graph_bounds
, fps_graph_
);
406 // Collect graph and histogram data.
409 const int kHistogramSize
= 20;
410 double histogram
[kHistogramSize
] = { 1.0 };
411 double max_bucket_value
= 1.0;
413 for (FrameRateCounter::RingBufferType::Iterator it
= --fps_counter
->end(); it
;
415 base::TimeDelta delta
= fps_counter
->RecentFrameInterval(it
.index() + 1);
417 // Skip this particular instantaneous frame rate if it is not likely to have
419 if (!fps_counter
->IsBadFrameInterval(delta
)) {
420 double fps
= 1.0 / delta
.InSecondsF();
422 // Clamp the FPS to the range we want to plot visually.
423 double p
= fps
/ fps_graph_
.current_upper_bound
;
427 // Plot this data point.
429 SkPoint::Make(graph_bounds
.left() + it
.index(),
430 graph_bounds
.bottom() - p
* graph_bounds
.height());
436 // Use the fps value to find the right bucket in the histogram.
437 int bucket_index
= floor(p
* (kHistogramSize
- 1));
439 // Add the delta time to take the time spent at that fps rate into
441 histogram
[bucket_index
] += delta
.InSecondsF();
442 max_bucket_value
= std::max(histogram
[bucket_index
], max_bucket_value
);
446 // Draw FPS histogram.
447 paint
.setColor(DebugColors::HUDSeparatorLineColor());
448 canvas
->drawLine(histogram_bounds
.left() - 1,
449 histogram_bounds
.top() - 1,
450 histogram_bounds
.left() - 1,
451 histogram_bounds
.bottom() + 1,
453 canvas
->drawLine(histogram_bounds
.right() + 1,
454 histogram_bounds
.top() - 1,
455 histogram_bounds
.right() + 1,
456 histogram_bounds
.bottom() + 1,
459 paint
.setColor(DebugColors::FPSDisplayTextAndGraphColor());
460 const double bar_height
= histogram_bounds
.height() / kHistogramSize
;
462 for (int i
= kHistogramSize
- 1; i
>= 0; --i
) {
463 if (histogram
[i
] > 0) {
465 histogram
[i
] / max_bucket_value
* histogram_bounds
.width();
467 SkRect::MakeXYWH(histogram_bounds
.left(),
468 histogram_bounds
.bottom() - (i
+ 1) * bar_height
,
476 paint
.setAntiAlias(true);
477 paint
.setStyle(SkPaint::kStroke_Style
);
478 paint
.setStrokeWidth(1);
479 canvas
->drawPath(path
, paint
);
484 SkRect
HeadsUpDisplayLayerImpl::DrawMemoryDisplay(SkCanvas
* canvas
,
488 if (!memory_entry_
.bytes_total())
489 return SkRect::MakeEmpty();
491 const int kPadding
= 4;
492 const int kFontHeight
= 13;
494 const int height
= 3 * kFontHeight
+ 4 * kPadding
;
495 const int left
= bounds().width() - width
- right
;
496 const SkRect area
= SkRect::MakeXYWH(left
, top
, width
, height
);
498 const double megabyte
= 1024.0 * 1024.0;
500 SkPaint paint
= CreatePaint();
501 DrawGraphBackground(canvas
, &paint
, area
);
503 SkPoint title_pos
= SkPoint::Make(left
+ kPadding
, top
+ kFontHeight
);
504 SkPoint stat1_pos
= SkPoint::Make(left
+ width
- kPadding
- 1,
505 top
+ kPadding
+ 2 * kFontHeight
);
506 SkPoint stat2_pos
= SkPoint::Make(left
+ width
- kPadding
- 1,
507 top
+ 2 * kPadding
+ 3 * kFontHeight
);
509 paint
.setColor(DebugColors::MemoryDisplayTextColor());
513 SkPaint::kLeft_Align
,
518 base::StringPrintf("%6.1f MB used",
519 (memory_entry_
.bytes_unreleasable
+
520 memory_entry_
.bytes_allocated
) / megabyte
);
521 DrawText(canvas
, &paint
, text
, SkPaint::kRight_Align
, kFontHeight
, stat1_pos
);
523 if (memory_entry_
.bytes_over
) {
524 paint
.setColor(SK_ColorRED
);
525 text
= base::StringPrintf("%6.1f MB over",
526 memory_entry_
.bytes_over
/ megabyte
);
528 text
= base::StringPrintf("%6.1f MB max ",
529 memory_entry_
.total_budget_in_bytes
/ megabyte
);
531 DrawText(canvas
, &paint
, text
, SkPaint::kRight_Align
, kFontHeight
, stat2_pos
);
536 SkRect
HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay(
538 const PaintTimeCounter
* paint_time_counter
,
541 const int kPadding
= 4;
542 const int kFontHeight
= 15;
544 const int kGraphWidth
= paint_time_counter
->HistorySize();
545 const int kGraphHeight
= 40;
547 const int width
= kGraphWidth
+ 2 * kPadding
;
549 kFontHeight
+ kGraphHeight
+ 4 * kPadding
+ 2 + kFontHeight
+ kPadding
;
550 const int left
= bounds().width() - width
- right
;
552 const SkRect area
= SkRect::MakeXYWH(left
, top
, width
, height
);
554 SkPaint paint
= CreatePaint();
555 DrawGraphBackground(canvas
, &paint
, area
);
557 SkRect text_bounds
= SkRect::MakeXYWH(
558 left
+ kPadding
, top
+ kPadding
, kGraphWidth
, kFontHeight
);
559 SkRect text_bounds2
= SkRect::MakeXYWH(left
+ kPadding
,
560 text_bounds
.bottom() + kPadding
,
563 SkRect graph_bounds
= SkRect::MakeXYWH(left
+ kPadding
,
564 text_bounds2
.bottom() + 2 * kPadding
,
568 const std::string value_text
=
569 base::StringPrintf("%.1f", paint_time_graph_
.value
);
570 const std::string min_max_text
= base::StringPrintf(
571 "%.1f-%.1f", paint_time_graph_
.min
, paint_time_graph_
.max
);
573 paint
.setColor(DebugColors::PaintTimeDisplayTextAndGraphColor());
576 "Page paint time (ms)",
577 SkPaint::kLeft_Align
,
580 text_bounds
.bottom());
584 SkPaint::kLeft_Align
,
587 text_bounds2
.bottom());
591 SkPaint::kRight_Align
,
593 text_bounds2
.right(),
594 text_bounds2
.bottom());
596 paint
.setColor(DebugColors::PaintTimeDisplayTextAndGraphColor());
597 for (PaintTimeCounter::RingBufferType::Iterator it
=
598 paint_time_counter
->End();
601 double pt
= it
->InMillisecondsF();
606 double p
= pt
/ paint_time_graph_
.current_upper_bound
;
611 SkRect::MakeXYWH(graph_bounds
.left() + it
.index(),
612 graph_bounds
.bottom() - p
* graph_bounds
.height(),
614 p
* graph_bounds
.height()),
618 DrawGraphLines(canvas
, &paint
, graph_bounds
, paint_time_graph_
);
623 void HeadsUpDisplayLayerImpl::DrawDebugRect(
626 const DebugRect
& rect
,
627 SkColor stroke_color
,
630 const std::string
& label_text
) const {
631 gfx::Rect debug_layer_rect
= gfx::ScaleToEnclosingRect(
632 rect
.rect
, 1.0 / contents_scale_x(), 1.0 / contents_scale_y());
633 SkIRect sk_rect
= RectToSkIRect(debug_layer_rect
);
634 paint
->setColor(fill_color
);
635 paint
->setStyle(SkPaint::kFill_Style
);
636 canvas
->drawIRect(sk_rect
, *paint
);
638 paint
->setColor(stroke_color
);
639 paint
->setStyle(SkPaint::kStroke_Style
);
640 paint
->setStrokeWidth(SkFloatToScalar(stroke_width
));
641 canvas
->drawIRect(sk_rect
, *paint
);
643 if (label_text
.length()) {
644 const int kFontHeight
= 12;
645 const int kPadding
= 3;
647 // The debug_layer_rect may be huge, and converting to a floating point may
648 // be lossy, so intersect with the HUD layer bounds first to prevent that.
649 gfx::Rect clip_rect
= debug_layer_rect
;
650 clip_rect
.Intersect(gfx::Rect(content_bounds()));
651 SkRect sk_clip_rect
= RectToSkRect(clip_rect
);
654 canvas
->clipRect(sk_clip_rect
);
655 canvas
->translate(sk_clip_rect
.x(), sk_clip_rect
.y());
657 SkPaint label_paint
= CreatePaint();
658 label_paint
.setTextSize(kFontHeight
);
659 label_paint
.setTypeface(typeface_
.get());
660 label_paint
.setColor(stroke_color
);
662 const SkScalar label_text_width
=
663 label_paint
.measureText(label_text
.c_str(), label_text
.length());
664 canvas
->drawRect(SkRect::MakeWH(label_text_width
+ 2 * kPadding
,
665 kFontHeight
+ 2 * kPadding
),
668 label_paint
.setAntiAlias(true);
669 label_paint
.setColor(SkColorSetARGB(255, 50, 50, 50));
670 canvas
->drawText(label_text
.c_str(),
673 kFontHeight
* 0.8f
+ kPadding
,
680 void HeadsUpDisplayLayerImpl::DrawDebugRects(
682 DebugRectHistory
* debug_rect_history
) {
683 SkPaint paint
= CreatePaint();
685 const std::vector
<DebugRect
>& debug_rects
= debug_rect_history
->debug_rects();
686 std::vector
<DebugRect
> new_paint_rects
;
688 for (size_t i
= 0; i
< debug_rects
.size(); ++i
) {
689 SkColor stroke_color
= 0;
690 SkColor fill_color
= 0;
691 float stroke_width
= 0.f
;
692 std::string label_text
;
694 switch (debug_rects
[i
].type
) {
695 case PAINT_RECT_TYPE
:
696 new_paint_rects
.push_back(debug_rects
[i
]);
698 case PROPERTY_CHANGED_RECT_TYPE
:
699 stroke_color
= DebugColors::PropertyChangedRectBorderColor();
700 fill_color
= DebugColors::PropertyChangedRectFillColor();
701 stroke_width
= DebugColors::PropertyChangedRectBorderWidth();
703 case SURFACE_DAMAGE_RECT_TYPE
:
704 stroke_color
= DebugColors::SurfaceDamageRectBorderColor();
705 fill_color
= DebugColors::SurfaceDamageRectFillColor();
706 stroke_width
= DebugColors::SurfaceDamageRectBorderWidth();
708 case REPLICA_SCREEN_SPACE_RECT_TYPE
:
709 stroke_color
= DebugColors::ScreenSpaceSurfaceReplicaRectBorderColor();
710 fill_color
= DebugColors::ScreenSpaceSurfaceReplicaRectFillColor();
711 stroke_width
= DebugColors::ScreenSpaceSurfaceReplicaRectBorderWidth();
713 case SCREEN_SPACE_RECT_TYPE
:
714 stroke_color
= DebugColors::ScreenSpaceLayerRectBorderColor();
715 fill_color
= DebugColors::ScreenSpaceLayerRectFillColor();
716 stroke_width
= DebugColors::ScreenSpaceLayerRectBorderWidth();
718 case OCCLUDING_RECT_TYPE
:
719 stroke_color
= DebugColors::OccludingRectBorderColor();
720 fill_color
= DebugColors::OccludingRectFillColor();
721 stroke_width
= DebugColors::OccludingRectBorderWidth();
723 case NONOCCLUDING_RECT_TYPE
:
724 stroke_color
= DebugColors::NonOccludingRectBorderColor();
725 fill_color
= DebugColors::NonOccludingRectFillColor();
726 stroke_width
= DebugColors::NonOccludingRectBorderWidth();
728 case TOUCH_EVENT_HANDLER_RECT_TYPE
:
729 stroke_color
= DebugColors::TouchEventHandlerRectBorderColor();
730 fill_color
= DebugColors::TouchEventHandlerRectFillColor();
731 stroke_width
= DebugColors::TouchEventHandlerRectBorderWidth();
732 label_text
= "touch event listener";
734 case WHEEL_EVENT_HANDLER_RECT_TYPE
:
735 stroke_color
= DebugColors::WheelEventHandlerRectBorderColor();
736 fill_color
= DebugColors::WheelEventHandlerRectFillColor();
737 stroke_width
= DebugColors::WheelEventHandlerRectBorderWidth();
738 label_text
= "mousewheel event listener";
740 case SCROLL_EVENT_HANDLER_RECT_TYPE
:
741 stroke_color
= DebugColors::ScrollEventHandlerRectBorderColor();
742 fill_color
= DebugColors::ScrollEventHandlerRectFillColor();
743 stroke_width
= DebugColors::ScrollEventHandlerRectBorderWidth();
744 label_text
= "scroll event listener";
746 case NON_FAST_SCROLLABLE_RECT_TYPE
:
747 stroke_color
= DebugColors::NonFastScrollableRectBorderColor();
748 fill_color
= DebugColors::NonFastScrollableRectFillColor();
749 stroke_width
= DebugColors::NonFastScrollableRectBorderWidth();
750 label_text
= "repaints on scroll";
752 case ANIMATION_BOUNDS_RECT_TYPE
:
753 stroke_color
= DebugColors::LayerAnimationBoundsBorderColor();
754 fill_color
= DebugColors::LayerAnimationBoundsFillColor();
755 stroke_width
= DebugColors::LayerAnimationBoundsBorderWidth();
756 label_text
= "animation bounds";
760 DrawDebugRect(canvas
,
769 if (new_paint_rects
.size()) {
770 paint_rects_
.swap(new_paint_rects
);
771 fade_step_
= DebugColors::kFadeSteps
;
773 if (fade_step_
> 0) {
775 for (size_t i
= 0; i
< paint_rects_
.size(); ++i
) {
776 DrawDebugRect(canvas
,
779 DebugColors::PaintRectBorderColor(fade_step_
),
780 DebugColors::PaintRectFillColor(fade_step_
),
781 DebugColors::PaintRectBorderWidth(),
787 const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const {
788 return "cc::HeadsUpDisplayLayerImpl";
791 void HeadsUpDisplayLayerImpl::AsValueInto(
792 base::debug::TracedValue
* dict
) const {
793 LayerImpl::AsValueInto(dict
);
794 dict
->SetString("layer_name", "Heads Up Display Layer");