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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "src/core/SkClipStack.h" |
| 11 | #include "src/gpu/GrClip.h" |
| 12 | #include "src/gpu/GrReducedClip.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: |
Michael Ludwig | e06a897 | 2020-06-11 10:29:00 -0400 | [diff] [blame] | 23 | GrClipStackClip(const SkISize& dimensions, |
| 24 | const SkClipStack* stack = nullptr, |
| 25 | const SkMatrixProvider* matrixProvider = nullptr) |
| 26 | : fDeviceSize(dimensions) |
| 27 | , fStack(stack) |
| 28 | , fMatrixProvider(matrixProvider) {} |
csmartdalton | c6f411e | 2016-08-05 22:32:12 -0700 | [diff] [blame] | 29 | |
Michael Ludwig | e06a897 | 2020-06-11 10:29:00 -0400 | [diff] [blame] | 30 | SkIRect getConservativeBounds() const final; |
Chris Dalton | ea46ef3 | 2021-07-12 15:09:06 -0600 | [diff] [blame^] | 31 | Effect apply(GrRecordingContext*, GrSurfaceDrawContext*, GrDrawOp*, GrAAType aaType, |
| 32 | GrAppliedClip* out, SkRect* bounds) const final; |
Michael Ludwig | 6397e80 | 2020-08-05 15:50:01 -0400 | [diff] [blame] | 33 | PreClipResult preApply(const SkRect& drawBounds, GrAA aa) const final; |
bsalomon | cb31e51 | 2016-08-26 10:48:19 -0700 | [diff] [blame] | 34 | |
Robert Phillips | 4e105e2 | 2020-07-16 09:18:50 -0400 | [diff] [blame] | 35 | sk_sp<GrTextureProxy> testingOnly_createClipMask(GrRecordingContext*) const; |
Brian Salomon | c3833b4 | 2018-07-09 18:23:58 +0000 | [diff] [blame] | 36 | static const char kMaskTestTag[]; |
Brian Salomon | 19f0ed5 | 2017-01-06 13:54:58 -0500 | [diff] [blame] | 37 | |
bsalomon@google.com | a320194 | 2012-06-21 19:58:20 +0000 | [diff] [blame] | 38 | private: |
Brian Salomon | eebe735 | 2020-12-09 16:37:04 -0500 | [diff] [blame] | 39 | bool applyClipMask(GrRecordingContext*, GrSurfaceDrawContext*, const GrReducedClip&, |
Chris Dalton | 6edc8d9 | 2021-05-27 09:40:43 -0600 | [diff] [blame] | 40 | GrAppliedClip*) const; |
Chris Dalton | a32a3c3 | 2017-12-05 10:05:21 -0700 | [diff] [blame] | 41 | |
Chris Dalton | c534808 | 2018-03-30 15:59:38 +0000 | [diff] [blame] | 42 | // Creates an alpha mask of the clip. The mask is a rasterization of elements through the |
| 43 | // rect specified by clipSpaceIBounds. |
Greg Daniel | e32506b | 2020-02-10 16:00:54 -0500 | [diff] [blame] | 44 | GrSurfaceProxyView createAlphaClipMask(GrRecordingContext*, const GrReducedClip&) const; |
Chris Dalton | c534808 | 2018-03-30 15:59:38 +0000 | [diff] [blame] | 45 | |
| 46 | // Similar to createAlphaClipMask but it rasterizes in SW and uploads to the result texture. |
Greg Daniel | e32506b | 2020-02-10 16:00:54 -0500 | [diff] [blame] | 47 | GrSurfaceProxyView createSoftwareClipMask(GrRecordingContext*, const GrReducedClip&, |
Brian Salomon | eebe735 | 2020-12-09 16:37:04 -0500 | [diff] [blame] | 48 | GrSurfaceDrawContext*) const; |
robertphillips@google.com | f294b77 | 2012-04-27 14:29:26 +0000 | [diff] [blame] | 49 | |
Robert Phillips | 6f0e02f | 2019-02-13 11:02:28 -0500 | [diff] [blame] | 50 | static bool UseSWOnlyPath(GrRecordingContext*, |
Brian Salomon | eebe735 | 2020-12-09 16:37:04 -0500 | [diff] [blame] | 51 | const GrSurfaceDrawContext*, |
Chris Dalton | c534808 | 2018-03-30 15:59:38 +0000 | [diff] [blame] | 52 | const GrReducedClip&); |
| 53 | |
Michael Ludwig | e06a897 | 2020-06-11 10:29:00 -0400 | [diff] [blame] | 54 | // SkClipStack does not track device bounds explicitly, but it will refine these device bounds |
| 55 | // as clip elements are added to the stack. |
| 56 | SkISize fDeviceSize; |
Michael Ludwig | 4e221bd | 2020-06-05 11:29:36 -0400 | [diff] [blame] | 57 | const SkClipStack* fStack; |
| 58 | const SkMatrixProvider* fMatrixProvider; // for applying clip shaders |
robertphillips@google.com | 1e945b7 | 2012-04-16 18:03:03 +0000 | [diff] [blame] | 59 | }; |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 60 | |
csmartdalton | c6f411e | 2016-08-05 22:32:12 -0700 | [diff] [blame] | 61 | #endif // GrClipStackClip_DEFINED |