blob: d44c1e84e408064bc58720d98ab509ad173511dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrFixedClip_DEFINED
#define GrFixedClip_DEFINED
#include "GrClip.h"
#include "GrScissorState.h"
#include "GrWindowRectsState.h"
/**
* Implements GrHardClip with scissor and window rectangles.
*/
class GrFixedClip final : public GrHardClip {
public:
GrFixedClip() = default;
explicit GrFixedClip(const SkIRect& scissorRect) : fScissorState(scissorRect) {}
const GrScissorState& scissorState() const { return fScissorState; }
bool scissorEnabled() const { return fScissorState.enabled(); }
const SkIRect& scissorRect() const { SkASSERT(scissorEnabled()); return fScissorState.rect(); }
void disableScissor() { fScissorState.setDisabled(); }
void setScissor(const SkIRect& irect) {
fScissorState.set(irect);
}
bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& irect) {
return fScissorState.intersect(irect);
}
const GrWindowRectsState& windowRectsState() const { return fWindowRectsState; }
bool hasWindowRectangles() const { return fWindowRectsState.enabled(); }
void disableWindowRectangles() { fWindowRectsState.setDisabled(); }
void setWindowRectangles(const GrWindowRectangles& windows, GrWindowRectsState::Mode mode) {
fWindowRectsState.set(windows, mode);
}
bool quickContains(const SkRect&) const override;
void getConservativeBounds(int w, int h, SkIRect* devResult, bool* iior) const override;
bool isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA*) const override;
bool apply(int rtWidth, int rtHeight, GrAppliedHardClip*, SkRect*) const override;
static const GrFixedClip& Disabled();
private:
GrScissorState fScissorState;
GrWindowRectsState fWindowRectsState;
};
#endif
|