OLD | NEW |
---|---|
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> |
11 | 11 |
12 #include "third_party/skia/include/core/SkBitmap.h" | 12 #include "third_party/skia/include/core/SkBitmap.h" |
13 #include "ui/gfx/geometry/point3_f.h" | 13 #include "ui/gfx/geometry/point3_f.h" |
14 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
15 #include "ui/gfx/geometry/rect_f.h" | 15 #include "ui/gfx/geometry/rect_f.h" |
16 #include "ui/gfx/geometry/scroll_offset.h" | 16 #include "ui/gfx/geometry/scroll_offset.h" |
17 #include "ui/gfx/range/range.h" | 17 #include "ui/gfx/range/range.h" |
18 #include "ui/gfx/transform.h" | |
18 | 19 |
19 #if defined(OS_MACOSX) | 20 #if defined(OS_MACOSX) |
20 #include "ipc/mach_port_mac.h" | 21 #include "ipc/mach_port_mac.h" |
21 #endif | 22 #endif |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 struct SkBitmap_Data { | 26 struct SkBitmap_Data { |
26 // The color type for the bitmap (bits per pixel, etc). | 27 // The color type for the bitmap (bits per pixel, etc). |
27 SkColorType fColorType; | 28 SkColorType fColorType; |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 } | 357 } |
357 | 358 |
358 void ParamTraits<gfx::ScrollOffset>::Log(const param_type& p, std::string* l) { | 359 void ParamTraits<gfx::ScrollOffset>::Log(const param_type& p, std::string* l) { |
359 l->append("("); | 360 l->append("("); |
360 LogParam(p.x(), l); | 361 LogParam(p.x(), l); |
361 l->append(", "); | 362 l->append(", "); |
362 LogParam(p.y(), l); | 363 LogParam(p.y(), l); |
363 l->append(")"); | 364 l->append(")"); |
364 } | 365 } |
365 | 366 |
367 void ParamTraits<gfx::Transform>::Write(base::Pickle* m, const param_type& p) { | |
368 #ifdef SK_MSCALAR_IS_FLOAT | |
369 float column_major_data[16]; | |
370 p.matrix().asColMajorf(column_major_data); | |
371 #else | |
372 double column_major_data[16]; | |
373 p.matrix().asColMajord(column_major_data); | |
374 #endif | |
375 m->WriteBytes(&column_major_data, sizeof(SkMScalar) * 16); | |
dcheng
2016/03/08 00:39:42
I know you're just moving this, but mind adding a
dmazzoni
2016/03/16 21:38:14
Done.
| |
376 } | |
377 | |
378 bool ParamTraits<gfx::Transform>::Read(const base::Pickle* m, | |
379 base::PickleIterator* iter, | |
380 param_type* r) { | |
381 const char* column_major_data; | |
382 if (!iter->ReadBytes(&column_major_data, sizeof(SkMScalar) * 16)) | |
383 return false; | |
384 r->matrix().setColMajor( | |
385 reinterpret_cast<const SkMScalar*>(column_major_data)); | |
386 return true; | |
387 } | |
388 | |
389 void ParamTraits<gfx::Transform>::Log( | |
390 const param_type& p, std::string* l) { | |
391 #ifdef SK_MSCALAR_IS_FLOAT | |
392 float row_major_data[16]; | |
393 p.matrix().asRowMajorf(row_major_data); | |
394 #else | |
395 double row_major_data[16]; | |
396 p.matrix().asRowMajord(row_major_data); | |
397 #endif | |
398 l->append("("); | |
399 for (int i = 0; i < 16; ++i) { | |
400 if (i > 0) | |
401 l->append(", "); | |
402 LogParam(row_major_data[i], l); | |
403 } | |
404 l->append(") "); | |
405 } | |
406 | |
366 #if defined(OS_MACOSX) && !defined(OS_IOS) | 407 #if defined(OS_MACOSX) && !defined(OS_IOS) |
367 void ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Write( | 408 void ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Write( |
368 base::Pickle* m, | 409 base::Pickle* m, |
369 const param_type p) { | 410 const param_type p) { |
370 MachPortMac mach_port_mac(p.get()); | 411 MachPortMac mach_port_mac(p.get()); |
371 ParamTraits<MachPortMac>::Write(m, mach_port_mac); | 412 ParamTraits<MachPortMac>::Write(m, mach_port_mac); |
372 } | 413 } |
373 | 414 |
374 bool ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Read( | 415 bool ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Read( |
375 const base::Pickle* m, | 416 const base::Pickle* m, |
(...skipping 29 matching lines...) Expand all Loading... | |
405 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ | 446 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ |
406 #include "ui/gfx/ipc/gfx_param_traits_macros.h" | 447 #include "ui/gfx/ipc/gfx_param_traits_macros.h" |
407 } // namespace IPC | 448 } // namespace IPC |
408 | 449 |
409 // Generate param traits log methods. | 450 // Generate param traits log methods. |
410 #include "ipc/param_traits_log_macros.h" | 451 #include "ipc/param_traits_log_macros.h" |
411 namespace IPC { | 452 namespace IPC { |
412 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ | 453 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ |
413 #include "ui/gfx/ipc/gfx_param_traits_macros.h" | 454 #include "ui/gfx/ipc/gfx_param_traits_macros.h" |
414 } // namespace IPC | 455 } // namespace IPC |
OLD | NEW |