bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 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 | |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 8 | #ifndef GrPathRendererChain_DEFINED |
| 9 | #define GrPathRendererChain_DEFINED |
| 10 | |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 11 | #include "GrPathRenderer.h" |
| 12 | |
csmartdalton | 008b9d8 | 2017-02-22 12:00:42 -0700 | [diff] [blame] | 13 | #include "GrContextOptions.h" |
robertphillips | 13391dd | 2015-10-30 05:15:11 -0700 | [diff] [blame] | 14 | #include "SkTypes.h" |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 15 | #include "SkTArray.h" |
| 16 | |
| 17 | class GrContext; |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 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 | */ |
robertphillips | 13391dd | 2015-10-30 05:15:11 -0700 | [diff] [blame] | 25 | class GrPathRendererChain : public SkNoncopyable { |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 26 | public: |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 27 | struct Options { |
csmartdalton | 008b9d8 | 2017-02-22 12:00:42 -0700 | [diff] [blame] | 28 | using GpuPathRenderers = GrContextOptions::GpuPathRenderers; |
bsalomon | 39ef7fb | 2016-09-21 11:16:05 -0700 | [diff] [blame] | 29 | bool fAllowPathMaskCaching = false; |
csmartdalton | 008b9d8 | 2017-02-22 12:00:42 -0700 | [diff] [blame] | 30 | GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kAll; |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 31 | }; |
| 32 | GrPathRendererChain(GrContext* context, const Options&); |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 33 | |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 34 | /** Documents how the caller plans to use a GrPathRenderer to draw a path. It affects the PR |
| 35 | returned by getPathRenderer */ |
Brian Salomon | 82125e9 | 2016-12-10 09:35:48 -0500 | [diff] [blame] | 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 |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 40 | }; |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 41 | |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 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 |
skia.committer@gmail.com | c7b4be7 | 2012-12-11 02:01:20 +0000 | [diff] [blame] | 45 | StencilSupport in GrPathRenderer.h. */ |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 46 | GrPathRenderer* getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args, |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 47 | DrawType drawType, |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 48 | GrPathRenderer::StencilSupport* stencilSupport); |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 49 | |
| 50 | private: |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 51 | enum { |
| 52 | kPreAllocCount = 8, |
| 53 | }; |
csmartdalton | 008b9d8 | 2017-02-22 12:00:42 -0700 | [diff] [blame] | 54 | SkSTArray<kPreAllocCount, sk_sp<GrPathRenderer>> fChain; |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 55 | }; |
| 56 | |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 57 | #endif |