blob: 0f4305b0634101267289308a8bff973faea81f17 [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
13#include "GrRefCnt.h"
14#include "GrTArray.h"
15
16class GrContext;
17class GrDrawTarget;
18class SkPath;
19class GrPathRenderer;
20
21/**
22 * Keeps track of a ordered list of path renderers. When a path needs to be
23 * drawn this list is scanned to find the most preferred renderer. To add your
24 * path renderer to the list implement the GrPathRenderer::AddPathRenderers
25 * function.
26 */
27class GrPathRendererChain : public SkRefCnt {
28public:
29
30 enum UsageFlags {
31 kNone_UsageFlag = 0,
32 kNonAAOnly_UsageFlag = 1,
33 };
senorblanco@chromium.org7ccf4602011-08-29 21:45:23 +000034
bsalomon@google.com30085192011-08-19 15:42:31 +000035 GrPathRendererChain(GrContext* context, UsageFlags flags);
senorblanco@chromium.org7ccf4602011-08-29 21:45:23 +000036
bsalomon@google.com30085192011-08-19 15:42:31 +000037 ~GrPathRendererChain();
38
39 // takes a ref and unrefs in destructor
40 GrPathRenderer* addPathRenderer(GrPathRenderer* pr);
41
42 GrPathRenderer* getPathRenderer(const GrDrawTarget* target,
43 const SkPath& path,
44 GrPathFill fill);
45
46private:
47
48 GrPathRendererChain();
49
50 void init();
51
52 enum {
53 kPreAllocCount = 8,
54 };
55 bool fInit;
56 GrContext* fOwner;
57 UsageFlags fFlags;
58 GrAlignedSTStorage<kPreAllocCount, GrPathRenderer*> fStorage;
59 GrTArray<GrPathRenderer*, true> fChain;
60};
61
62GR_MAKE_BITFIELD_OPS(GrPathRendererChain::UsageFlags)
63
senorblanco@chromium.org7ccf4602011-08-29 21:45:23 +000064#endif