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/strings/stringprintf.h"
11 #include "cc/debug/debug_colors.h"
12 #include "cc/debug/frame_rate_counter.h"
13 #include "cc/debug/paint_time_counter.h"
14 #include "cc/debug/traced_value.h"
15 #include "cc/output/renderer.h"
16 #include "cc/quads/texture_draw_quad.h"
17 #include "cc/resources/memory_history.h"
18 #include "cc/trees/layer_tree_impl.h"
19 #include "skia/ext/platform_canvas.h"
20 #include "third_party/khronos/GLES2/gl2.h"
21 #include "third_party/khronos/GLES2/gl2ext.h"
22 #include "third_party/skia/include/core/SkBitmap.h"
23 #include "third_party/skia/include/core/SkPaint.h"
24 #include "third_party/skia/include/core/SkTypeface.h"
25 #include "third_party/skia/include/effects/SkColorMatrixFilter.h"
26 #include "ui/gfx/point.h"
27 #include "ui/gfx/size.h"
31 static inline SkPaint
CreatePaint() {
33 #if (SK_R32_SHIFT || SK_B32_SHIFT != 16)
34 // The SkCanvas is in RGBA but the shader is expecting BGRA, so we need to
35 // swizzle our colors when drawing to the SkCanvas.
36 SkColorMatrix swizzle_matrix
;
37 for (int i
= 0; i
< 20; ++i
)
38 swizzle_matrix
.fMat
[i
] = 0;
39 swizzle_matrix
.fMat
[0 + 5 * 2] = 1;
40 swizzle_matrix
.fMat
[1 + 5 * 1] = 1;
41 swizzle_matrix
.fMat
[2 + 5 * 0] = 1;
42 swizzle_matrix
.fMat
[3 + 5 * 3] = 1;
44 skia::RefPtr
<SkColorMatrixFilter
> filter
=
45 skia::AdoptRef(SkColorMatrixFilter::Create(swizzle_matrix
));
46 paint
.setColorFilter(filter
.get());
51 HeadsUpDisplayLayerImpl::Graph::Graph(double indicator_value
,
52 double start_upper_bound
)
56 current_upper_bound(start_upper_bound
),
57 default_upper_bound(start_upper_bound
),
58 indicator(indicator_value
) {}
60 double HeadsUpDisplayLayerImpl::Graph::UpdateUpperBound() {
61 double target_upper_bound
= std::max(max
, default_upper_bound
);
62 current_upper_bound
+= (target_upper_bound
- current_upper_bound
) * 0.5;
63 return current_upper_bound
;
66 HeadsUpDisplayLayerImpl::HeadsUpDisplayLayerImpl(LayerTreeImpl
* tree_impl
,
68 : LayerImpl(tree_impl
, id
),
69 typeface_(skia::AdoptRef(
70 SkTypeface::CreateFromName("monospace", SkTypeface::kBold
))),
71 fps_graph_(60.0, 80.0),
72 paint_time_graph_(16.0, 48.0),
75 HeadsUpDisplayLayerImpl::~HeadsUpDisplayLayerImpl() {}
77 scoped_ptr
<LayerImpl
> HeadsUpDisplayLayerImpl::CreateLayerImpl(
78 LayerTreeImpl
* tree_impl
) {
79 return HeadsUpDisplayLayerImpl::Create(tree_impl
, id()).PassAs
<LayerImpl
>();
82 bool HeadsUpDisplayLayerImpl::WillDraw(DrawMode draw_mode
,
83 ResourceProvider
* resource_provider
) {
84 if (draw_mode
== DRAW_MODE_RESOURCELESS_SOFTWARE
)
88 hud_resource_
= ScopedResource::Create(resource_provider
);
90 // TODO(danakj): The HUD could swap between two textures instead of creating a
91 // texture every frame in ubercompositor.
92 if (hud_resource_
->size() != content_bounds() ||
93 (hud_resource_
->id() &&
94 resource_provider
->InUseByConsumer(hud_resource_
->id()))) {
95 hud_resource_
->Free();
98 if (!hud_resource_
->id()) {
99 hud_resource_
->Allocate(content_bounds(),
100 ResourceProvider::TextureUsageAny
,
104 return LayerImpl::WillDraw(draw_mode
, resource_provider
);
107 void HeadsUpDisplayLayerImpl::AppendQuads(
108 RenderPass
* render_pass
,
109 const OcclusionTracker
<LayerImpl
>& occlusion_tracker
,
110 AppendQuadsData
* append_quads_data
) {
111 if (!hud_resource_
->id())
114 SharedQuadState
* shared_quad_state
=
115 render_pass
->CreateAndAppendSharedQuadState();
116 PopulateSharedQuadState(shared_quad_state
);
118 gfx::Rect
quad_rect(content_bounds());
119 gfx::Rect
opaque_rect(contents_opaque() ? quad_rect
: gfx::Rect());
120 gfx::Rect
visible_quad_rect(quad_rect
);
121 bool premultiplied_alpha
= true;
122 gfx::PointF
uv_top_left(0.f
, 0.f
);
123 gfx::PointF
uv_bottom_right(1.f
, 1.f
);
124 const float vertex_opacity
[] = { 1.f
, 1.f
, 1.f
, 1.f
};
125 bool flipped
= false;
126 TextureDrawQuad
* quad
=
127 render_pass
->CreateAndAppendDrawQuad
<TextureDrawQuad
>();
128 quad
->SetNew(shared_quad_state
,
141 void HeadsUpDisplayLayerImpl::UpdateHudTexture(
143 ResourceProvider
* resource_provider
) {
144 if (draw_mode
== DRAW_MODE_RESOURCELESS_SOFTWARE
|| !hud_resource_
->id())
149 canvas_size
= hud_canvas_
->getDeviceSize();
151 canvas_size
.set(0, 0);
153 if (canvas_size
.width() != content_bounds().width() ||
154 canvas_size
.height() != content_bounds().height() || !hud_canvas_
) {
155 TRACE_EVENT0("cc", "ResizeHudCanvas");
157 hud_canvas_
= make_scoped_ptr(skia::CreateBitmapCanvas(
158 content_bounds().width(), content_bounds().height(), opaque
));
164 TRACE_EVENT0("cc", "DrawHudContents");
165 hud_canvas_
->clear(SkColorSetARGB(0, 0, 0, 0));
167 hud_canvas_
->scale(contents_scale_x(), contents_scale_y());
169 DrawHudContents(hud_canvas_
.get());
171 hud_canvas_
->restore();
174 TRACE_EVENT0("cc", "UploadHudTexture");
176 size_t row_bytes
= 0;
177 const void* pixels
= hud_canvas_
->peekPixels(&info
, &row_bytes
);
179 gfx::Rect
content_rect(content_bounds());
180 DCHECK(info
.colorType() == kN32_SkColorType
);
181 resource_provider
->SetPixels(hud_resource_
->id(),
182 static_cast<const uint8_t*>(pixels
),
188 void HeadsUpDisplayLayerImpl::ReleaseResources() { hud_resource_
.reset(); }
190 void HeadsUpDisplayLayerImpl::UpdateHudContents() {
191 const LayerTreeDebugState
& debug_state
= layer_tree_impl()->debug_state();
193 // Don't update numbers every frame so text is readable.
194 base::TimeTicks now
= layer_tree_impl()->CurrentFrameTimeTicks();
195 if (base::TimeDelta(now
- time_of_last_graph_update_
).InSecondsF() > 0.25f
) {
196 time_of_last_graph_update_
= now
;
198 if (debug_state
.show_fps_counter
) {
199 FrameRateCounter
* fps_counter
= layer_tree_impl()->frame_rate_counter();
200 fps_graph_
.value
= fps_counter
->GetAverageFPS();
201 fps_counter
->GetMinAndMaxFPS(&fps_graph_
.min
, &fps_graph_
.max
);
204 if (debug_state
.continuous_painting
) {
205 PaintTimeCounter
* paint_time_counter
=
206 layer_tree_impl()->paint_time_counter();
207 base::TimeDelta latest
, min
, max
;
209 if (paint_time_counter
->End())
210 latest
= **paint_time_counter
->End();
211 paint_time_counter
->GetMinAndMaxPaintTime(&min
, &max
);
213 paint_time_graph_
.value
= latest
.InMillisecondsF();
214 paint_time_graph_
.min
= min
.InMillisecondsF();
215 paint_time_graph_
.max
= max
.InMillisecondsF();
218 if (debug_state
.ShowMemoryStats()) {
219 MemoryHistory
* memory_history
= layer_tree_impl()->memory_history();
220 if (memory_history
->End())
221 memory_entry_
= **memory_history
->End();
223 memory_entry_
= MemoryHistory::Entry();
227 fps_graph_
.UpdateUpperBound();
228 paint_time_graph_
.UpdateUpperBound();
231 void HeadsUpDisplayLayerImpl::DrawHudContents(SkCanvas
* canvas
) {
232 const LayerTreeDebugState
& debug_state
= layer_tree_impl()->debug_state();
234 if (debug_state
.ShowHudRects()) {
235 DrawDebugRects(canvas
, layer_tree_impl()->debug_rect_history());
236 if (IsAnimatingHUDContents()) {
237 layer_tree_impl()->SetNeedsRedraw();
241 SkRect area
= SkRect::MakeEmpty();
242 if (debug_state
.continuous_painting
) {
243 area
= DrawPaintTimeDisplay(
244 canvas
, layer_tree_impl()->paint_time_counter(), 0, 0);
245 } else if (debug_state
.show_fps_counter
) {
246 // Don't show the FPS display when continuous painting is enabled, because
247 // it would show misleading numbers.
249 DrawFPSDisplay(canvas
, layer_tree_impl()->frame_rate_counter(), 0, 0);
252 if (debug_state
.ShowMemoryStats())
253 DrawMemoryDisplay(canvas
, 0, area
.bottom(), SkMaxScalar(area
.width(), 150));
256 void HeadsUpDisplayLayerImpl::DrawText(SkCanvas
* canvas
,
258 const std::string
& text
,
259 SkPaint::Align align
,
263 const bool anti_alias
= paint
->isAntiAlias();
264 paint
->setAntiAlias(true);
266 paint
->setTextSize(size
);
267 paint
->setTextAlign(align
);
268 paint
->setTypeface(typeface_
.get());
269 canvas
->drawText(text
.c_str(), text
.length(), x
, y
, *paint
);
271 paint
->setAntiAlias(anti_alias
);
274 void HeadsUpDisplayLayerImpl::DrawText(SkCanvas
* canvas
,
276 const std::string
& text
,
277 SkPaint::Align align
,
279 const SkPoint
& pos
) const {
280 DrawText(canvas
, paint
, text
, align
, size
, pos
.x(), pos
.y());
283 void HeadsUpDisplayLayerImpl::DrawGraphBackground(SkCanvas
* canvas
,
285 const SkRect
& bounds
) const {
286 paint
->setColor(DebugColors::HUDBackgroundColor());
287 canvas
->drawRect(bounds
, *paint
);
290 void HeadsUpDisplayLayerImpl::DrawGraphLines(SkCanvas
* canvas
,
292 const SkRect
& bounds
,
293 const Graph
& graph
) const {
294 // Draw top and bottom line.
295 paint
->setColor(DebugColors::HUDSeparatorLineColor());
296 canvas
->drawLine(bounds
.left(),
302 bounds
.left(), bounds
.bottom(), bounds
.right(), bounds
.bottom(), *paint
);
304 // Draw indicator line (additive blend mode to increase contrast when drawn on
306 paint
->setColor(DebugColors::HUDIndicatorLineColor());
307 paint
->setXfermodeMode(SkXfermode::kPlus_Mode
);
308 const double indicator_top
=
309 bounds
.height() * (1.0 - graph
.indicator
/ graph
.current_upper_bound
) -
311 canvas
->drawLine(bounds
.left(),
312 bounds
.top() + indicator_top
,
314 bounds
.top() + indicator_top
,
316 paint
->setXfermode(NULL
);
319 SkRect
HeadsUpDisplayLayerImpl::DrawFPSDisplay(
321 const FrameRateCounter
* fps_counter
,
324 const int kPadding
= 4;
327 const int kFontHeight
= 15;
329 const int kGraphWidth
= fps_counter
->time_stamp_history_size() - 2;
330 const int kGraphHeight
= 40;
332 const int kHistogramWidth
= 37;
334 int width
= kGraphWidth
+ kHistogramWidth
+ 4 * kPadding
;
335 int height
= kFontHeight
+ kGraphHeight
+ 4 * kPadding
+ 2;
336 int left
= bounds().width() - width
- right
;
337 SkRect area
= SkRect::MakeXYWH(left
, top
, width
, height
);
339 SkPaint paint
= CreatePaint();
340 DrawGraphBackground(canvas
, &paint
, area
);
343 SkRect::MakeXYWH(left
+ kPadding
,
345 kGraphWidth
+ kHistogramWidth
+ kGap
+ 2,
347 SkRect graph_bounds
= SkRect::MakeXYWH(left
+ kPadding
,
348 text_bounds
.bottom() + 2 * kPadding
,
351 SkRect histogram_bounds
= SkRect::MakeXYWH(graph_bounds
.right() + kGap
,
356 const std::string value_text
=
357 base::StringPrintf("FPS:%5.1f", fps_graph_
.value
);
358 const std::string min_max_text
=
359 base::StringPrintf("%.0f-%.0f", fps_graph_
.min
, fps_graph_
.max
);
361 paint
.setColor(DebugColors::FPSDisplayTextAndGraphColor());
365 SkPaint::kLeft_Align
,
368 text_bounds
.bottom());
372 SkPaint::kRight_Align
,
375 text_bounds
.bottom());
377 DrawGraphLines(canvas
, &paint
, graph_bounds
, fps_graph_
);
379 // Collect graph and histogram data.
382 const int kHistogramSize
= 20;
383 double histogram
[kHistogramSize
] = { 1.0 };
384 double max_bucket_value
= 1.0;
386 for (FrameRateCounter::RingBufferType::Iterator it
= --fps_counter
->end(); it
;
388 base::TimeDelta delta
= fps_counter
->RecentFrameInterval(it
.index() + 1);
390 // Skip this particular instantaneous frame rate if it is not likely to have
392 if (!fps_counter
->IsBadFrameInterval(delta
)) {
393 double fps
= 1.0 / delta
.InSecondsF();
395 // Clamp the FPS to the range we want to plot visually.
396 double p
= fps
/ fps_graph_
.current_upper_bound
;
400 // Plot this data point.
402 SkPoint::Make(graph_bounds
.left() + it
.index(),
403 graph_bounds
.bottom() - p
* graph_bounds
.height());
409 // Use the fps value to find the right bucket in the histogram.
410 int bucket_index
= floor(p
* (kHistogramSize
- 1));
412 // Add the delta time to take the time spent at that fps rate into
414 histogram
[bucket_index
] += delta
.InSecondsF();
415 max_bucket_value
= std::max(histogram
[bucket_index
], max_bucket_value
);
419 // Draw FPS histogram.
420 paint
.setColor(DebugColors::HUDSeparatorLineColor());
421 canvas
->drawLine(histogram_bounds
.left() - 1,
422 histogram_bounds
.top() - 1,
423 histogram_bounds
.left() - 1,
424 histogram_bounds
.bottom() + 1,
426 canvas
->drawLine(histogram_bounds
.right() + 1,
427 histogram_bounds
.top() - 1,
428 histogram_bounds
.right() + 1,
429 histogram_bounds
.bottom() + 1,
432 paint
.setColor(DebugColors::FPSDisplayTextAndGraphColor());
433 const double bar_height
= histogram_bounds
.height() / kHistogramSize
;
435 for (int i
= kHistogramSize
- 1; i
>= 0; --i
) {
436 if (histogram
[i
] > 0) {
438 histogram
[i
] / max_bucket_value
* histogram_bounds
.width();
440 SkRect::MakeXYWH(histogram_bounds
.left(),
441 histogram_bounds
.bottom() - (i
+ 1) * bar_height
,
449 paint
.setAntiAlias(true);
450 paint
.setStyle(SkPaint::kStroke_Style
);
451 paint
.setStrokeWidth(1);
452 canvas
->drawPath(path
, paint
);
457 SkRect
HeadsUpDisplayLayerImpl::DrawMemoryDisplay(SkCanvas
* canvas
,
461 if (!memory_entry_
.bytes_total())
462 return SkRect::MakeEmpty();
464 const int kPadding
= 4;
465 const int kFontHeight
= 13;
467 const int height
= 3 * kFontHeight
+ 4 * kPadding
;
468 const int left
= bounds().width() - width
- right
;
469 const SkRect area
= SkRect::MakeXYWH(left
, top
, width
, height
);
471 const double megabyte
= 1024.0 * 1024.0;
473 SkPaint paint
= CreatePaint();
474 DrawGraphBackground(canvas
, &paint
, area
);
476 SkPoint title_pos
= SkPoint::Make(left
+ kPadding
, top
+ kFontHeight
);
477 SkPoint stat1_pos
= SkPoint::Make(left
+ width
- kPadding
- 1,
478 top
+ kPadding
+ 2 * kFontHeight
);
479 SkPoint stat2_pos
= SkPoint::Make(left
+ width
- kPadding
- 1,
480 top
+ 2 * kPadding
+ 3 * kFontHeight
);
482 paint
.setColor(DebugColors::MemoryDisplayTextColor());
486 SkPaint::kLeft_Align
,
491 base::StringPrintf("%6.1f MB used",
492 (memory_entry_
.bytes_unreleasable
+
493 memory_entry_
.bytes_allocated
) / megabyte
);
494 DrawText(canvas
, &paint
, text
, SkPaint::kRight_Align
, kFontHeight
, stat1_pos
);
496 if (memory_entry_
.bytes_over
) {
497 paint
.setColor(SK_ColorRED
);
498 text
= base::StringPrintf("%6.1f MB over",
499 memory_entry_
.bytes_over
/ megabyte
);
501 text
= base::StringPrintf("%6.1f MB max ",
502 memory_entry_
.total_budget_in_bytes
/ megabyte
);
504 DrawText(canvas
, &paint
, text
, SkPaint::kRight_Align
, kFontHeight
, stat2_pos
);
509 SkRect
HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay(
511 const PaintTimeCounter
* paint_time_counter
,
514 const int kPadding
= 4;
515 const int kFontHeight
= 15;
517 const int kGraphWidth
= paint_time_counter
->HistorySize();
518 const int kGraphHeight
= 40;
520 const int width
= kGraphWidth
+ 2 * kPadding
;
522 kFontHeight
+ kGraphHeight
+ 4 * kPadding
+ 2 + kFontHeight
+ kPadding
;
523 const int left
= bounds().width() - width
- right
;
525 const SkRect area
= SkRect::MakeXYWH(left
, top
, width
, height
);
527 SkPaint paint
= CreatePaint();
528 DrawGraphBackground(canvas
, &paint
, area
);
530 SkRect text_bounds
= SkRect::MakeXYWH(
531 left
+ kPadding
, top
+ kPadding
, kGraphWidth
, kFontHeight
);
532 SkRect text_bounds2
= SkRect::MakeXYWH(left
+ kPadding
,
533 text_bounds
.bottom() + kPadding
,
536 SkRect graph_bounds
= SkRect::MakeXYWH(left
+ kPadding
,
537 text_bounds2
.bottom() + 2 * kPadding
,
541 const std::string value_text
=
542 base::StringPrintf("%.1f", paint_time_graph_
.value
);
543 const std::string min_max_text
= base::StringPrintf(
544 "%.1f-%.1f", paint_time_graph_
.min
, paint_time_graph_
.max
);
546 paint
.setColor(DebugColors::PaintTimeDisplayTextAndGraphColor());
549 "Page paint time (ms)",
550 SkPaint::kLeft_Align
,
553 text_bounds
.bottom());
557 SkPaint::kLeft_Align
,
560 text_bounds2
.bottom());
564 SkPaint::kRight_Align
,
566 text_bounds2
.right(),
567 text_bounds2
.bottom());
569 paint
.setColor(DebugColors::PaintTimeDisplayTextAndGraphColor());
570 for (PaintTimeCounter::RingBufferType::Iterator it
=
571 paint_time_counter
->End();
574 double pt
= it
->InMillisecondsF();
579 double p
= pt
/ paint_time_graph_
.current_upper_bound
;
584 SkRect::MakeXYWH(graph_bounds
.left() + it
.index(),
585 graph_bounds
.bottom() - p
* graph_bounds
.height(),
587 p
* graph_bounds
.height()),
591 DrawGraphLines(canvas
, &paint
, graph_bounds
, paint_time_graph_
);
596 void HeadsUpDisplayLayerImpl::DrawDebugRect(
599 const DebugRect
& rect
,
600 SkColor stroke_color
,
603 const std::string
& label_text
) const {
604 gfx::Rect debug_layer_rect
= gfx::ScaleToEnclosingRect(
605 rect
.rect
, 1.0 / contents_scale_x(), 1.0 / contents_scale_y());
606 SkIRect sk_rect
= RectToSkIRect(debug_layer_rect
);
607 paint
->setColor(fill_color
);
608 paint
->setStyle(SkPaint::kFill_Style
);
609 canvas
->drawIRect(sk_rect
, *paint
);
611 paint
->setColor(stroke_color
);
612 paint
->setStyle(SkPaint::kStroke_Style
);
613 paint
->setStrokeWidth(SkFloatToScalar(stroke_width
));
614 canvas
->drawIRect(sk_rect
, *paint
);
616 if (label_text
.length()) {
617 const int kFontHeight
= 12;
618 const int kPadding
= 3;
620 // The debug_layer_rect may be huge, and converting to a floating point may
621 // be lossy, so intersect with the HUD layer bounds first to prevent that.
622 gfx::Rect clip_rect
= debug_layer_rect
;
623 clip_rect
.Intersect(gfx::Rect(content_bounds()));
624 SkRect sk_clip_rect
= RectToSkRect(clip_rect
);
627 canvas
->clipRect(sk_clip_rect
);
628 canvas
->translate(sk_clip_rect
.x(), sk_clip_rect
.y());
630 SkPaint label_paint
= CreatePaint();
631 label_paint
.setTextSize(kFontHeight
);
632 label_paint
.setTypeface(typeface_
.get());
633 label_paint
.setColor(stroke_color
);
635 const SkScalar label_text_width
=
636 label_paint
.measureText(label_text
.c_str(), label_text
.length());
637 canvas
->drawRect(SkRect::MakeWH(label_text_width
+ 2 * kPadding
,
638 kFontHeight
+ 2 * kPadding
),
641 label_paint
.setAntiAlias(true);
642 label_paint
.setColor(SkColorSetARGB(255, 50, 50, 50));
643 canvas
->drawText(label_text
.c_str(),
646 kFontHeight
* 0.8f
+ kPadding
,
653 void HeadsUpDisplayLayerImpl::DrawDebugRects(
655 DebugRectHistory
* debug_rect_history
) {
656 SkPaint paint
= CreatePaint();
658 const std::vector
<DebugRect
>& debug_rects
= debug_rect_history
->debug_rects();
659 std::vector
<DebugRect
> new_paint_rects
;
661 for (size_t i
= 0; i
< debug_rects
.size(); ++i
) {
662 SkColor stroke_color
= 0;
663 SkColor fill_color
= 0;
664 float stroke_width
= 0.f
;
665 std::string label_text
;
667 switch (debug_rects
[i
].type
) {
668 case PAINT_RECT_TYPE
:
669 new_paint_rects
.push_back(debug_rects
[i
]);
671 case PROPERTY_CHANGED_RECT_TYPE
:
672 stroke_color
= DebugColors::PropertyChangedRectBorderColor();
673 fill_color
= DebugColors::PropertyChangedRectFillColor();
674 stroke_width
= DebugColors::PropertyChangedRectBorderWidth();
676 case SURFACE_DAMAGE_RECT_TYPE
:
677 stroke_color
= DebugColors::SurfaceDamageRectBorderColor();
678 fill_color
= DebugColors::SurfaceDamageRectFillColor();
679 stroke_width
= DebugColors::SurfaceDamageRectBorderWidth();
681 case REPLICA_SCREEN_SPACE_RECT_TYPE
:
682 stroke_color
= DebugColors::ScreenSpaceSurfaceReplicaRectBorderColor();
683 fill_color
= DebugColors::ScreenSpaceSurfaceReplicaRectFillColor();
684 stroke_width
= DebugColors::ScreenSpaceSurfaceReplicaRectBorderWidth();
686 case SCREEN_SPACE_RECT_TYPE
:
687 stroke_color
= DebugColors::ScreenSpaceLayerRectBorderColor();
688 fill_color
= DebugColors::ScreenSpaceLayerRectFillColor();
689 stroke_width
= DebugColors::ScreenSpaceLayerRectBorderWidth();
691 case OCCLUDING_RECT_TYPE
:
692 stroke_color
= DebugColors::OccludingRectBorderColor();
693 fill_color
= DebugColors::OccludingRectFillColor();
694 stroke_width
= DebugColors::OccludingRectBorderWidth();
696 case NONOCCLUDING_RECT_TYPE
:
697 stroke_color
= DebugColors::NonOccludingRectBorderColor();
698 fill_color
= DebugColors::NonOccludingRectFillColor();
699 stroke_width
= DebugColors::NonOccludingRectBorderWidth();
701 case TOUCH_EVENT_HANDLER_RECT_TYPE
:
702 stroke_color
= DebugColors::TouchEventHandlerRectBorderColor();
703 fill_color
= DebugColors::TouchEventHandlerRectFillColor();
704 stroke_width
= DebugColors::TouchEventHandlerRectBorderWidth();
705 label_text
= "touch event listener";
707 case WHEEL_EVENT_HANDLER_RECT_TYPE
:
708 stroke_color
= DebugColors::WheelEventHandlerRectBorderColor();
709 fill_color
= DebugColors::WheelEventHandlerRectFillColor();
710 stroke_width
= DebugColors::WheelEventHandlerRectBorderWidth();
711 label_text
= "mousewheel event listener";
713 case SCROLL_EVENT_HANDLER_RECT_TYPE
:
714 stroke_color
= DebugColors::ScrollEventHandlerRectBorderColor();
715 fill_color
= DebugColors::ScrollEventHandlerRectFillColor();
716 stroke_width
= DebugColors::ScrollEventHandlerRectBorderWidth();
717 label_text
= "scroll event listener";
719 case NON_FAST_SCROLLABLE_RECT_TYPE
:
720 stroke_color
= DebugColors::NonFastScrollableRectBorderColor();
721 fill_color
= DebugColors::NonFastScrollableRectFillColor();
722 stroke_width
= DebugColors::NonFastScrollableRectBorderWidth();
723 label_text
= "repaints on scroll";
725 case ANIMATION_BOUNDS_RECT_TYPE
:
726 stroke_color
= DebugColors::LayerAnimationBoundsBorderColor();
727 fill_color
= DebugColors::LayerAnimationBoundsFillColor();
728 stroke_width
= DebugColors::LayerAnimationBoundsBorderWidth();
729 label_text
= "animation bounds";
733 DrawDebugRect(canvas
,
742 if (new_paint_rects
.size()) {
743 paint_rects_
.swap(new_paint_rects
);
744 fade_step_
= DebugColors::kFadeSteps
;
746 if (fade_step_
> 0) {
748 for (size_t i
= 0; i
< paint_rects_
.size(); ++i
) {
749 DrawDebugRect(canvas
,
752 DebugColors::PaintRectBorderColor(fade_step_
),
753 DebugColors::PaintRectFillColor(fade_step_
),
754 DebugColors::PaintRectBorderWidth(),
760 const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const {
761 return "cc::HeadsUpDisplayLayerImpl";
764 void HeadsUpDisplayLayerImpl::AsValueInto(base::DictionaryValue
* dict
) const {
765 LayerImpl::AsValueInto(dict
);
766 dict
->SetString("layer_name", "Heads Up Display Layer");