summaryrefslogtreecommitdiffstats
path: root/cc/test/occlusion_tracker_test_common.h
blob: af8ed3c470a1edcadab70f6685e23d70f94632a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CC_TEST_OCCLUSION_TRACKER_TEST_COMMON_H_
#define CC_TEST_OCCLUSION_TRACKER_TEST_COMMON_H_

#include "cc/layers/render_surface.h"
#include "cc/layers/render_surface_impl.h"
#include "cc/trees/occlusion_tracker.h"

namespace cc {

// A subclass to expose the total current occlusion.
template <typename LayerType, typename RenderSurfaceType>
class TestOcclusionTrackerBase
    : public OcclusionTrackerBase<LayerType, RenderSurfaceType> {
 public:
  TestOcclusionTrackerBase(gfx::Rect screen_scissor_rect,
                           bool record_metrics_for_frame)
      : OcclusionTrackerBase<LayerType, RenderSurfaceType>(
            screen_scissor_rect,
            record_metrics_for_frame) {}

  Region occlusion_from_inside_target() const {
    return OcclusionTrackerBase<LayerType, RenderSurfaceType>::stack_.back().
        occlusion_from_inside_target;
  }
  Region occlusion_from_outside_target() const {
    return OcclusionTrackerBase<LayerType, RenderSurfaceType>::stack_.back().
        occlusion_from_outside_target;
  }

  void set_occlusion_from_outside_target(const Region& region) {
    OcclusionTrackerBase<LayerType, RenderSurfaceType>::stack_.back().
        occlusion_from_outside_target = region;
  }
  void set_occlusion_from_inside_target(const Region& region) {
    OcclusionTrackerBase<LayerType, RenderSurfaceType>::stack_.back().
        occlusion_from_inside_target = region;
  }
};

typedef TestOcclusionTrackerBase<Layer, RenderSurface> TestOcclusionTracker;
typedef TestOcclusionTrackerBase<LayerImpl, RenderSurfaceImpl>
    TestOcclusionTrackerImpl;

}  // namespace cc

#endif  // CC_TEST_OCCLUSION_TRACKER_TEST_COMMON_H_