Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: content/common/cc_messages.cc

Issue 11316128: Send compositor frame IPC with metadata. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix compile errors on mac/win Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/common/cc_messages.h ('k') | content/common/cc_messages_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/common/cc_messages.h" 5 #include "content/common/cc_messages.h"
6 6
7 #include "cc/compositor_frame.h" 7 #include "cc/compositor_frame.h"
8 #include "content/public/common/common_param_traits.h" 8 #include "content/public/common/common_param_traits.h"
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebData.h" 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebData.h"
10 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations .h" 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations .h"
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 DCHECK(bytes); 562 DCHECK(bytes);
563 memcpy(p->name, bytes, sizeof(p->name)); 563 memcpy(p->name, bytes, sizeof(p->name));
564 return true; 564 return true;
565 } 565 }
566 566
567 void ParamTraits<cc::Mailbox>::Log(const param_type& p, std::string* l) { 567 void ParamTraits<cc::Mailbox>::Log(const param_type& p, std::string* l) {
568 for (size_t i = 0; i < sizeof(p.name); ++i) 568 for (size_t i = 0; i < sizeof(p.name); ++i)
569 *l += base::StringPrintf("%02x", p.name[i]); 569 *l += base::StringPrintf("%02x", p.name[i]);
570 } 570 }
571 571
572 void ParamTraits<cc::CompositorFrame>::Write(Message* m, const param_type& p) { 572 namespace {
573 enum CompositorFrameType {
574 DELEGATED_FRAME,
575 GL_FRAME,
576 };
577 }
578
579 void ParamTraits<cc::CompositorFrame>::Write(Message* m,
580 const param_type& p) {
581 WriteParam(m, p.metadata);
582 if (p.delegated_frame_data) {
583 DCHECK(!p.gl_frame_data);
584 WriteParam(m, static_cast<int>(DELEGATED_FRAME));
585 WriteParam(m, *p.delegated_frame_data);
586 } else {
587 DCHECK(p.gl_frame_data);
588 WriteParam(m, static_cast<int>(GL_FRAME));
589 WriteParam(m, *p.gl_frame_data);
590 }
591 }
592
593 bool ParamTraits<cc::CompositorFrame>::Read(const Message* m,
594 PickleIterator* iter,
595 param_type* p) {
596 if (!ReadParam(m, iter, &p->metadata))
597 return false;
598
599 int compositor_frame_type;
600 if (!ReadParam(m, iter, &compositor_frame_type))
601 return false;
602
603 switch (compositor_frame_type) {
604 case DELEGATED_FRAME:
605 p->delegated_frame_data.reset(new cc::DelegatedFrameData());
606 if (!ReadParam(m, iter, p->delegated_frame_data.get()))
607 return false;
608 break;
609 case GL_FRAME:
610 p->gl_frame_data.reset(new cc::GLFrameData());
611 if (!ReadParam(m, iter, p->gl_frame_data.get()))
612 return false;
613 break;
614 default:
615 return false;
616 }
617 return true;
618 }
619
620 void ParamTraits<cc::CompositorFrame>::Log(const param_type& p,
621 std::string* l) {
622 l->append("CompositorFrame(");
623 LogParam(p.metadata, l);
624 l->append(", ");
625 if (p.delegated_frame_data)
626 LogParam(*p.delegated_frame_data, l);
627 else if (p.gl_frame_data)
628 LogParam(*p.gl_frame_data, l);
629 l->append(")");
630 }
631
632 void ParamTraits<cc::DelegatedFrameData>::Write(Message* m,
633 const param_type& p) {
573 WriteParam(m, p.size); 634 WriteParam(m, p.size);
574 WriteParam(m, p.resource_list); 635 WriteParam(m, p.resource_list);
575 WriteParam(m, p.render_pass_list.size()); 636 WriteParam(m, p.render_pass_list.size());
576 for (size_t i = 0; i < p.render_pass_list.size(); ++i) 637 for (size_t i = 0; i < p.render_pass_list.size(); ++i)
577 WriteParam(m, *p.render_pass_list[i]); 638 WriteParam(m, *p.render_pass_list[i]);
578 } 639 }
579 640
580 bool ParamTraits<cc::CompositorFrame>::Read(const Message* m, 641 bool ParamTraits<cc::DelegatedFrameData>::Read(const Message* m,
581 PickleIterator* iter, 642 PickleIterator* iter,
582 param_type* p) { 643 param_type* p) {
583 const static size_t kMaxRenderPasses = 10000; 644 const static size_t kMaxRenderPasses = 10000;
584 645
585 size_t num_render_passes; 646 size_t num_render_passes;
586 if (!ReadParam(m, iter, &p->size) || 647 if (!ReadParam(m, iter, &p->size) ||
587 !ReadParam(m, iter, &p->resource_list) || 648 !ReadParam(m, iter, &p->resource_list) ||
588 !ReadParam(m, iter, &num_render_passes) || 649 !ReadParam(m, iter, &num_render_passes) ||
589 num_render_passes > kMaxRenderPasses) 650 num_render_passes > kMaxRenderPasses)
590 return false; 651 return false;
591 for (size_t i = 0; i < num_render_passes; ++i) { 652 for (size_t i = 0; i < num_render_passes; ++i) {
592 scoped_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); 653 scoped_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create();
593 if (!ReadParam(m, iter, render_pass.get())) 654 if (!ReadParam(m, iter, render_pass.get()))
594 return false; 655 return false;
595 p->render_pass_list.append(render_pass.Pass()); 656 p->render_pass_list.append(render_pass.Pass());
596 } 657 }
597 return true; 658 return true;
598 } 659 }
599 660
600 void ParamTraits<cc::CompositorFrame>::Log(const param_type& p, 661 void ParamTraits<cc::DelegatedFrameData>::Log(const param_type& p,
601 std::string* l) { 662 std::string* l) {
602 l->append("CompositorFrame("); 663 l->append("DelegatedFrameData(");
603 LogParam(p.size, l); 664 LogParam(p.size, l);
604 l->append(", "); 665 l->append(", ");
605 LogParam(p.resource_list, l); 666 LogParam(p.resource_list, l);
606 l->append(", ["); 667 l->append(", [");
607 for (size_t i = 0; i < p.render_pass_list.size(); ++i) { 668 for (size_t i = 0; i < p.render_pass_list.size(); ++i) {
608 if (i) 669 if (i)
609 l->append(", "); 670 l->append(", ");
610 LogParam(*p.render_pass_list[i], l); 671 LogParam(*p.render_pass_list[i], l);
611 } 672 }
612 l->append("])"); 673 l->append("])");
613 } 674 }
614 675
615 } // namespace IPC 676 } // namespace IPC
OLDNEW
« no previous file with comments | « content/common/cc_messages.h ('k') | content/common/cc_messages_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698