blob: 8f95ea3059694d737e8e3639339721a64263c674 [file] [log] [blame]
bsalomon@google.com30085192011-08-19 15:42:31 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10#ifndef GrPathRendererChain_DEFINED
11#define GrPathRendererChain_DEFINED
12
bsalomon@google.com289533a2011-10-27 12:34:25 +000013#include "GrDrawTarget.h"
bsalomon@google.com30085192011-08-19 15:42:31 +000014#include "GrRefCnt.h"
bsalomon@google.com49313f62011-09-14 13:54:05 +000015#include "SkTArray.h"
bsalomon@google.com30085192011-08-19 15:42:31 +000016
17class GrContext;
bsalomon@google.com289533a2011-10-27 12:34:25 +000018
bsalomon@google.com30085192011-08-19 15:42:31 +000019class SkPath;
20class GrPathRenderer;
21
22/**
23 * Keeps track of a 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 * path renderer to the list implement the GrPathRenderer::AddPathRenderers
26 * function.
27 */
28class GrPathRendererChain : public SkRefCnt {
29public:
30
31 enum UsageFlags {
32 kNone_UsageFlag = 0,
33 kNonAAOnly_UsageFlag = 1,
34 };
senorblanco@chromium.org7ccf4602011-08-29 21:45:23 +000035
bsalomon@google.com30085192011-08-19 15:42:31 +000036 GrPathRendererChain(GrContext* context, UsageFlags flags);
senorblanco@chromium.org7ccf4602011-08-29 21:45:23 +000037
bsalomon@google.com30085192011-08-19 15:42:31 +000038 ~GrPathRendererChain();
39
40 // takes a ref and unrefs in destructor
41 GrPathRenderer* addPathRenderer(GrPathRenderer* pr);
42
bsalomon@google.com289533a2011-10-27 12:34:25 +000043 GrPathRenderer* getPathRenderer(const GrDrawTarget::Caps& targetCaps,
bsalomon@google.com30085192011-08-19 15:42:31 +000044 const SkPath& path,
bsalomon@google.com289533a2011-10-27 12:34:25 +000045 GrPathFill fill,
46 bool antiAlias);
bsalomon@google.com30085192011-08-19 15:42:31 +000047
48private:
49
50 GrPathRendererChain();
51
52 void init();
53
54 enum {
55 kPreAllocCount = 8,
56 };
57 bool fInit;
58 GrContext* fOwner;
59 UsageFlags fFlags;
bsalomon@google.com92669012011-09-27 19:10:05 +000060 SkSTArray<kPreAllocCount, GrPathRenderer*, true> fChain;
bsalomon@google.com30085192011-08-19 15:42:31 +000061};
62
63GR_MAKE_BITFIELD_OPS(GrPathRendererChain::UsageFlags)
64
senorblanco@chromium.org7ccf4602011-08-29 21:45:23 +000065#endif