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

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

Issue 2099743002: cc: Move background filters to the effect tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ' Created 4 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
« no previous file with comments | « cc/trees/layer_tree_host_common_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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 if (surface->MaskLayer() || 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 RenderSurfaceImpl* contributing_surface,
195 const gfx::Rect& surface_rect, 195 const gfx::Rect& surface_rect,
196 const gfx::Transform& surface_transform, 196 const gfx::Transform& surface_transform,
197 const LayerImpl* render_target,
198 SimpleEnclosedRegion* occlusion_from_inside_target) { 197 SimpleEnclosedRegion* occlusion_from_inside_target) {
199 if (surface_rect.IsEmpty()) 198 if (surface_rect.IsEmpty())
200 return; 199 return;
201 200
202 gfx::Rect affected_area_in_target = 201 gfx::Rect affected_area_in_target =
203 MathUtil::MapEnclosingClippedRect(surface_transform, surface_rect); 202 MathUtil::MapEnclosingClippedRect(surface_transform, surface_rect);
204 if (contributing_layer->render_surface()->is_clipped()) { 203 if (contributing_surface->is_clipped()) {
205 affected_area_in_target.Intersect( 204 affected_area_in_target.Intersect(contributing_surface->clip_rect());
206 contributing_layer->render_surface()->clip_rect());
207 } 205 }
208 if (affected_area_in_target.IsEmpty()) 206 if (affected_area_in_target.IsEmpty())
209 return; 207 return;
210 208
211 int outset_top, outset_right, outset_bottom, outset_left; 209 int outset_top, outset_right, outset_bottom, outset_left;
212 contributing_layer->background_filters().GetOutsets( 210 contributing_surface->BackgroundFilters().GetOutsets(
213 &outset_top, &outset_right, &outset_bottom, &outset_left); 211 &outset_top, &outset_right, &outset_bottom, &outset_left);
214 212
215 // The filter can move pixels from outside of the clip, so allow affected_area 213 // The filter can move pixels from outside of the clip, so allow affected_area
216 // to expand outside the clip. 214 // to expand outside the clip.
217 affected_area_in_target.Inset( 215 affected_area_in_target.Inset(
218 -outset_left, -outset_top, -outset_right, -outset_bottom); 216 -outset_left, -outset_top, -outset_right, -outset_bottom);
219 SimpleEnclosedRegion affected_occlusion = *occlusion_from_inside_target; 217 SimpleEnclosedRegion affected_occlusion = *occlusion_from_inside_target;
220 affected_occlusion.Intersect(affected_area_in_target); 218 affected_occlusion.Intersect(affected_area_in_target);
221 219
222 occlusion_from_inside_target->Subtract(affected_area_in_target); 220 occlusion_from_inside_target->Subtract(affected_area_in_target);
(...skipping 27 matching lines...) Expand all
250 DCHECK(new_target->has_render_surface()); 248 DCHECK(new_target->has_render_surface());
251 bool surface_will_be_at_top_after_pop = 249 bool surface_will_be_at_top_after_pop =
252 stack_.size() > 1 && 250 stack_.size() > 1 &&
253 stack_[last_index - 1].target == new_target->render_surface(); 251 stack_[last_index - 1].target == new_target->render_surface();
254 252
255 // We merge the screen occlusion from the current RenderSurfaceImpl subtree 253 // We merge the screen occlusion from the current RenderSurfaceImpl subtree
256 // out to its parent target RenderSurfaceImpl. The target occlusion can be 254 // out to its parent target RenderSurfaceImpl. The target occlusion can be
257 // merged out as well but needs to be transformed to the new target. 255 // merged out as well but needs to be transformed to the new target.
258 256
259 const RenderSurfaceImpl* old_surface = stack_[last_index].target; 257 const RenderSurfaceImpl* old_surface = stack_[last_index].target;
260 const LayerImpl* old_target =
261 new_target->layer_tree_impl()->LayerById(old_surface->OwningLayerId());
262 258
263 SimpleEnclosedRegion old_occlusion_from_inside_target_in_new_target = 259 SimpleEnclosedRegion old_occlusion_from_inside_target_in_new_target =
264 TransformSurfaceOpaqueRegion( 260 TransformSurfaceOpaqueRegion(
265 stack_[last_index].occlusion_from_inside_target, 261 stack_[last_index].occlusion_from_inside_target,
266 old_surface->is_clipped(), old_surface->clip_rect(), 262 old_surface->is_clipped(), old_surface->clip_rect(),
267 old_surface->draw_transform()); 263 old_surface->draw_transform());
268 if (old_surface->HasReplica() && !old_surface->HasReplicaMask()) { 264 if (old_surface->HasReplica() && !old_surface->HasReplicaMask()) {
269 old_occlusion_from_inside_target_in_new_target.Union( 265 old_occlusion_from_inside_target_in_new_target.Union(
270 TransformSurfaceOpaqueRegion( 266 TransformSurfaceOpaqueRegion(
271 stack_[last_index].occlusion_from_inside_target, 267 stack_[last_index].occlusion_from_inside_target,
272 old_surface->is_clipped(), old_surface->clip_rect(), 268 old_surface->is_clipped(), old_surface->clip_rect(),
273 old_surface->replica_draw_transform())); 269 old_surface->replica_draw_transform()));
274 } 270 }
275 271
276 SimpleEnclosedRegion old_occlusion_from_outside_target_in_new_target = 272 SimpleEnclosedRegion old_occlusion_from_outside_target_in_new_target =
277 TransformSurfaceOpaqueRegion( 273 TransformSurfaceOpaqueRegion(
278 stack_[last_index].occlusion_from_outside_target, false, gfx::Rect(), 274 stack_[last_index].occlusion_from_outside_target, false, gfx::Rect(),
279 old_surface->draw_transform()); 275 old_surface->draw_transform());
280 276
281 gfx::Rect unoccluded_surface_rect; 277 gfx::Rect unoccluded_surface_rect;
282 gfx::Rect unoccluded_replica_rect; 278 gfx::Rect unoccluded_replica_rect;
283 if (old_target->background_filters().HasFilterThatMovesPixels()) { 279 if (old_surface->BackgroundFilters().HasFilterThatMovesPixels()) {
284 Occlusion surface_occlusion = GetCurrentOcclusionForContributingSurface( 280 Occlusion surface_occlusion = GetCurrentOcclusionForContributingSurface(
285 old_surface->draw_transform()); 281 old_surface->draw_transform());
286 unoccluded_surface_rect = 282 unoccluded_surface_rect =
287 surface_occlusion.GetUnoccludedContentRect(old_surface->content_rect()); 283 surface_occlusion.GetUnoccludedContentRect(old_surface->content_rect());
288 if (old_surface->HasReplica()) { 284 if (old_surface->HasReplica()) {
289 Occlusion replica_occlusion = GetCurrentOcclusionForContributingSurface( 285 Occlusion replica_occlusion = GetCurrentOcclusionForContributingSurface(
290 old_surface->replica_draw_transform()); 286 old_surface->replica_draw_transform());
291 unoccluded_replica_rect = replica_occlusion.GetUnoccludedContentRect( 287 unoccluded_replica_rect = replica_occlusion.GetUnoccludedContentRect(
292 old_surface->content_rect()); 288 old_surface->content_rect());
293 } 289 }
(...skipping 16 matching lines...) Expand all
310 stack_.back().occlusion_from_inside_target = 306 stack_.back().occlusion_from_inside_target =
311 old_occlusion_from_inside_target_in_new_target; 307 old_occlusion_from_inside_target_in_new_target;
312 if (!new_target->layer_tree_impl()->IsRootLayer(new_target)) { 308 if (!new_target->layer_tree_impl()->IsRootLayer(new_target)) {
313 stack_.back().occlusion_from_outside_target = 309 stack_.back().occlusion_from_outside_target =
314 old_occlusion_from_outside_target_in_new_target; 310 old_occlusion_from_outside_target_in_new_target;
315 } else { 311 } else {
316 stack_.back().occlusion_from_outside_target.Clear(); 312 stack_.back().occlusion_from_outside_target.Clear();
317 } 313 }
318 } 314 }
319 315
320 if (!old_target->background_filters().HasFilterThatMovesPixels()) 316 if (!old_surface->BackgroundFilters().HasFilterThatMovesPixels())
321 return; 317 return;
322 318
323 ReduceOcclusionBelowSurface(old_target, 319 ReduceOcclusionBelowSurface(old_surface, unoccluded_surface_rect,
324 unoccluded_surface_rect,
325 old_surface->draw_transform(), 320 old_surface->draw_transform(),
326 new_target,
327 &stack_.back().occlusion_from_inside_target); 321 &stack_.back().occlusion_from_inside_target);
328 ReduceOcclusionBelowSurface(old_target, 322 ReduceOcclusionBelowSurface(old_surface, unoccluded_surface_rect,
329 unoccluded_surface_rect,
330 old_surface->draw_transform(), 323 old_surface->draw_transform(),
331 new_target,
332 &stack_.back().occlusion_from_outside_target); 324 &stack_.back().occlusion_from_outside_target);
333 325
334 if (!old_surface->HasReplica()) 326 if (!old_surface->HasReplica())
335 return; 327 return;
336 ReduceOcclusionBelowSurface(old_target, 328 ReduceOcclusionBelowSurface(old_surface, unoccluded_replica_rect,
337 unoccluded_replica_rect,
338 old_surface->replica_draw_transform(), 329 old_surface->replica_draw_transform(),
339 new_target,
340 &stack_.back().occlusion_from_inside_target); 330 &stack_.back().occlusion_from_inside_target);
341 ReduceOcclusionBelowSurface(old_target, 331 ReduceOcclusionBelowSurface(old_surface, unoccluded_replica_rect,
342 unoccluded_replica_rect,
343 old_surface->replica_draw_transform(), 332 old_surface->replica_draw_transform(),
344 new_target,
345 &stack_.back().occlusion_from_outside_target); 333 &stack_.back().occlusion_from_outside_target);
346 } 334 }
347 335
348 void OcclusionTracker::MarkOccludedBehindLayer(const LayerImpl* layer) { 336 void OcclusionTracker::MarkOccludedBehindLayer(const LayerImpl* layer) {
349 DCHECK(!stack_.empty()); 337 DCHECK(!stack_.empty());
350 DCHECK_EQ(layer->render_target(), stack_.back().target); 338 DCHECK_EQ(layer->render_target(), stack_.back().target);
351 339
352 if (layer->draw_opacity() < 1) 340 if (layer->draw_opacity() < 1)
353 return; 341 return;
354 342
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 DCHECK(layer_tree->RootRenderSurface() == stack_.back().target); 382 DCHECK(layer_tree->RootRenderSurface() == stack_.back().target);
395 const SimpleEnclosedRegion& occluded = 383 const SimpleEnclosedRegion& occluded =
396 stack_.back().occlusion_from_inside_target; 384 stack_.back().occlusion_from_inside_target;
397 Region visible_region(screen_space_clip_rect_); 385 Region visible_region(screen_space_clip_rect_);
398 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i) 386 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i)
399 visible_region.Subtract(occluded.GetRect(i)); 387 visible_region.Subtract(occluded.GetRect(i));
400 return visible_region; 388 return visible_region;
401 } 389 }
402 390
403 } // namespace cc 391 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common_unittest.cc ('k') | cc/trees/occlusion_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698