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 : #ifndef GrClipStackClip_DEFINED
8 : #define GrClipStackClip_DEFINED
9 :
10 : #include "GrClip.h"
11 : #include "GrReducedClip.h"
12 : #include "SkClipStack.h"
13 :
14 : class GrPathRenderer;
15 : class GrTextureProxy;
16 :
17 : /**
18 : * GrClipStackClip can apply a generic SkClipStack to the draw state. It may need to generate an
19 : * 8-bit alpha clip mask and/or modify the stencil buffer during apply().
20 : */
21 0 : class GrClipStackClip final : public GrClip {
22 : public:
23 0 : GrClipStackClip(const SkClipStack* stack = nullptr) { this->reset(stack); }
24 :
25 0 : void reset(const SkClipStack* stack) { fStack = stack; }
26 :
27 : bool quickContains(const SkRect&) const final;
28 : bool quickContains(const SkRRect&) const final;
29 : void getConservativeBounds(int width, int height, SkIRect* devResult,
30 : bool* isIntersectionOfRects) const final;
31 : bool apply(GrContext*, GrRenderTargetContext*, bool useHWAA, bool hasUserStencilSettings,
32 : GrAppliedClip* out, SkRect* bounds) const final;
33 :
34 : bool isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA* aa) const override;
35 :
36 : sk_sp<GrTextureProxy> testingOnly_createClipMask(GrContext*) const;
37 : static const char kMaskTestTag[];
38 :
39 : private:
40 : static bool PathNeedsSWRenderer(GrContext* context,
41 : bool hasUserStencilSettings,
42 : const GrRenderTargetContext*,
43 : const SkMatrix& viewMatrix,
44 : const SkClipStack::Element* element,
45 : GrPathRenderer** prOut,
46 : bool needsStencil);
47 :
48 : // Creates an alpha mask of the clip. The mask is a rasterization of elements through the
49 : // rect specified by clipSpaceIBounds.
50 : sk_sp<GrTextureProxy> createAlphaClipMask(GrContext*, const GrReducedClip&) const;
51 :
52 : // Similar to createAlphaClipMask but it rasterizes in SW and uploads to the result texture.
53 : sk_sp<GrTextureProxy> createSoftwareClipMask(GrContext*, const GrReducedClip&) const;
54 :
55 : static bool UseSWOnlyPath(GrContext*,
56 : bool hasUserStencilSettings,
57 : const GrRenderTargetContext*,
58 : const GrReducedClip&);
59 :
60 : const SkClipStack* fStack;
61 : };
62 :
63 : #endif // GrClipStackClip_DEFINED
|