| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
| 10 #include "cc/debug/overdraw_metrics.h" | 10 #include "cc/debug/overdraw_metrics.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 222 |
| 223 RenderSurfaceType* surface = finished_target->render_surface(); | 223 RenderSurfaceType* surface = finished_target->render_surface(); |
| 224 | 224 |
| 225 // If the occlusion within the surface can not be applied to things outside of | 225 // If the occlusion within the surface can not be applied to things outside of |
| 226 // the surface's subtree, then clear the occlusion here so it won't be used. | 226 // the surface's subtree, then clear the occlusion here so it won't be used. |
| 227 // TODO(senorblanco): Make this smarter for SkImageFilter case: once | 227 // TODO(senorblanco): Make this smarter for SkImageFilter case: once |
| 228 // SkImageFilters can report affectsOpacity(), call that. | 228 // SkImageFilters can report affectsOpacity(), call that. |
| 229 if (finished_target->mask_layer() || | 229 if (finished_target->mask_layer() || |
| 230 !SurfaceOpacityKnown(surface) || | 230 !SurfaceOpacityKnown(surface) || |
| 231 surface->draw_opacity() < 1 || | 231 surface->draw_opacity() < 1 || |
| 232 finished_target->filters().hasFilterThatAffectsOpacity() || | 232 finished_target->filters().HasFilterThatAffectsOpacity() || |
| 233 finished_target->filter()) { | 233 finished_target->filter()) { |
| 234 stack_.back().occlusion_from_outside_target.Clear(); | 234 stack_.back().occlusion_from_outside_target.Clear(); |
| 235 stack_.back().occlusion_from_inside_target.Clear(); | 235 stack_.back().occlusion_from_inside_target.Clear(); |
| 236 } else if (!SurfaceTransformsToTargetKnown(surface)) { | 236 } else if (!SurfaceTransformsToTargetKnown(surface)) { |
| 237 stack_.back().occlusion_from_inside_target.Clear(); | 237 stack_.back().occlusion_from_inside_target.Clear(); |
| 238 stack_.back().occlusion_from_outside_target.Clear(); | 238 stack_.back().occlusion_from_outside_target.Clear(); |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 template <typename LayerType> | 242 template <typename LayerType> |
| 243 static void ReduceOcclusionBelowSurface(LayerType* contributing_layer, | 243 static void ReduceOcclusionBelowSurface(LayerType* contributing_layer, |
| 244 gfx::Rect surface_rect, | 244 gfx::Rect surface_rect, |
| 245 const gfx::Transform& surface_transform, | 245 const gfx::Transform& surface_transform, |
| 246 LayerType* render_target, | 246 LayerType* render_target, |
| 247 Region* occlusion_from_inside_target) { | 247 Region* occlusion_from_inside_target) { |
| 248 if (surface_rect.IsEmpty()) | 248 if (surface_rect.IsEmpty()) |
| 249 return; | 249 return; |
| 250 | 250 |
| 251 gfx::Rect affected_area_in_target = gfx::ToEnclosingRect( | 251 gfx::Rect affected_area_in_target = gfx::ToEnclosingRect( |
| 252 MathUtil::MapClippedRect(surface_transform, gfx::RectF(surface_rect))); | 252 MathUtil::MapClippedRect(surface_transform, gfx::RectF(surface_rect))); |
| 253 if (contributing_layer->render_surface()->is_clipped()) { | 253 if (contributing_layer->render_surface()->is_clipped()) { |
| 254 affected_area_in_target.Intersect( | 254 affected_area_in_target.Intersect( |
| 255 contributing_layer->render_surface()->clip_rect()); | 255 contributing_layer->render_surface()->clip_rect()); |
| 256 } | 256 } |
| 257 if (affected_area_in_target.IsEmpty()) | 257 if (affected_area_in_target.IsEmpty()) |
| 258 return; | 258 return; |
| 259 | 259 |
| 260 int outset_top, outset_right, outset_bottom, outset_left; | 260 int outset_top, outset_right, outset_bottom, outset_left; |
| 261 contributing_layer->background_filters().getOutsets( | 261 contributing_layer->background_filters().GetOutsets( |
| 262 outset_top, outset_right, outset_bottom, outset_left); | 262 &outset_top, &outset_right, &outset_bottom, &outset_left); |
| 263 | 263 |
| 264 // The filter can move pixels from outside of the clip, so allow affected_area | 264 // The filter can move pixels from outside of the clip, so allow affected_area |
| 265 // to expand outside the clip. | 265 // to expand outside the clip. |
| 266 affected_area_in_target.Inset( | 266 affected_area_in_target.Inset( |
| 267 -outset_left, -outset_top, -outset_right, -outset_bottom); | 267 -outset_left, -outset_top, -outset_right, -outset_bottom); |
| 268 | 268 |
| 269 gfx::Rect FilterOutsetsInTarget(-outset_left, | 269 gfx::Rect FilterOutsetsInTarget(-outset_left, |
| 270 -outset_top, | 270 -outset_top, |
| 271 outset_left + outset_right, | 271 outset_left + outset_right, |
| 272 outset_top + outset_bottom); | 272 outset_top + outset_bottom); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 331 |
| 332 Region old_occlusion_from_outside_target_in_new_target = | 332 Region old_occlusion_from_outside_target_in_new_target = |
| 333 TransformSurfaceOpaqueRegion<RenderSurfaceType>( | 333 TransformSurfaceOpaqueRegion<RenderSurfaceType>( |
| 334 stack_[last_index].occlusion_from_outside_target, | 334 stack_[last_index].occlusion_from_outside_target, |
| 335 false, | 335 false, |
| 336 gfx::Rect(), | 336 gfx::Rect(), |
| 337 old_surface->draw_transform()); | 337 old_surface->draw_transform()); |
| 338 | 338 |
| 339 gfx::Rect unoccluded_surface_rect; | 339 gfx::Rect unoccluded_surface_rect; |
| 340 gfx::Rect unoccluded_replica_rect; | 340 gfx::Rect unoccluded_replica_rect; |
| 341 if (old_target->background_filters().hasFilterThatMovesPixels()) { | 341 if (old_target->background_filters().HasFilterThatMovesPixels()) { |
| 342 unoccluded_surface_rect = UnoccludedContributingSurfaceContentRect( | 342 unoccluded_surface_rect = UnoccludedContributingSurfaceContentRect( |
| 343 old_target, false, old_surface->content_rect(), NULL); | 343 old_target, false, old_surface->content_rect(), NULL); |
| 344 if (old_target->has_replica()) { | 344 if (old_target->has_replica()) { |
| 345 unoccluded_replica_rect = UnoccludedContributingSurfaceContentRect( | 345 unoccluded_replica_rect = UnoccludedContributingSurfaceContentRect( |
| 346 old_target, true, old_surface->content_rect(), NULL); | 346 old_target, true, old_surface->content_rect(), NULL); |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 | 349 |
| 350 if (surface_will_be_at_top_after_pop) { | 350 if (surface_will_be_at_top_after_pop) { |
| 351 // Merge the top of the stack down. | 351 // Merge the top of the stack down. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 364 stack_.back().occlusion_from_inside_target = | 364 stack_.back().occlusion_from_inside_target = |
| 365 old_occlusion_from_inside_target_in_new_target; | 365 old_occlusion_from_inside_target_in_new_target; |
| 366 if (new_target->parent()) { | 366 if (new_target->parent()) { |
| 367 stack_.back().occlusion_from_outside_target = | 367 stack_.back().occlusion_from_outside_target = |
| 368 old_occlusion_from_outside_target_in_new_target; | 368 old_occlusion_from_outside_target_in_new_target; |
| 369 } else { | 369 } else { |
| 370 stack_.back().occlusion_from_outside_target.Clear(); | 370 stack_.back().occlusion_from_outside_target.Clear(); |
| 371 } | 371 } |
| 372 } | 372 } |
| 373 | 373 |
| 374 if (!old_target->background_filters().hasFilterThatMovesPixels()) | 374 if (!old_target->background_filters().HasFilterThatMovesPixels()) |
| 375 return; | 375 return; |
| 376 | 376 |
| 377 ReduceOcclusionBelowSurface(old_target, | 377 ReduceOcclusionBelowSurface(old_target, |
| 378 unoccluded_surface_rect, | 378 unoccluded_surface_rect, |
| 379 old_surface->draw_transform(), | 379 old_surface->draw_transform(), |
| 380 new_target, | 380 new_target, |
| 381 &stack_.back().occlusion_from_inside_target); | 381 &stack_.back().occlusion_from_inside_target); |
| 382 ReduceOcclusionBelowSurface(old_target, | 382 ReduceOcclusionBelowSurface(old_target, |
| 383 unoccluded_surface_rect, | 383 unoccluded_surface_rect, |
| 384 old_surface->draw_transform(), | 384 old_surface->draw_transform(), |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 } | 728 } |
| 729 | 729 |
| 730 return unoccluded_rect; | 730 return unoccluded_rect; |
| 731 } | 731 } |
| 732 | 732 |
| 733 // Instantiate (and export) templates here for the linker. | 733 // Instantiate (and export) templates here for the linker. |
| 734 template class OcclusionTrackerBase<Layer, RenderSurface>; | 734 template class OcclusionTrackerBase<Layer, RenderSurface>; |
| 735 template class OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>; | 735 template class OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>; |
| 736 | 736 |
| 737 } // namespace cc | 737 } // namespace cc |
| OLD | NEW |