1 | /* |
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 "src/gpu/GrPathRenderer.h" |
12 | #include "src/gpu/GrSurfaceProxyView.h" |
13 | |
14 | class GrProxyProvider; |
15 | |
16 | /** |
17 | * This class uses the software side to render a path to an SkBitmap and |
18 | * then uploads the result to the gpu |
19 | */ |
20 | class GrSoftwarePathRenderer : public GrPathRenderer { |
21 | public: |
22 | GrSoftwarePathRenderer(GrProxyProvider* proxyProvider, bool allowCaching) |
23 | : fProxyProvider(proxyProvider) |
24 | , fAllowCaching(allowCaching) { |
25 | } |
26 | |
27 | static bool GetShapeAndClipBounds(GrRenderTargetContext*, |
28 | const GrClip& clip, |
29 | const GrShape& shape, |
30 | const SkMatrix& matrix, |
31 | SkIRect* unclippedDevShapeBounds, |
32 | SkIRect* clippedDevShapeBounds, |
33 | SkIRect* devClipBounds); |
34 | |
35 | private: |
36 | static void DrawNonAARect(GrRenderTargetContext* renderTargetContext, |
37 | GrPaint&& paint, |
38 | const GrUserStencilSettings& userStencilSettings, |
39 | const GrClip& clip, |
40 | const SkMatrix& viewMatrix, |
41 | const SkRect& rect, |
42 | const SkMatrix& localMatrix); |
43 | static void DrawAroundInvPath(GrRenderTargetContext* renderTargetContext, |
44 | GrPaint&& paint, |
45 | const GrUserStencilSettings& userStencilSettings, |
46 | const GrClip& clip, |
47 | const SkMatrix& viewMatrix, |
48 | const SkIRect& devClipBounds, |
49 | const SkIRect& devPathBounds); |
50 | |
51 | // This utility draws a path mask using a provided paint. The rectangle is drawn in device |
52 | // space. The 'viewMatrix' will be used to ensure the correct local coords are provided to |
53 | // any fragment processors in the paint. |
54 | static void DrawToTargetWithShapeMask(GrSurfaceProxyView, |
55 | GrRenderTargetContext* renderTargetContext, |
56 | GrPaint&& paint, |
57 | const GrUserStencilSettings& userStencilSettings, |
58 | const GrClip& clip, |
59 | const SkMatrix& viewMatrix, |
60 | const SkIPoint& textureOriginInDeviceSpace, |
61 | const SkIRect& deviceSpaceRectToDraw); |
62 | |
63 | StencilSupport onGetStencilSupport(const GrShape&) const override { |
64 | return GrPathRenderer::kNoSupport_StencilSupport; |
65 | } |
66 | |
67 | CanDrawPath onCanDrawPath(const CanDrawPathArgs&) const override; |
68 | |
69 | bool onDrawPath(const DrawPathArgs&) override; |
70 | |
71 | private: |
72 | GrProxyProvider* fProxyProvider; |
73 | bool fAllowCaching; |
74 | |
75 | typedef GrPathRenderer INHERITED; |
76 | }; |
77 | |
78 | #endif |
79 | |