Line data Source code
1 : /*
2 : * Copyright 2016 Google Inc.
3 : *
4 : * Use of this source code is governed by a BSD-style license that can be
5 : * found in the LICENSE file.
6 : */
7 :
8 : #ifndef GrWindowRectsState_DEFINED
9 : #define GrWindowRectsState_DEFINED
10 :
11 : #include "GrWindowRectangles.h"
12 :
13 0 : class GrWindowRectsState {
14 : public:
15 : enum class Mode : bool {
16 : kExclusive,
17 : kInclusive
18 : };
19 :
20 0 : GrWindowRectsState() : fMode(Mode::kExclusive) {}
21 : GrWindowRectsState(const GrWindowRectangles& windows, Mode mode)
22 : : fMode(mode)
23 : , fWindows(windows) {
24 : }
25 :
26 0 : bool enabled() const { return Mode::kInclusive == fMode || !fWindows.empty(); }
27 0 : Mode mode() const { return fMode; }
28 0 : const GrWindowRectangles& windows() const { return fWindows; }
29 0 : int numWindows() const { return fWindows.count(); }
30 :
31 0 : void setDisabled() {
32 0 : fMode = Mode::kExclusive;
33 0 : fWindows.reset();
34 0 : }
35 :
36 0 : void set(const GrWindowRectangles& windows, Mode mode) {
37 0 : fMode = mode;
38 0 : fWindows = windows;
39 0 : }
40 :
41 0 : bool operator==(const GrWindowRectsState& that) const {
42 0 : if (fMode != that.fMode) {
43 0 : return false;
44 : }
45 0 : return fWindows == that.fWindows;
46 : }
47 0 : bool operator!=(const GrWindowRectsState& that) const { return !(*this == that); }
48 :
49 : private:
50 : Mode fMode;
51 : GrWindowRectangles fWindows;
52 : };
53 :
54 : #endif
|