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