blob: a9752b00e245440c70a6c1c6444d207e0014187b [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"
Brian Salomon99a813c2020-03-02 12:50:47 -050012#include "src/gpu/GrSurfaceProxyView.h"
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000013
Robert Phillips1afd4cd2018-01-08 13:40:32 -050014class GrProxyProvider;
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 Phillipsa6286052020-04-13 10:55:08 -040022 const char* name() const final { return "SW"; }
23
Robert Phillips1afd4cd2018-01-08 13:40:32 -050024 GrSoftwarePathRenderer(GrProxyProvider* proxyProvider, bool allowCaching)
25 : fProxyProvider(proxyProvider)
26 , fAllowCaching(allowCaching) {
27 }
28
Robert Phillips4dca8312021-07-28 15:13:20 -040029 static bool GetShapeAndClipBounds(skgpu::v1::SurfaceDrawContext*,
30 const GrClip*,
31 const GrStyledShape&,
32 const SkMatrix& viewMatrix,
Robert Phillips20390c32018-08-17 11:01:03 -040033 SkIRect* unclippedDevShapeBounds,
34 SkIRect* clippedDevShapeBounds,
35 SkIRect* devClipBounds);
36
bsalomon0aff2fa2015-07-31 06:48:27 -070037private:
Robert Phillips4dca8312021-07-28 15:13:20 -040038 static void DrawNonAARect(skgpu::v1::SurfaceDrawContext*,
39 GrPaint&&,
40 const GrUserStencilSettings&,
41 const GrClip*,
robertphillips976f5f02016-06-03 10:59:20 -070042 const SkMatrix& viewMatrix,
43 const SkRect& rect,
44 const SkMatrix& localMatrix);
Robert Phillips4dca8312021-07-28 15:13:20 -040045 static void DrawAroundInvPath(skgpu::v1::SurfaceDrawContext*,
46 GrPaint&&,
47 const GrUserStencilSettings&,
48 const GrClip*,
robertphillips976f5f02016-06-03 10:59:20 -070049 const SkMatrix& viewMatrix,
50 const SkIRect& devClipBounds,
51 const SkIRect& devPathBounds);
52
Brian Osmanc7da1462017-08-17 16:14:25 -040053 // This utility draws a path mask using a provided paint. The rectangle is drawn in device
54 // space. The 'viewMatrix' will be used to ensure the correct local coords are provided to
55 // any fragment processors in the paint.
Greg Daniel9f0dfbd2020-02-10 11:47:11 -050056 static void DrawToTargetWithShapeMask(GrSurfaceProxyView,
Robert Phillips4dca8312021-07-28 15:13:20 -040057 skgpu::v1::SurfaceDrawContext*,
58 GrPaint&&,
59 const GrUserStencilSettings&,
60 const GrClip*,
Brian Osmanc7da1462017-08-17 16:14:25 -040061 const SkMatrix& viewMatrix,
62 const SkIPoint& textureOriginInDeviceSpace,
63 const SkIRect& deviceSpaceRectToDraw);
64
Michael Ludwig2686d692020-04-17 20:21:37 +000065 StencilSupport onGetStencilSupport(const GrStyledShape&) const override {
robertphillipse7d4b2f2015-08-13 07:57:10 -070066 return GrPathRenderer::kNoSupport_StencilSupport;
67 }
halcanary9d524f22016-03-29 09:03:52 -070068
Chris Dalton5ed44232017-09-07 13:22:46 -060069 CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
bsalomon@google.com45a15f52012-12-10 19:10:17 +000070
bsalomon0aff2fa2015-07-31 06:48:27 -070071 bool onDrawPath(const DrawPathArgs&) override;
rmistry@google.comd6176b02012-08-23 18:14:13 +000072
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000073private:
Robert Phillips1afd4cd2018-01-08 13:40:32 -050074 GrProxyProvider* fProxyProvider;
bsalomon39ef7fb2016-09-21 11:16:05 -070075 bool fAllowCaching;
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000076
John Stiles7571f9e2020-09-02 22:42:33 -040077 using INHERITED = GrPathRenderer;
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000078};
79
80#endif