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 | |
| 11 | #include "GrPathRenderer.h" |
| 12 | |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 13 | class GrProxyProvider; |
Brian Salomon | 653f42f | 2018-07-10 10:07:31 -0400 | [diff] [blame] | 14 | class GrTextureProxy; |
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 | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 22 | GrSoftwarePathRenderer(GrProxyProvider* proxyProvider, bool allowCaching) |
| 23 | : fProxyProvider(proxyProvider) |
| 24 | , fAllowCaching(allowCaching) { |
| 25 | } |
| 26 | |
bsalomon | 0aff2fa | 2015-07-31 06:48:27 -0700 | [diff] [blame] | 27 | private: |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 28 | static void DrawNonAARect(GrRenderTargetContext* renderTargetContext, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 29 | GrPaint&& paint, |
robertphillips | d2b6d64 | 2016-07-21 08:55:08 -0700 | [diff] [blame] | 30 | const GrUserStencilSettings& userStencilSettings, |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 31 | const GrClip& clip, |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 32 | const SkMatrix& viewMatrix, |
| 33 | const SkRect& rect, |
| 34 | const SkMatrix& localMatrix); |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 35 | static void DrawAroundInvPath(GrRenderTargetContext* renderTargetContext, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 36 | GrPaint&& paint, |
robertphillips | d2b6d64 | 2016-07-21 08:55:08 -0700 | [diff] [blame] | 37 | const GrUserStencilSettings& userStencilSettings, |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 38 | const GrClip& clip, |
robertphillips | 976f5f0 | 2016-06-03 10:59:20 -0700 | [diff] [blame] | 39 | const SkMatrix& viewMatrix, |
| 40 | const SkIRect& devClipBounds, |
| 41 | const SkIRect& devPathBounds); |
| 42 | |
Brian Osman | c7da146 | 2017-08-17 16:14:25 -0400 | [diff] [blame] | 43 | // This utility draws a path mask using a provided paint. The rectangle is drawn in device |
| 44 | // space. The 'viewMatrix' will be used to ensure the correct local coords are provided to |
| 45 | // any fragment processors in the paint. |
| 46 | static void DrawToTargetWithShapeMask(sk_sp<GrTextureProxy> proxy, |
| 47 | GrRenderTargetContext* renderTargetContext, |
| 48 | GrPaint&& paint, |
| 49 | const GrUserStencilSettings& userStencilSettings, |
| 50 | const GrClip& clip, |
| 51 | const SkMatrix& viewMatrix, |
| 52 | const SkIPoint& textureOriginInDeviceSpace, |
| 53 | const SkIRect& deviceSpaceRectToDraw); |
| 54 | |
bsalomon | 8acedde | 2016-06-24 10:42:16 -0700 | [diff] [blame] | 55 | StencilSupport onGetStencilSupport(const GrShape&) const override { |
robertphillips | e7d4b2f | 2015-08-13 07:57:10 -0700 | [diff] [blame] | 56 | return GrPathRenderer::kNoSupport_StencilSupport; |
| 57 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 58 | |
Chris Dalton | 5ed4423 | 2017-09-07 13:22:46 -0600 | [diff] [blame] | 59 | CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 60 | |
bsalomon | 0aff2fa | 2015-07-31 06:48:27 -0700 | [diff] [blame] | 61 | bool onDrawPath(const DrawPathArgs&) override; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 62 | |
robertphillips@google.com | f4c2c52 | 2012-04-27 12:08:47 +0000 | [diff] [blame] | 63 | private: |
Robert Phillips | 1afd4cd | 2018-01-08 13:40:32 -0500 | [diff] [blame] | 64 | GrProxyProvider* fProxyProvider; |
bsalomon | 39ef7fb | 2016-09-21 11:16:05 -0700 | [diff] [blame] | 65 | bool fAllowCaching; |
robertphillips@google.com | f4c2c52 | 2012-04-27 12:08:47 +0000 | [diff] [blame] | 66 | |
| 67 | typedef GrPathRenderer INHERITED; |
| 68 | }; |
| 69 | |
| 70 | #endif |