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

Unified Diff: content/common/cc_messages.cc

Issue 551013002: Use Custome ListContainer to Allocate SharedQuadState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@DQAllo
Patch Set: use ElementAt for unittest Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/common/cc_messages.cc
diff --git a/content/common/cc_messages.cc b/content/common/cc_messages.cc
index b1c34be339a5ccb402dc99231479a5947c17743f..28e32535a4a5c0b0879b2c81dbb3aa08aa8b53e7 100644
--- a/content/common/cc_messages.cc
+++ b/content/common/cc_messages.cc
@@ -294,11 +294,12 @@ void ParamTraits<cc::RenderPass>::Write(
WriteParam(m, p.damage_rect);
WriteParam(m, p.transform_to_root_target);
WriteParam(m, p.has_transparent_background);
- WriteParam(m, p.shared_quad_state_list.size());
WriteParam(m, p.quad_list.size());
- size_t shared_quad_state_index = 0;
- size_t last_shared_quad_state_index = kuint32max;
+ cc::SharedQuadStateList::ConstIterator shared_quad_state_index =
danakj 2014/09/26 20:40:55 this isn't an index, it's an iterator, so let's na
weiliangc 2014/10/01 23:02:00 Done.
+ p.shared_quad_state_list.begin();
+ cc::SharedQuadStateList::ConstIterator last_shared_quad_state_index =
danakj 2014/09/26 20:40:55 same
weiliangc 2014/10/01 23:02:00 Done.
+ p.shared_quad_state_list.end();
for (cc::QuadList::ConstIterator iter = p.quad_list.begin();
iter != p.quad_list.end();
++iter) {
@@ -349,35 +350,23 @@ void ParamTraits<cc::RenderPass>::Write(
break;
}
- const cc::ScopedPtrVector<cc::SharedQuadState>& sqs_list =
- p.shared_quad_state_list;
-
- // This is an invalid index.
- size_t bad_index = sqs_list.size();
-
// Null shared quad states should not occur.
DCHECK(quad->shared_quad_state);
- if (!quad->shared_quad_state) {
- WriteParam(m, bad_index);
- continue;
- }
// SharedQuadStates should appear in the order they are used by DrawQuads.
// Find the SharedQuadState for this DrawQuad.
- while (shared_quad_state_index < sqs_list.size() &&
- quad->shared_quad_state != sqs_list[shared_quad_state_index])
+ while (shared_quad_state_index != p.shared_quad_state_list.end() &&
+ quad->shared_quad_state != &(*shared_quad_state_index))
danakj 2014/09/26 20:40:55 &*?
weiliangc 2014/10/01 23:02:00 Done.
++shared_quad_state_index;
- DCHECK_LT(shared_quad_state_index, sqs_list.size());
- if (shared_quad_state_index >= sqs_list.size()) {
- WriteParam(m, bad_index);
- continue;
- }
+ DCHECK(shared_quad_state_index != p.shared_quad_state_list.end());
- WriteParam(m, shared_quad_state_index);
if (shared_quad_state_index != last_shared_quad_state_index) {
- WriteParam(m, *sqs_list[shared_quad_state_index]);
+ WriteParam(m, true);
+ WriteParam(m, *shared_quad_state_index);
last_shared_quad_state_index = shared_quad_state_index;
+ } else {
+ WriteParam(m, false);
}
}
}
@@ -388,7 +377,7 @@ static size_t ReserveSizeForRenderPassWrite(const cc::RenderPass& p) {
to_reserve += p.shared_quad_state_list.size() * sizeof(cc::SharedQuadState);
// The shared_quad_state_index for each quad.
danakj 2014/09/26 20:40:55 update this
weiliangc 2014/10/01 23:02:50 I think the logic is correct, but I add more comme
- to_reserve += p.quad_list.size() * sizeof(size_t);
+ to_reserve += p.quad_list.size() * sizeof(bool);
// The largest quad type, verified by a unit test.
to_reserve += p.quad_list.size() * sizeof(cc::kLargestDrawQuad);
@@ -412,7 +401,6 @@ bool ParamTraits<cc::RenderPass>::Read(
gfx::Rect damage_rect;
gfx::Transform transform_to_root_target;
bool has_transparent_background;
- size_t shared_quad_state_list_size;
size_t quad_list_size;
if (!ReadParam(m, iter, &id) ||
@@ -420,7 +408,6 @@ bool ParamTraits<cc::RenderPass>::Read(
!ReadParam(m, iter, &damage_rect) ||
!ReadParam(m, iter, &transform_to_root_target) ||
!ReadParam(m, iter, &has_transparent_background) ||
- !ReadParam(m, iter, &shared_quad_state_list_size) ||
!ReadParam(m, iter, &quad_list_size))
return false;
@@ -430,7 +417,6 @@ bool ParamTraits<cc::RenderPass>::Read(
transform_to_root_target,
has_transparent_background);
- size_t last_shared_quad_state_index = kuint32max;
for (size_t i = 0; i < quad_list_size; ++i) {
cc::DrawQuad::Material material;
PickleIterator temp_iter = *iter;
@@ -491,22 +477,15 @@ bool ParamTraits<cc::RenderPass>::Read(
return false;
}
- size_t shared_quad_state_index;
- if (!ReadParam(m, iter, &shared_quad_state_index))
- return false;
- if (shared_quad_state_index >= shared_quad_state_list_size)
- return false;
- // SharedQuadState indexes should be in ascending order.
- if (last_shared_quad_state_index != kuint32max &&
- shared_quad_state_index < last_shared_quad_state_index)
+ bool has_new_shared_quad_state;
+ if (!ReadParam(m, iter, &has_new_shared_quad_state))
return false;
// If the quad has a new shared quad state, read it in.
- if (last_shared_quad_state_index != shared_quad_state_index) {
+ if (has_new_shared_quad_state) {
cc::SharedQuadState* state = p->CreateAndAppendSharedQuadState();
if (!ReadParam(m, iter, state))
return false;
- last_shared_quad_state_index = shared_quad_state_index;
}
draw_quad->shared_quad_state = p->shared_quad_state_list.back();
@@ -530,10 +509,13 @@ void ParamTraits<cc::RenderPass>::Log(
l->append(", ");
l->append("[");
- for (size_t i = 0; i < p.shared_quad_state_list.size(); ++i) {
- if (i)
+ for (cc::SharedQuadStateList::ConstIterator iter =
danakj 2014/09/26 20:40:55 Can you use auto and c++11 for loops in this CL? T
+ p.shared_quad_state_list.begin();
+ iter != p.shared_quad_state_list.end();
+ ++iter) {
+ if (iter != p.shared_quad_state_list.begin())
l->append(", ");
- LogParam(*p.shared_quad_state_list[i], l);
+ LogParam(*(&(*iter)), l);
danakj 2014/09/26 20:40:55 wat. you mean *iter?
weiliangc 2014/10/01 23:02:00 Done.
}
l->append("], [");
for (cc::QuadList::ConstIterator iter = p.quad_list.begin();
@@ -719,6 +701,7 @@ void ParamTraits<cc::DelegatedFrameData>::Write(Message* m,
to_reserve += p.resource_list.size() * sizeof(cc::TransferableResource);
for (size_t i = 0; i < p.render_pass_list.size(); ++i) {
const cc::RenderPass* pass = p.render_pass_list[i];
+ to_reserve += sizeof(size_t);
danakj 2014/09/26 20:40:55 *2?
weiliangc 2014/10/01 23:02:00 Done.
to_reserve += ReserveSizeForRenderPassWrite(*pass);
}
m->Reserve(to_reserve);
@@ -726,8 +709,11 @@ void ParamTraits<cc::DelegatedFrameData>::Write(Message* m,
WriteParam(m, p.device_scale_factor);
WriteParam(m, p.resource_list);
WriteParam(m, p.render_pass_list.size());
- for (size_t i = 0; i < p.render_pass_list.size(); ++i)
+ for (size_t i = 0; i < p.render_pass_list.size(); ++i) {
+ WriteParam(m, p.render_pass_list[i]->quad_list.size());
+ WriteParam(m, p.render_pass_list[i]->shared_quad_state_list.size());
WriteParam(m, *p.render_pass_list[i]);
+ }
}
bool ParamTraits<cc::DelegatedFrameData>::Read(const Message* m,
@@ -744,7 +730,13 @@ bool ParamTraits<cc::DelegatedFrameData>::Read(const Message* m,
num_render_passes > kMaxRenderPasses || num_render_passes == 0)
return false;
for (size_t i = 0; i < num_render_passes; ++i) {
- scoped_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create();
+ size_t quad_list_size;
+ size_t shared_quad_state_list_size;
+ if (!ReadParam(m, iter, &quad_list_size) ||
danakj 2014/09/26 20:40:55 can you range check these things? like kMaxRenderP
weiliangc 2014/10/01 23:02:00 Done.
+ !ReadParam(m, iter, &shared_quad_state_list_size))
+ return false;
+ scoped_ptr<cc::RenderPass> render_pass =
+ cc::RenderPass::Create(shared_quad_state_list_size, quad_list_size);
if (!ReadParam(m, iter, render_pass.get()))
return false;
p->render_pass_list.push_back(render_pass.Pass());

Powered by Google App Engine
This is Rietveld 408576698