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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 } | 341 } |
341 | 342 |
342 void ParamTraits<gfx::ScrollOffset>::Log(const param_type& p, std::string* l) { | 343 void ParamTraits<gfx::ScrollOffset>::Log(const param_type& p, std::string* l) { |
343 l->append("("); | 344 l->append("("); |
344 LogParam(p.x(), l); | 345 LogParam(p.x(), l); |
345 l->append(", "); | 346 l->append(", "); |
346 LogParam(p.y(), l); | 347 LogParam(p.y(), l); |
347 l->append(")"); | 348 l->append(")"); |
348 } | 349 } |
349 | 350 |
| 351 void ParamTraits<gfx::Transform>::Write(base::Pickle* m, const param_type& p) { |
| 352 #ifdef SK_MSCALAR_IS_FLOAT |
| 353 float column_major_data[16]; |
| 354 p.matrix().asColMajorf(column_major_data); |
| 355 #else |
| 356 double column_major_data[16]; |
| 357 p.matrix().asColMajord(column_major_data); |
| 358 #endif |
| 359 m->WriteBytes(&column_major_data, sizeof(SkMScalar) * 16); |
| 360 } |
| 361 |
| 362 bool ParamTraits<gfx::Transform>::Read(const base::Pickle* m, |
| 363 base::PickleIterator* iter, |
| 364 param_type* r) { |
| 365 const char* column_major_data; |
| 366 if (!iter->ReadBytes(&column_major_data, sizeof(SkMScalar) * 16)) |
| 367 return false; |
| 368 r->matrix().setColMajor( |
| 369 reinterpret_cast<const SkMScalar*>(column_major_data)); |
| 370 return true; |
| 371 } |
| 372 |
| 373 void ParamTraits<gfx::Transform>::Log( |
| 374 const param_type& p, std::string* l) { |
| 375 #ifdef SK_MSCALAR_IS_FLOAT |
| 376 float row_major_data[16]; |
| 377 p.matrix().asRowMajorf(row_major_data); |
| 378 #else |
| 379 double row_major_data[16]; |
| 380 p.matrix().asRowMajord(row_major_data); |
| 381 #endif |
| 382 l->append("("); |
| 383 for (int i = 0; i < 16; ++i) { |
| 384 if (i > 0) |
| 385 l->append(", "); |
| 386 LogParam(row_major_data[i], l); |
| 387 } |
| 388 l->append(") "); |
| 389 } |
| 390 |
350 #if defined(OS_MACOSX) && !defined(OS_IOS) | 391 #if defined(OS_MACOSX) && !defined(OS_IOS) |
351 void ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Write( | 392 void ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Write( |
352 base::Pickle* m, | 393 base::Pickle* m, |
353 const param_type p) { | 394 const param_type p) { |
354 MachPortMac mach_port_mac(p.get()); | 395 MachPortMac mach_port_mac(p.get()); |
355 ParamTraits<MachPortMac>::Write(m, mach_port_mac); | 396 ParamTraits<MachPortMac>::Write(m, mach_port_mac); |
356 } | 397 } |
357 | 398 |
358 bool ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Read( | 399 bool ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort>::Read( |
359 const base::Pickle* m, | 400 const base::Pickle* m, |
(...skipping 29 matching lines...) Expand all Loading... |
389 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ | 430 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ |
390 #include "ui/gfx/ipc/gfx_param_traits_macros.h" | 431 #include "ui/gfx/ipc/gfx_param_traits_macros.h" |
391 } // namespace IPC | 432 } // namespace IPC |
392 | 433 |
393 // Generate param traits log methods. | 434 // Generate param traits log methods. |
394 #include "ipc/param_traits_log_macros.h" | 435 #include "ipc/param_traits_log_macros.h" |
395 namespace IPC { | 436 namespace IPC { |
396 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ | 437 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ |
397 #include "ui/gfx/ipc/gfx_param_traits_macros.h" | 438 #include "ui/gfx/ipc/gfx_param_traits_macros.h" |
398 } // namespace IPC | 439 } // namespace IPC |
OLD | NEW |