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

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, 5 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.
vmpstr 2014/07/02 23:51:29 Changes in this file are a part of the original pa
enne (OOO) 2014/07/07 19:41:59 I'm not sure what you mean by that?
vmpstr 2014/07/07 23:24:46 I just mean that this is a part of the original pr
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"
11 #include "cc/debug/debug_colors.h" 11 #include "cc/debug/debug_colors.h"
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 paint.setStrokeWidth(1); 451 paint.setStrokeWidth(1);
452 canvas->drawPath(path, paint); 452 canvas->drawPath(path, paint);
453 453
454 return area; 454 return area;
455 } 455 }
456 456
457 SkRect HeadsUpDisplayLayerImpl::DrawMemoryDisplay(SkCanvas* canvas, 457 SkRect HeadsUpDisplayLayerImpl::DrawMemoryDisplay(SkCanvas* canvas,
458 int right, 458 int right,
459 int top, 459 int top,
460 int width) const { 460 int width) const {
461 if (!memory_entry_.bytes_total()) 461 if (!memory_entry_.total_bytes_used)
462 return SkRect::MakeEmpty(); 462 return SkRect::MakeEmpty();
463 463
464 const int kPadding = 4; 464 const int kPadding = 4;
465 const int kFontHeight = 13; 465 const int kFontHeight = 13;
466 466
467 const int height = 3 * kFontHeight + 4 * kPadding; 467 const int height = 3 * kFontHeight + 4 * kPadding;
468 const int left = bounds().width() - width - right; 468 const int left = bounds().width() - width - right;
469 const SkRect area = SkRect::MakeXYWH(left, top, width, height); 469 const SkRect area = SkRect::MakeXYWH(left, top, width, height);
470 470
471 const double megabyte = 1024.0 * 1024.0; 471 const double kMegabyte = 1024.0 * 1024.0;
472 472
473 SkPaint paint = CreatePaint(); 473 SkPaint paint = CreatePaint();
474 DrawGraphBackground(canvas, &paint, area); 474 DrawGraphBackground(canvas, &paint, area);
475 475
476 SkPoint title_pos = SkPoint::Make(left + kPadding, top + kFontHeight); 476 SkPoint title_pos = SkPoint::Make(left + kPadding, top + kFontHeight);
477 SkPoint stat1_pos = SkPoint::Make(left + width - kPadding - 1, 477 SkPoint stat1_pos = SkPoint::Make(left + width - kPadding - 1,
478 top + kPadding + 2 * kFontHeight); 478 top + kPadding + 2 * kFontHeight);
479 SkPoint stat2_pos = SkPoint::Make(left + width - kPadding - 1, 479 SkPoint stat2_pos = SkPoint::Make(left + width - kPadding - 1,
480 top + 2 * kPadding + 3 * kFontHeight); 480 top + 2 * kPadding + 3 * kFontHeight);
481 481
482 paint.setColor(DebugColors::MemoryDisplayTextColor()); 482 paint.setColor(DebugColors::MemoryDisplayTextColor());
483 DrawText(canvas, 483 DrawText(canvas,
484 &paint, 484 &paint,
485 "GPU memory", 485 "GPU memory",
486 SkPaint::kLeft_Align, 486 SkPaint::kLeft_Align,
487 kFontHeight, 487 kFontHeight,
488 title_pos); 488 title_pos);
489 489
490 std::string text = 490 std::string text = base::StringPrintf(
491 base::StringPrintf("%6.1f MB used", 491 "%6.1f MB used", memory_entry_.total_bytes_used / kMegabyte);
492 (memory_entry_.bytes_unreleasable +
493 memory_entry_.bytes_allocated) / megabyte);
494 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat1_pos); 492 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat1_pos);
495 493
496 if (memory_entry_.bytes_over) { 494 if (!memory_entry_.had_enough_memory)
497 paint.setColor(SK_ColorRED); 495 paint.setColor(SK_ColorRED);
498 text = base::StringPrintf("%6.1f MB over", 496 text = base::StringPrintf("%6.1f MB max ",
499 memory_entry_.bytes_over / megabyte); 497 memory_entry_.total_budget_in_bytes / kMegabyte);
500 } else {
501 text = base::StringPrintf("%6.1f MB max ",
502 memory_entry_.total_budget_in_bytes / megabyte);
503 }
504 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat2_pos); 498 DrawText(canvas, &paint, text, SkPaint::kRight_Align, kFontHeight, stat2_pos);
505 499
506 return area; 500 return area;
507 } 501 }
508 502
509 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay( 503 SkRect HeadsUpDisplayLayerImpl::DrawPaintTimeDisplay(
510 SkCanvas* canvas, 504 SkCanvas* canvas,
511 const PaintTimeCounter* paint_time_counter, 505 const PaintTimeCounter* paint_time_counter,
512 int right, 506 int right,
513 int top) const { 507 int top) const {
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const { 754 const char* HeadsUpDisplayLayerImpl::LayerTypeAsString() const {
761 return "cc::HeadsUpDisplayLayerImpl"; 755 return "cc::HeadsUpDisplayLayerImpl";
762 } 756 }
763 757
764 void HeadsUpDisplayLayerImpl::AsValueInto(base::DictionaryValue* dict) const { 758 void HeadsUpDisplayLayerImpl::AsValueInto(base::DictionaryValue* dict) const {
765 LayerImpl::AsValueInto(dict); 759 LayerImpl::AsValueInto(dict);
766 dict->SetString("layer_name", "Heads Up Display Layer"); 760 dict->SetString("layer_name", "Heads Up Display Layer");
767 } 761 }
768 762
769 } // namespace cc 763 } // 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.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698