Chromium Code Reviews| 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<uint8_t>::Write(m, p.opacity); | |
| 674 switch(p.type) { | |
| 675 case ppapi::CompositorLayerData::TYPE_COLOR: | |
| 676 ParamTraits<uint8_t>::Write(m, p.color.red); | |
| 677 ParamTraits<uint8_t>::Write(m, p.color.green); | |
| 678 ParamTraits<uint8_t>::Write(m, p.color.blue); | |
| 679 ParamTraits<uint8_t>::Write(m, p.color.alpha); | |
| 680 break; | |
| 681 case ppapi::CompositorLayerData::TYPE_TEXTURE: | |
| 682 ParamTraits<int32_t>::Write(m, p.texture.id); | |
| 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<int32_t>::Write(m, p.image.id); | |
| 691 ParamTraits<PP_Instance>::Write(m, p.image.instance); | |
| 692 ParamTraits<PP_Resource>::Write(m, p.image.host_resource); | |
| 693 ParamTraits<PP_FloatRect>::Write(m, p.texture.source_rect); | |
| 694 break; | |
| 695 default: | |
| 696 NOTREACHED(); | |
| 697 }; | |
| 698 } | |
| 699 | |
| 700 // static | |
| 701 bool ParamTraits<ppapi::CompositorLayerData>::Read(const Message* m, | |
| 702 PickleIterator* iter, | |
| 703 param_type* r) { | |
| 704 if (!ParamTraits<ppapi::CompositorLayerData::Type>::Read(m, iter, &r->type)) | |
| 705 return false; | |
| 706 if (!ParamTraits<PP_Size>::Read(m, iter, &r->size)) | |
| 707 return false; | |
| 708 ParamTraits<PP_Rect>::Read(m, iter, &r->clip_rect); | |
| 709 for (size_t i = 0; i < arraysize(r->transform);i++) { | |
| 710 if (!ParamTraits<float>::Read(m, iter, &r->transform[i])) | |
| 711 return false; | |
| 712 } | |
| 713 if (!ParamTraits<PP_BlendMode>::Read(m, iter, &r->blend_mode)) | |
| 714 return false; | |
| 715 if (!ParamTraits<uint8_t>::Read(m, iter, &r->opacity)) | |
| 716 return false; | |
| 717 switch(r->type) { | |
| 718 case ppapi::CompositorLayerData::TYPE_COLOR: | |
| 719 return | |
| 720 ParamTraits<uint8_t>::Read(m, iter, &r->color.red) && | |
| 721 ParamTraits<uint8_t>::Read(m, iter, &r->color.green) && | |
| 722 ParamTraits<uint8_t>::Read(m, iter, &r->color.blue) && | |
| 723 ParamTraits<uint8_t>::Read(m, iter, &r->color.alpha); | |
| 724 case ppapi::CompositorLayerData::TYPE_TEXTURE: | |
| 725 return | |
| 726 ParamTraits<int32_t>::Read(m, iter, &r->texture.id) && | |
| 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<int32_t>::Read(m, iter, &r->image.id) && | |
| 735 ParamTraits<PP_Instance>::Read(m, iter, &r->image.instance) && | |
| 736 ParamTraits<PP_Resource>::Read(m, iter, &r->image.host_resource) && | |
| 737 ParamTraits<PP_FloatRect>::Read(m, iter, &r->texture.source_rect); | |
| 738 default: | |
| 739 return false;; | |
|
raymes
2014/06/03 00:43:22
nit: extra ;
Peng
2014/06/03 18:32:24
Done.
| |
| 740 } | |
| 741 | |
| 742 return true; | |
| 743 } | |
| 744 | |
| 745 // static | |
| 746 void ParamTraits<ppapi::CompositorLayerData>::Log(const param_type& p, | |
| 747 std::string* l) { | |
| 748 } | |
| 749 | |
| 636 } // namespace IPC | 750 } // namespace IPC |
| OLD | NEW |