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

Unified Diff: cc/layers/delegated_renderer_layer_impl.cc

Issue 23891003: cc: Be robust against invalid RenderPassDrawQuads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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: cc/layers/delegated_renderer_layer_impl.cc
diff --git a/cc/layers/delegated_renderer_layer_impl.cc b/cc/layers/delegated_renderer_layer_impl.cc
index 17a0c1c95ac25b8efe7c84a52749ac4af74bdaa7..a8e71c573f0f02471a2ef7ad56026c1ad9d05d6f 100644
--- a/cc/layers/delegated_renderer_layer_impl.cc
+++ b/cc/layers/delegated_renderer_layer_impl.cc
@@ -240,13 +240,21 @@ RenderPass::Id DelegatedRendererLayerImpl::NextContributingRenderPassId(
return RenderPass::Id(previous.layer_id, previous.index + 1);
}
-RenderPass::Id DelegatedRendererLayerImpl::ConvertDelegatedRenderPassId(
- RenderPass::Id delegated_render_pass_id) const {
+// Returns |true| if the delegated_render_pass_id is part of the current
+// frame and can be converted.
piman 2013/09/04 19:03:12 nit: should this be in the header instead?
danakj 2013/09/05 16:46:55 Ya.. thanks.
+bool DelegatedRendererLayerImpl::ConvertDelegatedRenderPassId(
+ RenderPass::Id delegated_render_pass_id,
+ RenderPass::Id* output_render_pass_id) const {
base::hash_map<RenderPass::Id, int>::const_iterator found =
render_passes_index_by_id_.find(delegated_render_pass_id);
- DCHECK(found != render_passes_index_by_id_.end());
+ if (found == render_passes_index_by_id_.end()) {
+ // Be robust against a RenderPass id that isn't part of the frame.
+ return false;
+ }
unsigned delegated_render_pass_index = found->second;
- return RenderPass::Id(id(), IndexToId(delegated_render_pass_index));
+ *output_render_pass_id =
+ RenderPass::Id(id(), IndexToId(delegated_render_pass_index));
+ return true;
}
void DelegatedRendererLayerImpl::AppendContributingRenderPasses(
@@ -254,10 +262,14 @@ void DelegatedRendererLayerImpl::AppendContributingRenderPasses(
DCHECK(HasContributingDelegatedRenderPasses());
for (size_t i = 0; i < render_passes_in_draw_order_.size() - 1; ++i) {
- RenderPass::Id output_render_pass_id =
- ConvertDelegatedRenderPassId(render_passes_in_draw_order_[i]->id);
+ RenderPass::Id output_render_pass_id(-1, -1);
+ bool present =
+ ConvertDelegatedRenderPassId(render_passes_in_draw_order_[i]->id,
+ &output_render_pass_id);
// Don't clash with the RenderPass we generate if we own a RenderSurface.
+ DCHECK(present) << render_passes_in_draw_order_[i]->id.layer_id << ", "
+ << render_passes_in_draw_order_[i]->id.index;
DCHECK_GT(output_render_pass_id.index, 0);
render_pass_sink->AppendRenderPass(
@@ -447,18 +459,26 @@ void DelegatedRendererLayerImpl::AppendRenderPassQuads(
} else {
RenderPass::Id delegated_contributing_render_pass_id =
RenderPassDrawQuad::MaterialCast(delegated_quad)->render_pass_id;
- RenderPass::Id output_contributing_render_pass_id =
- ConvertDelegatedRenderPassId(delegated_contributing_render_pass_id);
- DCHECK(output_contributing_render_pass_id !=
- append_quads_data->render_pass_id);
-
- output_quad = RenderPassDrawQuad::MaterialCast(delegated_quad)->Copy(
- output_shared_quad_state,
- output_contributing_render_pass_id).PassAs<DrawQuad>();
+ RenderPass::Id output_contributing_render_pass_id(-1, -1);
+
+ bool present =
+ ConvertDelegatedRenderPassId(delegated_contributing_render_pass_id,
+ &output_contributing_render_pass_id);
+
+ // The frame may have a RenderPassDrawQuad that points to a RenderPass not
+ // part of the frame. Just ignore these quads.
+ if (present) {
+ DCHECK(output_contributing_render_pass_id !=
+ append_quads_data->render_pass_id);
+
+ output_quad = RenderPassDrawQuad::MaterialCast(delegated_quad)->Copy(
+ output_shared_quad_state,
+ output_contributing_render_pass_id).PassAs<DrawQuad>();
+ }
}
- DCHECK(output_quad.get());
- quad_sink->Append(output_quad.Pass(), append_quads_data);
+ if (output_quad)
+ quad_sink->Append(output_quad.Pass(), append_quads_data);
}
}

Powered by Google App Engine
This is Rietveld 408576698