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

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

Issue 495873002: cc: Stop converting Rect to QuadF to map to an enclosed rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: enclosed: . Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « cc/base/math_util_unittest.cc ('k') | no next file » | 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/base/region.h" 10 #include "cc/base/region.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Verify that rects within the |surface| will remain rects in its target 77 // Verify that rects within the |surface| will remain rects in its target
78 // surface after applying |transform|. If this is true, then apply |transform| 78 // surface after applying |transform|. If this is true, then apply |transform|
79 // to each rect within |region| in order to transform the entire Region. 79 // to each rect within |region| in order to transform the entire Region.
80 80
81 // TODO(danakj): Find a rect interior to each transformed quad. 81 // TODO(danakj): Find a rect interior to each transformed quad.
82 if (!transform.Preserves2dAxisAlignment()) 82 if (!transform.Preserves2dAxisAlignment())
83 return SimpleEnclosedRegion(); 83 return SimpleEnclosedRegion();
84 84
85 SimpleEnclosedRegion transformed_region; 85 SimpleEnclosedRegion transformed_region;
86 for (size_t i = 0; i < region.GetRegionComplexity(); ++i) { 86 for (size_t i = 0; i < region.GetRegionComplexity(); ++i) {
87 bool clipped;
88 gfx::QuadF transformed_quad =
89 MathUtil::MapQuad(transform, gfx::QuadF(region.GetRect(i)), &clipped);
90 gfx::Rect transformed_rect = 87 gfx::Rect transformed_rect =
91 gfx::ToEnclosedRect(transformed_quad.BoundingBox()); 88 MathUtil::MapEnclosedRectWith2dAxisAlignedTransform(transform,
92 DCHECK(!clipped); // We only map if the transform preserves axis alignment. 89 region.GetRect(i));
93 if (have_clip_rect) 90 if (have_clip_rect)
94 transformed_rect.Intersect(clip_rect_in_new_target); 91 transformed_rect.Intersect(clip_rect_in_new_target);
95 transformed_region.Union(transformed_rect); 92 transformed_region.Union(transformed_rect);
96 } 93 }
97 return transformed_region; 94 return transformed_region;
98 } 95 }
99 96
100 static inline bool LayerOpacityKnown(const Layer* layer) { 97 static inline bool LayerOpacityKnown(const Layer* layer) {
101 return !layer->draw_opacity_is_animating(); 98 return !layer->draw_opacity_is_animating();
102 } 99 }
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 gfx::Rect clip_rect_in_target = ScreenSpaceClipRectInTargetSurface( 422 gfx::Rect clip_rect_in_target = ScreenSpaceClipRectInTargetSurface(
426 layer->render_target()->render_surface(), screen_space_clip_rect_); 423 layer->render_target()->render_surface(), screen_space_clip_rect_);
427 if (layer->is_clipped()) { 424 if (layer->is_clipped()) {
428 clip_rect_in_target.Intersect(layer->clip_rect()); 425 clip_rect_in_target.Intersect(layer->clip_rect());
429 } else { 426 } else {
430 clip_rect_in_target.Intersect( 427 clip_rect_in_target.Intersect(
431 layer->render_target()->render_surface()->content_rect()); 428 layer->render_target()->render_surface()->content_rect());
432 } 429 }
433 430
434 for (size_t i = 0; i < opaque_contents.GetRegionComplexity(); ++i) { 431 for (size_t i = 0; i < opaque_contents.GetRegionComplexity(); ++i) {
435 bool clipped;
436 gfx::QuadF transformed_quad =
437 MathUtil::MapQuad(layer->draw_transform(),
438 gfx::QuadF(opaque_contents.GetRect(i)),
439 &clipped);
440 gfx::Rect transformed_rect = 432 gfx::Rect transformed_rect =
441 gfx::ToEnclosedRect(transformed_quad.BoundingBox()); 433 MathUtil::MapEnclosedRectWith2dAxisAlignedTransform(
442 DCHECK(!clipped); // We only map if the transform preserves axis alignment. 434 layer->draw_transform(), opaque_contents.GetRect(i));
443 transformed_rect.Intersect(clip_rect_in_target); 435 transformed_rect.Intersect(clip_rect_in_target);
444 if (transformed_rect.width() < minimum_tracking_size_.width() && 436 if (transformed_rect.width() < minimum_tracking_size_.width() &&
445 transformed_rect.height() < minimum_tracking_size_.height()) 437 transformed_rect.height() < minimum_tracking_size_.height())
446 continue; 438 continue;
447 stack_.back().occlusion_from_inside_target.Union(transformed_rect); 439 stack_.back().occlusion_from_inside_target.Union(transformed_rect);
448 440
449 if (!occluding_screen_space_rects_) 441 if (!occluding_screen_space_rects_)
450 continue; 442 continue;
451 443
452 // Save the occluding area in screen space for debug visualization. 444 // Save the occluding area in screen space for debug visualization.
445 bool clipped;
453 gfx::QuadF screen_space_quad = MathUtil::MapQuad( 446 gfx::QuadF screen_space_quad = MathUtil::MapQuad(
454 layer->render_target()->render_surface()->screen_space_transform(), 447 layer->render_target()->render_surface()->screen_space_transform(),
455 gfx::QuadF(transformed_rect), &clipped); 448 gfx::QuadF(transformed_rect), &clipped);
456 // TODO(danakj): Store the quad in the debug info instead of the bounding 449 // TODO(danakj): Store the quad in the debug info instead of the bounding
457 // box. 450 // box.
458 gfx::Rect screen_space_rect = 451 gfx::Rect screen_space_rect =
459 gfx::ToEnclosedRect(screen_space_quad.BoundingBox()); 452 gfx::ToEnclosedRect(screen_space_quad.BoundingBox());
460 occluding_screen_space_rects_->push_back(screen_space_rect); 453 occluding_screen_space_rects_->push_back(screen_space_rect);
461 } 454 }
462 455
463 if (!non_occluding_screen_space_rects_) 456 if (!non_occluding_screen_space_rects_)
464 return; 457 return;
465 458
466 Region non_opaque_contents(gfx::Rect(layer->content_bounds())); 459 Region non_opaque_contents(gfx::Rect(layer->content_bounds()));
467 non_opaque_contents.Subtract(opaque_contents); 460 non_opaque_contents.Subtract(opaque_contents);
468 461
469 for (Region::Iterator non_opaque_content_rects(non_opaque_contents); 462 for (Region::Iterator non_opaque_content_rects(non_opaque_contents);
470 non_opaque_content_rects.has_rect(); 463 non_opaque_content_rects.has_rect();
471 non_opaque_content_rects.next()) { 464 non_opaque_content_rects.next()) {
472 // We've already checked for clipping in the MapQuad call above, these calls 465 gfx::Rect transformed_rect =
473 // should not clip anything further. 466 MathUtil::MapEnclosedRectWith2dAxisAlignedTransform(
474 gfx::Rect transformed_rect = gfx::ToEnclosedRect( 467 layer->draw_transform(), non_opaque_content_rects.rect());
475 MathUtil::MapClippedRect(layer->draw_transform(),
476 gfx::RectF(non_opaque_content_rects.rect())));
477 transformed_rect.Intersect(clip_rect_in_target); 468 transformed_rect.Intersect(clip_rect_in_target);
478 if (transformed_rect.IsEmpty()) 469 if (transformed_rect.IsEmpty())
479 continue; 470 continue;
480 471
481 bool clipped; 472 bool clipped;
482 gfx::QuadF screen_space_quad = MathUtil::MapQuad( 473 gfx::QuadF screen_space_quad = MathUtil::MapQuad(
483 layer->render_target()->render_surface()->screen_space_transform(), 474 layer->render_target()->render_surface()->screen_space_transform(),
484 gfx::QuadF(transformed_rect), 475 gfx::QuadF(transformed_rect),
485 &clipped); 476 &clipped);
486 // TODO(danakj): Store the quad in the debug info instead of the bounding 477 // TODO(danakj): Store the quad in the debug info instead of the bounding
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i) 620 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i)
630 visible_region.Subtract(occluded.GetRect(i)); 621 visible_region.Subtract(occluded.GetRect(i));
631 return visible_region; 622 return visible_region;
632 } 623 }
633 624
634 // Instantiate (and export) templates here for the linker. 625 // Instantiate (and export) templates here for the linker.
635 template class OcclusionTracker<Layer>; 626 template class OcclusionTracker<Layer>;
636 template class OcclusionTracker<LayerImpl>; 627 template class OcclusionTracker<LayerImpl>;
637 628
638 } // namespace cc 629 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/math_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698