2 * Copyright 2012 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SoftwarePathRenderer_DEFINED
9 #define SoftwarePathRenderer_DEFINED
11 #include "src/gpu/ganesh/GrSurfaceProxyView.h"
12 #include "src/gpu/ganesh/v1/PathRenderer.h"
14 class GrProxyProvider;
19 * This class uses the software side to render a path to an SkBitmap and
20 * then uploads the result to the gpu
22 class SoftwarePathRenderer final : public PathRenderer {
24 const char* name() const override { return "SW"; }
26 SoftwarePathRenderer(GrProxyProvider* proxyProvider, bool allowCaching)
27 : fProxyProvider(proxyProvider)
28 , fAllowCaching(allowCaching) {
31 static bool GetShapeAndClipBounds(SurfaceDrawContext*,
34 const SkMatrix& viewMatrix,
35 SkIRect* unclippedDevShapeBounds,
36 SkIRect* clippedDevShapeBounds,
37 SkIRect* devClipBounds);
40 static void DrawNonAARect(SurfaceDrawContext*,
42 const GrUserStencilSettings&,
44 const SkMatrix& viewMatrix,
46 const SkMatrix& localMatrix);
47 static void DrawAroundInvPath(SurfaceDrawContext*,
49 const GrUserStencilSettings&,
51 const SkMatrix& viewMatrix,
52 const SkIRect& devClipBounds,
53 const SkIRect& devPathBounds);
55 // This utility draws a path mask using a provided paint. The rectangle is drawn in device
56 // space. The 'viewMatrix' will be used to ensure the correct local coords are provided to
57 // any fragment processors in the paint.
58 static void DrawToTargetWithShapeMask(GrSurfaceProxyView,
61 const GrUserStencilSettings&,
63 const SkMatrix& viewMatrix,
64 const SkIPoint& textureOriginInDeviceSpace,
65 const SkIRect& deviceSpaceRectToDraw);
67 StencilSupport onGetStencilSupport(const GrStyledShape&) const override {
68 return PathRenderer::kNoSupport_StencilSupport;
71 CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override;
73 bool onDrawPath(const DrawPathArgs&) override;
76 GrProxyProvider* fProxyProvider;
80 } // namespace skgpu::v1
82 #endif // SoftwarePathRenderer_DEFINED