| 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/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 paint.setStrokeWidth(1); | 449 paint.setStrokeWidth(1); |
| 450 canvas->drawPath(path, paint); | 450 canvas->drawPath(path, paint); |
| 451 | 451 |
| 452 return area; | 452 return area; |
| 453 } | 453 } |
| 454 | 454 |
| 455 SkRect HeadsUpDisplayLayerImpl::DrawMemoryDisplay(SkCanvas* canvas, | 455 SkRect HeadsUpDisplayLayerImpl::DrawMemoryDisplay(SkCanvas* canvas, |
| 456 int right, | 456 int right, |
| 457 int top, | 457 int top, |
| 458 int width) const { | 458 int width) const { |
| 459 if (!memory_entry_.bytes_total()) | 459 if (!memory_entry_.total_bytes_used) |
| 460 return SkRect::MakeEmpty(); | 460 return SkRect::MakeEmpty(); |
| 461 | 461 |
| 462 const int kPadding = 4; | 462 const int kPadding = 4; |
| 463 const int kFontHeight = 13; | 463 const int kFontHeight = 13; |
| 464 | 464 |
| 465 const int height = 3 * kFontHeight + 4 * kPadding; | 465 const int height = 3 * kFontHeight + 4 * kPadding; |
| 466 const int left = bounds().width() - width - right; | 466 const int left = bounds().width() - width - right; |
| 467 const SkRect area = SkRect::MakeXYWH(left, top, width, height); | 467 const SkRect area = SkRect::MakeXYWH(left, top, width, height); |
| 468 | 468 |
| 469 const double megabyte = 1024.0 * 1024.0; | 469 const double kMegabyte = 1024.0 * 1024.0; |
| 470 | 470 |
| 471 SkPaint paint = CreatePaint(); | 471 SkPaint paint = CreatePaint(); |
| 472 DrawGraphBackground(canvas, &paint, area); | 472 DrawGraphBackground(canvas, &paint, area); |
| 473 | 473 |
| 474 SkPoint title_pos = SkPoint::Make(left + kPadding, top + kFontHeight); | 474 SkPoint title_pos = SkPoint::Make(left + kPadding, top + kFontHeight); |
| 475 SkPoint stat1_pos = SkPoint::Make(left + width - kPadding - 1, | 475 SkPoint stat1_pos = SkPoint::Make(left + width - kPadding - 1, |
| 476 top + kPadding + 2 * kFontHeight); | 476 top + kPadding + 2 * kFontHeight); |
| 477 SkPoint stat2_pos = SkPoint::Make(left + width - kPadding - 1, | 477 SkPoint stat2_pos = SkPoint::Make(left + width - kPadding - 1, |
| 478 top + 2 * kPadding + 3 * kFontHeight); | 478 top + 2 * kPadding + 3 * kFontHeight); |
| 479 | 479 |
| 480 paint.setColor(DebugColors::MemoryDisplayTextColor()); | 480 paint.setColor(DebugColors::MemoryDisplayTextColor()); |
| 481 DrawText(canvas, | 481 DrawText(canvas, |
| 482 &paint, | 482 &paint, |
| 483 "GPU memory", | 483 "GPU memory", |
| 484 SkPaint::kLeft_Align, | 484 SkPaint::kLeft_Align, |
| 485 kFontHeight, | 485 kFontHeight, |
| 486 title_pos); | 486 title_pos); |
| 487 | 487 |
| 488 std::string text = | 488 std::string text = base::StringPrintf( |
| 489 base::StringPrintf("%6.1f MB used", | 489 "%6.1f MB used", memory_entry_.total_bytes_used / kMegabyte); |
| 490 (memory_entry_.bytes_unreleasable + | |
| 491 memory_entry_.bytes_allocated) / megabyte); | |
| 492 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat1_pos); | 490 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat1_pos); |
| 493 | 491 |
| 494 if (memory_entry_.bytes_over) { | 492 if (!memory_entry_.had_enough_memory) |
| 495 paint.setColor(SK_ColorRED); | 493 paint.setColor(SK_ColorRED); |
| 496 text = base::StringPrintf("%6.1f MB over", | 494 text = base::StringPrintf("%6.1f MB max ", |
| 497 memory_entry_.bytes_over / megabyte); | 495 memory_entry_.total_budget_in_bytes / kMegabyte); |
| 498 } else { | |
| 499 text = base::StringPrintf("%6.1f MB max ", | |
| 500 memory_entry_.total_budget_in_bytes / megabyte); | |
| 501 } | |
| 502 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat2_pos); | 496 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat2_pos); |
| 503 | 497 |
| 504 return area; | 498 return area; |
| 505 } | 499 } |
| 506 | 500 |
| 507 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay( | 501 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay( |
| 508 SkCanvas* canvas, | 502 SkCanvas* canvas, |
| 509 const PaintTimeCounter* paint_time_counter, | 503 const PaintTimeCounter* paint_time_counter, |
| 510 int right, | 504 int right, |
| 511 int top) const { | 505 int top) const { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const { | 752 const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const { |
| 759 return "cc::HeadsUpDisplayLayerImpl"; | 753 return "cc::HeadsUpDisplayLayerImpl"; |
| 760 } | 754 } |
| 761 | 755 |
| 762 void HeadsUpDisplayLayerImpl::AsValueInto(base::DictionaryValue* dict) const { | 756 void HeadsUpDisplayLayerImpl::AsValueInto(base::DictionaryValue* dict) const { |
| 763 LayerImpl::AsValueInto(dict); | 757 LayerImpl::AsValueInto(dict); |
| 764 dict->SetString("layer_name", "Heads Up Display Layer"); | 758 dict->SetString("layer_name", "Heads Up Display Layer"); |
| 765 } | 759 } |
| 766 | 760 |
| 767 } // namespace cc | 761 } // namespace cc |
| OLD | NEW |