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

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

Issue 2035863003: cc: Add mask and replica layer ids to the effect tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments 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/trees/layer_tree_impl_unittest.cc ('k') | cc/trees/occlusion_tracker_unittest.cc » ('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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 RenderSurfaceImpl* surface = finished_target->render_surface(); 175 RenderSurfaceImpl* surface = finished_target->render_surface();
176 176
177 // Readbacks always happen on render targets so we only need to check 177 // Readbacks always happen on render targets so we only need to check
178 // for readbacks here. 178 // for readbacks here.
179 bool target_is_only_for_copy_request = 179 bool target_is_only_for_copy_request =
180 surface->HasCopyRequest() && finished_target->IsHidden(); 180 surface->HasCopyRequest() && finished_target->IsHidden();
181 181
182 // If the occlusion within the surface can not be applied to things outside of 182 // If the occlusion within the surface can not be applied to things outside of
183 // the surface's subtree, then clear the occlusion here so it won't be used. 183 // the surface's subtree, then clear the occlusion here so it won't be used.
184 if (finished_target->mask_layer() || surface->draw_opacity() < 1 || 184 if (surface->MaskLayer() || surface->draw_opacity() < 1 ||
185 !finished_target->uses_default_blend_mode() || 185 !finished_target->uses_default_blend_mode() ||
186 target_is_only_for_copy_request || 186 target_is_only_for_copy_request ||
187 finished_target->filters().HasFilterThatAffectsOpacity()) { 187 finished_target->filters().HasFilterThatAffectsOpacity()) {
188 stack_.back().occlusion_from_outside_target.Clear(); 188 stack_.back().occlusion_from_outside_target.Clear();
189 stack_.back().occlusion_from_inside_target.Clear(); 189 stack_.back().occlusion_from_inside_target.Clear();
190 } 190 }
191 } 191 }
192 192
193 static void ReduceOcclusionBelowSurface( 193 static void ReduceOcclusionBelowSurface(
194 const LayerImpl* contributing_layer, 194 const LayerImpl* contributing_layer,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 const RenderSurfaceImpl* old_surface = stack_[last_index].target; 259 const RenderSurfaceImpl* old_surface = stack_[last_index].target;
260 const LayerImpl* old_target = 260 const LayerImpl* old_target =
261 new_target->layer_tree_impl()->LayerById(old_surface->OwningLayerId()); 261 new_target->layer_tree_impl()->LayerById(old_surface->OwningLayerId());
262 262
263 SimpleEnclosedRegion old_occlusion_from_inside_target_in_new_target = 263 SimpleEnclosedRegion old_occlusion_from_inside_target_in_new_target =
264 TransformSurfaceOpaqueRegion( 264 TransformSurfaceOpaqueRegion(
265 stack_[last_index].occlusion_from_inside_target, 265 stack_[last_index].occlusion_from_inside_target,
266 old_surface->is_clipped(), old_surface->clip_rect(), 266 old_surface->is_clipped(), old_surface->clip_rect(),
267 old_surface->draw_transform()); 267 old_surface->draw_transform());
268 if (old_target->has_replica() && !old_target->replica_has_mask()) { 268 if (old_surface->HasReplica() && !old_surface->HasReplicaMask()) {
269 old_occlusion_from_inside_target_in_new_target.Union( 269 old_occlusion_from_inside_target_in_new_target.Union(
270 TransformSurfaceOpaqueRegion( 270 TransformSurfaceOpaqueRegion(
271 stack_[last_index].occlusion_from_inside_target, 271 stack_[last_index].occlusion_from_inside_target,
272 old_surface->is_clipped(), old_surface->clip_rect(), 272 old_surface->is_clipped(), old_surface->clip_rect(),
273 old_surface->replica_draw_transform())); 273 old_surface->replica_draw_transform()));
274 } 274 }
275 275
276 SimpleEnclosedRegion old_occlusion_from_outside_target_in_new_target = 276 SimpleEnclosedRegion old_occlusion_from_outside_target_in_new_target =
277 TransformSurfaceOpaqueRegion( 277 TransformSurfaceOpaqueRegion(
278 stack_[last_index].occlusion_from_outside_target, false, gfx::Rect(), 278 stack_[last_index].occlusion_from_outside_target, false, gfx::Rect(),
279 old_surface->draw_transform()); 279 old_surface->draw_transform());
280 280
281 gfx::Rect unoccluded_surface_rect; 281 gfx::Rect unoccluded_surface_rect;
282 gfx::Rect unoccluded_replica_rect; 282 gfx::Rect unoccluded_replica_rect;
283 if (old_target->background_filters().HasFilterThatMovesPixels()) { 283 if (old_target->background_filters().HasFilterThatMovesPixels()) {
284 Occlusion surface_occlusion = GetCurrentOcclusionForContributingSurface( 284 Occlusion surface_occlusion = GetCurrentOcclusionForContributingSurface(
285 old_surface->draw_transform()); 285 old_surface->draw_transform());
286 unoccluded_surface_rect = 286 unoccluded_surface_rect =
287 surface_occlusion.GetUnoccludedContentRect(old_surface->content_rect()); 287 surface_occlusion.GetUnoccludedContentRect(old_surface->content_rect());
288 if (old_target->has_replica()) { 288 if (old_surface->HasReplica()) {
289 Occlusion replica_occlusion = GetCurrentOcclusionForContributingSurface( 289 Occlusion replica_occlusion = GetCurrentOcclusionForContributingSurface(
290 old_surface->replica_draw_transform()); 290 old_surface->replica_draw_transform());
291 unoccluded_replica_rect = replica_occlusion.GetUnoccludedContentRect( 291 unoccluded_replica_rect = replica_occlusion.GetUnoccludedContentRect(
292 old_surface->content_rect()); 292 old_surface->content_rect());
293 } 293 }
294 } 294 }
295 295
296 if (surface_will_be_at_top_after_pop) { 296 if (surface_will_be_at_top_after_pop) {
297 // Merge the top of the stack down. 297 // Merge the top of the stack down.
298 stack_[last_index - 1].occlusion_from_inside_target.Union( 298 stack_[last_index - 1].occlusion_from_inside_target.Union(
(...skipping 25 matching lines...) Expand all
324 unoccluded_surface_rect, 324 unoccluded_surface_rect,
325 old_surface->draw_transform(), 325 old_surface->draw_transform(),
326 new_target, 326 new_target,
327 &stack_.back().occlusion_from_inside_target); 327 &stack_.back().occlusion_from_inside_target);
328 ReduceOcclusionBelowSurface(old_target, 328 ReduceOcclusionBelowSurface(old_target,
329 unoccluded_surface_rect, 329 unoccluded_surface_rect,
330 old_surface->draw_transform(), 330 old_surface->draw_transform(),
331 new_target, 331 new_target,
332 &stack_.back().occlusion_from_outside_target); 332 &stack_.back().occlusion_from_outside_target);
333 333
334 if (!old_target->has_replica()) 334 if (!old_surface->HasReplica())
335 return; 335 return;
336 ReduceOcclusionBelowSurface(old_target, 336 ReduceOcclusionBelowSurface(old_target,
337 unoccluded_replica_rect, 337 unoccluded_replica_rect,
338 old_surface->replica_draw_transform(), 338 old_surface->replica_draw_transform(),
339 new_target, 339 new_target,
340 &stack_.back().occlusion_from_inside_target); 340 &stack_.back().occlusion_from_inside_target);
341 ReduceOcclusionBelowSurface(old_target, 341 ReduceOcclusionBelowSurface(old_target,
342 unoccluded_replica_rect, 342 unoccluded_replica_rect,
343 old_surface->replica_draw_transform(), 343 old_surface->replica_draw_transform(),
344 new_target, 344 new_target,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 DCHECK(layer_tree->root_layer()->render_surface() == stack_.back().target); 394 DCHECK(layer_tree->root_layer()->render_surface() == stack_.back().target);
395 const SimpleEnclosedRegion& occluded = 395 const SimpleEnclosedRegion& occluded =
396 stack_.back().occlusion_from_inside_target; 396 stack_.back().occlusion_from_inside_target;
397 Region visible_region(screen_space_clip_rect_); 397 Region visible_region(screen_space_clip_rect_);
398 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i) 398 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i)
399 visible_region.Subtract(occluded.GetRect(i)); 399 visible_region.Subtract(occluded.GetRect(i));
400 return visible_region; 400 return visible_region;
401 } 401 }
402 402
403 } // namespace cc 403 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl_unittest.cc ('k') | cc/trees/occlusion_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698