3 * Copyright 2011 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
8 #include "SkPathHeap.h"
11 #include "SkReadBuffer.h"
12 #include "SkWriteBuffer.h"
17 SkPathHeap::SkPathHeap() : fHeap(kPathCount * sizeof(SkPath)) {
20 SkPathHeap::SkPathHeap(SkReadBuffer& buffer)
21 : fHeap(kPathCount * sizeof(SkPath)) {
22 const int count = buffer.readInt();
24 fPaths.setCount(count);
25 SkPath** ptr = fPaths.begin();
26 SkPath* p = (SkPath*)fHeap.allocThrow(count * sizeof(SkPath));
28 for (int i = 0; i < count; i++) {
31 *ptr++ = p; // record the pointer
32 p++; // move to the next storage location
36 SkPathHeap::~SkPathHeap() {
37 SkPath** iter = fPaths.begin();
38 SkPath** stop = fPaths.end();
45 int SkPathHeap::append(const SkPath& path) {
46 SkPath* p = (SkPath*)fHeap.allocThrow(sizeof(SkPath));
49 return fPaths.count();
52 void SkPathHeap::flatten(SkWriteBuffer& buffer) const {
53 int count = fPaths.count();
55 buffer.writeInt(count);
56 SkPath* const* iter = fPaths.begin();
57 SkPath* const* stop = fPaths.end();
59 buffer.writePath(**iter);