Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / src / gpu / ganesh / GrFixedClip.h
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 GrFixedClip_DEFINED
9 #define GrFixedClip_DEFINED
10
11 #include "src/gpu/ganesh/GrClip.h"
12 #include "src/gpu/ganesh/GrScissorState.h"
13 #include "src/gpu/ganesh/GrWindowRectsState.h"
14
15 /**
16  * Implements GrHardClip with scissor and window rectangles.
17  */
18 class GrFixedClip final : public GrHardClip {
19 public:
20     explicit GrFixedClip(const SkISize& rtDims) : fScissorState(rtDims) {}
21     GrFixedClip(const SkISize& rtDims, const SkIRect& scissorRect)
22             : GrFixedClip(rtDims) {
23         SkAssertResult(fScissorState.set(scissorRect));
24     }
25
26     const GrScissorState& scissorState() const { return fScissorState; }
27     bool scissorEnabled() const { return fScissorState.enabled(); }
28     // Returns the scissor rect or rt bounds if the scissor test is not enabled.
29     const SkIRect& scissorRect() const { return fScissorState.rect(); }
30
31     void disableScissor() { fScissorState.setDisabled(); }
32
33     bool SK_WARN_UNUSED_RESULT setScissor(const SkIRect& irect) {
34         return fScissorState.set(irect);
35     }
36     bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& irect) {
37         return fScissorState.intersect(irect);
38     }
39
40     const GrWindowRectsState& windowRectsState() const { return fWindowRectsState; }
41     bool hasWindowRectangles() const { return fWindowRectsState.enabled(); }
42
43     void disableWindowRectangles() { fWindowRectsState.setDisabled(); }
44
45     void setWindowRectangles(const GrWindowRectangles& windows, GrWindowRectsState::Mode mode) {
46         fWindowRectsState.set(windows, mode);
47     }
48
49     SkIRect getConservativeBounds() const final;
50     Effect apply(GrAppliedHardClip*, SkIRect*) const final;
51     PreClipResult preApply(const SkRect& drawBounds, GrAA aa) const final;
52
53 private:
54     GrScissorState       fScissorState;
55     GrWindowRectsState   fWindowRectsState;
56 };
57
58 #endif