OLD | NEW |
---|---|
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/compositing_display_item.h" | 5 #include "cc/playback/compositing_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 "cc/proto/skia_conversions.h" | 11 #include "cc/proto/skia_conversions.h" |
12 #include "third_party/skia/include/core/SkCanvas.h" | 12 #include "third_party/skia/include/core/SkCanvas.h" |
13 #include "third_party/skia/include/core/SkData.h" | 13 #include "third_party/skia/include/core/SkData.h" |
14 #include "third_party/skia/include/core/SkFlattenable.h" | 14 #include "third_party/skia/include/core/SkFlattenable.h" |
15 #include "third_party/skia/include/core/SkFlattenableSerialization.h" | 15 #include "third_party/skia/include/core/SkFlattenableSerialization.h" |
16 #include "third_party/skia/include/core/SkPaint.h" | 16 #include "third_party/skia/include/core/SkPaint.h" |
17 #include "third_party/skia/include/core/SkXfermode.h" | 17 #include "third_party/skia/include/core/SkXfermode.h" |
18 #include "ui/gfx/skia_util.h" | 18 #include "ui/gfx/skia_util.h" |
19 | 19 |
20 namespace cc { | 20 namespace cc { |
21 | 21 |
22 CompositingDisplayItem::CompositingDisplayItem() { | 22 CompositingDisplayItem::CompositingDisplayItem(uint8_t alpha, |
23 SkXfermode::Mode xfermode, | |
24 SkRect* bounds, | |
25 skia::RefPtr<SkColorFilter> cf) { | |
26 SetNew(alpha, xfermode, bounds, cf); | |
danakj
2015/12/08 19:18:14
move cf
| |
27 } | |
28 | |
29 CompositingDisplayItem::CompositingDisplayItem( | |
30 const proto::DisplayItem& proto) { | |
31 FromProtobuf(proto); | |
23 } | 32 } |
24 | 33 |
25 CompositingDisplayItem::~CompositingDisplayItem() { | 34 CompositingDisplayItem::~CompositingDisplayItem() { |
26 } | 35 } |
27 | 36 |
28 void CompositingDisplayItem::SetNew(uint8_t alpha, | 37 void CompositingDisplayItem::SetNew(uint8_t alpha, |
29 SkXfermode::Mode xfermode, | 38 SkXfermode::Mode xfermode, |
30 SkRect* bounds, | 39 SkRect* bounds, |
31 skia::RefPtr<SkColorFilter> cf) { | 40 skia::RefPtr<SkColorFilter> cf) { |
32 alpha_ = alpha; | 41 alpha_ = alpha; |
33 xfermode_ = xfermode; | 42 xfermode_ = xfermode; |
34 has_bounds_ = !!bounds; | 43 has_bounds_ = !!bounds; |
35 if (bounds) | 44 if (bounds) |
36 bounds_ = SkRect(*bounds); | 45 bounds_ = SkRect(*bounds); |
37 color_filter_ = cf; | 46 color_filter_ = cf; |
danakj
2015/12/08 19:18:14
this should move cf too while you're at it
| |
38 | |
39 // TODO(pdr): Include color_filter's memory here. | |
40 size_t external_memory_usage = 0; | |
41 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 1 /* op_count */, | |
42 external_memory_usage); | |
43 } | 47 } |
44 | 48 |
45 void CompositingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 49 void CompositingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
46 proto->set_type(proto::DisplayItem::Type_Compositing); | 50 proto->set_type(proto::DisplayItem::Type_Compositing); |
47 | 51 |
48 proto::CompositingDisplayItem* details = proto->mutable_compositing_item(); | 52 proto::CompositingDisplayItem* details = proto->mutable_compositing_item(); |
49 details->set_alpha(static_cast<uint32_t>(alpha_)); | 53 details->set_alpha(static_cast<uint32_t>(alpha_)); |
50 details->set_mode(SkXfermodeModeToProto(xfermode_)); | 54 details->set_mode(SkXfermodeModeToProto(xfermode_)); |
51 if (has_bounds_) | 55 if (has_bounds_) |
52 RectFToProto(gfx::SkRectToRectF(bounds_), details->mutable_bounds()); | 56 RectFToProto(gfx::SkRectToRectF(bounds_), details->mutable_bounds()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 array->AppendString(base::StringPrintf( | 103 array->AppendString(base::StringPrintf( |
100 "CompositingDisplayItem alpha: %d, xfermode: %d, visualRect: [%s]", | 104 "CompositingDisplayItem alpha: %d, xfermode: %d, visualRect: [%s]", |
101 alpha_, xfermode_, visual_rect.ToString().c_str())); | 105 alpha_, xfermode_, visual_rect.ToString().c_str())); |
102 if (has_bounds_) | 106 if (has_bounds_) |
103 array->AppendString(base::StringPrintf( | 107 array->AppendString(base::StringPrintf( |
104 ", bounds: [%f, %f, %f, %f]", static_cast<float>(bounds_.x()), | 108 ", bounds: [%f, %f, %f, %f]", static_cast<float>(bounds_.x()), |
105 static_cast<float>(bounds_.y()), static_cast<float>(bounds_.width()), | 109 static_cast<float>(bounds_.y()), static_cast<float>(bounds_.width()), |
106 static_cast<float>(bounds_.height()))); | 110 static_cast<float>(bounds_.height()))); |
107 } | 111 } |
108 | 112 |
109 EndCompositingDisplayItem::EndCompositingDisplayItem() { | 113 size_t CompositingDisplayItem::ExternalMemoryUsage() const { |
110 DisplayItem::SetNew(true /* suitable_for_gpu_raster */, 0 /* op_count */, | 114 // TODO(pdr): Include color_filter's memory here. |
111 0 /* external_memory_usage */); | 115 return 0; |
116 } | |
117 | |
118 EndCompositingDisplayItem::EndCompositingDisplayItem() {} | |
119 | |
120 EndCompositingDisplayItem::EndCompositingDisplayItem( | |
121 const proto::DisplayItem& proto) { | |
122 FromProtobuf(proto); | |
112 } | 123 } |
113 | 124 |
114 EndCompositingDisplayItem::~EndCompositingDisplayItem() { | 125 EndCompositingDisplayItem::~EndCompositingDisplayItem() { |
115 } | 126 } |
116 | 127 |
117 void EndCompositingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { | 128 void EndCompositingDisplayItem::ToProtobuf(proto::DisplayItem* proto) const { |
118 proto->set_type(proto::DisplayItem::Type_EndCompositing); | 129 proto->set_type(proto::DisplayItem::Type_EndCompositing); |
119 } | 130 } |
120 | 131 |
121 void EndCompositingDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { | 132 void EndCompositingDisplayItem::FromProtobuf(const proto::DisplayItem& proto) { |
122 DCHECK_EQ(proto::DisplayItem::Type_EndCompositing, proto.type()); | 133 DCHECK_EQ(proto::DisplayItem::Type_EndCompositing, proto.type()); |
123 } | 134 } |
124 | 135 |
125 void EndCompositingDisplayItem::Raster( | 136 void EndCompositingDisplayItem::Raster( |
126 SkCanvas* canvas, | 137 SkCanvas* canvas, |
127 const gfx::Rect& canvas_target_playback_rect, | 138 const gfx::Rect& canvas_target_playback_rect, |
128 SkPicture::AbortCallback* callback) const { | 139 SkPicture::AbortCallback* callback) const { |
129 canvas->restore(); | 140 canvas->restore(); |
130 } | 141 } |
131 | 142 |
132 void EndCompositingDisplayItem::AsValueInto( | 143 void EndCompositingDisplayItem::AsValueInto( |
133 const gfx::Rect& visual_rect, | 144 const gfx::Rect& visual_rect, |
134 base::trace_event::TracedValue* array) const { | 145 base::trace_event::TracedValue* array) const { |
135 array->AppendString( | 146 array->AppendString( |
136 base::StringPrintf("EndCompositingDisplayItem visualRect: [%s]", | 147 base::StringPrintf("EndCompositingDisplayItem visualRect: [%s]", |
137 visual_rect.ToString().c_str())); | 148 visual_rect.ToString().c_str())); |
138 } | 149 } |
139 | 150 |
151 size_t EndCompositingDisplayItem::ExternalMemoryUsage() const { | |
152 return 0; | |
153 } | |
154 | |
140 } // namespace cc | 155 } // namespace cc |
OLD | NEW |