blob: 99c2626b041e95b8b359a046fb6cf1d33d9294bc [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +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 */
reed@android.com8a1c16f2008-12-17 15:59:43 +00008#ifndef SkPathHeap_DEFINED
9#define SkPathHeap_DEFINED
10
11#include "SkRefCnt.h"
12#include "SkChunkAlloc.h"
13#include "SkTDArray.h"
14
15class SkPath;
16class SkFlattenableReadBuffer;
17class SkFlattenableWriteBuffer;
18
19class SkPathHeap : public SkRefCnt {
20public:
21 SkPathHeap();
22 SkPathHeap(SkFlattenableReadBuffer&);
23 virtual ~SkPathHeap();
24
reed@android.coma6efe062010-03-05 18:46:37 +000025 /** 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.com8a1c16f2008-12-17 15:59:43 +000029 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
39private:
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