blob: d36b2f648641937f7f3e0ddb19b625971b6a963f [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
Brian Osman32342f02017-03-04 08:12:46 -050013class GrResourceProvider;
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:
Brian Osman32342f02017-03-04 08:12:46 -050021 GrSoftwarePathRenderer(GrResourceProvider* resourceProvider, bool allowCaching)
22 : fResourceProvider(resourceProvider)
bsalomon39ef7fb2016-09-21 11:16:05 -070023 , fAllowCaching(allowCaching) {}
bsalomon0aff2fa2015-07-31 06:48:27 -070024private:
Brian Osman11052242016-10-27 14:47:55 -040025 static void DrawNonAARect(GrRenderTargetContext* renderTargetContext,
Brian Salomon82f44312017-01-11 13:42:54 -050026 GrPaint&& paint,
robertphillipsd2b6d642016-07-21 08:55:08 -070027 const GrUserStencilSettings& userStencilSettings,
robertphillips976f5f02016-06-03 10:59:20 -070028 const GrClip& clip,
robertphillips976f5f02016-06-03 10:59:20 -070029 const SkMatrix& viewMatrix,
30 const SkRect& rect,
31 const SkMatrix& localMatrix);
Brian Osman11052242016-10-27 14:47:55 -040032 static void DrawAroundInvPath(GrRenderTargetContext* renderTargetContext,
Brian Salomon82f44312017-01-11 13:42:54 -050033 GrPaint&& paint,
robertphillipsd2b6d642016-07-21 08:55:08 -070034 const GrUserStencilSettings& userStencilSettings,
robertphillips976f5f02016-06-03 10:59:20 -070035 const GrClip& clip,
robertphillips976f5f02016-06-03 10:59:20 -070036 const SkMatrix& viewMatrix,
37 const SkIRect& devClipBounds,
38 const SkIRect& devPathBounds);
39
Brian Osmanc7da1462017-08-17 16:14:25 -040040 // This utility draws a path mask using a provided paint. The rectangle is drawn in device
41 // space. The 'viewMatrix' will be used to ensure the correct local coords are provided to
42 // any fragment processors in the paint.
43 static void DrawToTargetWithShapeMask(sk_sp<GrTextureProxy> proxy,
44 GrRenderTargetContext* renderTargetContext,
45 GrPaint&& paint,
46 const GrUserStencilSettings& userStencilSettings,
47 const GrClip& clip,
48 const SkMatrix& viewMatrix,
49 const SkIPoint& textureOriginInDeviceSpace,
50 const SkIRect& deviceSpaceRectToDraw);
51
bsalomon8acedde2016-06-24 10:42:16 -070052 StencilSupport onGetStencilSupport(const GrShape&) const override {
robertphillipse7d4b2f2015-08-13 07:57:10 -070053 return GrPathRenderer::kNoSupport_StencilSupport;
54 }
halcanary9d524f22016-03-29 09:03:52 -070055
Chris Dalton5ed44232017-09-07 13:22:46 -060056 CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
bsalomon@google.com45a15f52012-12-10 19:10:17 +000057
bsalomon0aff2fa2015-07-31 06:48:27 -070058 bool onDrawPath(const DrawPathArgs&) override;
rmistry@google.comd6176b02012-08-23 18:14:13 +000059
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000060private:
Brian Osman32342f02017-03-04 08:12:46 -050061 GrResourceProvider* fResourceProvider;
bsalomon39ef7fb2016-09-21 11:16:05 -070062 bool fAllowCaching;
robertphillips@google.comf4c2c522012-04-27 12:08:47 +000063
64 typedef GrPathRenderer INHERITED;
65};
66
67#endif