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 GrScissorState_DEFINED
9 : #define GrScissorState_DEFINED
10 :
11 : #include "SkRect.h"
12 :
13 : class GrScissorState {
14 : public:
15 0 : GrScissorState() : fEnabled(false) {}
16 0 : GrScissorState(const SkIRect& rect) : fEnabled(true), fRect(rect) {}
17 0 : void setDisabled() { fEnabled = false; }
18 0 : void set(const SkIRect& rect) { fRect = rect; fEnabled = true; }
19 0 : bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& rect) {
20 0 : if (!fEnabled) {
21 0 : this->set(rect);
22 0 : return true;
23 : }
24 0 : return fRect.intersect(rect);
25 : }
26 0 : bool operator==(const GrScissorState& other) const {
27 0 : return fEnabled == other.fEnabled &&
28 0 : (false == fEnabled || fRect == other.fRect);
29 : }
30 0 : bool operator!=(const GrScissorState& other) const { return !(*this == other); }
31 :
32 0 : bool enabled() const { return fEnabled; }
33 0 : const SkIRect& rect() const { return fRect; }
34 :
35 : private:
36 : bool fEnabled;
37 : SkIRect fRect;
38 : };
39 :
40 : #endif
|