blob: 925cc52889d238e2544a2e976f570fae9129c478 [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
bsalomon0aff2fa2015-07-31 06:48:27 -070027private:
Brian Osman11052242016-10-27 14:47:55 -040028 static void DrawNonAARect(GrRenderTargetContext* renderTargetContext,
Brian Salomon82f44312017-01-11 13:42:54 -050029 GrPaint&& paint,
robertphillipsd2b6d642016-07-21 08:55:08 -070030 const GrUserStencilSettings& userStencilSettings,
robertphillips976f5f02016-06-03 10:59:20 -070031 const GrClip& clip,
robertphillips976f5f02016-06-03 10:59:20 -070032 const SkMatrix& viewMatrix,
33 const SkRect& rect,
34 const SkMatrix& localMatrix);
Brian Osman11052242016-10-27 14:47:55 -040035 static void DrawAroundInvPath(GrRenderTargetContext* renderTargetContext,
Brian Salomon82f44312017-01-11 13:42:54 -050036 GrPaint&& paint,
robertphillipsd2b6d642016-07-21 08:55:08 -070037 const GrUserStencilSettings& userStencilSettings,
robertphillips976f5f02016-06-03 10:59:20 -070038 const GrClip& clip,
robertphillips976f5f02016-06-03 10:59:20 -070039 const SkMatrix& viewMatrix,
40 const SkIRect& devClipBounds,
41 const SkIRect& devPathBounds);
42
Brian Osmanc7da1462017-08-17 16:14:25 -040043 // 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
bsalomon8acedde2016-06-24 10:42:16 -070055 StencilSupport onGetStencilSupport(const GrShape&) const override {
robertphillipse7d4b2f2015-08-13 07:57:10 -070056 return GrPathRenderer::kNoSupport_StencilSupport;
57 }
halcanary9d524f22016-03-29 09:03:52 -070058
Chris Dalton5ed44232017-09-07 13:22:46 -060059 CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
bsalomon@google.com45a15f52012-12-10 19:10:17 +000060
bsalomon0aff2fa2015-07-31 06:48:27 -070061 bool onDrawPath(const DrawPathArgs&) override;
rmistry@google.comd6176b02012-08-23 18:14:13 +000062
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000063private:
Robert Phillips1afd4cd2018-01-08 13:40:32 -050064 GrProxyProvider* fProxyProvider;
bsalomon39ef7fb2016-09-21 11:16:05 -070065 bool fAllowCaching;
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000066
67 typedef GrPathRenderer INHERITED;
68};
69
70#endif