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

Side by Side Diff: cc/layers/layer_impl.cc

Issue 2017263002: cc: Move copy requests from layers to the effect tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo in comment Created 4 years, 6 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/layers/layer_impl.h ('k') | cc/layers/layer_impl_test_properties.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 DCHECK(layer_tree_impl_); 89 DCHECK(layer_tree_impl_);
90 layer_tree_impl_->RegisterLayer(this); 90 layer_tree_impl_->RegisterLayer(this);
91 layer_tree_impl_->AddToElementMap(this); 91 layer_tree_impl_->AddToElementMap(this);
92 92
93 SetNeedsPushProperties(); 93 SetNeedsPushProperties();
94 } 94 }
95 95
96 LayerImpl::~LayerImpl() { 96 LayerImpl::~LayerImpl() {
97 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); 97 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_);
98 98
99 if (!copy_requests_.empty() && layer_tree_impl_->IsActiveTree())
100 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this);
101 layer_tree_impl_->UnregisterScrollLayer(this); 99 layer_tree_impl_->UnregisterScrollLayer(this);
102 layer_tree_impl_->UnregisterLayer(this); 100 layer_tree_impl_->UnregisterLayer(this);
103 layer_tree_impl_->RemoveLayerShouldPushProperties(this); 101 layer_tree_impl_->RemoveLayerShouldPushProperties(this);
104 102
105 layer_tree_impl_->RemoveFromElementMap(this); 103 layer_tree_impl_->RemoveFromElementMap(this);
106 104
107 TRACE_EVENT_OBJECT_DELETED_WITH_ID( 105 TRACE_EVENT_OBJECT_DELETED_WITH_ID(
108 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this); 106 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerImpl", this);
109 107
110 if (mask_layer_) 108 if (mask_layer_)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 void LayerImpl::SetEffectTreeIndex(int index) { 198 void LayerImpl::SetEffectTreeIndex(int index) {
201 effect_tree_index_ = index; 199 effect_tree_index_ = index;
202 SetNeedsPushProperties(); 200 SetNeedsPushProperties();
203 } 201 }
204 202
205 void LayerImpl::SetScrollTreeIndex(int index) { 203 void LayerImpl::SetScrollTreeIndex(int index) {
206 scroll_tree_index_ = index; 204 scroll_tree_index_ = index;
207 SetNeedsPushProperties(); 205 SetNeedsPushProperties();
208 } 206 }
209 207
210 void LayerImpl::PassCopyRequests(
211 std::vector<std::unique_ptr<CopyOutputRequest>>* requests) {
212 // In the case that a layer still has a copy request, this means that there's
213 // a commit to the active tree without a draw. This only happens in some
214 // edge cases during lost context or visibility changes, so don't try to
215 // handle preserving these output requests (and their surface).
216 if (!copy_requests_.empty()) {
217 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this);
218 // Destroying these will abort them.
219 copy_requests_.clear();
220 }
221
222 if (requests->empty())
223 return;
224
225 bool was_empty = copy_requests_.empty();
226 for (auto& request : *requests)
227 copy_requests_.push_back(std::move(request));
228 requests->clear();
229
230 if (was_empty && layer_tree_impl()->IsActiveTree())
231 layer_tree_impl()->AddLayerWithCopyOutputRequest(this);
232 }
233
234 void LayerImpl::TakeCopyRequestsAndTransformToTarget(
235 std::vector<std::unique_ptr<CopyOutputRequest>>* requests) {
236 DCHECK(!copy_requests_.empty());
237 DCHECK(layer_tree_impl()->IsActiveTree());
238 DCHECK(has_render_surface());
239 DCHECK_EQ(render_target(), render_surface());
240
241 size_t first_inserted_request = requests->size();
242 for (auto& request : copy_requests_)
243 requests->push_back(std::move(request));
244 copy_requests_.clear();
245
246 for (size_t i = first_inserted_request; i < requests->size(); ++i) {
247 CopyOutputRequest* request = (*requests)[i].get();
248 if (!request->has_area())
249 continue;
250
251 gfx::Rect request_in_layer_space = request->area();
252 request_in_layer_space.Intersect(gfx::Rect(bounds()));
253 request->set_area(MathUtil::MapEnclosingClippedRect(
254 DrawTransform(), request_in_layer_space));
255 }
256
257 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this);
258 layer_tree_impl()->set_needs_update_draw_properties();
259 }
260
261 void LayerImpl::ClearRenderSurfaceLayerList() { 208 void LayerImpl::ClearRenderSurfaceLayerList() {
262 if (render_surface_) 209 if (render_surface_)
263 render_surface_->ClearLayerLists(); 210 render_surface_->ClearLayerLists();
264 } 211 }
265 212
266 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const { 213 void LayerImpl::PopulateSharedQuadState(SharedQuadState* state) const {
267 state->SetAll(draw_properties_.target_space_transform, bounds(), 214 state->SetAll(draw_properties_.target_space_transform, bounds(),
268 draw_properties_.visible_layer_rect, draw_properties_.clip_rect, 215 draw_properties_.visible_layer_rect, draw_properties_.clip_rect,
269 draw_properties_.is_clipped, draw_properties_.opacity, 216 draw_properties_.is_clipped, draw_properties_.opacity,
270 draw_blend_mode_, sorting_context_id_); 217 draw_blend_mode_, sorting_context_id_);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 layer->set_user_scrollable_vertical(user_scrollable_vertical_); 401 layer->set_user_scrollable_vertical(user_scrollable_vertical_);
455 402
456 layer->Set3dSortingContextId(sorting_context_id_); 403 layer->Set3dSortingContextId(sorting_context_id_);
457 404
458 layer->SetTransformTreeIndex(transform_tree_index_); 405 layer->SetTransformTreeIndex(transform_tree_index_);
459 layer->SetClipTreeIndex(clip_tree_index_); 406 layer->SetClipTreeIndex(clip_tree_index_);
460 layer->SetEffectTreeIndex(effect_tree_index_); 407 layer->SetEffectTreeIndex(effect_tree_index_);
461 layer->SetScrollTreeIndex(scroll_tree_index_); 408 layer->SetScrollTreeIndex(scroll_tree_index_);
462 layer->set_offset_to_transform_parent(offset_to_transform_parent_); 409 layer->set_offset_to_transform_parent(offset_to_transform_parent_);
463 410
464 layer->PassCopyRequests(&copy_requests_);
465
466 // If the main thread commits multiple times before the impl thread actually 411 // If the main thread commits multiple times before the impl thread actually
467 // draws, then damage tracking will become incorrect if we simply clobber the 412 // draws, then damage tracking will become incorrect if we simply clobber the
468 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. 413 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e.
469 // union) any update changes that have occurred on the main thread. 414 // union) any update changes that have occurred on the main thread.
470 update_rect_.Union(layer->update_rect()); 415 update_rect_.Union(layer->update_rect());
471 layer->SetUpdateRect(update_rect_); 416 layer->SetUpdateRect(update_rect_);
472 417
473 if (owned_debug_info_) 418 if (owned_debug_info_)
474 layer->SetDebugInfo(std::move(owned_debug_info_)); 419 layer->SetDebugInfo(std::move(owned_debug_info_));
475 420
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 .layer_transforms_should_scale_layer_contents) { 1340 .layer_transforms_should_scale_layer_contents) {
1396 return default_scale; 1341 return default_scale;
1397 } 1342 }
1398 1343
1399 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1344 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1400 ScreenSpaceTransform(), default_scale); 1345 ScreenSpaceTransform(), default_scale);
1401 return std::max(transform_scales.x(), transform_scales.y()); 1346 return std::max(transform_scales.x(), transform_scales.y());
1402 } 1347 }
1403 1348
1404 } // namespace cc 1349 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/layers/layer_impl_test_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698