csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 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 | class GrWindowRectsState { |
| 14 | public: |
| 15 | enum class Mode : bool { |
| 16 | kExclusive, |
| 17 | kInclusive |
| 18 | }; |
| 19 | |
| 20 | GrWindowRectsState() : fMode(Mode::kExclusive) {} |
Brian Salomon | 9a76772 | 2017-03-13 17:57:28 -0400 | [diff] [blame] | 21 | GrWindowRectsState(const GrWindowRectangles& windows, Mode mode) |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 22 | : fMode(mode) |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 23 | , fWindows(windows) { |
| 24 | } |
| 25 | |
| 26 | bool enabled() const { return Mode::kInclusive == fMode || !fWindows.empty(); } |
| 27 | Mode mode() const { return fMode; } |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 28 | const GrWindowRectangles& windows() const { return fWindows; } |
| 29 | int numWindows() const { return fWindows.count(); } |
| 30 | |
| 31 | void setDisabled() { |
| 32 | fMode = Mode::kExclusive; |
| 33 | fWindows.reset(); |
| 34 | } |
| 35 | |
Brian Salomon | 9a76772 | 2017-03-13 17:57:28 -0400 | [diff] [blame] | 36 | void set(const GrWindowRectangles& windows, Mode mode) { |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 37 | fMode = mode; |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 38 | fWindows = windows; |
| 39 | } |
| 40 | |
Brian Salomon | 9a76772 | 2017-03-13 17:57:28 -0400 | [diff] [blame] | 41 | bool operator==(const GrWindowRectsState& that) const { |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 42 | if (fMode != that.fMode) { |
| 43 | return false; |
| 44 | } |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 45 | return fWindows == that.fWindows; |
| 46 | } |
Brian Salomon | 9a76772 | 2017-03-13 17:57:28 -0400 | [diff] [blame] | 47 | bool operator!=(const GrWindowRectsState& that) const { return !(*this == that); } |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 48 | |
| 49 | private: |
| 50 | Mode fMode; |
csmartdalton | bf4a8f9 | 2016-09-06 10:01:06 -0700 | [diff] [blame] | 51 | GrWindowRectangles fWindows; |
| 52 | }; |
| 53 | |
| 54 | #endif |