robertphillips@google.com | 1e945b7 | 2012-04-16 18:03:03 +0000 | [diff] [blame] | 1 | /* |
csmartdalton | c6f411e | 2016-08-05 22:32:12 -0700 | [diff] [blame] | 2 | * Copyright 2016 Google Inc. |
robertphillips@google.com | 1e945b7 | 2012-04-16 18:03:03 +0000 | [diff] [blame] | 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
csmartdalton | c6f411e | 2016-08-05 22:32:12 -0700 | [diff] [blame] | 7 | #ifndef GrClipStackClip_DEFINED |
| 8 | #define GrClipStackClip_DEFINED |
| 9 | |
| 10 | #include "GrClip.h" |
bsalomon@google.com | 4c2443e | 2012-12-06 20:58:57 +0000 | [diff] [blame] | 11 | #include "GrReducedClip.h" |
robertphillips@google.com | 641f8b1 | 2012-07-31 19:15:58 +0000 | [diff] [blame] | 12 | #include "SkClipStack.h" |
robertphillips@google.com | 1fcc1b8 | 2012-08-29 12:52:05 +0000 | [diff] [blame] | 13 | |
csmartdalton | c6f411e | 2016-08-05 22:32:12 -0700 | [diff] [blame] | 14 | class GrPathRenderer; |
Robert Phillips | 875218e | 2017-02-24 08:37:13 -0500 | [diff] [blame] | 15 | class GrTextureProxy; |
bsalomon | 0ba8c24 | 2015-10-07 09:20:28 -0700 | [diff] [blame] | 16 | |
| 17 | /** |
csmartdalton | c6f411e | 2016-08-05 22:32:12 -0700 | [diff] [blame] | 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(). |
robertphillips@google.com | 1e945b7 | 2012-04-16 18:03:03 +0000 | [diff] [blame] | 20 | */ |
csmartdalton | c6f411e | 2016-08-05 22:32:12 -0700 | [diff] [blame] | 21 | class GrClipStackClip final : public GrClip { |
robertphillips@google.com | 1e945b7 | 2012-04-16 18:03:03 +0000 | [diff] [blame] | 22 | public: |
Brian Salomon | 9a76772 | 2017-03-13 17:57:28 -0400 | [diff] [blame] | 23 | GrClipStackClip(const SkClipStack* stack = nullptr) { this->reset(stack); } |
csmartdalton | c6f411e | 2016-08-05 22:32:12 -0700 | [diff] [blame] | 24 | |
Brian Salomon | 9a76772 | 2017-03-13 17:57:28 -0400 | [diff] [blame] | 25 | void reset(const SkClipStack* stack) { fStack = stack; } |
csmartdalton | c6f411e | 2016-08-05 22:32:12 -0700 | [diff] [blame] | 26 | |
| 27 | bool quickContains(const SkRect&) const final; |
bsalomon | 7f0d9f3 | 2016-08-15 14:49:10 -0700 | [diff] [blame] | 28 | bool quickContains(const SkRRect&) const final; |
csmartdalton | c6f411e | 2016-08-05 22:32:12 -0700 | [diff] [blame] | 29 | void getConservativeBounds(int width, int height, SkIRect* devResult, |
| 30 | bool* isIntersectionOfRects) const final; |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 31 | bool apply(GrContext*, GrRenderTargetContext*, bool useHWAA, bool hasUserStencilSettings, |
Brian Salomon | 97180af | 2017-03-14 13:42:58 -0400 | [diff] [blame] | 32 | GrAppliedClip* out, SkRect* bounds) const final; |
robertphillips | 391395d | 2016-03-02 09:26:36 -0800 | [diff] [blame] | 33 | |
Brian Salomon | 0e8fc8b | 2016-12-09 15:10:07 -0500 | [diff] [blame] | 34 | bool isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA* aa) const override; |
bsalomon | cb31e51 | 2016-08-26 10:48:19 -0700 | [diff] [blame] | 35 | |
Robert Phillips | 875218e | 2017-02-24 08:37:13 -0500 | [diff] [blame] | 36 | sk_sp<GrTextureProxy> testingOnly_createClipMask(GrContext*) const; |
Brian Salomon | 19f0ed5 | 2017-01-06 13:54:58 -0500 | [diff] [blame] | 37 | static const char kMaskTestTag[]; |
| 38 | |
bsalomon@google.com | a320194 | 2012-06-21 19:58:20 +0000 | [diff] [blame] | 39 | private: |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 40 | static bool PathNeedsSWRenderer(GrContext* context, |
cdalton | 93a379b | 2016-05-11 13:58:08 -0700 | [diff] [blame] | 41 | bool hasUserStencilSettings, |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 42 | const GrRenderTargetContext*, |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 43 | const SkMatrix& viewMatrix, |
| 44 | const SkClipStack::Element* element, |
| 45 | GrPathRenderer** prOut, |
| 46 | bool needsStencil); |
commit-bot@chromium.org | e5a041c | 2014-03-07 19:43:43 +0000 | [diff] [blame] | 47 | |
bsalomon@google.com | 4c2443e | 2012-12-06 20:58:57 +0000 | [diff] [blame] | 48 | // Creates an alpha mask of the clip. The mask is a rasterization of elements through the |
| 49 | // rect specified by clipSpaceIBounds. |
Robert Phillips | 875218e | 2017-02-24 08:37:13 -0500 | [diff] [blame] | 50 | sk_sp<GrTextureProxy> createAlphaClipMask(GrContext*, const GrReducedClip&) const; |
joshualitt | 9853cce | 2014-11-17 14:22:48 -0800 | [diff] [blame] | 51 | |
bsalomon@google.com | 4c2443e | 2012-12-06 20:58:57 +0000 | [diff] [blame] | 52 | // Similar to createAlphaClipMask but it rasterizes in SW and uploads to the result texture. |
Robert Phillips | 875218e | 2017-02-24 08:37:13 -0500 | [diff] [blame] | 53 | sk_sp<GrTextureProxy> createSoftwareClipMask(GrContext*, const GrReducedClip&) const; |
robertphillips@google.com | f294b77 | 2012-04-27 14:29:26 +0000 | [diff] [blame] | 54 | |
Brian Salomon | 19f0ed5 | 2017-01-06 13:54:58 -0500 | [diff] [blame] | 55 | static bool UseSWOnlyPath(GrContext*, |
| 56 | bool hasUserStencilSettings, |
| 57 | const GrRenderTargetContext*, |
| 58 | const GrReducedClip&); |
csmartdalton | c6f411e | 2016-08-05 22:32:12 -0700 | [diff] [blame] | 59 | |
Mike Reed | 7ba4d71 | 2017-03-10 00:21:52 -0500 | [diff] [blame] | 60 | const SkClipStack* fStack; |
robertphillips@google.com | 1e945b7 | 2012-04-16 18:03:03 +0000 | [diff] [blame] | 61 | }; |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 62 | |
csmartdalton | c6f411e | 2016-08-05 22:32:12 -0700 | [diff] [blame] | 63 | #endif // GrClipStackClip_DEFINED |