aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrPathRendererChain.h
blob: e5ccabb95d27b4832ce42385d3fc1579f4ca04f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

/*
 * 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

#include "GrDrawTarget.h"
#include "GrRefCnt.h"
#include "SkTArray.h"

class GrContext;

class SkPath;
class GrPathRenderer;

/**
 * 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:
    SK_DECLARE_INST_COUNT(GrPathRendererChain)

    enum UsageFlags {
        kNone_UsageFlag      = 0,
        kNonAAOnly_UsageFlag = 1,
    };

    GrPathRendererChain(GrContext* context, UsageFlags flags);

    ~GrPathRendererChain();

    // takes a ref and unrefs in destructor
    GrPathRenderer* addPathRenderer(GrPathRenderer* pr);

    GrPathRenderer* getPathRenderer(const SkPath& path,
                                    GrPathFill fill,
                                    const GrDrawTarget* target,
                                    bool antiAlias);

private:

    GrPathRendererChain();

    void init();

    enum {
        kPreAllocCount = 8,
    };
    bool fInit;
    GrContext*                                          fOwner;
    UsageFlags                                          fFlags;
    SkSTArray<kPreAllocCount, GrPathRenderer*, true>    fChain;

    typedef SkRefCnt INHERITED;
};

GR_MAKE_BITFIELD_OPS(GrPathRendererChain::UsageFlags)

#endif