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

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

Issue 2873593002: Force use of and cache render surface. (Closed)
Patch Set: Reduce unneeded code in surface aggregator and add more test. Created 3 years, 5 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
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 RenderPass::RenderPass() 64 RenderPass::RenderPass()
65 : quad_list(kDefaultNumQuadsToReserve), 65 : quad_list(kDefaultNumQuadsToReserve),
66 shared_quad_state_list(alignof(SharedQuadState), 66 shared_quad_state_list(alignof(SharedQuadState),
67 sizeof(SharedQuadState), 67 sizeof(SharedQuadState),
68 kDefaultNumSharedQuadStatesToReserve) {} 68 kDefaultNumSharedQuadStatesToReserve) {}
69 69
70 // Each layer usually produces one shared quad state, so the number of layers 70 // Each layer usually produces one shared quad state, so the number of layers
71 // is a good hint for what to reserve here. 71 // is a good hint for what to reserve here.
72 RenderPass::RenderPass(size_t num_layers) 72 RenderPass::RenderPass(size_t num_layers)
73 : has_transparent_background(true), 73 : has_transparent_background(true),
74 cache_render_surface(false),
75 has_damage_from_contributing_content(false),
74 quad_list(kDefaultNumQuadsToReserve), 76 quad_list(kDefaultNumQuadsToReserve),
75 shared_quad_state_list(alignof(SharedQuadState), 77 shared_quad_state_list(alignof(SharedQuadState),
76 sizeof(SharedQuadState), 78 sizeof(SharedQuadState),
77 num_layers) {} 79 num_layers) {}
78 80
79 RenderPass::RenderPass(size_t shared_quad_state_list_size, 81 RenderPass::RenderPass(size_t shared_quad_state_list_size,
80 size_t quad_list_size) 82 size_t quad_list_size)
81 : has_transparent_background(true), 83 : has_transparent_background(true),
84 cache_render_surface(false),
85 has_damage_from_contributing_content(false),
82 quad_list(quad_list_size), 86 quad_list(quad_list_size),
83 shared_quad_state_list(alignof(SharedQuadState), 87 shared_quad_state_list(alignof(SharedQuadState),
84 sizeof(SharedQuadState), 88 sizeof(SharedQuadState),
85 shared_quad_state_list_size) {} 89 shared_quad_state_list_size) {}
86 90
87 RenderPass::~RenderPass() { 91 RenderPass::~RenderPass() {
88 TRACE_EVENT_OBJECT_DELETED_WITH_ID( 92 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
89 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), "cc::RenderPass", 93 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), "cc::RenderPass",
90 reinterpret_cast<void*>(id)); 94 reinterpret_cast<void*>(id));
91 } 95 }
92 96
93 std::unique_ptr<RenderPass> RenderPass::Copy(int new_id) const { 97 std::unique_ptr<RenderPass> RenderPass::Copy(int new_id) const {
94 std::unique_ptr<RenderPass> copy_pass( 98 std::unique_ptr<RenderPass> copy_pass(
95 Create(shared_quad_state_list.size(), quad_list.size())); 99 Create(shared_quad_state_list.size(), quad_list.size()));
96 copy_pass->SetAll(new_id, output_rect, damage_rect, transform_to_root_target, 100 copy_pass->SetAll(new_id, output_rect, damage_rect, transform_to_root_target,
97 filters, background_filters, color_space, 101 filters, background_filters, color_space,
98 has_transparent_background); 102 has_transparent_background, cache_render_surface,
103 has_damage_from_contributing_content);
99 return copy_pass; 104 return copy_pass;
100 } 105 }
101 106
102 std::unique_ptr<RenderPass> RenderPass::DeepCopy() const { 107 std::unique_ptr<RenderPass> RenderPass::DeepCopy() const {
103 // Since we can't copy these, it's wrong to use DeepCopy in a situation where 108 // Since we can't copy these, it's wrong to use DeepCopy in a situation where
104 // you may have copy_requests present. 109 // you may have copy_requests present.
105 DCHECK_EQ(copy_requests.size(), 0u); 110 DCHECK_EQ(copy_requests.size(), 0u);
106 111
107 std::unique_ptr<RenderPass> copy_pass( 112 std::unique_ptr<RenderPass> copy_pass(
108 Create(shared_quad_state_list.size(), quad_list.size())); 113 Create(shared_quad_state_list.size(), quad_list.size()));
109 copy_pass->SetAll(id, output_rect, damage_rect, transform_to_root_target, 114 copy_pass->SetAll(id, output_rect, damage_rect, transform_to_root_target,
110 filters, background_filters, color_space, 115 filters, background_filters, color_space,
111 has_transparent_background); 116 has_transparent_background, cache_render_surface,
117 has_damage_from_contributing_content);
112 for (auto* shared_quad_state : shared_quad_state_list) { 118 for (auto* shared_quad_state : shared_quad_state_list) {
113 SharedQuadState* copy_shared_quad_state = 119 SharedQuadState* copy_shared_quad_state =
114 copy_pass->CreateAndAppendSharedQuadState(); 120 copy_pass->CreateAndAppendSharedQuadState();
115 *copy_shared_quad_state = *shared_quad_state; 121 *copy_shared_quad_state = *shared_quad_state;
116 } 122 }
117 SharedQuadStateList::ConstIterator sqs_iter = shared_quad_state_list.begin(); 123 SharedQuadStateList::ConstIterator sqs_iter = shared_quad_state_list.begin();
118 SharedQuadStateList::Iterator copy_sqs_iter = 124 SharedQuadStateList::Iterator copy_sqs_iter =
119 copy_pass->shared_quad_state_list.begin(); 125 copy_pass->shared_quad_state_list.begin();
120 for (auto* quad : quad_list) { 126 for (auto* quad : quad_list) {
121 while (quad->shared_quad_state != *sqs_iter) { 127 while (quad->shared_quad_state != *sqs_iter) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 DCHECK(shared_quad_state_list.empty()); 170 DCHECK(shared_quad_state_list.empty());
165 } 171 }
166 172
167 void RenderPass::SetAll(uint64_t id, 173 void RenderPass::SetAll(uint64_t id,
168 const gfx::Rect& output_rect, 174 const gfx::Rect& output_rect,
169 const gfx::Rect& damage_rect, 175 const gfx::Rect& damage_rect,
170 const gfx::Transform& transform_to_root_target, 176 const gfx::Transform& transform_to_root_target,
171 const FilterOperations& filters, 177 const FilterOperations& filters,
172 const FilterOperations& background_filters, 178 const FilterOperations& background_filters,
173 const gfx::ColorSpace& color_space, 179 const gfx::ColorSpace& color_space,
174 bool has_transparent_background) { 180 bool has_transparent_background,
181 bool cache_render_surface,
182 bool has_damage_from_contributing_content) {
175 DCHECK(id); 183 DCHECK(id);
176 184
177 this->id = id; 185 this->id = id;
178 this->output_rect = output_rect; 186 this->output_rect = output_rect;
179 this->damage_rect = damage_rect; 187 this->damage_rect = damage_rect;
180 this->transform_to_root_target = transform_to_root_target; 188 this->transform_to_root_target = transform_to_root_target;
181 this->filters = filters; 189 this->filters = filters;
182 this->background_filters = background_filters; 190 this->background_filters = background_filters;
183 this->color_space = color_space; 191 this->color_space = color_space;
184 this->has_transparent_background = has_transparent_background; 192 this->has_transparent_background = has_transparent_background;
193 this->cache_render_surface = cache_render_surface;
194 this->has_damage_from_contributing_content =
195 has_damage_from_contributing_content;
185 196
186 DCHECK(quad_list.empty()); 197 DCHECK(quad_list.empty());
187 DCHECK(shared_quad_state_list.empty()); 198 DCHECK(shared_quad_state_list.empty());
188 } 199 }
189 200
190 void RenderPass::AsValueInto(base::trace_event::TracedValue* value) const { 201 void RenderPass::AsValueInto(base::trace_event::TracedValue* value) const {
191 MathUtil::AddToTracedValue("output_rect", output_rect, value); 202 MathUtil::AddToTracedValue("output_rect", output_rect, value);
192 MathUtil::AddToTracedValue("damage_rect", damage_rect, value); 203 MathUtil::AddToTracedValue("damage_rect", damage_rect, value);
193 204
194 value->SetBoolean("has_transparent_background", has_transparent_background); 205 value->SetBoolean("has_transparent_background", has_transparent_background);
206 value->SetBoolean("cache_render_surface", cache_render_surface);
207 value->SetBoolean("has_damage_from_contributing_content",
208 has_damage_from_contributing_content);
195 value->SetInteger("copy_requests", 209 value->SetInteger("copy_requests",
196 base::saturated_cast<int>(copy_requests.size())); 210 base::saturated_cast<int>(copy_requests.size()));
197 211
198 value->BeginArray("filters"); 212 value->BeginArray("filters");
199 filters.AsValueInto(value); 213 filters.AsValueInto(value);
200 value->EndArray(); 214 value->EndArray();
201 215
202 value->BeginArray("background_filters"); 216 value->BeginArray("background_filters");
203 background_filters.AsValueInto(value); 217 background_filters.AsValueInto(value);
204 value->EndArray(); 218 value->EndArray();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 case DrawQuad::RENDER_PASS: 285 case DrawQuad::RENDER_PASS:
272 case DrawQuad::INVALID: 286 case DrawQuad::INVALID:
273 LOG(FATAL) << "Invalid DrawQuad material " << quad->material; 287 LOG(FATAL) << "Invalid DrawQuad material " << quad->material;
274 break; 288 break;
275 } 289 }
276 quad_list.back()->shared_quad_state = shared_quad_state; 290 quad_list.back()->shared_quad_state = shared_quad_state;
277 return quad_list.back(); 291 return quad_list.back();
278 } 292 }
279 293
280 } // namespace cc 294 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698