blob: f04322202710b4beb8b96a91ff86b21986bb91a8 [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:
robertphillips@google.com4d73ac22012-06-13 18:54:08 +000021 SK_DECLARE_INST_COUNT(SkPathHeap)
22
23 SkPathHeap();
24 SkPathHeap(SkFlattenableReadBuffer&);
reed@android.com8a1c16f2008-12-17 15:59:43 +000025 virtual ~SkPathHeap();
26
reed@android.coma6efe062010-03-05 18:46:37 +000027 /** Copy the path into the heap, and return the new total number of paths.
28 Thus, the returned value will be index+1, where index is the index of
29 this newly added (copied) path.
30 */
reed@android.com8a1c16f2008-12-17 15:59:43 +000031 int append(const SkPath&);
rmistry@google.comfbfcd562012-08-23 18:09:54 +000032
reed@android.com8a1c16f2008-12-17 15:59:43 +000033 // called during picture-playback
34 int count() const { return fPaths.count(); }
35 const SkPath& operator[](int index) const {
36 return *fPaths[index];
37 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +000038
reed@android.com8a1c16f2008-12-17 15:59:43 +000039 void flatten(SkFlattenableWriteBuffer&) const;
rmistry@google.comfbfcd562012-08-23 18:09:54 +000040
reed@android.com8a1c16f2008-12-17 15:59:43 +000041private:
42 // we store the paths in the heap (placement new)
43 SkChunkAlloc fHeap;
44 // we just store ptrs into fHeap here
45 SkTDArray<SkPath*> fPaths;
robertphillips@google.com4d73ac22012-06-13 18:54:08 +000046
47 typedef SkRefCnt INHERITED;
reed@android.com8a1c16f2008-12-17 15:59:43 +000048};
49
50#endif
51