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
|
|
|
|
|
2015-10-29 19:12:21 +00:00
|
|
|
#include "GrPathRenderer.h"
|
|
|
|
|
2017-02-22 19:00:42 +00:00
|
|
|
#include "GrContextOptions.h"
|
2015-10-30 12:15:11 +00:00
|
|
|
#include "SkTypes.h"
|
2012-12-10 19:10:17 +00:00
|
|
|
#include "SkTArray.h"
|
|
|
|
|
|
|
|
class GrContext;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2015-10-30 12:15:11 +00:00
|
|
|
class GrPathRendererChain : public SkNoncopyable {
|
2012-12-10 19:10:17 +00:00
|
|
|
public:
|
2016-09-15 20:50:26 +00:00
|
|
|
struct Options {
|
2017-02-22 19:00:42 +00:00
|
|
|
using GpuPathRenderers = GrContextOptions::GpuPathRenderers;
|
2016-09-21 18:16:05 +00:00
|
|
|
bool fAllowPathMaskCaching = false;
|
2017-02-22 19:00:42 +00:00
|
|
|
GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kAll;
|
2016-09-15 20:50:26 +00:00
|
|
|
};
|
|
|
|
GrPathRendererChain(GrContext* context, const Options&);
|
2012-12-10 19:10:17 +00:00
|
|
|
|
|
|
|
/** Documents how the caller plans to use a GrPathRenderer to draw a path. It affects the PR
|
|
|
|
returned by getPathRenderer */
|
2016-12-10 14:35:48 +00:00
|
|
|
enum class DrawType {
|
|
|
|
kColor, // draw to the color buffer, no AA
|
|
|
|
kStencil, // draw just to the stencil buffer
|
|
|
|
kStencilAndColor, // draw the stencil and color buffer, no AA
|
2012-12-10 19:10:17 +00:00
|
|
|
};
|
2015-10-29 19:12:21 +00:00
|
|
|
|
2012-12-10 19:10:17 +00:00
|
|
|
/** 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. */
|
2015-10-29 19:12:21 +00:00
|
|
|
GrPathRenderer* getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args,
|
2012-12-10 19:10:17 +00:00
|
|
|
DrawType drawType,
|
2015-10-29 19:12:21 +00:00
|
|
|
GrPathRenderer::StencilSupport* stencilSupport);
|
2012-12-10 19:10:17 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
enum {
|
|
|
|
kPreAllocCount = 8,
|
|
|
|
};
|
2017-02-22 19:00:42 +00:00
|
|
|
SkSTArray<kPreAllocCount, sk_sp<GrPathRenderer>> fChain;
|
2012-12-10 19:10:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|