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
58
59
|
/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrStencilClip_DEFINED
#define GrStencilClip_DEFINED
#include "GrAppliedClip.h"
#include "GrFixedClip.h"
/**
* Implements GrHardClip with the currently-existing stencil buffer contents and GrFixedClip.
*/
class GrStencilClip final : public GrHardClip {
public:
GrStencilClip(uint32_t stencilStackID = SK_InvalidGenID) : fStencilStackID(stencilStackID) {}
explicit GrStencilClip(const SkIRect& scissorRect, uint32_t stencilStackID = SK_InvalidGenID)
: fFixedClip(scissorRect)
, fStencilStackID(stencilStackID) {
}
const GrFixedClip& fixedClip() const { return fFixedClip; }
GrFixedClip& fixedClip() { return fFixedClip; }
bool stencilStackID() const { return fStencilStackID; }
bool hasStencilClip() const { return SK_InvalidGenID != fStencilStackID; }
void setStencilClip(uint32_t stencilStackID) { fStencilStackID = stencilStackID; }
bool quickContains(const SkRect& rect) const override {
return !this->hasStencilClip() && fFixedClip.quickContains(rect);
}
void getConservativeBounds(int width, int height, SkIRect* bounds, bool* iior) const override {
fFixedClip.getConservativeBounds(width, height, bounds, iior);
}
bool isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA* aa) const override {
return !this->hasStencilClip() && fFixedClip.isRRect(rtBounds, rr, aa);
}
bool apply(int rtWidth, int rtHeight, GrAppliedHardClip* out, SkRect* bounds) const override {
if (!fFixedClip.apply(rtWidth, rtHeight, out, bounds)) {
return false;
}
if (this->hasStencilClip()) {
out->addStencilClip(fStencilStackID);
}
return true;
}
private:
GrFixedClip fFixedClip;
uint32_t fStencilStackID;
typedef GrClip INHERITED;
};
#endif
|