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

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

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

Powered by Google App Engine
This is Rietveld 408576698