blob: 01498c11613429330606e833ce29cfb9ee6ac9dd [file] [log] [blame]
csmartdalton02fa32c2016-08-19 13:29:27 -07001/*
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 "GrTypesPriv.h"
13
14/**
15 * GrFixedClip is a clip that can be represented by fixed-function hardware. It never modifies the
16 * stencil buffer itself, but can be configured to use whatever clip is already there.
17 */
18class GrFixedClip final : public GrClip {
19public:
20 GrFixedClip() : fHasStencilClip(false) {}
21 GrFixedClip(const SkIRect& scissorRect)
22 : fScissorState(scissorRect)
23 , fHasStencilClip(false) {}
24
25 void reset() {
26 fScissorState.setDisabled();
27 fHasStencilClip = false;
28 }
29
30 void reset(const SkIRect& scissorRect) {
31 fScissorState.set(scissorRect);
32 fHasStencilClip = false;
33 }
34
35 void enableStencilClip() { fHasStencilClip = true; }
36 void disableStencilClip() { fHasStencilClip = false; }
37
38 bool quickContains(const SkRect&) const final;
39 void getConservativeBounds(int width, int height, SkIRect* devResult,
40 bool* isIntersectionOfRects) const final;
41
42private:
43 bool apply(GrContext*, GrDrawContext*, bool useHWAA, bool hasUserStencilSettings,
44 GrAppliedClip* out) const final;
45
46 GrScissorState fScissorState;
47 bool fHasStencilClip;
48};
49
50#endif