OLD | NEW |
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 "ppapi/proxy/ppapi_param_traits.h" | 5 #include "ppapi/proxy/ppapi_param_traits.h" |
6 | 6 |
7 #include <string.h> // For memcpy | 7 #include <string.h> // For memcpy |
8 | 8 |
9 #include "ppapi/c/pp_resource.h" | 9 #include "ppapi/c/pp_resource.h" |
10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 // No default so the compiler will warn on new types. | 626 // No default so the compiler will warn on new types. |
627 } | 627 } |
628 return false; | 628 return false; |
629 } | 629 } |
630 | 630 |
631 // static | 631 // static |
632 void ParamTraits<ppapi::SocketOptionData>::Log(const param_type& p, | 632 void ParamTraits<ppapi::SocketOptionData>::Log(const param_type& p, |
633 std::string* l) { | 633 std::string* l) { |
634 } | 634 } |
635 | 635 |
| 636 // ppapi::CompositorLayerData -------------------------------------------------- |
| 637 |
| 638 // static |
| 639 void ParamTraits<ppapi::CompositorLayerData::Mailbox>::Write( |
| 640 Message* m, |
| 641 const param_type& p) { |
| 642 m->WriteBytes(p, sizeof(p)); |
| 643 } |
| 644 |
| 645 // static |
| 646 bool ParamTraits<ppapi::CompositorLayerData::Mailbox>::Read( |
| 647 const Message* m, |
| 648 PickleIterator* iter, |
| 649 param_type* r) { |
| 650 const char* data = NULL; |
| 651 if (!m->ReadBytes(iter, &data, sizeof(*r))) |
| 652 return false; |
| 653 memcpy(r, data, sizeof(*r)); |
| 654 return true; |
| 655 } |
| 656 |
| 657 // static |
| 658 void ParamTraits<ppapi::CompositorLayerData::Mailbox>::Log( |
| 659 const param_type& p, |
| 660 std::string* l) { |
| 661 } |
| 662 |
| 663 // static |
| 664 void ParamTraits<ppapi::CompositorLayerData>::Write( |
| 665 Message* m, |
| 666 const param_type& p) { |
| 667 ParamTraits<ppapi::CompositorLayerData::Type>::Write(m, p.type); |
| 668 ParamTraits<PP_Size>::Write(m, p.size); |
| 669 ParamTraits<PP_Rect>::Write(m, p.clip_rect); |
| 670 for (size_t i = 0; i < arraysize(p.transform); i++) |
| 671 ParamTraits<float>::Write(m, p.transform[i]); |
| 672 ParamTraits<PP_BlendMode>::Write(m, p.blend_mode); |
| 673 ParamTraits<float>::Write(m, p.opacity); |
| 674 ParamTraits<int32_t>::Write(m, p.resource_id); |
| 675 switch(p.type) { |
| 676 case ppapi::CompositorLayerData::TYPE_COLOR: |
| 677 ParamTraits<float>::Write(m, p.color.red); |
| 678 ParamTraits<float>::Write(m, p.color.green); |
| 679 ParamTraits<float>::Write(m, p.color.blue); |
| 680 ParamTraits<float>::Write(m, p.color.alpha); |
| 681 break; |
| 682 case ppapi::CompositorLayerData::TYPE_TEXTURE: |
| 683 ParamTraits<ppapi::CompositorLayerData::Mailbox>::Write( |
| 684 m, p.texture.mailbox); |
| 685 ParamTraits<uint32_t>::Write(m, p.texture.sync_point); |
| 686 ParamTraits<PP_FloatRect>::Write(m, p.texture.source_rect); |
| 687 ParamTraits<bool>::Write(m, p.texture.premult_alpha); |
| 688 break; |
| 689 case ppapi::CompositorLayerData::TYPE_IMAGE: |
| 690 ParamTraits<PP_Instance>::Write(m, p.image.instance); |
| 691 ParamTraits<PP_Resource>::Write(m, p.image.host_resource); |
| 692 ParamTraits<PP_FloatRect>::Write(m, p.texture.source_rect); |
| 693 break; |
| 694 default: |
| 695 NOTREACHED(); |
| 696 }; |
| 697 } |
| 698 |
| 699 // static |
| 700 bool ParamTraits<ppapi::CompositorLayerData>::Read(const Message* m, |
| 701 PickleIterator* iter, |
| 702 param_type* r) { |
| 703 if (!ParamTraits<ppapi::CompositorLayerData::Type>::Read(m, iter, &r->type)) |
| 704 return false; |
| 705 if (!ParamTraits<PP_Size>::Read(m, iter, &r->size)) |
| 706 return false; |
| 707 ParamTraits<PP_Rect>::Read(m, iter, &r->clip_rect); |
| 708 for (size_t i = 0; i < arraysize(r->transform);i++) { |
| 709 if (!ParamTraits<float>::Read(m, iter, &r->transform[i])) |
| 710 return false; |
| 711 } |
| 712 if (!ParamTraits<PP_BlendMode>::Read(m, iter, &r->blend_mode)) |
| 713 return false; |
| 714 if (!ParamTraits<float>::Read(m, iter, &r->opacity)) |
| 715 return false; |
| 716 if (!ParamTraits<int32_t>::Read(m, iter, &r->resource_id)) |
| 717 return false; |
| 718 switch(r->type) { |
| 719 case ppapi::CompositorLayerData::TYPE_COLOR: |
| 720 return |
| 721 ParamTraits<float>::Read(m, iter, &r->color.red) && |
| 722 ParamTraits<float>::Read(m, iter, &r->color.green) && |
| 723 ParamTraits<float>::Read(m, iter, &r->color.blue) && |
| 724 ParamTraits<float>::Read(m, iter, &r->color.alpha); |
| 725 case ppapi::CompositorLayerData::TYPE_TEXTURE: |
| 726 return |
| 727 ParamTraits<ppapi::CompositorLayerData::Mailbox>::Read( |
| 728 m, iter, &r->texture.mailbox) && |
| 729 ParamTraits<uint32_t>::Read(m, iter, &r->texture.sync_point) && |
| 730 ParamTraits<PP_FloatRect>::Read(m, iter, &r->texture.source_rect) && |
| 731 ParamTraits<bool>::Read(m, iter, &r->texture.premult_alpha); |
| 732 case ppapi::CompositorLayerData::TYPE_IMAGE: |
| 733 return |
| 734 ParamTraits<PP_Instance>::Read(m, iter, &r->image.instance) && |
| 735 ParamTraits<PP_Resource>::Read(m, iter, &r->image.host_resource) && |
| 736 ParamTraits<PP_FloatRect>::Read(m, iter, &r->texture.source_rect); |
| 737 default: |
| 738 return false; |
| 739 } |
| 740 |
| 741 return true; |
| 742 } |
| 743 |
| 744 // static |
| 745 void ParamTraits<ppapi::CompositorLayerData>::Log(const param_type& p, |
| 746 std::string* l) { |
| 747 } |
| 748 |
636 } // namespace IPC | 749 } // namespace IPC |
OLD | NEW |