Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 return; | 214 return; |
| 215 | 215 |
| 216 gfx::Rect affected_area_in_target = | 216 gfx::Rect affected_area_in_target = |
| 217 MathUtil::MapEnclosingClippedRect(surface_transform, surface_rect); | 217 MathUtil::MapEnclosingClippedRect(surface_transform, surface_rect); |
| 218 if (contributing_surface->is_clipped()) { | 218 if (contributing_surface->is_clipped()) { |
| 219 affected_area_in_target.Intersect(contributing_surface->clip_rect()); | 219 affected_area_in_target.Intersect(contributing_surface->clip_rect()); |
| 220 } | 220 } |
| 221 if (affected_area_in_target.IsEmpty()) | 221 if (affected_area_in_target.IsEmpty()) |
| 222 return; | 222 return; |
| 223 | 223 |
| 224 // The filter's bounds for asymmetric filters (ex: background filter) are | |
|
danakj
2017/05/23 17:49:23
asymmetric background filters (ex: drop shadow)
| |
| 225 // relative to the target surface, which moves the pixels from outside of the | |
| 226 // clip to the filtered surface. As a result, |affected_area| needs to expand. | |
| 227 // Since we are concerned with the target surface, we need to swap the outsets | |
| 228 // before applying them to the filtered surface bounds. | |
| 224 int outset_top, outset_right, outset_bottom, outset_left; | 229 int outset_top, outset_right, outset_bottom, outset_left; |
| 225 contributing_surface->BackgroundFilters().GetOutsets( | 230 contributing_surface->BackgroundFilters().GetOutsets( |
| 226 &outset_top, &outset_right, &outset_bottom, &outset_left); | 231 &outset_bottom, &outset_left, &outset_top, &outset_right); |
| 227 | 232 |
| 228 // The filter can move pixels from outside of the clip, so allow affected_area | 233 affected_area_in_target.Inset(-outset_left, -outset_top, -outset_right, |
| 229 // to expand outside the clip. Notably the content we're concerned with here | 234 -outset_bottom); |
| 230 // is not the affected area, but rather stuff slightly outside it. Thus the | |
| 231 // directions of the outsets are reversed from normal. | |
| 232 affected_area_in_target.Inset(-outset_right, -outset_bottom, -outset_left, | |
| 233 -outset_top); | |
| 234 SimpleEnclosedRegion affected_occlusion = *occlusion_from_inside_target; | 235 SimpleEnclosedRegion affected_occlusion = *occlusion_from_inside_target; |
| 235 affected_occlusion.Intersect(affected_area_in_target); | 236 affected_occlusion.Intersect(affected_area_in_target); |
| 236 | 237 |
| 237 occlusion_from_inside_target->Subtract(affected_area_in_target); | 238 occlusion_from_inside_target->Subtract(affected_area_in_target); |
| 238 for (size_t i = 0; i < affected_occlusion.GetRegionComplexity(); ++i) { | 239 for (size_t i = 0; i < affected_occlusion.GetRegionComplexity(); ++i) { |
| 239 gfx::Rect occlusion_rect = affected_occlusion.GetRect(i); | 240 gfx::Rect occlusion_rect = affected_occlusion.GetRect(i); |
| 240 | 241 |
| 241 // Shrink the rect by expanding the non-opaque pixels outside the rect. | 242 // Shrink the rect by expanding the non-opaque pixels outside the rect. |
| 242 | 243 |
| 243 // The left outset of the filters moves pixels on the right side of | 244 // The left outset of the filters moves pixels on the right side of |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 DCHECK(layer_tree->RootRenderSurface() == stack_.back().target); | 375 DCHECK(layer_tree->RootRenderSurface() == stack_.back().target); |
| 375 const SimpleEnclosedRegion& occluded = | 376 const SimpleEnclosedRegion& occluded = |
| 376 stack_.back().occlusion_from_inside_target; | 377 stack_.back().occlusion_from_inside_target; |
| 377 Region visible_region(screen_space_clip_rect_); | 378 Region visible_region(screen_space_clip_rect_); |
| 378 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i) | 379 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i) |
| 379 visible_region.Subtract(occluded.GetRect(i)); | 380 visible_region.Subtract(occluded.GetRect(i)); |
| 380 return visible_region; | 381 return visible_region; |
| 381 } | 382 } |
| 382 | 383 |
| 383 } // namespace cc | 384 } // namespace cc |
| OLD | NEW |