summaryrefslogtreecommitdiffstats
path: root/cc/quads/render_pass.cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-27 21:32:27 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-27 21:32:27 +0000
commit1b6965159a870721066bfbf9ee3018ba64376321 (patch)
tree24472c7654a28dd3ecdf07d5fc3572c94803cd51 /cc/quads/render_pass.cc
parentda2b622c0f813b430b35c12020c184c1f5dcb5a3 (diff)
downloadchromium_src-1b6965159a870721066bfbf9ee3018ba64376321.zip
chromium_src-1b6965159a870721066bfbf9ee3018ba64376321.tar.gz
chromium_src-1b6965159a870721066bfbf9ee3018ba64376321.tar.bz2
cc: Add RenderPass::CopyAll().
This method does a deep copy of a RenderPass. This is needed since we must copy the RenderPass contents from DelegatedRendererLayer to the DelegatedRendererLayerImpl instead of passing ownership, so that if the DelegatedRendererLayer moves to a new tree, it can still pass a copy of the render passes to the impl side again. Tests: RenderPassTest.CopyAllShouldBeIdentical R=piman BUG=263069 NOTRY=true Review URL: https://codereview.chromium.org/24619002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225783 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/quads/render_pass.cc')
-rw-r--r--cc/quads/render_pass.cc50
1 files changed, 49 insertions, 1 deletions
diff --git a/cc/quads/render_pass.cc b/cc/quads/render_pass.cc
index 50d5028..485898d 100644
--- a/cc/quads/render_pass.cc
+++ b/cc/quads/render_pass.cc
@@ -9,12 +9,14 @@
#include "cc/debug/traced_value.h"
#include "cc/output/copy_output_request.h"
#include "cc/quads/draw_quad.h"
+#include "cc/quads/render_pass_draw_quad.h"
#include "cc/quads/shared_quad_state.h"
namespace cc {
void* RenderPass::Id::AsTracingId() const {
- COMPILE_ASSERT(sizeof(size_t) <= sizeof(void*), size_t_bigger_than_pointer);
+ COMPILE_ASSERT(sizeof(size_t) <= sizeof(void*), // NOLINT(runtime/sizeof)
+ size_t_bigger_than_pointer);
return reinterpret_cast<void*>(base::HashPair(layer_id, index));
}
@@ -44,6 +46,52 @@ scoped_ptr<RenderPass> RenderPass::Copy(Id new_id) const {
return copy_pass.Pass();
}
+// static
+void RenderPass::CopyAll(const ScopedPtrVector<RenderPass>& in,
+ ScopedPtrVector<RenderPass>* out) {
+ for (size_t i = 0; i < in.size(); ++i) {
+ RenderPass* source = in[i];
+
+ // Since we can't copy these, it's wrong to use CopyAll in a situation where
+ // you may have copy_requests present.
+ DCHECK_EQ(source->copy_requests.size(), 0u);
+
+ scoped_ptr<RenderPass> copy_pass(Create());
+ copy_pass->SetAll(source->id,
+ source->output_rect,
+ source->damage_rect,
+ source->transform_to_root_target,
+ source->has_transparent_background,
+ source->has_occlusion_from_outside_target_surface);
+ for (size_t i = 0; i < source->shared_quad_state_list.size(); ++i) {
+ copy_pass->shared_quad_state_list.push_back(
+ source->shared_quad_state_list[i]->Copy());
+ }
+ for (size_t i = 0, sqs_i = 0; i < source->quad_list.size(); ++i) {
+ if (source->quad_list[i]->shared_quad_state !=
+ source->shared_quad_state_list[sqs_i])
+ ++sqs_i;
+ DCHECK(sqs_i < source->shared_quad_state_list.size());
+ DCHECK(source->quad_list[i]->shared_quad_state ==
+ source->shared_quad_state_list[sqs_i]);
+
+ DrawQuad* quad = source->quad_list[i];
+
+ if (quad->material == DrawQuad::RENDER_PASS) {
+ const RenderPassDrawQuad* pass_quad =
+ RenderPassDrawQuad::MaterialCast(quad);
+ copy_pass->quad_list.push_back(
+ pass_quad->Copy(copy_pass->shared_quad_state_list[sqs_i],
+ pass_quad->render_pass_id).PassAs<DrawQuad>());
+ } else {
+ copy_pass->quad_list.push_back(source->quad_list[i]->Copy(
+ copy_pass->shared_quad_state_list[sqs_i]));
+ }
+ }
+ out->push_back(copy_pass.Pass());
+ }
+}
+
void RenderPass::SetNew(Id id,
gfx::Rect output_rect,
gfx::RectF damage_rect,