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/geometry/point.h"
29 #include "ui/gfx/geometry/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());
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 Occlusion
& occlusion_in_content_space
,
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(nullptr);
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 VLOG(1) << value_text
;
390 paint
.setColor(DebugColors::FPSDisplayTextAndGraphColor());
394 SkPaint::kLeft_Align
,
397 text_bounds
.bottom());
401 SkPaint::kRight_Align
,
404 text_bounds
.bottom());
406 DrawGraphLines(canvas
, &paint
, graph_bounds
, fps_graph_
);
408 // Collect graph and histogram data.
411 const int kHistogramSize
= 20;
412 double histogram
[kHistogramSize
] = { 1.0 };
413 double max_bucket_value
= 1.0;
415 for (FrameRateCounter::RingBufferType::Iterator it
= --fps_counter
->end(); it
;
417 base::TimeDelta delta
= fps_counter
->RecentFrameInterval(it
.index() + 1);
419 // Skip this particular instantaneous frame rate if it is not likely to have
421 if (!fps_counter
->IsBadFrameInterval(delta
)) {
422 double fps
= 1.0 / delta
.InSecondsF();
424 // Clamp the FPS to the range we want to plot visually.
425 double p
= fps
/ fps_graph_
.current_upper_bound
;
429 // Plot this data point.
431 SkPoint::Make(graph_bounds
.left() + it
.index(),
432 graph_bounds
.bottom() - p
* graph_bounds
.height());
438 // Use the fps value to find the right bucket in the histogram.
439 int bucket_index
= floor(p
* (kHistogramSize
- 1));
441 // Add the delta time to take the time spent at that fps rate into
443 histogram
[bucket_index
] += delta
.InSecondsF();
444 max_bucket_value
= std::max(histogram
[bucket_index
], max_bucket_value
);
448 // Draw FPS histogram.
449 paint
.setColor(DebugColors::HUDSeparatorLineColor());
450 canvas
->drawLine(histogram_bounds
.left() - 1,
451 histogram_bounds
.top() - 1,
452 histogram_bounds
.left() - 1,
453 histogram_bounds
.bottom() + 1,
455 canvas
->drawLine(histogram_bounds
.right() + 1,
456 histogram_bounds
.top() - 1,
457 histogram_bounds
.right() + 1,
458 histogram_bounds
.bottom() + 1,
461 paint
.setColor(DebugColors::FPSDisplayTextAndGraphColor());
462 const double bar_height
= histogram_bounds
.height() / kHistogramSize
;
464 for (int i
= kHistogramSize
- 1; i
>= 0; --i
) {
465 if (histogram
[i
] > 0) {
467 histogram
[i
] / max_bucket_value
* histogram_bounds
.width();
469 SkRect::MakeXYWH(histogram_bounds
.left(),
470 histogram_bounds
.bottom() - (i
+ 1) * bar_height
,
478 paint
.setAntiAlias(true);
479 paint
.setStyle(SkPaint::kStroke_Style
);
480 paint
.setStrokeWidth(1);
481 canvas
->drawPath(path
, paint
);
486 SkRect
HeadsUpDisplayLayerImpl::DrawMemoryDisplay(SkCanvas
* canvas
,
490 if (!memory_entry_
.total_bytes_used
)
491 return SkRect::MakeEmpty();
493 const int kPadding
= 4;
494 const int kFontHeight
= 13;
496 const int height
= 3 * kFontHeight
+ 4 * kPadding
;
497 const int left
= bounds().width() - width
- right
;
498 const SkRect area
= SkRect::MakeXYWH(left
, top
, width
, height
);
500 const double kMegabyte
= 1024.0 * 1024.0;
502 SkPaint paint
= CreatePaint();
503 DrawGraphBackground(canvas
, &paint
, area
);
505 SkPoint title_pos
= SkPoint::Make(left
+ kPadding
, top
+ kFontHeight
);
506 SkPoint stat1_pos
= SkPoint::Make(left
+ width
- kPadding
- 1,
507 top
+ kPadding
+ 2 * kFontHeight
);
508 SkPoint stat2_pos
= SkPoint::Make(left
+ width
- kPadding
- 1,
509 top
+ 2 * kPadding
+ 3 * kFontHeight
);
511 paint
.setColor(DebugColors::MemoryDisplayTextColor());
515 SkPaint::kLeft_Align
,
519 std::string text
= base::StringPrintf(
520 "%6.1f MB used", memory_entry_
.total_bytes_used
/ kMegabyte
);
521 DrawText(canvas
, &paint
, text
, SkPaint::kRight_Align
, kFontHeight
, stat1_pos
);
523 if (!memory_entry_
.had_enough_memory
)
524 paint
.setColor(SK_ColorRED
);
525 text
= base::StringPrintf("%6.1f MB max ",
526 memory_entry_
.total_budget_in_bytes
/ kMegabyte
);
527 DrawText(canvas
, &paint
, text
, SkPaint::kRight_Align
, kFontHeight
, stat2_pos
);
532 SkRect
HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay(
534 const PaintTimeCounter
* paint_time_counter
,
537 const int kPadding
= 4;
538 const int kFontHeight
= 15;
540 const int kGraphWidth
= paint_time_counter
->HistorySize();
541 const int kGraphHeight
= 40;
543 const int width
= kGraphWidth
+ 2 * kPadding
;
545 kFontHeight
+ kGraphHeight
+ 4 * kPadding
+ 2 + kFontHeight
+ kPadding
;
546 const int left
= bounds().width() - width
- right
;
548 const SkRect area
= SkRect::MakeXYWH(left
, top
, width
, height
);
550 SkPaint paint
= CreatePaint();
551 DrawGraphBackground(canvas
, &paint
, area
);
553 SkRect text_bounds
= SkRect::MakeXYWH(
554 left
+ kPadding
, top
+ kPadding
, kGraphWidth
, kFontHeight
);
555 SkRect text_bounds2
= SkRect::MakeXYWH(left
+ kPadding
,
556 text_bounds
.bottom() + kPadding
,
559 SkRect graph_bounds
= SkRect::MakeXYWH(left
+ kPadding
,
560 text_bounds2
.bottom() + 2 * kPadding
,
564 const std::string value_text
=
565 base::StringPrintf("%.1f", paint_time_graph_
.value
);
566 const std::string min_max_text
= base::StringPrintf(
567 "%.1f-%.1f", paint_time_graph_
.min
, paint_time_graph_
.max
);
569 paint
.setColor(DebugColors::PaintTimeDisplayTextAndGraphColor());
570 DrawText(canvas
, &paint
, "Compositor frame time (ms)", SkPaint::kLeft_Align
,
571 kFontHeight
, text_bounds
.left(), text_bounds
.bottom());
575 SkPaint::kLeft_Align
,
578 text_bounds2
.bottom());
582 SkPaint::kRight_Align
,
584 text_bounds2
.right(),
585 text_bounds2
.bottom());
587 paint
.setColor(DebugColors::PaintTimeDisplayTextAndGraphColor());
588 for (PaintTimeCounter::RingBufferType::Iterator it
=
589 paint_time_counter
->End();
592 double pt
= it
->InMillisecondsF();
597 double p
= pt
/ paint_time_graph_
.current_upper_bound
;
602 SkRect::MakeXYWH(graph_bounds
.left() + it
.index(),
603 graph_bounds
.bottom() - p
* graph_bounds
.height(),
605 p
* graph_bounds
.height()),
609 DrawGraphLines(canvas
, &paint
, graph_bounds
, paint_time_graph_
);
614 void HeadsUpDisplayLayerImpl::DrawDebugRect(
617 const DebugRect
& rect
,
618 SkColor stroke_color
,
621 const std::string
& label_text
) const {
622 gfx::Rect debug_layer_rect
= gfx::ScaleToEnclosingRect(
623 rect
.rect
, 1.0 / contents_scale_x(), 1.0 / contents_scale_y());
624 SkIRect sk_rect
= RectToSkIRect(debug_layer_rect
);
625 paint
->setColor(fill_color
);
626 paint
->setStyle(SkPaint::kFill_Style
);
627 canvas
->drawIRect(sk_rect
, *paint
);
629 paint
->setColor(stroke_color
);
630 paint
->setStyle(SkPaint::kStroke_Style
);
631 paint
->setStrokeWidth(SkFloatToScalar(stroke_width
));
632 canvas
->drawIRect(sk_rect
, *paint
);
634 if (label_text
.length()) {
635 const int kFontHeight
= 12;
636 const int kPadding
= 3;
638 // The debug_layer_rect may be huge, and converting to a floating point may
639 // be lossy, so intersect with the HUD layer bounds first to prevent that.
640 gfx::Rect clip_rect
= debug_layer_rect
;
641 clip_rect
.Intersect(gfx::Rect(content_bounds()));
642 SkRect sk_clip_rect
= RectToSkRect(clip_rect
);
645 canvas
->clipRect(sk_clip_rect
);
646 canvas
->translate(sk_clip_rect
.x(), sk_clip_rect
.y());
648 SkPaint label_paint
= CreatePaint();
649 label_paint
.setTextSize(kFontHeight
);
650 label_paint
.setTypeface(typeface_
.get());
651 label_paint
.setColor(stroke_color
);
653 const SkScalar label_text_width
=
654 label_paint
.measureText(label_text
.c_str(), label_text
.length());
655 canvas
->drawRect(SkRect::MakeWH(label_text_width
+ 2 * kPadding
,
656 kFontHeight
+ 2 * kPadding
),
659 label_paint
.setAntiAlias(true);
660 label_paint
.setColor(SkColorSetARGB(255, 50, 50, 50));
661 canvas
->drawText(label_text
.c_str(),
664 kFontHeight
* 0.8f
+ kPadding
,
671 void HeadsUpDisplayLayerImpl::DrawDebugRects(
673 DebugRectHistory
* debug_rect_history
) {
674 SkPaint paint
= CreatePaint();
676 const std::vector
<DebugRect
>& debug_rects
= debug_rect_history
->debug_rects();
677 std::vector
<DebugRect
> new_paint_rects
;
679 for (size_t i
= 0; i
< debug_rects
.size(); ++i
) {
680 SkColor stroke_color
= 0;
681 SkColor fill_color
= 0;
682 float stroke_width
= 0.f
;
683 std::string label_text
;
685 switch (debug_rects
[i
].type
) {
686 case PAINT_RECT_TYPE
:
687 new_paint_rects
.push_back(debug_rects
[i
]);
689 case PROPERTY_CHANGED_RECT_TYPE
:
690 stroke_color
= DebugColors::PropertyChangedRectBorderColor();
691 fill_color
= DebugColors::PropertyChangedRectFillColor();
692 stroke_width
= DebugColors::PropertyChangedRectBorderWidth();
694 case SURFACE_DAMAGE_RECT_TYPE
:
695 stroke_color
= DebugColors::SurfaceDamageRectBorderColor();
696 fill_color
= DebugColors::SurfaceDamageRectFillColor();
697 stroke_width
= DebugColors::SurfaceDamageRectBorderWidth();
699 case REPLICA_SCREEN_SPACE_RECT_TYPE
:
700 stroke_color
= DebugColors::ScreenSpaceSurfaceReplicaRectBorderColor();
701 fill_color
= DebugColors::ScreenSpaceSurfaceReplicaRectFillColor();
702 stroke_width
= DebugColors::ScreenSpaceSurfaceReplicaRectBorderWidth();
704 case SCREEN_SPACE_RECT_TYPE
:
705 stroke_color
= DebugColors::ScreenSpaceLayerRectBorderColor();
706 fill_color
= DebugColors::ScreenSpaceLayerRectFillColor();
707 stroke_width
= DebugColors::ScreenSpaceLayerRectBorderWidth();
709 case OCCLUDING_RECT_TYPE
:
710 stroke_color
= DebugColors::OccludingRectBorderColor();
711 fill_color
= DebugColors::OccludingRectFillColor();
712 stroke_width
= DebugColors::OccludingRectBorderWidth();
714 case NONOCCLUDING_RECT_TYPE
:
715 stroke_color
= DebugColors::NonOccludingRectBorderColor();
716 fill_color
= DebugColors::NonOccludingRectFillColor();
717 stroke_width
= DebugColors::NonOccludingRectBorderWidth();
719 case TOUCH_EVENT_HANDLER_RECT_TYPE
:
720 stroke_color
= DebugColors::TouchEventHandlerRectBorderColor();
721 fill_color
= DebugColors::TouchEventHandlerRectFillColor();
722 stroke_width
= DebugColors::TouchEventHandlerRectBorderWidth();
723 label_text
= "touch event listener";
725 case WHEEL_EVENT_HANDLER_RECT_TYPE
:
726 stroke_color
= DebugColors::WheelEventHandlerRectBorderColor();
727 fill_color
= DebugColors::WheelEventHandlerRectFillColor();
728 stroke_width
= DebugColors::WheelEventHandlerRectBorderWidth();
729 label_text
= "mousewheel event listener";
731 case SCROLL_EVENT_HANDLER_RECT_TYPE
:
732 stroke_color
= DebugColors::ScrollEventHandlerRectBorderColor();
733 fill_color
= DebugColors::ScrollEventHandlerRectFillColor();
734 stroke_width
= DebugColors::ScrollEventHandlerRectBorderWidth();
735 label_text
= "scroll event listener";
737 case NON_FAST_SCROLLABLE_RECT_TYPE
:
738 stroke_color
= DebugColors::NonFastScrollableRectBorderColor();
739 fill_color
= DebugColors::NonFastScrollableRectFillColor();
740 stroke_width
= DebugColors::NonFastScrollableRectBorderWidth();
741 label_text
= "repaints on scroll";
743 case ANIMATION_BOUNDS_RECT_TYPE
:
744 stroke_color
= DebugColors::LayerAnimationBoundsBorderColor();
745 fill_color
= DebugColors::LayerAnimationBoundsFillColor();
746 stroke_width
= DebugColors::LayerAnimationBoundsBorderWidth();
747 label_text
= "animation bounds";
751 DrawDebugRect(canvas
,
760 if (new_paint_rects
.size()) {
761 paint_rects_
.swap(new_paint_rects
);
762 fade_step_
= DebugColors::kFadeSteps
;
764 if (fade_step_
> 0) {
766 for (size_t i
= 0; i
< paint_rects_
.size(); ++i
) {
767 DrawDebugRect(canvas
,
770 DebugColors::PaintRectBorderColor(fade_step_
),
771 DebugColors::PaintRectFillColor(fade_step_
),
772 DebugColors::PaintRectBorderWidth(),
778 const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const {
779 return "cc::HeadsUpDisplayLayerImpl";
782 void HeadsUpDisplayLayerImpl::AsValueInto(
783 base::debug::TracedValue
* dict
) const {
784 LayerImpl::AsValueInto(dict
);
785 dict
->SetString("layer_name", "Heads Up Display Layer");