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

Side by Side Diff: cc/trees/occlusion_checker.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: with test? 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_checker.h"
6
7 #include "cc/base/math_util.h"
8
9 namespace cc {
10
11 template <typename LayerType>
12 OcclusionChecker<LayerType>::OcclusionChecker() {
danakj 2014/09/09 15:14:39 wdyt of just naming this "Occlusion"? or maybe tha
vmpstr 2014/09/09 21:56:56 Done.
13 }
14
15 template <typename LayerType>
16 OcclusionChecker<LayerType>::OcclusionChecker(
17 const gfx::Transform& draw_transform,
18 const SimpleEnclosedRegion& occlusion_from_outside_target,
19 const SimpleEnclosedRegion& occlusion_from_inside_target)
20 : draw_transform_(draw_transform),
21 occlusion_from_outside_target_(occlusion_from_outside_target),
22 occlusion_from_inside_target_(occlusion_from_inside_target) {
23 }
24
25 template <typename LayerType>
26 bool OcclusionChecker<LayerType>::Occluded(
danakj 2014/09/09 15:14:39 nit: IsOccluded
vmpstr 2014/09/09 21:56:56 Done.
27 const gfx::Rect& content_rect) const {
28 if (content_rect.IsEmpty())
29 return true;
30
31 if (occlusion_from_inside_target_.IsEmpty() &&
32 occlusion_from_outside_target_.IsEmpty()) {
33 return false;
34 }
35
36 // Take the ToEnclosingRect at each step, as we want to contain any unoccluded
37 // partial pixels in the resulting Rect.
38 gfx::Rect unoccluded_rect_in_target_surface =
39 MathUtil::MapEnclosingClippedRect(draw_transform_, content_rect);
40 DCHECK_LE(occlusion_from_inside_target_.GetRegionComplexity(), 1u);
41 DCHECK_LE(occlusion_from_outside_target_.GetRegionComplexity(), 1u);
42 // These subtract operations are more lossy than if we did both operations at
43 // once.
44 unoccluded_rect_in_target_surface.Subtract(
45 occlusion_from_inside_target_.bounds());
46 unoccluded_rect_in_target_surface.Subtract(
47 occlusion_from_outside_target_.bounds());
48
49 return unoccluded_rect_in_target_surface.IsEmpty();
50 }
51
52 // Instantiate (and export) templates here for the linker.
53 template class OcclusionChecker<Layer>;
54 template class OcclusionChecker<LayerImpl>;
55
56 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698