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

Side by Side Diff: cc/playback/clip_display_item.cc

Issue 1226503006: cc: More consistent reasoning about display list memory usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: capacity unit test Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/playback/clip_display_item.h" 5 #include "cc/playback/clip_display_item.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/trace_event/trace_event_argument.h" 10 #include "base/trace_event/trace_event_argument.h"
11 #include "third_party/skia/include/core/SkCanvas.h" 11 #include "third_party/skia/include/core/SkCanvas.h"
12 #include "ui/gfx/skia_util.h" 12 #include "ui/gfx/skia_util.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 ClipDisplayItem::ClipDisplayItem() { 16 ClipDisplayItem::ClipDisplayItem() {
17 } 17 }
18 18
19 ClipDisplayItem::~ClipDisplayItem() { 19 ClipDisplayItem::~ClipDisplayItem() {
20 } 20 }
21 21
22 void ClipDisplayItem::SetNew(gfx::Rect clip_rect, 22 void ClipDisplayItem::SetNew(gfx::Rect clip_rect,
23 const std::vector<SkRRect>& rounded_clip_rects) { 23 const std::vector<SkRRect>& rounded_clip_rects) {
24 clip_rect_ = clip_rect; 24 clip_rect_ = clip_rect;
25 rounded_clip_rects_ = rounded_clip_rects; 25 rounded_clip_rects_ = rounded_clip_rects;
26 26
27 size_t memory_usage = sizeof(gfx::Rect); 27 size_t external_memory_usage =
28 for (size_t i = 0; i < rounded_clip_rects_.size(); ++i) { 28 rounded_clip_rects_.capacity() * sizeof(rounded_clip_rects_[0]);
29 memory_usage += sizeof(rounded_clip_rects_[i]); 29
30 }
31 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */, 30 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */,
32 memory_usage); 31 external_memory_usage);
33 } 32 }
34 33
35 void ClipDisplayItem::Raster(SkCanvas* canvas, 34 void ClipDisplayItem::Raster(SkCanvas* canvas,
36 const gfx::Rect& canvas_target_playback_rect, 35 const gfx::Rect& canvas_target_playback_rect,
37 SkPicture::AbortCallback* callback) const { 36 SkPicture::AbortCallback* callback) const {
38 canvas->save(); 37 canvas->save();
39 canvas->clipRect(SkRect::MakeXYWH(clip_rect_.x(), clip_rect_.y(), 38 canvas->clipRect(SkRect::MakeXYWH(clip_rect_.x(), clip_rect_.y(),
40 clip_rect_.width(), clip_rect_.height())); 39 clip_rect_.width(), clip_rect_.height()));
41 for (size_t i = 0; i < rounded_clip_rects_.size(); ++i) { 40 for (size_t i = 0; i < rounded_clip_rects_.size(); ++i) {
42 if (rounded_clip_rects_[i].isRect()) { 41 if (rounded_clip_rects_[i].isRect()) {
(...skipping 27 matching lines...) Expand all
70 lower_right_radius.y()); 69 lower_right_radius.y());
71 SkVector lower_left_radius = rounded_rect.radii(SkRRect::kLowerLeft_Corner); 70 SkVector lower_left_radius = rounded_rect.radii(SkRRect::kLowerLeft_Corner);
72 base::StringAppendF(&value, " [%f,%f]]", lower_left_radius.x(), 71 base::StringAppendF(&value, " [%f,%f]]", lower_left_radius.x(),
73 lower_left_radius.y()); 72 lower_left_radius.y());
74 } 73 }
75 array->AppendString(value); 74 array->AppendString(value);
76 } 75 }
77 76
78 EndClipDisplayItem::EndClipDisplayItem() { 77 EndClipDisplayItem::EndClipDisplayItem() {
79 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, 78 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */,
80 0 /* memory_usage */); 79 0 /* external_memory_usage */);
81 } 80 }
82 81
83 EndClipDisplayItem::~EndClipDisplayItem() { 82 EndClipDisplayItem::~EndClipDisplayItem() {
84 } 83 }
85 84
86 void EndClipDisplayItem::Raster(SkCanvas* canvas, 85 void EndClipDisplayItem::Raster(SkCanvas* canvas,
87 const gfx::Rect& canvas_target_playback_rect, 86 const gfx::Rect& canvas_target_playback_rect,
88 SkPicture::AbortCallback* callback) const { 87 SkPicture::AbortCallback* callback) const {
89 canvas->restore(); 88 canvas->restore();
90 } 89 }
91 90
92 void EndClipDisplayItem::AsValueInto( 91 void EndClipDisplayItem::AsValueInto(
93 base::trace_event::TracedValue* array) const { 92 base::trace_event::TracedValue* array) const {
94 array->AppendString("EndClipDisplayItem"); 93 array->AppendString("EndClipDisplayItem");
95 } 94 }
96 95
97 } // namespace cc 96 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698