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 GrFixedClip_DEFINED
9 : #define GrFixedClip_DEFINED
10 :
11 : #include "GrClip.h"
12 : #include "GrScissorState.h"
13 : #include "GrWindowRectsState.h"
14 :
15 : /**
16 : * GrFixedClip is a clip that gets implemented by fixed-function hardware.
17 : */
18 0 : class GrFixedClip final : public GrClip {
19 : public:
20 0 : GrFixedClip() = default;
21 0 : explicit GrFixedClip(const SkIRect& scissorRect) : fScissorState(scissorRect) {}
22 :
23 0 : const GrScissorState& scissorState() const { return fScissorState; }
24 0 : bool scissorEnabled() const { return fScissorState.enabled(); }
25 0 : const SkIRect& scissorRect() const { SkASSERT(scissorEnabled()); return fScissorState.rect(); }
26 :
27 0 : void disableScissor() { fScissorState.setDisabled(); }
28 :
29 0 : bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& irect) {
30 0 : return fScissorState.intersect(irect);
31 : }
32 :
33 0 : const GrWindowRectsState& windowRectsState() const { return fWindowRectsState; }
34 0 : bool hasWindowRectangles() const { return fWindowRectsState.enabled(); }
35 :
36 : void disableWindowRectangles() { fWindowRectsState.setDisabled(); }
37 :
38 0 : void setWindowRectangles(const GrWindowRectangles& windows, GrWindowRectsState::Mode mode) {
39 0 : fWindowRectsState.set(windows, mode);
40 0 : }
41 :
42 : bool quickContains(const SkRect&) const override;
43 : void getConservativeBounds(int w, int h, SkIRect* devResult, bool* iior) const override;
44 : bool isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA*) const override;
45 : bool apply(GrContext*, GrRenderTargetContext*, bool, bool, GrAppliedClip*,
46 : SkRect*) const override;
47 :
48 : static const GrFixedClip& Disabled();
49 :
50 : private:
51 : GrScissorState fScissorState;
52 : GrWindowRectsState fWindowRectsState;
53 : };
54 :
55 : #endif
|