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

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

Issue 1494223003: cc: Shrink size of display item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make SetNew private Created 5 years 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/float_clip_display_item.h" 5 #include "cc/playback/float_clip_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 "cc/proto/display_item.pb.h" 9 #include "cc/proto/display_item.pb.h"
10 #include "cc/proto/gfx_conversions.h" 10 #include "cc/proto/gfx_conversions.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 FloatClipDisplayItem::FloatClipDisplayItem() { 16 FloatClipDisplayItem::FloatClipDisplayItem(const gfx::RectF& clip_rect) {
17 SetNew(clip_rect);
18 }
19
20 FloatClipDisplayItem::FloatClipDisplayItem(const proto::DisplayItem& proto) {
21 FromProtobuf(proto);
17 } 22 }
18 23
19 FloatClipDisplayItem::~FloatClipDisplayItem() { 24 FloatClipDisplayItem::~FloatClipDisplayItem() {
20 } 25 }
21 26
22 void FloatClipDisplayItem::SetNew(const gfx::RectF& clip_rect) { 27 void FloatClipDisplayItem::SetNew(const gfx::RectF& clip_rect) {
23 clip_rect_ = clip_rect; 28 clip_rect_ = clip_rect;
24
25 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */,
26 0 /* external_memory_usage */);
27 } 29 }
28 30
29 void FloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { 31 void FloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
30 proto->set_type(proto::DisplayItem::Type_FloatClip); 32 proto->set_type(proto::DisplayItem::Type_FloatClip);
31 33
32 proto::FloatClipDisplayItem* details = proto->mutable_float_clip_item(); 34 proto::FloatClipDisplayItem* details = proto->mutable_float_clip_item();
33 RectFToProto(clip_rect_, details->mutable_clip_rect()); 35 RectFToProto(clip_rect_, details->mutable_clip_rect());
34 } 36 }
35 37
36 void FloatClipDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { 38 void FloatClipDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
(...skipping 13 matching lines...) Expand all
50 } 52 }
51 53
52 void FloatClipDisplayItem::AsValueInto( 54 void FloatClipDisplayItem::AsValueInto(
53 const gfx::Rect& visual_rect, 55 const gfx::Rect& visual_rect,
54 base::trace_event::TracedValue* array) const { 56 base::trace_event::TracedValue* array) const {
55 array->AppendString(base::StringPrintf( 57 array->AppendString(base::StringPrintf(
56 "FloatClipDisplayItem rect: [%s] visualRect: [%s]", 58 "FloatClipDisplayItem rect: [%s] visualRect: [%s]",
57 clip_rect_.ToString().c_str(), visual_rect.ToString().c_str())); 59 clip_rect_.ToString().c_str(), visual_rect.ToString().c_str()));
58 } 60 }
59 61
60 EndFloatClipDisplayItem::EndFloatClipDisplayItem() { 62 size_t FloatClipDisplayItem::ExternalMemoryUsage() const {
61 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, 63 return 0;
62 0 /* external_memory_usage */); 64 }
65
66 EndFloatClipDisplayItem::EndFloatClipDisplayItem() {}
67
68 EndFloatClipDisplayItem::EndFloatClipDisplayItem(
69 const proto::DisplayItem& proto) {
70 FromProtobuf(proto);
63 } 71 }
64 72
65 EndFloatClipDisplayItem::~EndFloatClipDisplayItem() { 73 EndFloatClipDisplayItem::~EndFloatClipDisplayItem() {
66 } 74 }
67 75
68 void EndFloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { 76 void EndFloatClipDisplayItem::ToProtobuf(proto::DisplayItem* proto) const {
69 proto->set_type(proto::DisplayItem::Type_EndFloatClip); 77 proto->set_type(proto::DisplayItem::Type_EndFloatClip);
70 } 78 }
71 79
72 void EndFloatClipDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { 80 void EndFloatClipDisplayItem::FromProtobuf(const proto::DisplayItem& proto) {
73 DCHECK_EQ(proto::DisplayItem::Type_EndFloatClip, proto.type()); 81 DCHECK_EQ(proto::DisplayItem::Type_EndFloatClip, proto.type());
74 } 82 }
75 83
76 void EndFloatClipDisplayItem::Raster( 84 void EndFloatClipDisplayItem::Raster(
77 SkCanvas* canvas, 85 SkCanvas* canvas,
78 const gfx::Rect& canvas_target_playback_rect, 86 const gfx::Rect& canvas_target_playback_rect,
79 SkPicture::AbortCallback* callback) const { 87 SkPicture::AbortCallback* callback) const {
80 canvas->restore(); 88 canvas->restore();
81 } 89 }
82 90
83 void EndFloatClipDisplayItem::AsValueInto( 91 void EndFloatClipDisplayItem::AsValueInto(
84 const gfx::Rect& visual_rect, 92 const gfx::Rect& visual_rect,
85 base::trace_event::TracedValue* array) const { 93 base::trace_event::TracedValue* array) const {
86 array->AppendString( 94 array->AppendString(
87 base::StringPrintf("EndFloatClipDisplayItem visualRect: [%s]", 95 base::StringPrintf("EndFloatClipDisplayItem visualRect: [%s]",
88 visual_rect.ToString().c_str())); 96 visual_rect.ToString().c_str()));
89 } 97 }
90 98
99 size_t EndFloatClipDisplayItem::ExternalMemoryUsage() const {
100 return 0;
101 }
102
91 } // namespace cc 103 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698