blob: 5d082020f87b8de20d2d67857e5e3435c0a68012 [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;
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,
55 GrRenderTargetContext* renderTargetContext,
56 GrPaint&& paint,
57 const GrUserStencilSettings& userStencilSettings,
58 const GrClip& clip,
59 const SkMatrix& viewMatrix,
60 const SkIPoint& textureOriginInDeviceSpace,
61 const SkIRect& deviceSpaceRectToDraw);
62
bsalomon8acedde2016-06-24 10:42:16 -070063 StencilSupport onGetStencilSupport(const GrShape&) const override {
robertphillipse7d4b2f2015-08-13 07:57:10 -070064 return GrPathRenderer::kNoSupport_StencilSupport;
65 }
halcanary9d524f22016-03-29 09:03:52 -070066
Chris Dalton5ed44232017-09-07 13:22:46 -060067 CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
bsalomon@google.com45a15f52012-12-10 19:10:17 +000068
bsalomon0aff2fa2015-07-31 06:48:27 -070069 bool onDrawPath(const DrawPathArgs&) override;
rmistry@google.comd6176b02012-08-23 18:14:13 +000070
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000071private:
Robert Phillips1afd4cd2018-01-08 13:40:32 -050072 GrProxyProvider* fProxyProvider;
bsalomon39ef7fb2016-09-21 11:16:05 -070073 bool fAllowCaching;
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000074
75 typedef GrPathRenderer INHERITED;
76};
77
78#endif