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

Side by Side Diff: ui/gfx/ipc/gfx_param_traits.cc

Issue 1648533002: [mojo] Get rid of Skia type converters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@native-arrays
Patch Set: fix ios gyp; proper pickle sizing Created 4 years, 10 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 "ui/gfx/ipc/gfx_param_traits.h" 5 #include "ui/gfx/ipc/gfx_param_traits.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 const float* values = reinterpret_cast<const float*>(char_values); 249 const float* values = reinterpret_cast<const float*>(char_values);
250 r->SetRect(values[0], values[1], values[2], values[3]); 250 r->SetRect(values[0], values[1], values[2], values[3]);
251 return true; 251 return true;
252 } 252 }
253 253
254 void ParamTraits<gfx::RectF>::Log(const gfx::RectF& p, std::string* l) { 254 void ParamTraits<gfx::RectF>::Log(const gfx::RectF& p, std::string* l) {
255 l->append(base::StringPrintf("(%f, %f, %f, %f)", p.x(), p.y(), 255 l->append(base::StringPrintf("(%f, %f, %f, %f)", p.x(), p.y(),
256 p.width(), p.height())); 256 p.width(), p.height()));
257 } 257 }
258 258
259 void ParamTraits<SkBitmap>::Write(Message* m, const SkBitmap& p) { 259 size_t ParamTraits<SkBitmap>::GetSize(const SkBitmap& p) {
Ken Rockot(use gerrit already) 2016/02/01 17:57:01 NOTE to tsepez@: Defining a GetSize() trait is a p
Tom Sepez 2016/02/01 18:31:58 I prefer the first approach, I wouldn't be fond of
260 return sizeof(int32_t) * 2 + sizeof(SkBitmap_Data) + p.getSize();
jam 2016/02/01 17:53:48 I'd expect this to match the Write method below, w
261 }
262
263 void ParamTraits<SkBitmap>::Write(base::Pickle* m, const SkBitmap& p) {
260 size_t fixed_size = sizeof(SkBitmap_Data); 264 size_t fixed_size = sizeof(SkBitmap_Data);
261 SkBitmap_Data bmp_data; 265 SkBitmap_Data bmp_data;
262 bmp_data.InitSkBitmapDataForTransfer(p); 266 bmp_data.InitSkBitmapDataForTransfer(p);
263 m->WriteData(reinterpret_cast<const char*>(&bmp_data), 267 m->WriteData(reinterpret_cast<const char*>(&bmp_data),
264 static_cast<int>(fixed_size)); 268 static_cast<int>(fixed_size));
265 size_t pixel_size = p.getSize(); 269 size_t pixel_size = p.getSize();
266 SkAutoLockPixels p_lock(p); 270 SkAutoLockPixels p_lock(p);
267 m->WriteData(reinterpret_cast<const char*>(p.getPixels()), 271 m->WriteData(reinterpret_cast<const char*>(p.getPixels()),
268 static_cast<int>(pixel_size)); 272 static_cast<int>(pixel_size));
269 } 273 }
270 274
271 bool ParamTraits<SkBitmap>::Read(const Message* m, 275 bool ParamTraits<SkBitmap>::Read(const base::Pickle* m,
272 base::PickleIterator* iter, 276 base::PickleIterator* iter,
273 SkBitmap* r) { 277 SkBitmap* r) {
274 const char* fixed_data; 278 const char* fixed_data;
275 int fixed_data_size = 0; 279 int fixed_data_size = 0;
276 if (!iter->ReadData(&fixed_data, &fixed_data_size) || 280 if (!iter->ReadData(&fixed_data, &fixed_data_size) ||
277 (fixed_data_size <= 0)) { 281 (fixed_data_size <= 0)) {
278 NOTREACHED(); 282 NOTREACHED();
279 return false; 283 return false;
280 } 284 }
281 if (fixed_data_size != sizeof(SkBitmap_Data)) 285 if (fixed_data_size != sizeof(SkBitmap_Data))
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ 390 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_
387 #include "ui/gfx/ipc/gfx_param_traits_macros.h" 391 #include "ui/gfx/ipc/gfx_param_traits_macros.h"
388 } // namespace IPC 392 } // namespace IPC
389 393
390 // Generate param traits log methods. 394 // Generate param traits log methods.
391 #include "ipc/param_traits_log_macros.h" 395 #include "ipc/param_traits_log_macros.h"
392 namespace IPC { 396 namespace IPC {
393 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ 397 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_
394 #include "ui/gfx/ipc/gfx_param_traits_macros.h" 398 #include "ui/gfx/ipc/gfx_param_traits_macros.h"
395 } // namespace IPC 399 } // namespace IPC
OLDNEW
« skia/public/interfaces/bitmap.mojom ('K') | « ui/gfx/ipc/gfx_param_traits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698