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

Side by Side Diff: cc/quads/render_pass.cc

Issue 2174843003: cc mojo: Use ArrayDataViews in RenderPasses (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix RenderPassId Created 4 years, 4 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
« no previous file with comments | « cc/quads/render_pass.h ('k') | mojo/public/cpp/bindings/array_traits.h » ('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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/quads/render_pass.h" 5 #include "cc/quads/render_pass.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 std::unique_ptr<RenderPass> copy_pass( 91 std::unique_ptr<RenderPass> copy_pass(
92 Create(shared_quad_state_list.size(), quad_list.size())); 92 Create(shared_quad_state_list.size(), quad_list.size()));
93 copy_pass->SetAll(new_id, 93 copy_pass->SetAll(new_id,
94 output_rect, 94 output_rect,
95 damage_rect, 95 damage_rect,
96 transform_to_root_target, 96 transform_to_root_target,
97 has_transparent_background); 97 has_transparent_background);
98 return copy_pass; 98 return copy_pass;
99 } 99 }
100 100
101 std::unique_ptr<RenderPass> RenderPass::DeepCopy() const {
102 // Since we can't copy these, it's wrong to use DeepCopy in a situation where
103 // you may have copy_requests present.
104 DCHECK_EQ(copy_requests.size(), 0u);
105
106 std::unique_ptr<RenderPass> copy_pass(
107 Create(shared_quad_state_list.size(), quad_list.size()));
108 copy_pass->SetAll(id, output_rect, damage_rect, transform_to_root_target,
109 has_transparent_background);
110 for (auto* shared_quad_state : shared_quad_state_list) {
111 SharedQuadState* copy_shared_quad_state =
112 copy_pass->CreateAndAppendSharedQuadState();
113 *copy_shared_quad_state = *shared_quad_state;
114 }
115 SharedQuadStateList::ConstIterator sqs_iter = shared_quad_state_list.begin();
116 SharedQuadStateList::Iterator copy_sqs_iter =
117 copy_pass->shared_quad_state_list.begin();
118 for (auto* quad : quad_list) {
119 while (quad->shared_quad_state != *sqs_iter) {
120 ++sqs_iter;
121 ++copy_sqs_iter;
122 DCHECK(sqs_iter != shared_quad_state_list.end());
123 }
124 DCHECK(quad->shared_quad_state == *sqs_iter);
125
126 SharedQuadState* copy_shared_quad_state = *copy_sqs_iter;
127
128 if (quad->material == DrawQuad::RENDER_PASS) {
129 const RenderPassDrawQuad* pass_quad =
130 RenderPassDrawQuad::MaterialCast(quad);
131 copy_pass->CopyFromAndAppendRenderPassDrawQuad(
132 pass_quad, copy_shared_quad_state, pass_quad->render_pass_id);
133 } else {
134 copy_pass->CopyFromAndAppendDrawQuad(quad, copy_shared_quad_state);
135 }
136 }
137 return copy_pass;
138 }
139
101 // static 140 // static
102 void RenderPass::CopyAll(const std::vector<std::unique_ptr<RenderPass>>& in, 141 void RenderPass::CopyAll(const std::vector<std::unique_ptr<RenderPass>>& in,
103 std::vector<std::unique_ptr<RenderPass>>* out) { 142 std::vector<std::unique_ptr<RenderPass>>* out) {
104 for (const auto& source : in) { 143 for (const auto& source : in)
105 // Since we can't copy these, it's wrong to use CopyAll in a situation where 144 out->push_back(source->DeepCopy());
106 // you may have copy_requests present.
107 DCHECK_EQ(source->copy_requests.size(), 0u);
108
109 std::unique_ptr<RenderPass> copy_pass(Create(
110 source->shared_quad_state_list.size(), source->quad_list.size()));
111 copy_pass->SetAll(source->id,
112 source->output_rect,
113 source->damage_rect,
114 source->transform_to_root_target,
115 source->has_transparent_background);
116 for (auto* shared_quad_state : source->shared_quad_state_list) {
117 SharedQuadState* copy_shared_quad_state =
118 copy_pass->CreateAndAppendSharedQuadState();
119 *copy_shared_quad_state = *shared_quad_state;
120 }
121 SharedQuadStateList::Iterator sqs_iter =
122 source->shared_quad_state_list.begin();
123 SharedQuadStateList::Iterator copy_sqs_iter =
124 copy_pass->shared_quad_state_list.begin();
125 for (auto* quad : source->quad_list) {
126 while (quad->shared_quad_state != *sqs_iter) {
127 ++sqs_iter;
128 ++copy_sqs_iter;
129 DCHECK(sqs_iter != source->shared_quad_state_list.end());
130 }
131 DCHECK(quad->shared_quad_state == *sqs_iter);
132
133 SharedQuadState* copy_shared_quad_state = *copy_sqs_iter;
134
135 if (quad->material == DrawQuad::RENDER_PASS) {
136 const RenderPassDrawQuad* pass_quad =
137 RenderPassDrawQuad::MaterialCast(quad);
138 copy_pass->CopyFromAndAppendRenderPassDrawQuad(
139 pass_quad, copy_shared_quad_state, pass_quad->render_pass_id);
140 } else {
141 copy_pass->CopyFromAndAppendDrawQuad(quad, copy_shared_quad_state);
142 }
143 }
144 out->push_back(std::move(copy_pass));
145 }
146 } 145 }
147 146
148 void RenderPass::SetNew(RenderPassId id, 147 void RenderPass::SetNew(RenderPassId id,
149 const gfx::Rect& output_rect, 148 const gfx::Rect& output_rect,
150 const gfx::Rect& damage_rect, 149 const gfx::Rect& damage_rect,
151 const gfx::Transform& transform_to_root_target) { 150 const gfx::Transform& transform_to_root_target) {
152 DCHECK(id.IsValid()); 151 DCHECK(id.IsValid());
153 DCHECK(damage_rect.IsEmpty() || output_rect.Contains(damage_rect)) 152 DCHECK(damage_rect.IsEmpty() || output_rect.Contains(damage_rect))
154 << "damage_rect: " << damage_rect.ToString() 153 << "damage_rect: " << damage_rect.ToString()
155 << " output_rect: " << output_rect.ToString(); 154 << " output_rect: " << output_rect.ToString();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 case DrawQuad::RENDER_PASS: 257 case DrawQuad::RENDER_PASS:
259 case DrawQuad::INVALID: 258 case DrawQuad::INVALID:
260 LOG(FATAL) << "Invalid DrawQuad material " << quad->material; 259 LOG(FATAL) << "Invalid DrawQuad material " << quad->material;
261 break; 260 break;
262 } 261 }
263 quad_list.back()->shared_quad_state = shared_quad_state; 262 quad_list.back()->shared_quad_state = shared_quad_state;
264 return quad_list.back(); 263 return quad_list.back();
265 } 264 }
266 265
267 } // namespace cc 266 } // namespace cc
OLDNEW
« no previous file with comments | « cc/quads/render_pass.h ('k') | mojo/public/cpp/bindings/array_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698