epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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 | */ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 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 | |
reed@android.com | a6efe06 | 2010-03-05 18:46:37 +0000 | [diff] [blame] | 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 | */ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 29 | int append(const SkPath&); |
| 30 | |
| 31 | // called during picture-playback |
| 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 | |