OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layers/heads_up_display_layer_impl.h" | 5 #include "cc/layers/heads_up_display_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/trace_event/trace_event.h" | 12 #include "base/trace_event/trace_event.h" |
13 #include "base/trace_event/trace_event_argument.h" | 13 #include "base/trace_event/trace_event_argument.h" |
14 #include "cc/debug/debug_colors.h" | 14 #include "cc/debug/debug_colors.h" |
15 #include "cc/debug/frame_rate_counter.h" | 15 #include "cc/debug/frame_rate_counter.h" |
16 #include "cc/output/begin_frame_args.h" | 16 #include "cc/output/begin_frame_args.h" |
17 #include "cc/output/renderer.h" | 17 #include "cc/output/renderer.h" |
18 #include "cc/quads/texture_draw_quad.h" | 18 #include "cc/quads/texture_draw_quad.h" |
19 #include "cc/resources/memory_history.h" | 19 #include "cc/resources/memory_history.h" |
20 #include "cc/trees/layer_tree_host_impl.h" | 20 #include "cc/trees/layer_tree_host_impl.h" |
21 #include "cc/trees/layer_tree_impl.h" | 21 #include "cc/trees/layer_tree_impl.h" |
22 #include "skia/ext/platform_canvas.h" | 22 #include "skia/ext/platform_canvas.h" |
23 #include "third_party/skia/include/core/SkPaint.h" | 23 #include "third_party/skia/include/core/SkPaint.h" |
24 #include "third_party/skia/include/core/SkPath.h" | 24 #include "third_party/skia/include/core/SkPath.h" |
25 #include "third_party/skia/include/core/SkRRect.h" | |
25 #include "third_party/skia/include/core/SkTypeface.h" | 26 #include "third_party/skia/include/core/SkTypeface.h" |
26 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" | 27 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" |
28 #include "third_party/skia/include/effects/SkGradientShader.h" | |
27 #include "ui/gfx/geometry/point.h" | 29 #include "ui/gfx/geometry/point.h" |
28 #include "ui/gfx/geometry/size.h" | 30 #include "ui/gfx/geometry/size.h" |
29 #include "ui/gfx/geometry/size_conversions.h" | 31 #include "ui/gfx/geometry/size_conversions.h" |
30 #include "ui/gfx/hud_font.h" | 32 #include "ui/gfx/hud_font.h" |
31 | 33 |
32 namespace cc { | 34 namespace cc { |
33 | 35 |
34 static inline SkPaint CreatePaint() { | 36 static inline SkPaint CreatePaint() { |
35 SkPaint paint; | 37 SkPaint paint; |
36 #if (SK_R32_SHIFT || SK_B32_SHIFT != 16) | 38 #if (SK_R32_SHIFT || SK_B32_SHIFT != 16) |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 if (debug_state.ShowHudRects()) { | 265 if (debug_state.ShowHudRects()) { |
264 DrawDebugRects(canvas, layer_tree_impl()->debug_rect_history()); | 266 DrawDebugRects(canvas, layer_tree_impl()->debug_rect_history()); |
265 if (IsAnimatingHUDContents()) { | 267 if (IsAnimatingHUDContents()) { |
266 layer_tree_impl()->SetNeedsRedraw(); | 268 layer_tree_impl()->SetNeedsRedraw(); |
267 } | 269 } |
268 } | 270 } |
269 | 271 |
270 if (!debug_state.show_fps_counter) | 272 if (!debug_state.show_fps_counter) |
271 return; | 273 return; |
272 | 274 |
273 SkRect area = | 275 SkRect area = DrawFPSDisplay(canvas, layer_tree_impl()->frame_rate_counter(), |
274 DrawFPSDisplay(canvas, layer_tree_impl()->frame_rate_counter(), 0, 0); | 276 0, 0, false); |
277 area = DrawDisplaySeparator(canvas, 0, area.bottom(), | |
278 SkMaxScalar(area.width(), 150)); | |
279 bool show_memory_display = | |
280 debug_state.ShowMemoryStats() && !!memory_entry_.total_bytes_used; | |
275 area = DrawGpuRasterizationStatus(canvas, 0, area.bottom(), | 281 area = DrawGpuRasterizationStatus(canvas, 0, area.bottom(), |
276 SkMaxScalar(area.width(), 150)); | 282 SkMaxScalar(area.width(), 150), |
277 | 283 !show_memory_display); |
278 if (debug_state.ShowMemoryStats()) | 284 if (show_memory_display) { |
279 DrawMemoryDisplay(canvas, 0, area.bottom(), SkMaxScalar(area.width(), 150)); | 285 area = DrawDisplaySeparator(canvas, 0, area.bottom(), |
286 SkMaxScalar(area.width(), 150)); | |
287 DrawMemoryDisplay(canvas, 0, area.bottom(), SkMaxScalar(area.width(), 150), | |
288 true); | |
289 } | |
280 } | 290 } |
281 int HeadsUpDisplayLayerImpl::MeasureText(SkPaint* paint, | 291 int HeadsUpDisplayLayerImpl::MeasureText(SkPaint* paint, |
282 const std::string& text, | 292 const std::string& text, |
283 int size) const { | 293 int size) const { |
284 const bool anti_alias = paint->isAntiAlias(); | 294 const bool anti_alias = paint->isAntiAlias(); |
285 paint->setAntiAlias(true); | 295 paint->setAntiAlias(true); |
286 paint->setTextSize(size); | 296 paint->setTextSize(size); |
287 paint->setTypeface(typeface_.get()); | 297 paint->setTypeface(typeface_.get()); |
288 SkScalar text_width = paint->measureText(text.c_str(), text.length()); | 298 SkScalar text_width = paint->measureText(text.c_str(), text.length()); |
289 | 299 |
290 paint->setAntiAlias(anti_alias); | 300 paint->setAntiAlias(anti_alias); |
291 return SkScalarCeilToInt(text_width); | 301 return SkScalarCeilToInt(text_width); |
292 } | 302 } |
293 void HeadsUpDisplayLayerImpl::DrawText(SkCanvas* canvas, | 303 void HeadsUpDisplayLayerImpl::DrawText(SkCanvas* canvas, |
294 SkPaint* paint, | 304 SkPaint* paint, |
295 const std::string& text, | 305 const std::string& text, |
296 SkPaint::Align align, | 306 SkPaint::Align align, |
297 int size, | 307 int size, |
298 int x, | 308 int x, |
299 int y) const { | 309 int y) const { |
300 const bool anti_alias = paint->isAntiAlias(); | 310 const bool anti_alias = paint->isAntiAlias(); |
301 paint->setAntiAlias(true); | 311 paint->setAntiAlias(true); |
302 | |
303 paint->setTextSize(size); | 312 paint->setTextSize(size); |
304 paint->setTextAlign(align); | 313 paint->setTextAlign(align); |
305 paint->setTypeface(typeface_.get()); | 314 paint->setTypeface(typeface_.get()); |
306 canvas->drawText(text.c_str(), text.length(), x, y, *paint); | 315 canvas->drawText(text.c_str(), text.length(), x, y, *paint); |
307 | |
308 paint->setAntiAlias(anti_alias); | 316 paint->setAntiAlias(anti_alias); |
309 } | 317 } |
310 | 318 |
311 void HeadsUpDisplayLayerImpl::DrawText(SkCanvas* canvas, | 319 void HeadsUpDisplayLayerImpl::DrawText(SkCanvas* canvas, |
312 SkPaint* paint, | 320 SkPaint* paint, |
313 const std::string& text, | 321 const std::string& text, |
314 SkPaint::Align align, | 322 SkPaint::Align align, |
315 int size, | 323 int size, |
316 const SkPoint& pos) const { | 324 const SkPoint& pos) const { |
317 DrawText(canvas, paint, text, align, size, pos.x(), pos.y()); | 325 DrawText(canvas, paint, text, align, size, pos.x(), pos.y()); |
318 } | 326 } |
319 | 327 |
320 void HeadsUpDisplayLayerImpl::DrawGraphBackground(SkCanvas* canvas, | 328 void HeadsUpDisplayLayerImpl::DrawGraphBackground(SkCanvas* canvas, |
321 SkPaint* paint, | 329 SkPaint* paint, |
322 const SkRect& bounds) const { | 330 const SkRect& bounds, |
331 bool rounded) const { | |
323 paint->setColor(DebugColors::HUDBackgroundColor()); | 332 paint->setColor(DebugColors::HUDBackgroundColor()); |
324 canvas->drawRect(bounds, *paint); | 333 |
334 if (rounded) { | |
danakj
2015/10/08 17:48:09
I don't think it's really worth adding code to mak
prashant.n
2015/10/09 01:01:52
Hmm. I will remove them.
| |
335 const bool anti_alias = paint->isAntiAlias(); | |
336 paint->setAntiAlias(true); | |
337 SkRRect rounded_bounds; | |
338 rounded_bounds.setNinePatch(bounds, 4, 0, 0, 4); | |
339 canvas->drawRRect(rounded_bounds, *paint); | |
340 paint->setAntiAlias(anti_alias); | |
341 } else { | |
342 canvas->drawRect(bounds, *paint); | |
343 } | |
325 } | 344 } |
326 | 345 |
327 void HeadsUpDisplayLayerImpl::DrawGraphLines(SkCanvas* canvas, | 346 void HeadsUpDisplayLayerImpl::DrawGraphLines(SkCanvas* canvas, |
328 SkPaint* paint, | 347 SkPaint* paint, |
329 const SkRect& bounds, | 348 const SkRect& bounds, |
330 const Graph& graph) const { | 349 const Graph& graph) const { |
331 // Draw top and bottom line. | 350 // Draw top and bottom line. |
332 paint->setColor(DebugColors::HUDSeparatorLineColor()); | 351 paint->setColor(DebugColors::HUDSeparatorLineColor()); |
333 canvas->drawLine(bounds.left(), | 352 canvas->drawLine(bounds.left(), |
334 bounds.top() - 1, | 353 bounds.top() - 1, |
(...skipping 15 matching lines...) Expand all Loading... | |
350 bounds.right(), | 369 bounds.right(), |
351 bounds.top() + indicator_top, | 370 bounds.top() + indicator_top, |
352 *paint); | 371 *paint); |
353 paint->setXfermode(nullptr); | 372 paint->setXfermode(nullptr); |
354 } | 373 } |
355 | 374 |
356 SkRect HeadsUpDisplayLayerImpl::DrawFPSDisplay( | 375 SkRect HeadsUpDisplayLayerImpl::DrawFPSDisplay( |
357 SkCanvas* canvas, | 376 SkCanvas* canvas, |
358 const FrameRateCounter* fps_counter, | 377 const FrameRateCounter* fps_counter, |
359 int right, | 378 int right, |
360 int top) const { | 379 int top, |
380 bool last_display) const { | |
361 const int kPadding = 4; | 381 const int kPadding = 4; |
362 const int kGap = 6; | 382 const int kGap = 6; |
363 | 383 |
364 const int kFontHeight = 15; | 384 const int kTitleFontHeight = 13; |
385 const int kFontHeight = 12; | |
365 | 386 |
366 const int kGraphWidth = | 387 const int kGraphWidth = |
367 base::saturated_cast<int>(fps_counter->time_stamp_history_size()) - 2; | 388 base::saturated_cast<int>(fps_counter->time_stamp_history_size()) - 2; |
368 const int kGraphHeight = 40; | 389 const int kGraphHeight = 40; |
369 | 390 |
370 const int kHistogramWidth = 37; | 391 const int kHistogramWidth = 37; |
371 | 392 |
372 int width = kGraphWidth + kHistogramWidth + 4 * kPadding; | 393 int width = kGraphWidth + kHistogramWidth + 4 * kPadding; |
373 int height = kFontHeight + kGraphHeight + 4 * kPadding + 2; | 394 int height = kTitleFontHeight + kFontHeight + kGraphHeight + 6 * kPadding + 2; |
374 int left = bounds().width() - width - right; | 395 int left = bounds().width() - width - right; |
375 SkRect area = SkRect::MakeXYWH(left, top, width, height); | 396 SkRect area = SkRect::MakeXYWH(left, top, width, height); |
376 | 397 |
377 SkPaint paint = CreatePaint(); | 398 SkPaint paint = CreatePaint(); |
378 DrawGraphBackground(canvas, &paint, area); | 399 DrawGraphBackground(canvas, &paint, area, last_display); |
379 | 400 |
401 SkRect title_bounds = SkRect::MakeXYWH( | |
402 left + kPadding, top + kPadding, kGraphWidth + kHistogramWidth + kGap + 2, | |
403 kTitleFontHeight); | |
380 SkRect text_bounds = | 404 SkRect text_bounds = |
381 SkRect::MakeXYWH(left + kPadding, | 405 SkRect::MakeXYWH(left + kPadding, title_bounds.bottom() + 2 * kPadding, |
382 top + kPadding, | 406 kGraphWidth + kHistogramWidth + kGap + 2, kFontHeight); |
383 kGraphWidth + kHistogramWidth + kGap + 2, | |
384 kFontHeight); | |
385 SkRect graph_bounds = SkRect::MakeXYWH(left + kPadding, | 407 SkRect graph_bounds = SkRect::MakeXYWH(left + kPadding, |
386 text_bounds.bottom() + 2 * kPadding, | 408 text_bounds.bottom() + 2 * kPadding, |
387 kGraphWidth, | 409 kGraphWidth, |
388 kGraphHeight); | 410 kGraphHeight); |
389 SkRect histogram_bounds = SkRect::MakeXYWH(graph_bounds.right() + kGap, | 411 SkRect histogram_bounds = SkRect::MakeXYWH(graph_bounds.right() + kGap, |
390 graph_bounds.top(), | 412 graph_bounds.top(), |
391 kHistogramWidth, | 413 kHistogramWidth, |
392 kGraphHeight); | 414 kGraphHeight); |
393 | 415 |
416 const std::string title("Frame Rate"); | |
394 const std::string value_text = | 417 const std::string value_text = |
395 base::StringPrintf("FPS:%5.1f", fps_graph_.value); | 418 base::StringPrintf("%5.1f fps", fps_graph_.value); |
396 const std::string min_max_text = | 419 const std::string min_max_text = |
397 base::StringPrintf("%.0f-%.0f", fps_graph_.min, fps_graph_.max); | 420 base::StringPrintf("%.0f-%.0f", fps_graph_.min, fps_graph_.max); |
398 | 421 |
399 VLOG(1) << value_text; | 422 VLOG(1) << value_text; |
400 | 423 |
424 paint.setColor(DebugColors::HUDTitleColor()); | |
425 DrawText(canvas, &paint, title, SkPaint::kLeft_Align, kTitleFontHeight, | |
426 title_bounds.left(), title_bounds.bottom()); | |
427 | |
401 paint.setColor(DebugColors::FPSDisplayTextAndGraphColor()); | 428 paint.setColor(DebugColors::FPSDisplayTextAndGraphColor()); |
402 DrawText(canvas, | 429 DrawText(canvas, |
403 &paint, | 430 &paint, |
404 value_text, | 431 value_text, |
405 SkPaint::kLeft_Align, | 432 SkPaint::kLeft_Align, |
406 kFontHeight, | 433 kFontHeight, |
407 text_bounds.left(), | 434 text_bounds.left(), |
408 text_bounds.bottom()); | 435 text_bounds.bottom()); |
409 DrawText(canvas, | 436 DrawText(canvas, |
410 &paint, | 437 &paint, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 paint.setStyle(SkPaint::kStroke_Style); | 517 paint.setStyle(SkPaint::kStroke_Style); |
491 paint.setStrokeWidth(1); | 518 paint.setStrokeWidth(1); |
492 canvas->drawPath(path, paint); | 519 canvas->drawPath(path, paint); |
493 | 520 |
494 return area; | 521 return area; |
495 } | 522 } |
496 | 523 |
497 SkRect HeadsUpDisplayLayerImpl::DrawMemoryDisplay(SkCanvas* canvas, | 524 SkRect HeadsUpDisplayLayerImpl::DrawMemoryDisplay(SkCanvas* canvas, |
498 int right, | 525 int right, |
499 int top, | 526 int top, |
500 int width) const { | 527 int width, |
501 if (!memory_entry_.total_bytes_used) | 528 bool last_display) const { |
502 return SkRect::MakeEmpty(); | 529 const int kPadding = 4; |
530 const int kTitleFontHeight = 13; | |
531 const int kFontHeight = 12; | |
503 | 532 |
504 const int kPadding = 4; | 533 const int height = kTitleFontHeight + 2 * kFontHeight + 5 * kPadding; |
505 const int kFontHeight = 13; | |
506 | |
507 const int height = 3 * kFontHeight + 4 * kPadding; | |
508 const int left = bounds().width() - width - right; | 534 const int left = bounds().width() - width - right; |
509 const SkRect area = SkRect::MakeXYWH(left, top, width, height); | 535 const SkRect area = SkRect::MakeXYWH(left, top, width, height); |
510 | 536 |
511 const double kMegabyte = 1024.0 * 1024.0; | 537 const double kMegabyte = 1024.0 * 1024.0; |
512 | 538 |
513 SkPaint paint = CreatePaint(); | 539 SkPaint paint = CreatePaint(); |
514 DrawGraphBackground(canvas, &paint, area); | 540 DrawGraphBackground(canvas, &paint, area, last_display); |
515 | 541 |
516 SkPoint title_pos = SkPoint::Make(left + kPadding, top + kFontHeight); | 542 SkPoint title_pos = |
543 SkPoint::Make(left + kPadding, top + kFontHeight + kPadding); | |
517 SkPoint stat1_pos = SkPoint::Make(left + width - kPadding - 1, | 544 SkPoint stat1_pos = SkPoint::Make(left + width - kPadding - 1, |
518 top + kPadding + 2 * kFontHeight); | 545 top + kPadding + 2 * kFontHeight); |
519 SkPoint stat2_pos = SkPoint::Make(left + width - kPadding - 1, | 546 SkPoint stat2_pos = SkPoint::Make(left + width - kPadding - 1, |
520 top + 2 * kPadding + 3 * kFontHeight); | 547 top + 2 * kPadding + 3 * kFontHeight); |
521 | 548 |
522 paint.setColor(DebugColors::MemoryDisplayTextColor()); | 549 paint.setColor(DebugColors::HUDTitleColor()); |
523 DrawText(canvas, | 550 DrawText(canvas, &paint, "GPU Memory", SkPaint::kLeft_Align, kTitleFontHeight, |
524 &paint, | |
525 "GPU memory", | |
526 SkPaint::kLeft_Align, | |
527 kFontHeight, | |
528 title_pos); | 551 title_pos); |
529 | 552 |
553 paint.setColor(DebugColors::MemoryDisplayTextColor()); | |
530 std::string text = base::StringPrintf( | 554 std::string text = base::StringPrintf( |
531 "%6.1f MB used", memory_entry_.total_bytes_used / kMegabyte); | 555 "%6.1f MB used", memory_entry_.total_bytes_used / kMegabyte); |
532 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat1_pos); | 556 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat1_pos); |
533 | 557 |
534 if (!memory_entry_.had_enough_memory) | 558 if (!memory_entry_.had_enough_memory) |
535 paint.setColor(SK_ColorRED); | 559 paint.setColor(SK_ColorRED); |
536 text = base::StringPrintf("%6.1f MB max ", | 560 text = base::StringPrintf("%6.1f MB max ", |
537 memory_entry_.total_budget_in_bytes / kMegabyte); | 561 memory_entry_.total_budget_in_bytes / kMegabyte); |
538 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat2_pos); | 562 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat2_pos); |
539 | 563 |
564 // Draw memory graph. | |
565 int length = 2 * kFontHeight + kPadding + 12; | |
566 SkRect oval = | |
567 SkRect::MakeXYWH(left + kPadding * 6, | |
568 top + kTitleFontHeight + kPadding * 3, length, length); | |
569 paint.setAntiAlias(true); | |
570 paint.setStyle(SkPaint::kFill_Style); | |
571 | |
572 paint.setColor(SkColorSetARGB(64, 255, 255, 0)); | |
573 canvas->drawArc(oval, 180, 180, true, paint); | |
574 | |
575 int radius = length / 2; | |
576 int cx = oval.left() + radius; | |
577 int cy = oval.top() + radius; | |
578 double angle = ((double)memory_entry_.total_bytes_used / | |
579 memory_entry_.total_budget_in_bytes) * | |
580 180; | |
581 | |
582 SkColor colors[] = {SK_ColorRED, SK_ColorGREEN, SK_ColorGREEN, | |
583 SkColorSetARGB(255, 255, 140, 0), SK_ColorRED}; | |
584 const SkScalar pos[] = {0.2, 0.4, 0.6, 0.8, 1.0}; | |
585 skia::RefPtr<SkShader> gradient_shader = | |
586 skia::AdoptRef(SkGradientShader::CreateSweep(cx, cy, colors, pos, 5)); | |
587 paint.setShader(gradient_shader.get()); | |
588 paint.setFlags(SkPaint::kAntiAlias_Flag); | |
589 | |
590 // Draw current status. | |
591 paint.setStyle(SkPaint::kStroke_Style); | |
592 paint.setAlpha(32); | |
593 paint.setStrokeWidth(4); | |
594 canvas->drawArc(oval, 180, angle, true, paint); | |
595 | |
596 paint.setStyle(SkPaint::kFill_Style); | |
597 paint.setColor(SkColorSetARGB(255, 0, 255, 0)); | |
598 canvas->drawArc(oval, 180, angle, true, paint); | |
599 paint.setShader(NULL); | |
600 | |
540 return area; | 601 return area; |
541 } | 602 } |
542 | 603 |
543 SkRect HeadsUpDisplayLayerImpl::DrawGpuRasterizationStatus(SkCanvas* canvas, | 604 SkRect HeadsUpDisplayLayerImpl::DrawGpuRasterizationStatus( |
544 int right, | 605 SkCanvas* canvas, |
545 int top, | 606 int right, |
546 int width) const { | 607 int top, |
608 int width, | |
609 bool last_display) const { | |
547 std::string status; | 610 std::string status; |
548 SkColor color = SK_ColorRED; | 611 SkColor color = SK_ColorRED; |
549 switch (layer_tree_impl()->GetGpuRasterizationStatus()) { | 612 switch (layer_tree_impl()->GetGpuRasterizationStatus()) { |
550 case GpuRasterizationStatus::ON: | 613 case GpuRasterizationStatus::ON: |
551 status = "on"; | 614 status = "on"; |
552 color = SK_ColorGREEN; | 615 color = SK_ColorGREEN; |
553 break; | 616 break; |
554 case GpuRasterizationStatus::ON_FORCED: | 617 case GpuRasterizationStatus::ON_FORCED: |
555 status = "on (forced)"; | 618 status = "on (forced)"; |
556 color = SK_ColorGREEN; | 619 color = SK_ColorGREEN; |
(...skipping 13 matching lines...) Expand all Loading... | |
570 case GpuRasterizationStatus::OFF_CONTENT: | 633 case GpuRasterizationStatus::OFF_CONTENT: |
571 status = "off (content)"; | 634 status = "off (content)"; |
572 color = SK_ColorYELLOW; | 635 color = SK_ColorYELLOW; |
573 break; | 636 break; |
574 } | 637 } |
575 | 638 |
576 if (status.empty()) | 639 if (status.empty()) |
577 return SkRect::MakeEmpty(); | 640 return SkRect::MakeEmpty(); |
578 | 641 |
579 const int kPadding = 4; | 642 const int kPadding = 4; |
580 const int kFontHeight = 13; | 643 const int kTitleFontHeight = 13; |
644 const int kFontHeight = 12; | |
581 | 645 |
582 const int height = 2 * kFontHeight + 3 * kPadding; | 646 const int height = kTitleFontHeight + kFontHeight + 3 * kPadding; |
583 const int left = bounds().width() - width - right; | 647 const int left = bounds().width() - width - right; |
584 const SkRect area = SkRect::MakeXYWH(left, top, width, height); | 648 const SkRect area = SkRect::MakeXYWH(left, top, width, height); |
585 | 649 |
586 SkPaint paint = CreatePaint(); | 650 SkPaint paint = CreatePaint(); |
587 DrawGraphBackground(canvas, &paint, area); | 651 DrawGraphBackground(canvas, &paint, area, last_display); |
588 | 652 |
589 SkPoint gpu_status_pos = SkPoint::Make(left + width - kPadding, | 653 SkPoint gpu_status_pos = SkPoint::Make(left + width - kPadding, |
590 top + 2 * kFontHeight + 2 * kPadding); | 654 top + 2 * kFontHeight + 2 * kPadding); |
591 | 655 paint.setColor(DebugColors::HUDTitleColor()); |
656 DrawText(canvas, &paint, "GPU Raster", SkPaint::kLeft_Align, kTitleFontHeight, | |
657 left + kPadding, top + kFontHeight + kPadding); | |
592 paint.setColor(color); | 658 paint.setColor(color); |
593 DrawText(canvas, &paint, "GPU raster: ", SkPaint::kLeft_Align, kFontHeight, | |
594 left + kPadding, top + kFontHeight + kPadding); | |
595 DrawText(canvas, &paint, status, SkPaint::kRight_Align, kFontHeight, | 659 DrawText(canvas, &paint, status, SkPaint::kRight_Align, kFontHeight, |
596 gpu_status_pos); | 660 gpu_status_pos); |
597 | 661 |
598 return area; | 662 return area; |
599 } | 663 } |
600 | 664 |
665 SkRect HeadsUpDisplayLayerImpl::DrawDisplaySeparator(SkCanvas* canvas, | |
666 int right, | |
667 int top, | |
668 int width) const { | |
669 const int height = 1; | |
670 const int left = bounds().width() - width - right; | |
671 const SkRect area = SkRect::MakeXYWH(left, top, width, height); | |
672 SkPaint paint = CreatePaint(); | |
673 paint.setColor(DebugColors::HUDDisplaySeparatorColor()); | |
danakj
2015/10/08 17:48:09
Similar comment here, I don't know that these sepa
prashant.n
2015/10/09 01:01:52
Adding separators between different displays makes
danakj
2015/10/09 04:41:35
I disagee, as I would like as little code in the H
prashant.n
2015/10/09 05:05:12
Basically it shows that fps counter and GPU status
danakj
2015/10/09 16:59:57
This isn't user-targeted UI like the chrome UI is.
prashant.n
2015/10/10 00:29:35
IMO, even the ui is not user targetted, it is publ
| |
674 canvas->drawRect(area, paint); | |
675 return area; | |
676 } | |
677 | |
601 void HeadsUpDisplayLayerImpl::DrawDebugRect( | 678 void HeadsUpDisplayLayerImpl::DrawDebugRect( |
602 SkCanvas* canvas, | 679 SkCanvas* canvas, |
603 SkPaint* paint, | 680 SkPaint* paint, |
604 const DebugRect& rect, | 681 const DebugRect& rect, |
605 SkColor stroke_color, | 682 SkColor stroke_color, |
606 SkColor fill_color, | 683 SkColor fill_color, |
607 float stroke_width, | 684 float stroke_width, |
608 const std::string& label_text) const { | 685 const std::string& label_text) const { |
609 gfx::Rect debug_layer_rect = | 686 gfx::Rect debug_layer_rect = |
610 gfx::ScaleToEnclosingRect(rect.rect, 1.0 / internal_contents_scale_, | 687 gfx::ScaleToEnclosingRect(rect.rect, 1.0 / internal_contents_scale_, |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
757 return "cc::HeadsUpDisplayLayerImpl"; | 834 return "cc::HeadsUpDisplayLayerImpl"; |
758 } | 835 } |
759 | 836 |
760 void HeadsUpDisplayLayerImpl::AsValueInto( | 837 void HeadsUpDisplayLayerImpl::AsValueInto( |
761 base::trace_event::TracedValue* dict) const { | 838 base::trace_event::TracedValue* dict) const { |
762 LayerImpl::AsValueInto(dict); | 839 LayerImpl::AsValueInto(dict); |
763 dict->SetString("layer_name", "Heads Up Display Layer"); | 840 dict->SetString("layer_name", "Heads Up Display Layer"); |
764 } | 841 } |
765 | 842 |
766 } // namespace cc | 843 } // namespace cc |
OLD | NEW |