blob: c0a0ee39f56809066385ea701e52df2dd51ae5d5 [file] [log] [blame]
bsalomon@google.com45a15f52012-12-10 19:10:17 +00001/*
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.com45a15f52012-12-10 19:10:17 +00008#ifndef GrPathRendererChain_DEFINED
9#define GrPathRendererChain_DEFINED
10
robertphillips68737822015-10-29 12:12:21 -070011#include "GrPathRenderer.h"
12
csmartdalton008b9d82017-02-22 12:00:42 -070013#include "GrContextOptions.h"
robertphillips13391dd2015-10-30 05:15:11 -070014#include "SkTypes.h"
bsalomon@google.com45a15f52012-12-10 19:10:17 +000015#include "SkTArray.h"
16
17class GrContext;
bsalomon@google.com45a15f52012-12-10 19:10:17 +000018
19/**
20 * Keeps track of an ordered list of path renderers. When a path needs to be
21 * drawn this list is scanned to find the most preferred renderer. To add your
22 * path renderer to the list implement the GrPathRenderer::AddPathRenderers
23 * function.
24 */
robertphillips13391dd2015-10-30 05:15:11 -070025class GrPathRendererChain : public SkNoncopyable {
bsalomon@google.com45a15f52012-12-10 19:10:17 +000026public:
bsalomon6b2552f2016-09-15 13:50:26 -070027 struct Options {
csmartdalton008b9d82017-02-22 12:00:42 -070028 using GpuPathRenderers = GrContextOptions::GpuPathRenderers;
bsalomon39ef7fb2016-09-21 11:16:05 -070029 bool fAllowPathMaskCaching = false;
csmartdalton008b9d82017-02-22 12:00:42 -070030 GpuPathRenderers fGpuPathRenderers = GpuPathRenderers::kAll;
bsalomon6b2552f2016-09-15 13:50:26 -070031 };
32 GrPathRendererChain(GrContext* context, const Options&);
bsalomon@google.com45a15f52012-12-10 19:10:17 +000033
bsalomon@google.com45a15f52012-12-10 19:10:17 +000034 /** Documents how the caller plans to use a GrPathRenderer to draw a path. It affects the PR
35 returned by getPathRenderer */
Brian Salomon82125e92016-12-10 09:35:48 -050036 enum class DrawType {
37 kColor, // draw to the color buffer, no AA
38 kStencil, // draw just to the stencil buffer
39 kStencilAndColor, // draw the stencil and color buffer, no AA
bsalomon@google.com45a15f52012-12-10 19:10:17 +000040 };
robertphillips68737822015-10-29 12:12:21 -070041
bsalomon@google.com45a15f52012-12-10 19:10:17 +000042 /** Returns a GrPathRenderer compatible with the request if one is available. If the caller
43 is drawing the path to the stencil buffer then stencilSupport can be used to determine
44 whether the path can be rendered with arbitrary stencil rules or not. See comments on
skia.committer@gmail.comc7b4be72012-12-11 02:01:20 +000045 StencilSupport in GrPathRenderer.h. */
robertphillips68737822015-10-29 12:12:21 -070046 GrPathRenderer* getPathRenderer(const GrPathRenderer::CanDrawPathArgs& args,
bsalomon@google.com45a15f52012-12-10 19:10:17 +000047 DrawType drawType,
robertphillips68737822015-10-29 12:12:21 -070048 GrPathRenderer::StencilSupport* stencilSupport);
bsalomon@google.com45a15f52012-12-10 19:10:17 +000049
50private:
bsalomon@google.com45a15f52012-12-10 19:10:17 +000051 enum {
52 kPreAllocCount = 8,
53 };
csmartdalton008b9d82017-02-22 12:00:42 -070054 SkSTArray<kPreAllocCount, sk_sp<GrPathRenderer>> fChain;
bsalomon@google.com45a15f52012-12-10 19:10:17 +000055};
56
bsalomon@google.com45a15f52012-12-10 19:10:17 +000057#endif