michael@0: /* michael@0: * Copyright 2011 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef GrPathRendererChain_DEFINED michael@0: #define GrPathRendererChain_DEFINED michael@0: michael@0: #include "SkRefCnt.h" michael@0: #include "SkTArray.h" michael@0: michael@0: class GrContext; michael@0: class GrDrawTarget; michael@0: class GrPathRenderer; michael@0: class SkPath; michael@0: class SkStrokeRec; michael@0: michael@0: /** michael@0: * Keeps track of an ordered list of path renderers. When a path needs to be michael@0: * drawn this list is scanned to find the most preferred renderer. To add your michael@0: * path renderer to the list implement the GrPathRenderer::AddPathRenderers michael@0: * function. michael@0: */ michael@0: class GrPathRendererChain : public SkRefCnt { michael@0: public: michael@0: // See comments in GrPathRenderer.h michael@0: enum StencilSupport { michael@0: kNoSupport_StencilSupport, michael@0: kStencilOnly_StencilSupport, michael@0: kNoRestriction_StencilSupport, michael@0: }; michael@0: michael@0: SK_DECLARE_INST_COUNT(GrPathRendererChain) michael@0: michael@0: GrPathRendererChain(GrContext* context); michael@0: michael@0: ~GrPathRendererChain(); michael@0: michael@0: // takes a ref and unrefs in destructor michael@0: GrPathRenderer* addPathRenderer(GrPathRenderer* pr); michael@0: michael@0: /** Documents how the caller plans to use a GrPathRenderer to draw a path. It affects the PR michael@0: returned by getPathRenderer */ michael@0: enum DrawType { michael@0: kColor_DrawType, // draw to the color buffer, no AA michael@0: kColorAntiAlias_DrawType, // draw to color buffer, with partial coverage AA michael@0: kStencilOnly_DrawType, // draw just to the stencil buffer michael@0: kStencilAndColor_DrawType, // draw the stencil and color buffer, no AA michael@0: kStencilAndColorAntiAlias_DrawType // draw the stencil and color buffer, with partial michael@0: // coverage AA. michael@0: }; michael@0: /** Returns a GrPathRenderer compatible with the request if one is available. If the caller michael@0: is drawing the path to the stencil buffer then stencilSupport can be used to determine michael@0: whether the path can be rendered with arbitrary stencil rules or not. See comments on michael@0: StencilSupport in GrPathRenderer.h. */ michael@0: GrPathRenderer* getPathRenderer(const SkPath& path, michael@0: const SkStrokeRec& rec, michael@0: const GrDrawTarget* target, michael@0: DrawType drawType, michael@0: StencilSupport* stencilSupport); michael@0: michael@0: private: michael@0: GrPathRendererChain(); michael@0: michael@0: void init(); michael@0: michael@0: enum { michael@0: kPreAllocCount = 8, michael@0: }; michael@0: bool fInit; michael@0: GrContext* fOwner; michael@0: SkSTArray fChain; michael@0: michael@0: typedef SkRefCnt INHERITED; michael@0: }; michael@0: michael@0: #endif