GrWindowRectsState.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #ifndef GrWindowRectsState_DEFINED
  8. #define GrWindowRectsState_DEFINED
  9. #include "src/gpu/GrWindowRectangles.h"
  10. class GrWindowRectsState {
  11. public:
  12. enum class Mode : bool {
  13. kExclusive,
  14. kInclusive
  15. };
  16. GrWindowRectsState() : fMode(Mode::kExclusive) {}
  17. GrWindowRectsState(const GrWindowRectangles& windows, Mode mode)
  18. : fMode(mode)
  19. , fWindows(windows) {
  20. }
  21. bool enabled() const { return Mode::kInclusive == fMode || !fWindows.empty(); }
  22. Mode mode() const { return fMode; }
  23. const GrWindowRectangles& windows() const { return fWindows; }
  24. int numWindows() const { return fWindows.count(); }
  25. void setDisabled() {
  26. fMode = Mode::kExclusive;
  27. fWindows.reset();
  28. }
  29. void set(const GrWindowRectangles& windows, Mode mode) {
  30. fMode = mode;
  31. fWindows = windows;
  32. }
  33. bool operator==(const GrWindowRectsState& that) const {
  34. if (fMode != that.fMode) {
  35. return false;
  36. }
  37. return fWindows == that.fWindows;
  38. }
  39. bool operator!=(const GrWindowRectsState& that) const { return !(*this == that); }
  40. private:
  41. Mode fMode;
  42. GrWindowRectangles fWindows;
  43. };
  44. #endif