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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 affected_area_in_target.Intersect( | 246 affected_area_in_target.Intersect( |
247 contributing_layer->render_surface()->clip_rect()); | 247 contributing_layer->render_surface()->clip_rect()); |
248 } | 248 } |
249 if (affected_area_in_target.IsEmpty()) | 249 if (affected_area_in_target.IsEmpty()) |
250 return; | 250 return; |
251 | 251 |
252 int outset_top, outset_right, outset_bottom, outset_left; | 252 int outset_top, outset_right, outset_bottom, outset_left; |
253 contributing_layer->background_filters().getOutsets( | 253 contributing_layer->background_filters().getOutsets( |
254 outset_top, outset_right, outset_bottom, outset_left); | 254 outset_top, outset_right, outset_bottom, outset_left); |
255 | 255 |
256 // The filter can move pixels from outside of the clip, so allow affectedArea | 256 // The filter can move pixels from outside of the clip, so allow affected_area |
257 // to expand outside the clip. | 257 // to expand outside the clip. |
258 affected_area_in_target.Inset( | 258 affected_area_in_target.Inset( |
259 -outset_left, -outset_top, -outset_right, -outset_bottom); | 259 -outset_left, -outset_top, -outset_right, -outset_bottom); |
260 | 260 |
261 gfx::Rect FilterOutsetsInTarget(-outset_left, | 261 gfx::Rect FilterOutsetsInTarget(-outset_left, |
262 -outset_top, | 262 -outset_top, |
263 outset_left + outset_right, | 263 outset_left + outset_right, |
264 outset_top + outset_bottom); | 264 outset_top + outset_bottom); |
265 | 265 |
266 Region affected_occlusion = IntersectRegions(*occlusion_from_inside_target, | 266 Region affected_occlusion = IntersectRegions(*occlusion_from_inside_target, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 layer->draw_transform(), gfx::QuadF(opaque_contents.bounds()), &clipped); | 419 layer->draw_transform(), gfx::QuadF(opaque_contents.bounds()), &clipped); |
420 // FIXME: Find a rect interior to each transformed quad. | 420 // FIXME: Find a rect interior to each transformed quad. |
421 if (clipped || !visible_transformed_quad.IsRectilinear()) | 421 if (clipped || !visible_transformed_quad.IsRectilinear()) |
422 return; | 422 return; |
423 | 423 |
424 gfx::Rect clip_rect_in_target = gfx::IntersectRects( | 424 gfx::Rect clip_rect_in_target = gfx::IntersectRects( |
425 layer->render_target()->render_surface()->content_rect(), | 425 layer->render_target()->render_surface()->content_rect(), |
426 ScreenSpaceClipRectInTargetSurface( | 426 ScreenSpaceClipRectInTargetSurface( |
427 layer->render_target()->render_surface(), screen_space_clip_rect_)); | 427 layer->render_target()->render_surface(), screen_space_clip_rect_)); |
428 | 428 |
429 for (Region::Iterator opaqueContentRects(opaque_contents); | 429 for (Region::Iterator opaque_content_rects(opaque_contents); |
430 opaqueContentRects.has_rect(); | 430 opaque_content_rects.has_rect(); |
431 opaqueContentRects.next()) { | 431 opaque_content_rects.next()) { |
432 gfx::QuadF transformed_quad = MathUtil::MapQuad( | 432 gfx::QuadF transformed_quad = MathUtil::MapQuad( |
433 layer->draw_transform(), | 433 layer->draw_transform(), |
434 gfx::QuadF(opaqueContentRects.rect()), | 434 gfx::QuadF(opaque_content_rects.rect()), |
435 &clipped); | 435 &clipped); |
436 gfx::Rect transformed_rect = | 436 gfx::Rect transformed_rect = |
437 gfx::ToEnclosedRect(transformed_quad.BoundingBox()); | 437 gfx::ToEnclosedRect(transformed_quad.BoundingBox()); |
438 DCHECK(!clipped); // We only map if the transform preserves axis alignment. | 438 DCHECK(!clipped); // We only map if the transform preserves axis alignment. |
439 transformed_rect.Intersect(clip_rect_in_target); | 439 transformed_rect.Intersect(clip_rect_in_target); |
440 if (transformed_rect.width() < minimum_tracking_size_.width() && | 440 if (transformed_rect.width() < minimum_tracking_size_.width() && |
441 transformed_rect.height() < minimum_tracking_size_.height()) | 441 transformed_rect.height() < minimum_tracking_size_.height()) |
442 continue; | 442 continue; |
443 stack_.back().occlusion_from_inside_target.Union(transformed_rect); | 443 stack_.back().occlusion_from_inside_target.Union(transformed_rect); |
444 | 444 |
445 if (!occluding_screen_space_rects_) | 445 if (!occluding_screen_space_rects_) |
446 continue; | 446 continue; |
447 | 447 |
448 // Save the occluding area in screen space for debug visualization. | 448 // Save the occluding area in screen space for debug visualization. |
449 gfx::QuadF screen_space_quad = MathUtil::MapQuad( | 449 gfx::QuadF screen_space_quad = MathUtil::MapQuad( |
450 layer->render_target()->render_surface()->screen_space_transform(), | 450 layer->render_target()->render_surface()->screen_space_transform(), |
451 gfx::QuadF(transformed_rect), &clipped); | 451 gfx::QuadF(transformed_rect), &clipped); |
452 // TODO(danakj): Store the quad in the debug info instead of the bounding | 452 // TODO(danakj): Store the quad in the debug info instead of the bounding |
453 // box. | 453 // box. |
454 gfx::Rect screen_space_rect = | 454 gfx::Rect screen_space_rect = |
455 gfx::ToEnclosedRect(screen_space_quad.BoundingBox()); | 455 gfx::ToEnclosedRect(screen_space_quad.BoundingBox()); |
456 occluding_screen_space_rects_->push_back(screen_space_rect); | 456 occluding_screen_space_rects_->push_back(screen_space_rect); |
457 } | 457 } |
458 | 458 |
459 if (!non_occluding_screen_space_rects_) | 459 if (!non_occluding_screen_space_rects_) |
460 return; | 460 return; |
461 | 461 |
462 Region non_opaque_contents = | 462 Region non_opaque_contents = |
463 SubtractRegions(gfx::Rect(layer->content_bounds()), opaque_contents); | 463 SubtractRegions(gfx::Rect(layer->content_bounds()), opaque_contents); |
464 for (Region::Iterator nonOpaqueContentRects(non_opaque_contents); | 464 for (Region::Iterator non_opaque_content_rects(non_opaque_contents); |
465 nonOpaqueContentRects.has_rect(); | 465 non_opaque_content_rects.has_rect(); |
466 nonOpaqueContentRects.next()) { | 466 non_opaque_content_rects.next()) { |
467 // We've already checked for clipping in the mapQuad call above, these calls | 467 // We've already checked for clipping in the MapQuad call above, these calls |
468 // should not clip anything further. | 468 // should not clip anything further. |
469 gfx::Rect transformed_rect = gfx::ToEnclosedRect( | 469 gfx::Rect transformed_rect = gfx::ToEnclosedRect( |
470 MathUtil::MapClippedRect(layer->draw_transform(), | 470 MathUtil::MapClippedRect(layer->draw_transform(), |
471 gfx::RectF(nonOpaqueContentRects.rect()))); | 471 gfx::RectF(non_opaque_content_rects.rect()))); |
472 transformed_rect.Intersect(clip_rect_in_target); | 472 transformed_rect.Intersect(clip_rect_in_target); |
473 if (transformed_rect.IsEmpty()) | 473 if (transformed_rect.IsEmpty()) |
474 continue; | 474 continue; |
475 | 475 |
476 gfx::QuadF screen_space_quad = MathUtil::MapQuad( | 476 gfx::QuadF screen_space_quad = MathUtil::MapQuad( |
477 layer->render_target()->render_surface()->screen_space_transform(), | 477 layer->render_target()->render_surface()->screen_space_transform(), |
478 gfx::QuadF(transformed_rect), | 478 gfx::QuadF(transformed_rect), |
479 &clipped); | 479 &clipped); |
480 // TODO(danakj): Store the quad in the debug info instead of the bounding | 480 // TODO(danakj): Store the quad in the debug info instead of the bounding |
481 // box. | 481 // box. |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 } | 709 } |
710 | 710 |
711 return unoccluded_rect; | 711 return unoccluded_rect; |
712 } | 712 } |
713 | 713 |
714 // Instantiate (and export) templates here for the linker. | 714 // Instantiate (and export) templates here for the linker. |
715 template class OcclusionTrackerBase<Layer, RenderSurface>; | 715 template class OcclusionTrackerBase<Layer, RenderSurface>; |
716 template class OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>; | 716 template class OcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>; |
717 | 717 |
718 } // namespace cc | 718 } // namespace cc |
OLD | NEW |