blob: d407791137ee4fb5f5bd8ea422474381619135c4 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "src/gpu/GrPathRenderer.h"
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000012
Robert Phillips1afd4cd2018-01-08 13:40:32 -050013class GrProxyProvider;
Brian Salomon653f42f2018-07-10 10:07:31 -040014class GrTextureProxy;
robertphillips@google.comb4f06d72012-05-15 12:10:05 +000015
16/**
robertphillips@google.comb4f06d72012-05-15 12:10:05 +000017 * 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.comf4c2c522012-04-27 12:08:47 +000020class GrSoftwarePathRenderer : public GrPathRenderer {
21public:
Robert Phillips1afd4cd2018-01-08 13:40:32 -050022 GrSoftwarePathRenderer(GrProxyProvider* proxyProvider, bool allowCaching)
23 : fProxyProvider(proxyProvider)
24 , fAllowCaching(allowCaching) {
25 }
26
Robert Phillips20390c32018-08-17 11:01:03 -040027 static bool GetShapeAndClipBounds(GrRenderTargetContext*,
28 const GrClip& clip,
29 const GrShape& shape,
30 const SkMatrix& matrix,
31 SkIRect* unclippedDevShapeBounds,
32 SkIRect* clippedDevShapeBounds,
33 SkIRect* devClipBounds);
34
bsalomon0aff2fa2015-07-31 06:48:27 -070035private:
Brian Osman11052242016-10-27 14:47:55 -040036 static void DrawNonAARect(GrRenderTargetContext* renderTargetContext,
Brian Salomon82f44312017-01-11 13:42:54 -050037 GrPaint&& paint,
robertphillipsd2b6d642016-07-21 08:55:08 -070038 const GrUserStencilSettings& userStencilSettings,
robertphillips976f5f02016-06-03 10:59:20 -070039 const GrClip& clip,
robertphillips976f5f02016-06-03 10:59:20 -070040 const SkMatrix& viewMatrix,
41 const SkRect& rect,
42 const SkMatrix& localMatrix);
Brian Osman11052242016-10-27 14:47:55 -040043 static void DrawAroundInvPath(GrRenderTargetContext* renderTargetContext,
Brian Salomon82f44312017-01-11 13:42:54 -050044 GrPaint&& paint,
robertphillipsd2b6d642016-07-21 08:55:08 -070045 const GrUserStencilSettings& userStencilSettings,
robertphillips976f5f02016-06-03 10:59:20 -070046 const GrClip& clip,
robertphillips976f5f02016-06-03 10:59:20 -070047 const SkMatrix& viewMatrix,
48 const SkIRect& devClipBounds,
49 const SkIRect& devPathBounds);
50
Brian Osmanc7da1462017-08-17 16:14:25 -040051 // This utility draws a path mask using a provided paint. The rectangle is drawn in device
52 // space. The 'viewMatrix' will be used to ensure the correct local coords are provided to
53 // any fragment processors in the paint.
54 static void DrawToTargetWithShapeMask(sk_sp<GrTextureProxy> proxy,
Brian Salomon078e8fa2019-11-22 04:10:18 +000055 GrColorType srcColorType,
Brian Osmanc7da1462017-08-17 16:14:25 -040056 GrRenderTargetContext* renderTargetContext,
57 GrPaint&& paint,
58 const GrUserStencilSettings& userStencilSettings,
59 const GrClip& clip,
60 const SkMatrix& viewMatrix,
61 const SkIPoint& textureOriginInDeviceSpace,
62 const SkIRect& deviceSpaceRectToDraw);
63
bsalomon8acedde2016-06-24 10:42:16 -070064 StencilSupport onGetStencilSupport(const GrShape&) const override {
robertphillipse7d4b2f2015-08-13 07:57:10 -070065 return GrPathRenderer::kNoSupport_StencilSupport;
66 }
halcanary9d524f22016-03-29 09:03:52 -070067
Chris Dalton5ed44232017-09-07 13:22:46 -060068 CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
bsalomon@google.com45a15f52012-12-10 19:10:17 +000069
bsalomon0aff2fa2015-07-31 06:48:27 -070070 bool onDrawPath(const DrawPathArgs&) override;
rmistry@google.comd6176b02012-08-23 18:14:13 +000071
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000072private:
Robert Phillips1afd4cd2018-01-08 13:40:32 -050073 GrProxyProvider* fProxyProvider;
bsalomon39ef7fb2016-09-21 11:16:05 -070074 bool fAllowCaching;
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000075
76 typedef GrPathRenderer INHERITED;
77};
78
79#endif