• 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 #ifndef SkPathHeap_DEFINED
9 #define SkPathHeap_DEFINED
10 
11 #include "SkRefCnt.h"
12 #include "SkChunkAlloc.h"
13 #include "SkTDArray.h"
14 
15 class SkPath;
16 class SkFlattenableReadBuffer;
17 class SkFlattenableWriteBuffer;
18 
19 class SkPathHeap : public SkRefCnt {
20 public:
21             SkPathHeap();
22             SkPathHeap(SkFlattenableReadBuffer&);
23     virtual ~SkPathHeap();
24 
25     /** Copy the path into the heap, and return the new total number of paths.
26         Thus, the returned value will be index+1, where index is the index of
27         this newly added (copied) path.
28      */
29     int append(const SkPath&);
30 
31     // called during picture-playback
count()32     int count() const { return fPaths.count(); }
33     const SkPath& operator[](int index) const {
34         return *fPaths[index];
35     }
36 
37     void flatten(SkFlattenableWriteBuffer&) const;
38 
39 private:
40     // we store the paths in the heap (placement new)
41     SkChunkAlloc        fHeap;
42     // we just store ptrs into fHeap here
43     SkTDArray<SkPath*>  fPaths;
44 };
45 
46 #endif
47 
48