Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: src/core/SkPathHeap.cpp

Issue 134163010: Refactor read and write buffers. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: original write flags were fine Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkPathHeap.h" 8 #include "SkPathHeap.h"
9 #include "SkPath.h" 9 #include "SkPath.h"
10 #include "SkStream.h" 10 #include "SkStream.h"
11 #include "SkFlattenableBuffers.h" 11 #include "SkReadBuffer.h"
12 #include "SkWriteBuffer.h"
12 #include <new> 13 #include <new>
13 14
14 #define kPathCount 64 15 #define kPathCount 64
15 16
16 SkPathHeap::SkPathHeap() : fHeap(kPathCount * sizeof(SkPath)) { 17 SkPathHeap::SkPathHeap() : fHeap(kPathCount * sizeof(SkPath)) {
17 } 18 }
18 19
19 SkPathHeap::SkPathHeap(SkFlattenableReadBuffer& buffer) 20 SkPathHeap::SkPathHeap(SkReadBuffer& buffer)
20 : fHeap(kPathCount * sizeof(SkPath)) { 21 : fHeap(kPathCount * sizeof(SkPath)) {
21 const int count = buffer.readInt(); 22 const int count = buffer.readInt();
22 23
23 fPaths.setCount(count); 24 fPaths.setCount(count);
24 SkPath** ptr = fPaths.begin(); 25 SkPath** ptr = fPaths.begin();
25 SkPath* p = (SkPath*)fHeap.allocThrow(count * sizeof(SkPath)); 26 SkPath* p = (SkPath*)fHeap.allocThrow(count * sizeof(SkPath));
26 27
27 for (int i = 0; i < count; i++) { 28 for (int i = 0; i < count; i++) {
28 new (p) SkPath; 29 new (p) SkPath;
29 buffer.readPath(p); 30 buffer.readPath(p);
(...skipping 11 matching lines...) Expand all
41 } 42 }
42 } 43 }
43 44
44 int SkPathHeap::append(const SkPath& path) { 45 int SkPathHeap::append(const SkPath& path) {
45 SkPath* p = (SkPath*)fHeap.allocThrow(sizeof(SkPath)); 46 SkPath* p = (SkPath*)fHeap.allocThrow(sizeof(SkPath));
46 new (p) SkPath(path); 47 new (p) SkPath(path);
47 *fPaths.append() = p; 48 *fPaths.append() = p;
48 return fPaths.count(); 49 return fPaths.count();
49 } 50 }
50 51
51 void SkPathHeap::flatten(SkFlattenableWriteBuffer& buffer) const { 52 void SkPathHeap::flatten(SkWriteBuffer& buffer) const {
52 int count = fPaths.count(); 53 int count = fPaths.count();
53 54
54 buffer.writeInt(count); 55 buffer.writeInt(count);
55 SkPath* const* iter = fPaths.begin(); 56 SkPath* const* iter = fPaths.begin();
56 SkPath* const* stop = fPaths.end(); 57 SkPath* const* stop = fPaths.end();
57 while (iter < stop) { 58 while (iter < stop) {
58 buffer.writePath(**iter); 59 buffer.writePath(**iter);
59 iter++; 60 iter++;
60 } 61 }
61 } 62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698