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

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

Issue 35893002: IPC pickling optimization for render passes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ccmessagesperf-reserve: fixbuild Created 7 years, 2 months 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 | Annotate | Revision Log
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/output/filter_operations.h" 9 #include "cc/output/filter_operations.h"
10 #include "content/public/common/common_param_traits.h" 10 #include "content/public/common/common_param_traits.h"
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 if (shared_quad_state_index >= sqs_list.size()) { 362 if (shared_quad_state_index >= sqs_list.size()) {
363 WriteParam(m, bad_index); 363 WriteParam(m, bad_index);
364 continue; 364 continue;
365 } 365 }
366 366
367 DCHECK_LT(shared_quad_state_index, p.shared_quad_state_list.size()); 367 DCHECK_LT(shared_quad_state_index, p.shared_quad_state_list.size());
368 WriteParam(m, shared_quad_state_index); 368 WriteParam(m, shared_quad_state_index);
369 } 369 }
370 } 370 }
371 371
372 static size_t ReserveSizeForRenderPassWrite(const cc::RenderPass& p) {
373 size_t to_reserve = sizeof(cc::RenderPass);
374
375 to_reserve += p.shared_quad_state_list.size() * sizeof(cc::SharedQuadState);
376
377 // The shared_quad_state_index for each quad.
378 to_reserve += p.quad_list.size() * sizeof(size_t);
379
380 // The largest quad type, verified by a unit test.
381 to_reserve += p.quad_list.size() * sizeof(cc::RenderPassDrawQuad);
382 return to_reserve;
383 }
384
372 template<typename QuadType> 385 template<typename QuadType>
373 static scoped_ptr<cc::DrawQuad> ReadDrawQuad(const Message* m, 386 static scoped_ptr<cc::DrawQuad> ReadDrawQuad(const Message* m,
374 PickleIterator* iter) { 387 PickleIterator* iter) {
375 scoped_ptr<QuadType> quad = QuadType::Create(); 388 scoped_ptr<QuadType> quad = QuadType::Create();
376 if (!ReadParam(m, iter, quad.get())) 389 if (!ReadParam(m, iter, quad.get()))
377 return scoped_ptr<QuadType>().template PassAs<cc::DrawQuad>(); 390 return scoped_ptr<QuadType>().template PassAs<cc::DrawQuad>();
378 return quad.template PassAs<cc::DrawQuad>(); 391 return quad.template PassAs<cc::DrawQuad>();
379 } 392 }
380 393
381 bool ParamTraits<cc::RenderPass>::Read( 394 bool ParamTraits<cc::RenderPass>::Read(
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 LogParam(p.last_software_frame_id, l); 686 LogParam(p.last_software_frame_id, l);
674 l->append(", "); 687 l->append(", ");
675 if (p.gl_frame_data) 688 if (p.gl_frame_data)
676 LogParam(*p.gl_frame_data, l); 689 LogParam(*p.gl_frame_data, l);
677 l->append(")"); 690 l->append(")");
678 } 691 }
679 692
680 void ParamTraits<cc::DelegatedFrameData>::Write(Message* m, 693 void ParamTraits<cc::DelegatedFrameData>::Write(Message* m,
681 const param_type& p) { 694 const param_type& p) {
682 DCHECK_NE(0u, p.render_pass_list.size()); 695 DCHECK_NE(0u, p.render_pass_list.size());
696
697 size_t to_reserve = p.resource_list.size() * sizeof(cc::TransferableResource);
698 for (size_t i = 0; i < p.render_pass_list.size(); ++i) {
699 const cc::RenderPass* pass = p.render_pass_list[i];
700 to_reserve += ReserveSizeForRenderPassWrite(*pass);
701 }
702 m->Reserve(to_reserve);
703
683 WriteParam(m, p.resource_list); 704 WriteParam(m, p.resource_list);
684 WriteParam(m, p.render_pass_list.size()); 705 WriteParam(m, p.render_pass_list.size());
685 for (size_t i = 0; i < p.render_pass_list.size(); ++i) 706 for (size_t i = 0; i < p.render_pass_list.size(); ++i)
686 WriteParam(m, *p.render_pass_list[i]); 707 WriteParam(m, *p.render_pass_list[i]);
687 } 708 }
688 709
689 bool ParamTraits<cc::DelegatedFrameData>::Read(const Message* m, 710 bool ParamTraits<cc::DelegatedFrameData>::Read(const Message* m,
690 PickleIterator* iter, 711 PickleIterator* iter,
691 param_type* p) { 712 param_type* p) {
692 const static size_t kMaxRenderPasses = 10000; 713 const static size_t kMaxRenderPasses = 10000;
(...skipping 19 matching lines...) Expand all
712 l->append(", ["); 733 l->append(", [");
713 for (size_t i = 0; i < p.render_pass_list.size(); ++i) { 734 for (size_t i = 0; i < p.render_pass_list.size(); ++i) {
714 if (i) 735 if (i)
715 l->append(", "); 736 l->append(", ");
716 LogParam(*p.render_pass_list[i], l); 737 LogParam(*p.render_pass_list[i], l);
717 } 738 }
718 l->append("])"); 739 l->append("])");
719 } 740 }
720 741
721 } // namespace IPC 742 } // namespace IPC
OLDNEW
« base/pickle.cc ('K') | « base/pickle.cc ('k') | content/common/cc_messages_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698