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 | |
robertphillips | 13391dd | 2015-10-30 05:15:11 -0700 | [diff] [blame] | 13 | #include "SkTypes.h" |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 14 | #include "SkTArray.h" |
| 15 | |
| 16 | class GrContext; |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 17 | |
| 18 | /** |
| 19 | * Keeps track of an ordered list of path renderers. When a path needs to be |
| 20 | * drawn this list is scanned to find the most preferred renderer. To add your |
| 21 | * path renderer to the list implement the GrPathRenderer::AddPathRenderers |
| 22 | * function. |
| 23 | */ |
robertphillips | 13391dd | 2015-10-30 05:15:11 -0700 | [diff] [blame] | 24 | class GrPathRendererChain : public SkNoncopyable { |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 25 | public: |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 26 | struct Options { |
| 27 | bool fDisableDistanceFieldRenderer = false; |
bsalomon | 39ef7fb | 2016-09-21 11:16:05 -0700 | [diff] [blame] | 28 | bool fAllowPathMaskCaching = false; |
| 29 | bool fDisableAllPathRenderers = false; |
bsalomon | 6b2552f | 2016-09-15 13:50:26 -0700 | [diff] [blame] | 30 | }; |
| 31 | GrPathRendererChain(GrContext* context, const Options&); |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 32 | |
| 33 | ~GrPathRendererChain(); |
| 34 | |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 35 | /** Documents how the caller plans to use a GrPathRenderer to draw a path. It affects the PR |
| 36 | returned by getPathRenderer */ |
| 37 | enum DrawType { |
| 38 | kColor_DrawType, // draw to the color buffer, no AA |
| 39 | kColorAntiAlias_DrawType, // draw to color buffer, with partial coverage AA |
| 40 | kStencilOnly_DrawType, // draw just to the stencil buffer |
| 41 | kStencilAndColor_DrawType, // draw the stencil and color buffer, no AA |
| 42 | kStencilAndColorAntiAlias_DrawType // draw the stencil and color buffer, with partial |
| 43 | // coverage AA. |
| 44 | }; |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 45 | |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 46 | /** Returns a GrPathRenderer compatible with the request if one is available. If the caller |
| 47 | is drawing the path to the stencil buffer then stencilSupport can be used to determine |
| 48 | 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] | 49 | StencilSupport in GrPathRenderer.h. */ |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 50 | GrPathRenderer* getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args, |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 51 | DrawType drawType, |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 52 | GrPathRenderer::StencilSupport* stencilSupport); |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 53 | |
| 54 | private: |
robertphillips | 6873782 | 2015-10-29 12:12:21 -0700 | [diff] [blame] | 55 | // takes a ref and unrefs in destructor |
| 56 | GrPathRenderer* addPathRenderer(GrPathRenderer* pr); |
| 57 | |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 58 | enum { |
| 59 | kPreAllocCount = 8, |
| 60 | }; |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 61 | SkSTArray<kPreAllocCount, GrPathRenderer*, true> fChain; |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
bsalomon@google.com | 45a15f5 | 2012-12-10 19:10:17 +0000 | [diff] [blame] | 64 | #endif |