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

Side by Side Diff: content/common/cc_messages.cc

Issue 1869753003: Replace many skia::RefPtr with sk_sp<> in cc/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fmalita review - deconstify sk_sp<>s Created 4 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/common/cc_messages.h" 5 #include "content/common/cc_messages.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
11 #include "cc/output/compositor_frame.h" 11 #include "cc/output/compositor_frame.h"
12 #include "cc/output/filter_operations.h" 12 #include "cc/output/filter_operations.h"
13 #include "cc/quads/draw_quad.h" 13 #include "cc/quads/draw_quad.h"
14 #include "cc/quads/largest_draw_quad.h" 14 #include "cc/quads/largest_draw_quad.h"
15 #include "cc/quads/render_pass_id.h" 15 #include "cc/quads/render_pass_id.h"
16 #include "content/public/common/common_param_traits.h" 16 #include "content/public/common/common_param_traits.h"
17 #include "third_party/skia/include/core/SkData.h" 17 #include "third_party/skia/include/core/SkData.h"
18 #include "third_party/skia/include/core/SkFlattenableSerialization.h" 18 #include "third_party/skia/include/core/SkFlattenableSerialization.h"
19 #include "third_party/skia/include/core/SkImageFilter.h"
20 #include "third_party/skia/include/core/SkRefCnt.h"
19 21
20 namespace IPC { 22 namespace IPC {
21 23
22 void ParamTraits<cc::FilterOperation>::Write(base::Pickle* m, 24 void ParamTraits<cc::FilterOperation>::Write(base::Pickle* m,
23 const param_type& p) { 25 const param_type& p) {
24 WriteParam(m, p.type()); 26 WriteParam(m, p.type());
25 switch (p.type()) { 27 switch (p.type()) {
26 case cc::FilterOperation::GRAYSCALE: 28 case cc::FilterOperation::GRAYSCALE:
27 case cc::FilterOperation::SEPIA: 29 case cc::FilterOperation::SEPIA:
28 case cc::FilterOperation::SATURATE: 30 case cc::FilterOperation::SATURATE:
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 if (ReadParam(m, iter, &amount) && 116 if (ReadParam(m, iter, &amount) &&
115 ReadParam(m, iter, &zoom_inset) && 117 ReadParam(m, iter, &zoom_inset) &&
116 amount >= 0.f && 118 amount >= 0.f &&
117 zoom_inset >= 0) { 119 zoom_inset >= 0) {
118 r->set_amount(amount); 120 r->set_amount(amount);
119 r->set_zoom_inset(zoom_inset); 121 r->set_zoom_inset(zoom_inset);
120 success = true; 122 success = true;
121 } 123 }
122 break; 124 break;
123 case cc::FilterOperation::REFERENCE: { 125 case cc::FilterOperation::REFERENCE: {
124 skia::RefPtr<SkImageFilter> filter; 126 sk_sp<SkImageFilter> filter;
125 if (!ReadParam(m, iter, &filter)) { 127 if (!ReadParam(m, iter, &filter)) {
126 success = false; 128 success = false;
127 break; 129 break;
128 } 130 }
129 r->set_image_filter(filter); 131 r->set_image_filter(filter);
f(malita) 2016/04/21 15:45:47 I can't quite tell what param type set_image_filte
tomhudson 2016/04/25 20:20:51 Yes, cc::FilterOperation() takes sk_sp<>, so we ca
130 success = true; 132 success = true;
131 break; 133 break;
132 } 134 }
133 case cc::FilterOperation::ALPHA_THRESHOLD: 135 case cc::FilterOperation::ALPHA_THRESHOLD:
134 break; 136 break;
135 } 137 }
136 return success; 138 return success;
137 } 139 }
138 140
139 void ParamTraits<cc::FilterOperation>::Log( 141 void ParamTraits<cc::FilterOperation>::Log(
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 const param_type& p, std::string* l) { 214 const param_type& p, std::string* l) {
213 l->append("("); 215 l->append("(");
214 for (std::size_t i = 0; i < p.size(); ++i) { 216 for (std::size_t i = 0; i < p.size(); ++i) {
215 if (i) 217 if (i)
216 l->append(", "); 218 l->append(", ");
217 LogParam(p.at(i), l); 219 LogParam(p.at(i), l);
218 } 220 }
219 l->append(")"); 221 l->append(")");
220 } 222 }
221 223
222 void ParamTraits<skia::RefPtr<SkImageFilter>>::Write(base::Pickle* m, 224 void ParamTraits<sk_sp<SkImageFilter>>::Write(base::Pickle* m,
223 const param_type& p) { 225 const param_type& p) {
224 SkImageFilter* filter = p.get(); 226 SkImageFilter* filter = p.get();
225 if (filter) { 227 if (filter) {
226 sk_sp<SkData> data(SkValidatingSerializeFlattenable(filter)); 228 sk_sp<SkData> data(SkValidatingSerializeFlattenable(filter));
227 m->WriteData(static_cast<const char*>(data->data()), data->size()); 229 m->WriteData(static_cast<const char*>(data->data()), data->size());
228 } else { 230 } else {
229 m->WriteData(0, 0); 231 m->WriteData(0, 0);
230 } 232 }
231 } 233 }
232 234
233 bool ParamTraits<skia::RefPtr<SkImageFilter>>::Read(const base::Pickle* m, 235 bool ParamTraits<sk_sp<SkImageFilter>>::Read(const base::Pickle* m,
234 base::PickleIterator* iter, 236 base::PickleIterator* iter,
235 param_type* r) { 237 param_type* r) {
236 const char* data = 0; 238 const char* data = 0;
237 int length = 0; 239 int length = 0;
238 if (!iter->ReadData(&data, &length)) 240 if (!iter->ReadData(&data, &length))
239 return false; 241 return false;
240 if (length > 0) { 242 if (length > 0) {
241 SkFlattenable* flattenable = SkValidatingDeserializeFlattenable( 243 SkFlattenable* flattenable = SkValidatingDeserializeFlattenable(
242 data, length, SkImageFilter::GetFlattenableType()); 244 data, length, SkImageFilter::GetFlattenableType());
243 *r = skia::AdoptRef(static_cast<SkImageFilter*>(flattenable)); 245 *r = sk_sp<SkImageFilter>(static_cast<SkImageFilter*>(flattenable));
244 } else { 246 } else {
245 r->clear(); 247 r->reset();
246 } 248 }
247 return true; 249 return true;
248 } 250 }
249 251
250 void ParamTraits<skia::RefPtr<SkImageFilter> >::Log( 252 void ParamTraits<sk_sp<SkImageFilter> >::Log(
251 const param_type& p, std::string* l) { 253 const param_type& p, std::string* l) {
252 l->append("("); 254 l->append("(");
253 LogParam(p.get() ? p->countInputs() : 0, l); 255 LogParam(p.get() ? p->countInputs() : 0, l);
254 l->append(")"); 256 l->append(")");
255 } 257 }
256 258
257 void ParamTraits<cc::RenderPass>::Write(base::Pickle* m, const param_type& p) { 259 void ParamTraits<cc::RenderPass>::Write(base::Pickle* m, const param_type& p) {
258 WriteParam(m, p.id); 260 WriteParam(m, p.id);
259 WriteParam(m, p.output_rect); 261 WriteParam(m, p.output_rect);
260 WriteParam(m, p.damage_rect); 262 WriteParam(m, p.damage_rect);
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 l->append("TextureDrawQuad::OverlayResources(["); 805 l->append("TextureDrawQuad::OverlayResources([");
804 for (size_t i = 0; i < cc::DrawQuad::Resources::kMaxResourceIdCount; ++i) { 806 for (size_t i = 0; i < cc::DrawQuad::Resources::kMaxResourceIdCount; ++i) {
805 LogParam(p.size_in_pixels[i], l); 807 LogParam(p.size_in_pixels[i], l);
806 if (i < (cc::DrawQuad::Resources::kMaxResourceIdCount - 1)) 808 if (i < (cc::DrawQuad::Resources::kMaxResourceIdCount - 1))
807 l->append(", "); 809 l->append(", ");
808 } 810 }
809 l->append("])"); 811 l->append("])");
810 } 812 }
811 813
812 } // namespace IPC 814 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698