1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2012 Google Inc. 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci#ifndef SoftwarePathRenderer_DEFINED 9cb93a386Sopenharmony_ci#define SoftwarePathRenderer_DEFINED 10cb93a386Sopenharmony_ci 11cb93a386Sopenharmony_ci#include "src/gpu/GrSurfaceProxyView.h" 12cb93a386Sopenharmony_ci#include "src/gpu/v1/PathRenderer.h" 13cb93a386Sopenharmony_ci 14cb93a386Sopenharmony_ciclass GrProxyProvider; 15cb93a386Sopenharmony_ci 16cb93a386Sopenharmony_cinamespace skgpu::v1 { 17cb93a386Sopenharmony_ci 18cb93a386Sopenharmony_ci/** 19cb93a386Sopenharmony_ci * This class uses the software side to render a path to an SkBitmap and 20cb93a386Sopenharmony_ci * then uploads the result to the gpu 21cb93a386Sopenharmony_ci */ 22cb93a386Sopenharmony_ciclass SoftwarePathRenderer final : public PathRenderer { 23cb93a386Sopenharmony_cipublic: 24cb93a386Sopenharmony_ci const char* name() const override { return "SW"; } 25cb93a386Sopenharmony_ci 26cb93a386Sopenharmony_ci SoftwarePathRenderer(GrProxyProvider* proxyProvider, bool allowCaching) 27cb93a386Sopenharmony_ci : fProxyProvider(proxyProvider) 28cb93a386Sopenharmony_ci , fAllowCaching(allowCaching) { 29cb93a386Sopenharmony_ci } 30cb93a386Sopenharmony_ci 31cb93a386Sopenharmony_ci static bool GetShapeAndClipBounds(SurfaceDrawContext*, 32cb93a386Sopenharmony_ci const GrClip*, 33cb93a386Sopenharmony_ci const GrStyledShape&, 34cb93a386Sopenharmony_ci const SkMatrix& viewMatrix, 35cb93a386Sopenharmony_ci SkIRect* unclippedDevShapeBounds, 36cb93a386Sopenharmony_ci SkIRect* clippedDevShapeBounds, 37cb93a386Sopenharmony_ci SkIRect* devClipBounds); 38cb93a386Sopenharmony_ci 39cb93a386Sopenharmony_ciprivate: 40cb93a386Sopenharmony_ci static void DrawNonAARect(SurfaceDrawContext*, 41cb93a386Sopenharmony_ci GrPaint&&, 42cb93a386Sopenharmony_ci const GrUserStencilSettings&, 43cb93a386Sopenharmony_ci const GrClip*, 44cb93a386Sopenharmony_ci const SkMatrix& viewMatrix, 45cb93a386Sopenharmony_ci const SkRect& rect, 46cb93a386Sopenharmony_ci const SkMatrix& localMatrix); 47cb93a386Sopenharmony_ci static void DrawAroundInvPath(SurfaceDrawContext*, 48cb93a386Sopenharmony_ci GrPaint&&, 49cb93a386Sopenharmony_ci const GrUserStencilSettings&, 50cb93a386Sopenharmony_ci const GrClip*, 51cb93a386Sopenharmony_ci const SkMatrix& viewMatrix, 52cb93a386Sopenharmony_ci const SkIRect& devClipBounds, 53cb93a386Sopenharmony_ci const SkIRect& devPathBounds); 54cb93a386Sopenharmony_ci 55cb93a386Sopenharmony_ci // This utility draws a path mask using a provided paint. The rectangle is drawn in device 56cb93a386Sopenharmony_ci // space. The 'viewMatrix' will be used to ensure the correct local coords are provided to 57cb93a386Sopenharmony_ci // any fragment processors in the paint. 58cb93a386Sopenharmony_ci static void DrawToTargetWithShapeMask(GrSurfaceProxyView, 59cb93a386Sopenharmony_ci SurfaceDrawContext*, 60cb93a386Sopenharmony_ci GrPaint&&, 61cb93a386Sopenharmony_ci const GrUserStencilSettings&, 62cb93a386Sopenharmony_ci const GrClip*, 63cb93a386Sopenharmony_ci const SkMatrix& viewMatrix, 64cb93a386Sopenharmony_ci const SkIPoint& textureOriginInDeviceSpace, 65cb93a386Sopenharmony_ci const SkIRect& deviceSpaceRectToDraw); 66cb93a386Sopenharmony_ci 67cb93a386Sopenharmony_ci StencilSupport onGetStencilSupport(const GrStyledShape&) const override { 68cb93a386Sopenharmony_ci return PathRenderer::kNoSupport_StencilSupport; 69cb93a386Sopenharmony_ci } 70cb93a386Sopenharmony_ci 71cb93a386Sopenharmony_ci CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; 72cb93a386Sopenharmony_ci 73cb93a386Sopenharmony_ci bool onDrawPath(const DrawPathArgs&) override; 74cb93a386Sopenharmony_ci 75cb93a386Sopenharmony_ciprivate: 76cb93a386Sopenharmony_ci GrProxyProvider* fProxyProvider; 77cb93a386Sopenharmony_ci bool fAllowCaching; 78cb93a386Sopenharmony_ci}; 79cb93a386Sopenharmony_ci 80cb93a386Sopenharmony_ci} // namespace skgpu::v1 81cb93a386Sopenharmony_ci 82cb93a386Sopenharmony_ci#endif // SoftwarePathRenderer_DEFINED 83