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 1057283003: Remove parts of //cc we aren't using (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 8 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_tracker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "cc/trees/occlusion.h"
6
7 #include "cc/base/math_util.h"
8 #include "ui/gfx/geometry/rect.h"
9
10 namespace cc {
11
12 Occlusion::Occlusion() {
13 }
14
15 Occlusion::Occlusion(const gfx::Transform& draw_transform,
16 const SimpleEnclosedRegion& occlusion_from_outside_target,
17 const SimpleEnclosedRegion& occlusion_from_inside_target)
18 : draw_transform_(draw_transform),
19 occlusion_from_outside_target_(occlusion_from_outside_target),
20 occlusion_from_inside_target_(occlusion_from_inside_target) {
21 }
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
34 bool Occlusion::IsOccluded(const gfx::Rect& content_rect) const {
35 if (content_rect.IsEmpty())
36 return true;
37
38 if (!HasOcclusion())
39 return false;
40
41 gfx::Rect unoccluded_rect_in_target_surface =
42 GetUnoccludedRectInTargetSurface(content_rect);
43 return unoccluded_rect_in_target_surface.IsEmpty();
44 }
45
46 gfx::Rect Occlusion::GetUnoccludedContentRect(
47 const gfx::Rect& content_rect) const {
48 if (content_rect.IsEmpty())
49 return content_rect;
50
51 if (!HasOcclusion())
52 return content_rect;
53
54 gfx::Rect unoccluded_rect_in_target_surface =
55 GetUnoccludedRectInTargetSurface(content_rect);
56 if (unoccluded_rect_in_target_surface.IsEmpty())
57 return gfx::Rect();
58
59 gfx::Transform inverse_draw_transform(gfx::Transform::kSkipInitialization);
60 bool ok = draw_transform_.GetInverse(&inverse_draw_transform);
61 DCHECK(ok);
62
63 gfx::Rect unoccluded_rect = MathUtil::ProjectEnclosingClippedRect(
64 inverse_draw_transform, unoccluded_rect_in_target_surface);
65 unoccluded_rect.Intersect(content_rect);
66
67 return unoccluded_rect;
68 }
69
70 gfx::Rect Occlusion::GetUnoccludedRectInTargetSurface(
71 const gfx::Rect& content_rect) const {
72 // Take the ToEnclosingRect at each step, as we want to contain any unoccluded
73 // partial pixels in the resulting Rect.
74 gfx::Rect unoccluded_rect_in_target_surface =
75 MathUtil::MapEnclosingClippedRect(draw_transform_, content_rect);
76 DCHECK_LE(occlusion_from_inside_target_.GetRegionComplexity(), 1u);
77 DCHECK_LE(occlusion_from_outside_target_.GetRegionComplexity(), 1u);
78 // These subtract operations are more lossy than if we did both operations at
79 // once.
80 unoccluded_rect_in_target_surface.Subtract(
81 occlusion_from_inside_target_.bounds());
82 unoccluded_rect_in_target_surface.Subtract(
83 occlusion_from_outside_target_.bounds());
84
85 return unoccluded_rect_in_target_surface;
86 }
87
88 bool Occlusion::IsEqual(const Occlusion& other) const {
89 return draw_transform_ == other.draw_transform_ &&
90 occlusion_from_inside_target_ == other.occlusion_from_inside_target_ &&
91 occlusion_from_outside_target_ == other.occlusion_from_outside_target_;
92 }
93
94 std::string Occlusion::ToString() const {
95 return draw_transform_.ToString() + "outside(" +
96 occlusion_from_outside_target_.ToString() + ") inside(" +
97 occlusion_from_inside_target_.ToString() + ")";
98 }
99
100 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/occlusion.h ('k') | cc/trees/occlusion_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698