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

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

Issue 22591002: Adding 2 functions to the Skia API (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Back to generic SkFlattenable version Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkFlattenableSerialization.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « include/core/SkFlattenableSerialization.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698