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

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: 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() {
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(const gfx::Rect& content_rect) {
27 if (content_rect.IsEmpty())
28 return true;
29
30 if (occlusion_from_inside_target_.IsEmpty() &&
31 occlusion_from_outside_target_.IsEmpty()) {
32 return false;
33 }
34
35 // Take the ToEnclosingRect at each step, as we want to contain any unoccluded
36 // partial pixels in the resulting Rect.
37 gfx::Rect unoccluded_rect_in_target_surface =
38 MathUtil::MapEnclosingClippedRect(draw_transform_, content_rect);
39 DCHECK_LE(occlusion_from_inside_target_.GetRegionComplexity(), 1u);
40 DCHECK_LE(occlusion_from_outside_target_.GetRegionComplexity(), 1u);
41 // These subtract operations are more lossy than if we did both operations at
42 // once.
43 unoccluded_rect_in_target_surface.Subtract(
44 occlusion_from_inside_target_.bounds());
45 unoccluded_rect_in_target_surface.Subtract(
46 occlusion_from_outside_target_.bounds());
47
48 return unoccluded_rect_in_target_surface.IsEmpty();
49 }
50
51 // Instantiate (and export) templates here for the linker.
52 template class OcclusionChecker<Layer>;
53 template class OcclusionChecker<LayerImpl>;
54
55 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698