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

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

Issue 607023003: cc: Unify the occlusion access by adding an ability to scale transform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: +build.gn change Created 6 years, 2 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
« no previous file with comments | « cc/trees/occlusion.h ('k') | cc/trees/occlusion_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
11 11
12 Occlusion::Occlusion() { 12 Occlusion::Occlusion() {
13 } 13 }
14 14
15 Occlusion::Occlusion(const gfx::Transform& draw_transform, 15 Occlusion::Occlusion(const gfx::Transform& draw_transform,
16 const SimpleEnclosedRegion& occlusion_from_outside_target, 16 const SimpleEnclosedRegion& occlusion_from_outside_target,
17 const SimpleEnclosedRegion& occlusion_from_inside_target) 17 const SimpleEnclosedRegion& occlusion_from_inside_target)
18 : draw_transform_(draw_transform), 18 : draw_transform_(draw_transform),
19 occlusion_from_outside_target_(occlusion_from_outside_target), 19 occlusion_from_outside_target_(occlusion_from_outside_target),
20 occlusion_from_inside_target_(occlusion_from_inside_target) { 20 occlusion_from_inside_target_(occlusion_from_inside_target) {
21 } 21 }
22 22
23 Occlusion Occlusion::GetOcclusionWithGivenDrawTransform(
24 const gfx::Transform& transform) const {
25 return Occlusion(
26 transform, occlusion_from_outside_target_, occlusion_from_inside_target_);
27 }
28
29 bool Occlusion::HasOcclusion() const {
30 return !occlusion_from_inside_target_.IsEmpty() ||
31 !occlusion_from_outside_target_.IsEmpty();
32 }
33
23 bool Occlusion::IsOccluded(const gfx::Rect& content_rect) const { 34 bool Occlusion::IsOccluded(const gfx::Rect& content_rect) const {
24 if (content_rect.IsEmpty()) 35 if (content_rect.IsEmpty())
25 return true; 36 return true;
26 37
27 if (occlusion_from_inside_target_.IsEmpty() && 38 if (!HasOcclusion())
28 occlusion_from_outside_target_.IsEmpty()) {
29 return false; 39 return false;
30 }
31 40
32 gfx::Rect unoccluded_rect_in_target_surface = 41 gfx::Rect unoccluded_rect_in_target_surface =
33 GetUnoccludedRectInTargetSurface(content_rect); 42 GetUnoccludedRectInTargetSurface(content_rect);
34 return unoccluded_rect_in_target_surface.IsEmpty(); 43 return unoccluded_rect_in_target_surface.IsEmpty();
35 } 44 }
36 45
37 gfx::Rect Occlusion::GetUnoccludedContentRect( 46 gfx::Rect Occlusion::GetUnoccludedContentRect(
38 const gfx::Rect& content_rect) const { 47 const gfx::Rect& content_rect) const {
39 if (content_rect.IsEmpty()) 48 if (content_rect.IsEmpty())
40 return content_rect; 49 return content_rect;
41 50
42 if (occlusion_from_inside_target_.IsEmpty() && 51 if (!HasOcclusion())
43 occlusion_from_outside_target_.IsEmpty()) {
44 return content_rect; 52 return content_rect;
45 }
46 53
47 gfx::Rect unoccluded_rect_in_target_surface = 54 gfx::Rect unoccluded_rect_in_target_surface =
48 GetUnoccludedRectInTargetSurface(content_rect); 55 GetUnoccludedRectInTargetSurface(content_rect);
49 if (unoccluded_rect_in_target_surface.IsEmpty()) 56 if (unoccluded_rect_in_target_surface.IsEmpty())
50 return gfx::Rect(); 57 return gfx::Rect();
51 58
52 gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization); 59 gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization);
53 bool ok = draw_transform_.GetInverse(&inverse_draw_transform); 60 bool ok = draw_transform_.GetInverse(&inverse_draw_transform);
54 DCHECK(ok); 61 DCHECK(ok);
55 62
(...skipping 16 matching lines...) Expand all
72 // once. 79 // once.
73 unoccluded_rect_in_target_surface.Subtract( 80 unoccluded_rect_in_target_surface.Subtract(
74 occlusion_from_inside_target_.bounds()); 81 occlusion_from_inside_target_.bounds());
75 unoccluded_rect_in_target_surface.Subtract( 82 unoccluded_rect_in_target_surface.Subtract(
76 occlusion_from_outside_target_.bounds()); 83 occlusion_from_outside_target_.bounds());
77 84
78 return unoccluded_rect_in_target_surface; 85 return unoccluded_rect_in_target_surface;
79 } 86 }
80 87
81 } // namespace cc 88 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/occlusion.h ('k') | cc/trees/occlusion_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698