OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2013 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #include "SkFlattenableSerialization.h" |
| 9 |
| 10 #include "SkData.h" |
| 11 #include "SkFlattenable.h" |
| 12 #include "SkOrderedReadBuffer.h" |
| 13 #include "SkOrderedWriteBuffer.h" |
| 14 |
| 15 SkData* SkSerializeFlattenable(SkFlattenable* flattenable) { |
| 16 SkOrderedWriteBuffer writer(1024); |
| 17 writer.setFlags(SkOrderedWriteBuffer::kCrossProcess_Flag); |
| 18 writer.writeFlattenable(flattenable); |
| 19 uint32_t size = writer.bytesWritten(); |
| 20 void* data = sk_malloc_throw(size); |
| 21 writer.writeToMemory(data); |
| 22 return SkData::NewFromMalloc(data, size); |
| 23 } |
| 24 |
| 25 SkFlattenable* SkDeserializeFlattenable(const void* data, size_t size) { |
| 26 SkOrderedReadBuffer buffer(data, size); |
| 27 return buffer.readFlattenable(); |
| 28 } |
OLD | NEW |