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

Side by Side Diff: cc/trees/occlusion_tracker.cc

Issue 2690753002: cc: Move render surface ownership from layers to the effect tree (Closed)
Patch Set: Only update surfaces when can_render_to_separate_surface changes Created 3 years, 10 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/trees/layer_tree_impl.cc ('k') | cc/trees/property_tree.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/trees/occlusion_tracker.h" 5 #include "cc/trees/occlusion_tracker.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 region.GetRect(i)); 112 region.GetRect(i));
113 if (have_clip_rect) 113 if (have_clip_rect)
114 transformed_rect.Intersect(clip_rect_in_new_target); 114 transformed_rect.Intersect(clip_rect_in_new_target);
115 transformed_region.Union(transformed_rect); 115 transformed_region.Union(transformed_rect);
116 } 116 }
117 return transformed_region; 117 return transformed_region;
118 } 118 }
119 119
120 void OcclusionTracker::EnterRenderTarget(const LayerImpl* new_target) { 120 void OcclusionTracker::EnterRenderTarget(const LayerImpl* new_target) {
121 DCHECK(new_target->has_render_surface()); 121 DCHECK(new_target->has_render_surface());
122 if (!stack_.empty() && stack_.back().target == new_target->render_surface()) 122 RenderSurfaceImpl* new_target_surface = new_target->render_surface();
123 if (!stack_.empty() && stack_.back().target == new_target_surface)
123 return; 124 return;
124 125
125 const RenderSurfaceImpl* old_target_surface = NULL; 126 const RenderSurfaceImpl* old_target_surface = NULL;
126 const RenderSurfaceImpl* old_occlusion_immune_ancestor = NULL; 127 const RenderSurfaceImpl* old_occlusion_immune_ancestor = NULL;
127 if (!stack_.empty()) { 128 if (!stack_.empty()) {
128 old_target_surface = stack_.back().target; 129 old_target_surface = stack_.back().target;
129 old_occlusion_immune_ancestor = 130 old_occlusion_immune_ancestor =
130 old_target_surface->nearest_occlusion_immune_ancestor(); 131 old_target_surface->nearest_occlusion_immune_ancestor();
131 } 132 }
132 const RenderSurfaceImpl* new_occlusion_immune_ancestor = 133 const RenderSurfaceImpl* new_occlusion_immune_ancestor =
133 new_target->render_surface()->nearest_occlusion_immune_ancestor(); 134 new_target_surface->nearest_occlusion_immune_ancestor();
134 135
135 stack_.push_back(StackObject(new_target->render_surface())); 136 stack_.push_back(StackObject(new_target_surface));
136 137
137 // We copy the screen occlusion into the new RenderSurfaceImpl subtree, but we 138 // We copy the screen occlusion into the new RenderSurfaceImpl subtree, but we
138 // never copy in the occlusion from inside the target, since we are looking 139 // never copy in the occlusion from inside the target, since we are looking
139 // at a new RenderSurfaceImpl target. 140 // at a new RenderSurfaceImpl target.
140 141
141 // If entering an unoccluded subtree, do not carry forward the outside 142 // If entering an unoccluded subtree, do not carry forward the outside
142 // occlusion calculated so far. 143 // occlusion calculated so far.
143 bool entering_unoccluded_subtree = 144 bool entering_unoccluded_subtree =
144 new_occlusion_immune_ancestor && 145 new_occlusion_immune_ancestor &&
145 new_occlusion_immune_ancestor != old_occlusion_immune_ancestor; 146 new_occlusion_immune_ancestor != old_occlusion_immune_ancestor;
146 147
147 gfx::Transform inverse_new_target_screen_space_transform( 148 gfx::Transform inverse_new_target_screen_space_transform(
148 // Note carefully, not used if screen space transform is uninvertible. 149 // Note carefully, not used if screen space transform is uninvertible.
149 gfx::Transform::kSkipInitialization); 150 gfx::Transform::kSkipInitialization);
150 bool have_transform_from_screen_to_new_target = 151 bool have_transform_from_screen_to_new_target =
151 new_target->render_surface()->screen_space_transform().GetInverse( 152 new_target_surface->screen_space_transform().GetInverse(
152 &inverse_new_target_screen_space_transform); 153 &inverse_new_target_screen_space_transform);
153 154
154 bool entering_root_target = 155 bool entering_root_target =
155 new_target->layer_tree_impl()->IsRootLayer(new_target); 156 new_target->layer_tree_impl()->IsRootLayer(new_target);
156 157
157 bool copy_outside_occlusion_forward = 158 bool copy_outside_occlusion_forward =
158 stack_.size() > 1 && 159 stack_.size() > 1 &&
159 !entering_unoccluded_subtree && 160 !entering_unoccluded_subtree &&
160 have_transform_from_screen_to_new_target && 161 have_transform_from_screen_to_new_target &&
161 !entering_root_target; 162 !entering_root_target;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 occlusion_rect.Inset(shrink_left, shrink_top, shrink_right, shrink_bottom); 249 occlusion_rect.Inset(shrink_left, shrink_top, shrink_right, shrink_bottom);
249 250
250 occlusion_from_inside_target->Union(occlusion_rect); 251 occlusion_from_inside_target->Union(occlusion_rect);
251 } 252 }
252 } 253 }
253 254
254 void OcclusionTracker::LeaveToRenderTarget(const LayerImpl* new_target) { 255 void OcclusionTracker::LeaveToRenderTarget(const LayerImpl* new_target) {
255 DCHECK(!stack_.empty()); 256 DCHECK(!stack_.empty());
256 size_t last_index = stack_.size() - 1; 257 size_t last_index = stack_.size() - 1;
257 DCHECK(new_target->has_render_surface()); 258 DCHECK(new_target->has_render_surface());
259 RenderSurfaceImpl* new_surface = new_target->render_surface();
258 bool surface_will_be_at_top_after_pop = 260 bool surface_will_be_at_top_after_pop =
259 stack_.size() > 1 && 261 stack_.size() > 1 && stack_[last_index - 1].target == new_surface;
260 stack_[last_index - 1].target == new_target->render_surface();
261 262
262 // We merge the screen occlusion from the current RenderSurfaceImpl subtree 263 // We merge the screen occlusion from the current RenderSurfaceImpl subtree
263 // out to its parent target RenderSurfaceImpl. The target occlusion can be 264 // out to its parent target RenderSurfaceImpl. The target occlusion can be
264 // merged out as well but needs to be transformed to the new target. 265 // merged out as well but needs to be transformed to the new target.
265 266
266 const RenderSurfaceImpl* old_surface = stack_[last_index].target; 267 const RenderSurfaceImpl* old_surface = stack_[last_index].target;
267 268
268 SimpleEnclosedRegion old_occlusion_from_inside_target_in_new_target = 269 SimpleEnclosedRegion old_occlusion_from_inside_target_in_new_target =
269 TransformSurfaceOpaqueRegion( 270 TransformSurfaceOpaqueRegion(
270 stack_[last_index].occlusion_from_inside_target, 271 stack_[last_index].occlusion_from_inside_target,
(...skipping 19 matching lines...) Expand all
290 old_occlusion_from_inside_target_in_new_target); 291 old_occlusion_from_inside_target_in_new_target);
291 // TODO(danakj): Strictly this should subtract the inside target occlusion 292 // TODO(danakj): Strictly this should subtract the inside target occlusion
292 // before union. 293 // before union.
293 if (!new_target->layer_tree_impl()->IsRootLayer(new_target)) { 294 if (!new_target->layer_tree_impl()->IsRootLayer(new_target)) {
294 stack_[last_index - 1].occlusion_from_outside_target.Union( 295 stack_[last_index - 1].occlusion_from_outside_target.Union(
295 old_occlusion_from_outside_target_in_new_target); 296 old_occlusion_from_outside_target_in_new_target);
296 } 297 }
297 stack_.pop_back(); 298 stack_.pop_back();
298 } else { 299 } else {
299 // Replace the top of the stack with the new pushed surface. 300 // Replace the top of the stack with the new pushed surface.
300 stack_.back().target = new_target->render_surface(); 301 stack_.back().target = new_surface;
301 stack_.back().occlusion_from_inside_target = 302 stack_.back().occlusion_from_inside_target =
302 old_occlusion_from_inside_target_in_new_target; 303 old_occlusion_from_inside_target_in_new_target;
303 if (!new_target->layer_tree_impl()->IsRootLayer(new_target)) { 304 if (!new_target->layer_tree_impl()->IsRootLayer(new_target)) {
304 stack_.back().occlusion_from_outside_target = 305 stack_.back().occlusion_from_outside_target =
305 old_occlusion_from_outside_target_in_new_target; 306 old_occlusion_from_outside_target_in_new_target;
306 } else { 307 } else {
307 stack_.back().occlusion_from_outside_target.Clear(); 308 stack_.back().occlusion_from_outside_target.Clear();
308 } 309 }
309 } 310 }
310 311
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 DCHECK(layer_tree->RootRenderSurface() == stack_.back().target); 370 DCHECK(layer_tree->RootRenderSurface() == stack_.back().target);
370 const SimpleEnclosedRegion& occluded = 371 const SimpleEnclosedRegion& occluded =
371 stack_.back().occlusion_from_inside_target; 372 stack_.back().occlusion_from_inside_target;
372 Region visible_region(screen_space_clip_rect_); 373 Region visible_region(screen_space_clip_rect_);
373 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i) 374 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i)
374 visible_region.Subtract(occluded.GetRect(i)); 375 visible_region.Subtract(occluded.GetRect(i));
375 return visible_region; 376 return visible_region;
376 } 377 }
377 378
378 } // namespace cc 379 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | cc/trees/property_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698