OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 | 8 |
9 #include "SkWriteBuffer.h" | 9 #include "SkWriteBuffer.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
11 #include "SkData.h" | 11 #include "SkData.h" |
12 #include "SkPixelRef.h" | 12 #include "SkPixelRef.h" |
13 #include "SkPtrRecorder.h" | 13 #include "SkPtrRecorder.h" |
14 #include "SkStream.h" | 14 #include "SkStream.h" |
15 #include "SkTypeface.h" | 15 #include "SkTypeface.h" |
16 | 16 |
17 SkWriteBuffer::SkWriteBuffer() | 17 SkWriteBuffer::SkWriteBuffer(uint32_t flags) |
18 : fFlags(0) | 18 : fFlags(flags) |
19 , fFactorySet(NULL) | 19 , fFactorySet(NULL) |
20 , fNamedFactorySet(NULL) | 20 , fNamedFactorySet(NULL) |
21 , fBitmapHeap(NULL) | 21 , fBitmapHeap(NULL) |
22 , fTFSet(NULL) | 22 , fTFSet(NULL) |
23 , fBitmapEncoder(NULL) { | 23 , fBitmapEncoder(NULL) { |
24 } | 24 } |
25 | 25 |
26 SkWriteBuffer::SkWriteBuffer(void* storage, size_t storageSize) | 26 SkWriteBuffer::SkWriteBuffer(void* storage, size_t storageSize, uint32_t flags) |
27 : fFlags(0) | 27 : fFlags(flags) |
28 , fFactorySet(NULL) | 28 , fFactorySet(NULL) |
29 , fNamedFactorySet(NULL) | 29 , fNamedFactorySet(NULL) |
30 , fWriter(storage, storageSize) | 30 , fWriter(storage, storageSize) |
31 , fBitmapHeap(NULL) | 31 , fBitmapHeap(NULL) |
32 , fTFSet(NULL) | 32 , fTFSet(NULL) |
33 , fBitmapEncoder(NULL) { | 33 , fBitmapEncoder(NULL) { |
34 } | 34 } |
35 | 35 |
36 SkWriteBuffer::~SkWriteBuffer() { | 36 SkWriteBuffer::~SkWriteBuffer() { |
37 SkSafeUnref(fFactorySet); | 37 SkSafeUnref(fFactorySet); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 // make room for the size of the flattened object | 316 // make room for the size of the flattened object |
317 (void)fWriter.reserve(sizeof(uint32_t)); | 317 (void)fWriter.reserve(sizeof(uint32_t)); |
318 // record the current size, so we can subtract after the object writes. | 318 // record the current size, so we can subtract after the object writes. |
319 uint32_t offset = fWriter.bytesWritten(); | 319 uint32_t offset = fWriter.bytesWritten(); |
320 // now flatten the object | 320 // now flatten the object |
321 flattenable->flatten(*this); | 321 flattenable->flatten(*this); |
322 uint32_t objSize = fWriter.bytesWritten() - offset; | 322 uint32_t objSize = fWriter.bytesWritten() - offset; |
323 // record the obj's size | 323 // record the obj's size |
324 *fWriter.peek32(offset - sizeof(uint32_t)) = objSize; | 324 *fWriter.peek32(offset - sizeof(uint32_t)) = objSize; |
325 } | 325 } |
OLD | NEW |