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

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

Issue 547723002: Reland of: cc: Add occlusion checker as a fixed view of occlusion tracker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update 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
(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
9 namespace cc {
10
11 Occlusion::Occlusion() {
12 }
13
14 Occlusion::Occlusion(const gfx::Transform& draw_transform,
15 const SimpleEnclosedRegion& occlusion_from_outside_target,
16 const SimpleEnclosedRegion& occlusion_from_inside_target)
17 : draw_transform_(draw_transform),
18 occlusion_from_outside_target_(occlusion_from_outside_target),
19 occlusion_from_inside_target_(occlusion_from_inside_target) {
20 }
21
22 bool Occlusion::IsOccluded(const gfx::Rect& content_rect) const {
23 if (content_rect.IsEmpty())
24 return true;
25
26 if (occlusion_from_inside_target_.IsEmpty() &&
27 occlusion_from_outside_target_.IsEmpty()) {
28 return false;
29 }
30
31 // Take the ToEnclosingRect at each step, as we want to contain any unoccluded
32 // partial pixels in the resulting Rect.
33 gfx::Rect unoccluded_rect_in_target_surface =
34 MathUtil::MapEnclosingClippedRect(draw_transform_, content_rect);
35 DCHECK_LE(occlusion_from_inside_target_.GetRegionComplexity(), 1u);
36 DCHECK_LE(occlusion_from_outside_target_.GetRegionComplexity(), 1u);
37 // These subtract operations are more lossy than if we did both operations at
38 // once.
39 unoccluded_rect_in_target_surface.Subtract(
40 occlusion_from_inside_target_.bounds());
41 unoccluded_rect_in_target_surface.Subtract(
42 occlusion_from_outside_target_.bounds());
43
44 return unoccluded_rect_in_target_surface.IsEmpty();
45 }
46
47 } // namespace cc
OLDNEW
« cc/trees/occlusion.h ('K') | « 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