• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
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 "GrDrawTarget.h"
14 #include "GrRefCnt.h"
15 #include "SkTArray.h"
16 
17 class GrContext;
18 
19 class SkPath;
20 class 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  */
28 class GrPathRendererChain : public SkRefCnt {
29 public:
30 
31     enum UsageFlags {
32         kNone_UsageFlag      = 0,
33         kNonAAOnly_UsageFlag = 1,
34     };
35 
36     GrPathRendererChain(GrContext* context, UsageFlags flags);
37 
38     ~GrPathRendererChain();
39 
40     // takes a ref and unrefs in destructor
41     GrPathRenderer* addPathRenderer(GrPathRenderer* pr);
42 
43     GrPathRenderer* getPathRenderer(const SkPath& path,
44                                     GrPathFill fill,
45                                     const GrDrawTarget* target,
46                                     bool antiAlias);
47 
48 private:
49 
50     GrPathRendererChain();
51 
52     void init();
53 
54     enum {
55         kPreAllocCount = 8,
56     };
57     bool fInit;
58     GrContext*                                          fOwner;
59     UsageFlags                                          fFlags;
60     SkSTArray<kPreAllocCount, GrPathRenderer*, true>    fChain;
61 };
62 
63 GR_MAKE_BITFIELD_OPS(GrPathRendererChain::UsageFlags)
64 
65 #endif
66