Line data Source code
1 : /*
2 : * Copyright 2011 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 GrPathRendererChain_DEFINED
9 : #define GrPathRendererChain_DEFINED
10 :
11 : #include "GrPathRenderer.h"
12 :
13 : #include "GrContextOptions.h"
14 : #include "SkTypes.h"
15 : #include "SkTArray.h"
16 :
17 : class GrContext;
18 :
19 : /**
20 : * Keeps track of an ordered list of path renderers. When a path needs to be
21 : * drawn this list is scanned to find the most preferred renderer. To add your
22 : * path renderer to the list implement the GrPathRenderer::AddPathRenderers
23 : * function.
24 : */
25 0 : class GrPathRendererChain : public SkNoncopyable {
26 : public:
27 : struct Options {
28 : using GpuPathRenderers = GrContextOptions::GpuPathRenderers;
29 : bool fAllowPathMaskCaching = false;
30 : GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kAll;
31 : };
32 : GrPathRendererChain(GrContext* context, const Options&);
33 :
34 : /** Documents how the caller plans to use a GrPathRenderer to draw a path. It affects the PR
35 : returned by getPathRenderer */
36 : enum class DrawType {
37 : kColor, // draw to the color buffer, no AA
38 : kStencil, // draw just to the stencil buffer
39 : kStencilAndColor, // draw the stencil and color buffer, no AA
40 : };
41 :
42 : /** Returns a GrPathRenderer compatible with the request if one is available. If the caller
43 : is drawing the path to the stencil buffer then stencilSupport can be used to determine
44 : whether the path can be rendered with arbitrary stencil rules or not. See comments on
45 : StencilSupport in GrPathRenderer.h. */
46 : GrPathRenderer* getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args,
47 : DrawType drawType,
48 : GrPathRenderer::StencilSupport* stencilSupport);
49 :
50 : private:
51 : enum {
52 : kPreAllocCount = 8,
53 : };
54 : SkSTArray<kPreAllocCount, sk_sp<GrPathRenderer>> fChain;
55 : };
56 :
57 : #endif
|