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

Side by Side Diff: cc/playback/clip_path_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_path_display_item.h" 5 #include "cc/playback/clip_path_display_item.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/trace_event/trace_event_argument.h" 8 #include "base/trace_event/trace_event_argument.h"
9 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 ClipPathDisplayItem::ClipPathDisplayItem() { 13 ClipPathDisplayItem::ClipPathDisplayItem() {
14 } 14 }
15 15
16 ClipPathDisplayItem::~ClipPathDisplayItem() { 16 ClipPathDisplayItem::~ClipPathDisplayItem() {
17 } 17 }
18 18
19 void ClipPathDisplayItem::SetNew(const SkPath& clip_path, 19 void ClipPathDisplayItem::SetNew(const SkPath& clip_path,
20 SkRegion::Op clip_op, 20 SkRegion::Op clip_op,
21 bool antialias) { 21 bool antialias) {
22 clip_path_ = clip_path; 22 clip_path_ = clip_path;
23 clip_op_ = clip_op; 23 clip_op_ = clip_op;
24 antialias_ = antialias; 24 antialias_ = antialias;
25 25
26 size_t memory_usage = sizeof(SkPath) + sizeof(SkRegion::Op) + sizeof(bool); 26 // The size of SkPath's external storage is not currently accounted for (and
27 // may well be shared anyway).
27 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */, 28 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */,
28 memory_usage); 29 0 /* external_memory_usage */);
29 } 30 }
30 31
31 void ClipPathDisplayItem::Raster(SkCanvas* canvas, 32 void ClipPathDisplayItem::Raster(SkCanvas* canvas,
32 const gfx::Rect& canvas_target_playback_rect, 33 const gfx::Rect& canvas_target_playback_rect,
33 SkPicture::AbortCallback* callback) const { 34 SkPicture::AbortCallback* callback) const {
34 canvas->save(); 35 canvas->save();
35 canvas->clipPath(clip_path_, clip_op_, antialias_); 36 canvas->clipPath(clip_path_, clip_op_, antialias_);
36 } 37 }
37 38
38 void ClipPathDisplayItem::AsValueInto( 39 void ClipPathDisplayItem::AsValueInto(
39 base::trace_event::TracedValue* array) const { 40 base::trace_event::TracedValue* array) const {
40 array->AppendString(base::StringPrintf("ClipPathDisplayItem length: %d", 41 array->AppendString(base::StringPrintf("ClipPathDisplayItem length: %d",
41 clip_path_.countPoints())); 42 clip_path_.countPoints()));
42 } 43 }
43 44
44 EndClipPathDisplayItem::EndClipPathDisplayItem() { 45 EndClipPathDisplayItem::EndClipPathDisplayItem() {
45 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, 46 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */,
46 0 /* memory_usage */); 47 0 /* external_memory_usage */);
47 } 48 }
48 49
49 EndClipPathDisplayItem::~EndClipPathDisplayItem() { 50 EndClipPathDisplayItem::~EndClipPathDisplayItem() {
50 } 51 }
51 52
52 void EndClipPathDisplayItem::Raster( 53 void EndClipPathDisplayItem::Raster(
53 SkCanvas* canvas, 54 SkCanvas* canvas,
54 const gfx::Rect& canvas_target_playback_rect, 55 const gfx::Rect& canvas_target_playback_rect,
55 SkPicture::AbortCallback* callback) const { 56 SkPicture::AbortCallback* callback) const {
56 canvas->restore(); 57 canvas->restore();
57 } 58 }
58 59
59 void EndClipPathDisplayItem::AsValueInto( 60 void EndClipPathDisplayItem::AsValueInto(
60 base::trace_event::TracedValue* array) const { 61 base::trace_event::TracedValue* array) const {
61 array->AppendString("EndClipPathDisplayItem"); 62 array->AppendString("EndClipPathDisplayItem");
62 } 63 }
63 64
64 } // namespace cc 65 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698