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