blob: b399a188b77f5229c8ee5a7e0f7b35756aa39e4c [file] [log] [blame]
robertphillips@google.comf4c2c522012-04-27 12:08:47 +00001/*
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 Phillips1afd4cd2018-01-08 13:40:32 -050013class GrProxyProvider;
robertphillips@google.comb4f06d72012-05-15 12:10:05 +000014
15/**
robertphillips@google.comb4f06d72012-05-15 12:10:05 +000016 * 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.comf4c2c522012-04-27 12:08:47 +000019class GrSoftwarePathRenderer : public GrPathRenderer {
20public:
Robert Phillips1afd4cd2018-01-08 13:40:32 -050021 GrSoftwarePathRenderer(GrProxyProvider* proxyProvider, bool allowCaching)
22 : fProxyProvider(proxyProvider)
23 , fAllowCaching(allowCaching) {
24 }
25
bsalomon0aff2fa2015-07-31 06:48:27 -070026private:
Brian Osman11052242016-10-27 14:47:55 -040027 static void DrawNonAARect(GrRenderTargetContext* renderTargetContext,
Brian Salomon82f44312017-01-11 13:42:54 -050028 GrPaint&& paint,
robertphillipsd2b6d642016-07-21 08:55:08 -070029 const GrUserStencilSettings& userStencilSettings,
robertphillips976f5f02016-06-03 10:59:20 -070030 const GrClip& clip,
robertphillips976f5f02016-06-03 10:59:20 -070031 const SkMatrix& viewMatrix,
32 const SkRect& rect,
33 const SkMatrix& localMatrix);
Brian Osman11052242016-10-27 14:47:55 -040034 static void DrawAroundInvPath(GrRenderTargetContext* renderTargetContext,
Brian Salomon82f44312017-01-11 13:42:54 -050035 GrPaint&& paint,
robertphillipsd2b6d642016-07-21 08:55:08 -070036 const GrUserStencilSettings& userStencilSettings,
robertphillips976f5f02016-06-03 10:59:20 -070037 const GrClip& clip,
robertphillips976f5f02016-06-03 10:59:20 -070038 const SkMatrix& viewMatrix,
39 const SkIRect& devClipBounds,
40 const SkIRect& devPathBounds);
41
Brian Osmanc7da1462017-08-17 16:14:25 -040042 // 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
bsalomon8acedde2016-06-24 10:42:16 -070054 StencilSupport onGetStencilSupport(const GrShape&) const override {
robertphillipse7d4b2f2015-08-13 07:57:10 -070055 return GrPathRenderer::kNoSupport_StencilSupport;
56 }
halcanary9d524f22016-03-29 09:03:52 -070057
Chris Dalton5ed44232017-09-07 13:22:46 -060058 CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
bsalomon@google.com45a15f52012-12-10 19:10:17 +000059
bsalomon0aff2fa2015-07-31 06:48:27 -070060 bool onDrawPath(const DrawPathArgs&) override;
rmistry@google.comd6176b02012-08-23 18:14:13 +000061
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000062private:
Robert Phillips1afd4cd2018-01-08 13:40:32 -050063 GrProxyProvider* fProxyProvider;
bsalomon39ef7fb2016-09-21 11:16:05 -070064 bool fAllowCaching;
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000065
66 typedef GrPathRenderer INHERITED;
67};
68
69#endif