| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrPathRendererChain_DEFINED | 8 #ifndef GrPathRendererChain_DEFINED |
| 9 #define GrPathRendererChain_DEFINED | 9 #define GrPathRendererChain_DEFINED |
| 10 | 10 |
| 11 #include "GrPathRenderer.h" |
| 12 |
| 11 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
| 12 #include "SkTArray.h" | 14 #include "SkTArray.h" |
| 13 | 15 |
| 14 class GrContext; | 16 class GrContext; |
| 15 class GrPathRenderer; | |
| 16 class GrPipelineBuilder; | 17 class GrPipelineBuilder; |
| 17 class GrShaderCaps; | 18 class GrShaderCaps; |
| 18 class GrStrokeInfo; | 19 class GrStrokeInfo; |
| 19 class SkMatrix; | 20 class SkMatrix; |
| 20 class SkPath; | 21 class SkPath; |
| 21 | 22 |
| 22 /** | 23 /** |
| 23 * Keeps track of an ordered list of path renderers. When a path needs to be | 24 * Keeps track of an ordered list of path renderers. When a path needs to be |
| 24 * drawn this list is scanned to find the most preferred renderer. To add your | 25 * drawn this list is scanned to find the most preferred renderer. To add your |
| 25 * path renderer to the list implement the GrPathRenderer::AddPathRenderers | 26 * path renderer to the list implement the GrPathRenderer::AddPathRenderers |
| 26 * function. | 27 * function. |
| 27 */ | 28 */ |
| 28 class GrPathRendererChain : public SkRefCnt { | 29 class GrPathRendererChain : public SkRefCnt { |
| 29 public: | 30 public: |
| 30 // See comments in GrPathRenderer.h | |
| 31 enum StencilSupport { | |
| 32 kNoSupport_StencilSupport, | |
| 33 kStencilOnly_StencilSupport, | |
| 34 kNoRestriction_StencilSupport, | |
| 35 }; | |
| 36 | |
| 37 GrPathRendererChain(GrContext* context); | 31 GrPathRendererChain(GrContext* context); |
| 38 | 32 |
| 39 ~GrPathRendererChain(); | 33 ~GrPathRendererChain(); |
| 40 | 34 |
| 41 // takes a ref and unrefs in destructor | |
| 42 GrPathRenderer* addPathRenderer(GrPathRenderer* pr); | |
| 43 | |
| 44 /** Documents how the caller plans to use a GrPathRenderer to draw a path. I
t affects the PR | 35 /** Documents how the caller plans to use a GrPathRenderer to draw a path. I
t affects the PR |
| 45 returned by getPathRenderer */ | 36 returned by getPathRenderer */ |
| 46 enum DrawType { | 37 enum DrawType { |
| 47 kColor_DrawType, // draw to the color buffer, no AA | 38 kColor_DrawType, // draw to the color buffer, no AA |
| 48 kColorAntiAlias_DrawType, // draw to color buffer, with partia
l coverage AA | 39 kColorAntiAlias_DrawType, // draw to color buffer, with partia
l coverage AA |
| 49 kStencilOnly_DrawType, // draw just to the stencil buffer | 40 kStencilOnly_DrawType, // draw just to the stencil buffer |
| 50 kStencilAndColor_DrawType, // draw the stencil and color buffer
, no AA | 41 kStencilAndColor_DrawType, // draw the stencil and color buffer
, no AA |
| 51 kStencilAndColorAntiAlias_DrawType // draw the stencil and color buffer
, with partial | 42 kStencilAndColorAntiAlias_DrawType // draw the stencil and color buffer
, with partial |
| 52 // coverage AA. | 43 // coverage AA. |
| 53 }; | 44 }; |
| 45 |
| 54 /** Returns a GrPathRenderer compatible with the request if one is available
. If the caller | 46 /** Returns a GrPathRenderer compatible with the request if one is available
. If the caller |
| 55 is drawing the path to the stencil buffer then stencilSupport can be use
d to determine | 47 is drawing the path to the stencil buffer then stencilSupport can be use
d to determine |
| 56 whether the path can be rendered with arbitrary stencil rules or not. Se
e comments on | 48 whether the path can be rendered with arbitrary stencil rules or not. Se
e comments on |
| 57 StencilSupport in GrPathRenderer.h. */ | 49 StencilSupport in GrPathRenderer.h. */ |
| 58 GrPathRenderer* getPathRenderer(const GrShaderCaps* shaderCaps, | 50 GrPathRenderer* getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args, |
| 59 const GrPipelineBuilder&, | |
| 60 const SkMatrix& viewMatrix, | |
| 61 const SkPath& path, | |
| 62 const GrStrokeInfo& stroke, | |
| 63 DrawType drawType, | 51 DrawType drawType, |
| 64 StencilSupport* stencilSupport); | 52 GrPathRenderer::StencilSupport* stencilSuppo
rt); |
| 65 | 53 |
| 66 private: | 54 private: |
| 67 GrPathRendererChain(); | 55 GrPathRendererChain(); |
| 68 | 56 |
| 57 // takes a ref and unrefs in destructor |
| 58 GrPathRenderer* addPathRenderer(GrPathRenderer* pr); |
| 59 |
| 69 void init(); | 60 void init(); |
| 70 | 61 |
| 71 enum { | 62 enum { |
| 72 kPreAllocCount = 8, | 63 kPreAllocCount = 8, |
| 73 }; | 64 }; |
| 74 bool fInit; | 65 bool fInit; |
| 75 GrContext* fOwner; | 66 GrContext* fOwner; |
| 76 SkSTArray<kPreAllocCount, GrPathRenderer*, true> fChain; | 67 SkSTArray<kPreAllocCount, GrPathRenderer*, true> fChain; |
| 77 | 68 |
| 78 typedef SkRefCnt INHERITED; | 69 typedef SkRefCnt INHERITED; |
| 79 }; | 70 }; |
| 80 | 71 |
| 81 #endif | 72 #endif |
| OLD | NEW |