Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: cc/layers/heads_up_display_layer_impl.cc

Issue 367833003: cc: Start using raster/eviction iterators. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 paint.setStrokeWidth(1); 452 paint.setStrokeWidth(1);
453 canvas->drawPath(path, paint); 453 canvas->drawPath(path, paint);
454 454
455 return area; 455 return area;
456 } 456 }
457 457
458 SkRect HeadsUpDisplayLayerImpl::DrawMemoryDisplay(SkCanvas* canvas, 458 SkRect HeadsUpDisplayLayerImpl::DrawMemoryDisplay(SkCanvas* canvas,
459 int right, 459 int right,
460 int top, 460 int top,
461 int width) const { 461 int width) const {
462 if (!memory_entry_.bytes_total()) 462 if (!memory_entry_.total_bytes_used)
463 return SkRect::MakeEmpty(); 463 return SkRect::MakeEmpty();
464 464
465 const int kPadding = 4; 465 const int kPadding = 4;
466 const int kFontHeight = 13; 466 const int kFontHeight = 13;
467 467
468 const int height = 3 * kFontHeight + 4 * kPadding; 468 const int height = 3 * kFontHeight + 4 * kPadding;
469 const int left = bounds().width() - width - right; 469 const int left = bounds().width() - width - right;
470 const SkRect area = SkRect::MakeXYWH(left, top, width, height); 470 const SkRect area = SkRect::MakeXYWH(left, top, width, height);
471 471
472 const double megabyte = 1024.0 * 1024.0; 472 const double kMegabyte = 1024.0 * 1024.0;
473 473
474 SkPaint paint = CreatePaint(); 474 SkPaint paint = CreatePaint();
475 DrawGraphBackground(canvas, &paint, area); 475 DrawGraphBackground(canvas, &paint, area);
476 476
477 SkPoint title_pos = SkPoint::Make(left + kPadding, top + kFontHeight); 477 SkPoint title_pos = SkPoint::Make(left + kPadding, top + kFontHeight);
478 SkPoint stat1_pos = SkPoint::Make(left + width - kPadding - 1, 478 SkPoint stat1_pos = SkPoint::Make(left + width - kPadding - 1,
479 top + kPadding + 2 * kFontHeight); 479 top + kPadding + 2 * kFontHeight);
480 SkPoint stat2_pos = SkPoint::Make(left + width - kPadding - 1, 480 SkPoint stat2_pos = SkPoint::Make(left + width - kPadding - 1,
481 top + 2 * kPadding + 3 * kFontHeight); 481 top + 2 * kPadding + 3 * kFontHeight);
482 482
483 paint.setColor(DebugColors::MemoryDisplayTextColor()); 483 paint.setColor(DebugColors::MemoryDisplayTextColor());
484 DrawText(canvas, 484 DrawText(canvas,
485 &paint, 485 &paint,
486 "GPU memory", 486 "GPU memory",
487 SkPaint::kLeft_Align, 487 SkPaint::kLeft_Align,
488 kFontHeight, 488 kFontHeight,
489 title_pos); 489 title_pos);
490 490
491 std::string text = 491 std::string text = base::StringPrintf(
492 base::StringPrintf("%6.1f MB used", 492 "%6.1f MB used", memory_entry_.total_bytes_used / kMegabyte);
493 (memory_entry_.bytes_unreleasable +
494 memory_entry_.bytes_allocated) / megabyte);
495 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat1_pos); 493 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat1_pos);
496 494
497 if (memory_entry_.bytes_over) { 495 if (!memory_entry_.had_enough_memory)
498 paint.setColor(SK_ColorRED); 496 paint.setColor(SK_ColorRED);
499 text = base::StringPrintf("%6.1f MB over", 497 text = base::StringPrintf("%6.1f MB max ",
500 memory_entry_.bytes_over / megabyte); 498 memory_entry_.total_budget_in_bytes / kMegabyte);
501 } else {
502 text = base::StringPrintf("%6.1f MB max ",
503 memory_entry_.total_budget_in_bytes / megabyte);
504 }
505 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat2_pos); 499 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat2_pos);
506 500
507 return area; 501 return area;
508 } 502 }
509 503
510 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay( 504 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay(
511 SkCanvas* canvas, 505 SkCanvas* canvas,
512 const PaintTimeCounter* paint_time_counter, 506 const PaintTimeCounter* paint_time_counter,
513 int right, 507 int right,
514 int top) const { 508 int top) const {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 return "cc::HeadsUpDisplayLayerImpl"; 756 return "cc::HeadsUpDisplayLayerImpl";
763 } 757 }
764 758
765 void HeadsUpDisplayLayerImpl::AsValueInto( 759 void HeadsUpDisplayLayerImpl::AsValueInto(
766 base::debug::TracedValue* dict) const { 760 base::debug::TracedValue* dict) const {
767 LayerImpl::AsValueInto(dict); 761 LayerImpl::AsValueInto(dict);
768 dict->SetString("layer_name", "Heads Up Display Layer"); 762 dict->SetString("layer_name", "Heads Up Display Layer");
769 } 763 }
770 764
771 } // namespace cc 765 } // namespace cc
OLDNEW
« no previous file with comments | « cc/cc_tests.gyp ('k') | cc/layers/picture_layer_impl.h » ('j') | cc/layers/picture_layer_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698