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::CompositorLayer ------------------------------------------------------ | |
637 | |
638 // static | |
639 void ParamTraits<ppapi::CompositorLayer::Mailbox>::Write(Message* m, | |
640 const param_type& p) { | |
641 m->WriteBytes(p, sizeof(p)); | |
642 } | |
643 | |
644 // static | |
645 bool ParamTraits<ppapi::CompositorLayer::Mailbox>::Read(const Message* m, | |
646 PickleIterator* iter, | |
647 param_type* r) { | |
648 const char* data = NULL; | |
649 if (!m->ReadBytes(iter, &data, sizeof(*r))) | |
650 return false; | |
651 memcpy(r, data, sizeof(*r)); | |
652 return true; | |
653 } | |
654 | |
655 // static | |
656 void ParamTraits<ppapi::CompositorLayer::Mailbox>::Log(const param_type& p, | |
657 std::string* l) { | |
658 } | |
659 | |
660 // static | |
661 void ParamTraits<ppapi::CompositorLayer>::Write(Message* m, | |
662 const param_type& p) { | |
663 ParamTraits<ppapi::CompositorLayer::Type>::Write(m, p.type); | |
664 ParamTraits<PP_Size>::Write(m, p.size); | |
665 ParamTraits<PP_Rect>::Write(m, p.clip_rect); | |
666 for (size_t i = 0; i < arraysize(p.transform); i++) | |
667 ParamTraits<float>::Write(m, p.transform[i]); | |
668 ParamTraits<PP_BlendMode>::Write(m, p.blend_mode); | |
669 ParamTraits<uint8_t>::Write(m, p.opacity); | |
670 switch(p.type) { | |
671 case ppapi::CompositorLayer::TYPE_COLOR: | |
672 ParamTraits<uint8_t>::Write(m, p.color.red); | |
673 ParamTraits<uint8_t>::Write(m, p.color.green); | |
674 ParamTraits<uint8_t>::Write(m, p.color.blue); | |
675 ParamTraits<uint8_t>::Write(m, p.color.alpha); | |
676 break; | |
677 case ppapi::CompositorLayer::TYPE_TEXTURE: | |
678 ParamTraits<int32_t>::Write(m, p.texture.id); | |
679 ParamTraits<ppapi::CompositorLayer::Mailbox>::Write(m, p.texture.mailbox); | |
680 ParamTraits<uint32_t>::Write(m, p.texture.sync_point); | |
681 ParamTraits<PP_FloatRect>::Write(m, p.texture.source_rect); | |
682 ParamTraits<bool>::Write(m, p.texture.premult_alpha); | |
683 break; | |
684 case ppapi::CompositorLayer::TYPE_IMAGE: | |
685 ParamTraits<int32_t>::Write(m, p.image.id); | |
686 ParamTraits<PP_Instance>::Write(m, p.image.instance); | |
687 ParamTraits<PP_Resource>::Write(m, p.image.host_resource); | |
688 ParamTraits<PP_FloatRect>::Write(m, p.texture.source_rect); | |
689 break; | |
690 default: | |
691 NOTREACHED(); | |
692 }; | |
693 } | |
694 | |
695 // static | |
696 bool ParamTraits<ppapi::CompositorLayer>::Read(const Message* m, | |
697 PickleIterator* iter, | |
698 param_type* r) { | |
699 if (!ParamTraits<ppapi::CompositorLayer::Type>::Read(m, iter, &r->type)) | |
700 return false; | |
701 if (!ParamTraits<PP_Size>::Read(m, iter, &r->size)) | |
702 return false; | |
703 ParamTraits<PP_Rect>::Read(m, iter, &r->clip_rect); | |
704 for (size_t i = 0; i < arraysize(r->transform);i++) { | |
705 if (!ParamTraits<float>::Read(m, iter, &r->transform[i])) | |
706 return false; | |
707 } | |
708 if (!ParamTraits<PP_BlendMode>::Read(m, iter, &r->blend_mode)) | |
709 return false; | |
710 if (!ParamTraits<uint8_t>::Read(m, iter, &r->opacity)) | |
711 return false; | |
712 switch(r->type) { | |
713 case ppapi::CompositorLayer::TYPE_COLOR: | |
714 return | |
715 ParamTraits<uint8_t>::Read(m, iter, &r->color.red) && | |
716 ParamTraits<uint8_t>::Read(m, iter, &r->color.green) && | |
717 ParamTraits<uint8_t>::Read(m, iter, &r->color.blue) && | |
718 ParamTraits<uint8_t>::Read(m, iter, &r->color.alpha); | |
719 case ppapi::CompositorLayer::TYPE_TEXTURE: | |
720 return | |
721 ParamTraits<int32_t>::Read(m, iter, &r->texture.id) && | |
722 ParamTraits<ppapi::CompositorLayer::Mailbox>::Read( | |
723 m, iter, &r->texture.mailbox) && | |
724 ParamTraits<uint32_t>::Read(m, iter, &r->texture.sync_point) && | |
725 ParamTraits<PP_FloatRect>::Read(m, iter, &r->texture.source_rect) && | |
726 ParamTraits<bool>::Read(m, iter, &r->texture.premult_alpha); | |
727 case ppapi::CompositorLayer::TYPE_IMAGE: | |
728 return | |
729 ParamTraits<int32_t>::Read(m, iter, &r->image.id) && | |
730 ParamTraits<PP_Instance>::Read(m, iter, &r->image.instance) && | |
731 ParamTraits<PP_Resource>::Read(m, iter, &r->image.host_resource) && | |
732 ParamTraits<PP_FloatRect>::Read(m, iter, &r->texture.source_rect); | |
733 default: | |
734 NOTREACHED(); | |
raymes
2014/06/02 03:51:08
return false?
Peng
2014/06/02 19:01:55
Done.
| |
735 } | |
736 | |
737 return true; | |
738 } | |
739 | |
740 // static | |
741 void ParamTraits<ppapi::CompositorLayer>::Log(const param_type& p, | |
742 std::string* l) { | |
743 } | |
744 | |
636 } // namespace IPC | 745 } // namespace IPC |
OLD | NEW |