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