robertphillips@google.com | f4c2c52 | 2012-04-27 12:08:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 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 | |
| 8 | #ifndef GrSoftwarePathRenderer_DEFINED |
| 9 | #define GrSoftwarePathRenderer_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "src/gpu/GrPathRenderer.h" |
Brian Salomon | 99a813c | 2020-03-02 12:50:47 -0500 | [diff] [blame] | 12 | #include "src/gpu/GrSurfaceProxyView.h" |
robertphillips@google.com | f4c2c52 | 2012-04-27 12:08:47 +0000 | [diff] [blame] | 13 | |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 14 | class GrProxyProvider; |
robertphillips@google.com | b4f06d7 | 2012-05-15 12:10:05 +0000 | [diff] [blame] | 15 | |
| 16 | /** |
robertphillips@google.com | b4f06d7 | 2012-05-15 12:10:05 +0000 | [diff] [blame] | 17 | * This class uses the software side to render a path to an SkBitmap and |
| 18 | * then uploads the result to the gpu |
| 19 | */ |
robertphillips@google.com | f4c2c52 | 2012-04-27 12:08:47 +0000 | [diff] [blame] | 20 | class GrSoftwarePathRenderer : public GrPathRenderer { |
| 21 | public: |
Robert Phillips | a628605 | 2020-04-13 10:55:08 -0400 | [diff] [blame] | 22 | const char* name() const final { return "SW"; } |
| 23 | |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 24 | GrSoftwarePathRenderer(GrProxyProvider* proxyProvider, bool allowCaching) |
| 25 | : fProxyProvider(proxyProvider) |
| 26 | , fAllowCaching(allowCaching) { |
| 27 | } |
| 28 | |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame^] | 29 | static bool GetShapeAndClipBounds(skgpu::v1::SurfaceDrawContext*, |
| 30 | const GrClip*, |
| 31 | const GrStyledShape&, |
| 32 | const SkMatrix& viewMatrix, |
Robert Phillips | 20390c3 | 2018-08-17 11:01:03 -0400 | [diff] [blame] | 33 | SkIRect* unclippedDevShapeBounds, |
| 34 | SkIRect* clippedDevShapeBounds, |
| 35 | SkIRect* devClipBounds); |
| 36 | |
bsalomon | 0aff2fa | 2015-07-31 06:48:27 -0700 | [diff] [blame] | 37 | private: |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame^] | 38 | static void DrawNonAARect(skgpu::v1::SurfaceDrawContext*, |
| 39 | GrPaint&&, |
| 40 | const GrUserStencilSettings&, |
| 41 | const GrClip*, |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 42 | const SkMatrix& viewMatrix, |
| 43 | const SkRect& rect, |
| 44 | const SkMatrix& localMatrix); |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame^] | 45 | static void DrawAroundInvPath(skgpu::v1::SurfaceDrawContext*, |
| 46 | GrPaint&&, |
| 47 | const GrUserStencilSettings&, |
| 48 | const GrClip*, |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 49 | const SkMatrix& viewMatrix, |
| 50 | const SkIRect& devClipBounds, |
| 51 | const SkIRect& devPathBounds); |
| 52 | |
Brian Osman | c7da146 | 2017-08-17 16:14:25 -0400 | [diff] [blame] | 53 | // This utility draws a path mask using a provided paint. The rectangle is drawn in device |
| 54 | // space. The 'viewMatrix' will be used to ensure the correct local coords are provided to |
| 55 | // any fragment processors in the paint. |
Greg Daniel | 9f0dfbd | 2020-02-10 11:47:11 -0500 | [diff] [blame] | 56 | static void DrawToTargetWithShapeMask(GrSurfaceProxyView, |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame^] | 57 | skgpu::v1::SurfaceDrawContext*, |
| 58 | GrPaint&&, |
| 59 | const GrUserStencilSettings&, |
| 60 | const GrClip*, |
Brian Osman | c7da146 | 2017-08-17 16:14:25 -0400 | [diff] [blame] | 61 | const SkMatrix& viewMatrix, |
| 62 | const SkIPoint& textureOriginInDeviceSpace, |
| 63 | const SkIRect& deviceSpaceRectToDraw); |
| 64 | |
Michael Ludwig | 2686d69 | 2020-04-17 20:21:37 +0000 | [diff] [blame] | 65 | StencilSupport onGetStencilSupport(const GrStyledShape&) const override { |
robertphillips | e7d4b2f | 2015-08-13 07:57:10 -0700 | [diff] [blame] | 66 | return GrPathRenderer::kNoSupport_StencilSupport; |
| 67 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 68 | |
Chris Dalton | 5ed4423 | 2017-09-07 13:22:46 -0600 | [diff] [blame] | 69 | CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 70 | |
bsalomon | 0aff2fa | 2015-07-31 06:48:27 -0700 | [diff] [blame] | 71 | bool onDrawPath(const DrawPathArgs&) override; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 72 | |
robertphillips@google.com | f4c2c52 | 2012-04-27 12:08:47 +0000 | [diff] [blame] | 73 | private: |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 74 | GrProxyProvider* fProxyProvider; |
bsalomon | 39ef7fb | 2016-09-21 11:16:05 -0700 | [diff] [blame] | 75 | bool fAllowCaching; |
robertphillips@google.com | f4c2c52 | 2012-04-27 12:08:47 +0000 | [diff] [blame] | 76 | |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 77 | using INHERITED = GrPathRenderer; |
robertphillips@google.com | f4c2c52 | 2012-04-27 12:08:47 +0000 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | #endif |