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

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
« cc/base/math_util.cc ('K') | « 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::MapEnclosedNonClippedRect(transform, region.GetRect(i));
92 DCHECK(!clipped); // We only map if the transform preserves axis alignment.
93 if (have_clip_rect) 89 if (have_clip_rect)
94 transformed_rect.Intersect(clip_rect_in_new_target); 90 transformed_rect.Intersect(clip_rect_in_new_target);
95 transformed_region.Union(transformed_rect); 91 transformed_region.Union(transformed_rect);
96 } 92 }
97 return transformed_region; 93 return transformed_region;
98 } 94 }
99 95
100 static inline bool LayerOpacityKnown(const Layer* layer) { 96 static inline bool LayerOpacityKnown(const Layer* layer) {
101 return !layer->draw_opacity_is_animating(); 97 return !layer->draw_opacity_is_animating();
102 } 98 }
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 gfx::Rect clip_rect_in_target = ScreenSpaceClipRectInTargetSurface( 421 gfx::Rect clip_rect_in_target = ScreenSpaceClipRectInTargetSurface(
426 layer->render_target()->render_surface(), screen_space_clip_rect_); 422 layer->render_target()->render_surface(), screen_space_clip_rect_);
427 if (layer->is_clipped()) { 423 if (layer->is_clipped()) {
428 clip_rect_in_target.Intersect(layer->clip_rect()); 424 clip_rect_in_target.Intersect(layer->clip_rect());
429 } else { 425 } else {
430 clip_rect_in_target.Intersect( 426 clip_rect_in_target.Intersect(
431 layer->render_target()->render_surface()->content_rect()); 427 layer->render_target()->render_surface()->content_rect());
432 } 428 }
433 429
434 for (size_t i = 0; i < opaque_contents.GetRegionComplexity(); ++i) { 430 for (size_t i = 0; i < opaque_contents.GetRegionComplexity(); ++i) {
435 bool clipped; 431 gfx::Rect transformed_rect = MathUtil::MapEnclosedNonClippedRect(
436 gfx::QuadF transformed_quad = 432 layer->draw_transform(), opaque_contents.GetRect(i));
437 MathUtil::MapQuad(layer->draw_transform(),
438 gfx::QuadF(opaque_contents.GetRect(i)),
439 &clipped);
440 gfx::Rect transformed_rect =
441 gfx::ToEnclosedRect(transformed_quad.BoundingBox());
442 DCHECK(!clipped); // We only map if the transform preserves axis alignment.
443 transformed_rect.Intersect(clip_rect_in_target); 433 transformed_rect.Intersect(clip_rect_in_target);
444 if (transformed_rect.width() < minimum_tracking_size_.width() && 434 if (transformed_rect.width() < minimum_tracking_size_.width() &&
445 transformed_rect.height() < minimum_tracking_size_.height()) 435 transformed_rect.height() < minimum_tracking_size_.height())
446 continue; 436 continue;
447 stack_.back().occlusion_from_inside_target.Union(transformed_rect); 437 stack_.back().occlusion_from_inside_target.Union(transformed_rect);
448 438
449 if (!occluding_screen_space_rects_) 439 if (!occluding_screen_space_rects_)
450 continue; 440 continue;
451 441
452 // Save the occluding area in screen space for debug visualization. 442 // Save the occluding area in screen space for debug visualization.
443 bool clipped;
453 gfx::QuadF screen_space_quad = MathUtil::MapQuad( 444 gfx::QuadF screen_space_quad = MathUtil::MapQuad(
454 layer->render_target()->render_surface()->screen_space_transform(), 445 layer->render_target()->render_surface()->screen_space_transform(),
455 gfx::QuadF(transformed_rect), &clipped); 446 gfx::QuadF(transformed_rect), &clipped);
456 // TODO(danakj): Store the quad in the debug info instead of the bounding 447 // TODO(danakj): Store the quad in the debug info instead of the bounding
457 // box. 448 // box.
458 gfx::Rect screen_space_rect = 449 gfx::Rect screen_space_rect =
459 gfx::ToEnclosedRect(screen_space_quad.BoundingBox()); 450 gfx::ToEnclosedRect(screen_space_quad.BoundingBox());
460 occluding_screen_space_rects_->push_back(screen_space_rect); 451 occluding_screen_space_rects_->push_back(screen_space_rect);
461 } 452 }
462 453
463 if (!non_occluding_screen_space_rects_) 454 if (!non_occluding_screen_space_rects_)
464 return; 455 return;
465 456
466 Region non_opaque_contents(gfx::Rect(layer->content_bounds())); 457 Region non_opaque_contents(gfx::Rect(layer->content_bounds()));
467 non_opaque_contents.Subtract(opaque_contents); 458 non_opaque_contents.Subtract(opaque_contents);
468 459
469 for (Region::Iterator non_opaque_content_rects(non_opaque_contents); 460 for (Region::Iterator non_opaque_content_rects(non_opaque_contents);
470 non_opaque_content_rects.has_rect(); 461 non_opaque_content_rects.has_rect();
471 non_opaque_content_rects.next()) { 462 non_opaque_content_rects.next()) {
472 // We've already checked for clipping in the MapQuad call above, these calls 463 gfx::Rect transformed_rect = MathUtil::MapEnclosedNonClippedRect(
473 // should not clip anything further. 464 layer->draw_transform(), non_opaque_content_rects.rect());
474 gfx::Rect transformed_rect = gfx::ToEnclosedRect(
475 MathUtil::MapClippedRect(layer->draw_transform(),
476 gfx::RectF(non_opaque_content_rects.rect())));
477 transformed_rect.Intersect(clip_rect_in_target); 465 transformed_rect.Intersect(clip_rect_in_target);
478 if (transformed_rect.IsEmpty()) 466 if (transformed_rect.IsEmpty())
479 continue; 467 continue;
480 468
481 bool clipped; 469 bool clipped;
482 gfx::QuadF screen_space_quad = MathUtil::MapQuad( 470 gfx::QuadF screen_space_quad = MathUtil::MapQuad(
483 layer->render_target()->render_surface()->screen_space_transform(), 471 layer->render_target()->render_surface()->screen_space_transform(),
484 gfx::QuadF(transformed_rect), 472 gfx::QuadF(transformed_rect),
485 &clipped); 473 &clipped);
486 // TODO(danakj): Store the quad in the debug info instead of the bounding 474 // 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) 617 for (size_t i = 0; i < occluded.GetRegionComplexity(); ++i)
630 visible_region.Subtract(occluded.GetRect(i)); 618 visible_region.Subtract(occluded.GetRect(i));
631 return visible_region; 619 return visible_region;
632 } 620 }
633 621
634 // Instantiate (and export) templates here for the linker. 622 // Instantiate (and export) templates here for the linker.
635 template class OcclusionTracker<Layer>; 623 template class OcclusionTracker<Layer>;
636 template class OcclusionTracker<LayerImpl>; 624 template class OcclusionTracker<LayerImpl>;
637 625
638 } // namespace cc 626 } // namespace cc
OLDNEW
« cc/base/math_util.cc ('K') | « cc/base/math_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698