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

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

Issue 576173003: cc: Move UnoccludedContentRect to Occlusion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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.h" 5 #include "cc/trees/occlusion.h"
6 6
7 #include "cc/base/math_util.h" 7 #include "cc/base/math_util.h"
8 #include "ui/gfx/rect.h" 8 #include "ui/gfx/rect.h"
9 9
10 namespace cc { 10 namespace cc {
(...skipping 11 matching lines...) Expand all
22 22
23 bool Occlusion::IsOccluded(const gfx::Rect& content_rect) const { 23 bool Occlusion::IsOccluded(const gfx::Rect& content_rect) const {
24 if (content_rect.IsEmpty()) 24 if (content_rect.IsEmpty())
25 return true; 25 return true;
26 26
27 if (occlusion_from_inside_target_.IsEmpty() && 27 if (occlusion_from_inside_target_.IsEmpty() &&
28 occlusion_from_outside_target_.IsEmpty()) { 28 occlusion_from_outside_target_.IsEmpty()) {
29 return false; 29 return false;
30 } 30 }
31 31
32 gfx::Rect unoccluded_rect_in_target_surface =
33 GetUnoccludedRectInTargetSurface(content_rect);
34 return unoccluded_rect_in_target_surface.IsEmpty();
35 }
36
37 gfx::Rect Occlusion::GetUnoccludedContentRect(
38 const gfx::Rect& content_rect) const {
39 if (content_rect.IsEmpty())
40 return content_rect;
41
42 if (occlusion_from_inside_target_.IsEmpty() &&
43 occlusion_from_outside_target_.IsEmpty()) {
44 return content_rect;
45 }
46
47 gfx::Rect unoccluded_rect_in_target_surface =
48 GetUnoccludedRectInTargetSurface(content_rect);
49 if (unoccluded_rect_in_target_surface.IsEmpty())
50 return gfx::Rect();
51
52 gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization);
53 bool ok = draw_transform_.GetInverse(&inverse_draw_transform);
54 DCHECK(ok);
55
56 gfx::Rect unoccluded_rect = MathUtil::ProjectEnclosingClippedRect(
57 inverse_draw_transform, unoccluded_rect_in_target_surface);
58 unoccluded_rect.Intersect(content_rect);
59
60 return unoccluded_rect;
61 }
62
63 gfx::Rect Occlusion::GetUnoccludedRectInTargetSurface(
64 const gfx::Rect& content_rect) const {
32 // Take the ToEnclosingRect at each step, as we want to contain any unoccluded 65 // Take the ToEnclosingRect at each step, as we want to contain any unoccluded
33 // partial pixels in the resulting Rect. 66 // partial pixels in the resulting Rect.
34 gfx::Rect unoccluded_rect_in_target_surface = 67 gfx::Rect unoccluded_rect_in_target_surface =
35 MathUtil::MapEnclosingClippedRect(draw_transform_, content_rect); 68 MathUtil::MapEnclosingClippedRect(draw_transform_, content_rect);
36 DCHECK_LE(occlusion_from_inside_target_.GetRegionComplexity(), 1u); 69 DCHECK_LE(occlusion_from_inside_target_.GetRegionComplexity(), 1u);
37 DCHECK_LE(occlusion_from_outside_target_.GetRegionComplexity(), 1u); 70 DCHECK_LE(occlusion_from_outside_target_.GetRegionComplexity(), 1u);
38 // These subtract operations are more lossy than if we did both operations at 71 // These subtract operations are more lossy than if we did both operations at
39 // once. 72 // once.
40 unoccluded_rect_in_target_surface.Subtract( 73 unoccluded_rect_in_target_surface.Subtract(
41 occlusion_from_inside_target_.bounds()); 74 occlusion_from_inside_target_.bounds());
42 unoccluded_rect_in_target_surface.Subtract( 75 unoccluded_rect_in_target_surface.Subtract(
43 occlusion_from_outside_target_.bounds()); 76 occlusion_from_outside_target_.bounds());
44 77
45 return unoccluded_rect_in_target_surface.IsEmpty(); 78 // TODO(vmpstr): Cache this.
79 return unoccluded_rect_in_target_surface;
46 } 80 }
47 81
48 } // namespace cc 82 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698