blob: cda3182835656c01a70970c3a34a919c3469bfb2 [file] [log] [blame]
* Copyright 2013 Google Inc.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
#include "SkFlattenableSerialization.h"
#include "SkData.h"
#include "SkFlattenable.h"
#include "SkImageFilter.h"
#include "SkOrderedReadBuffer.h"
#include "SkOrderedWriteBuffer.h"
SkData* SkSerializeFlattenable(SkFlattenable* flattenable) {
SkOrderedWriteBuffer writer(1024);
uint32_t size = writer.bytesWritten();
void* data = sk_malloc_throw(size);
return SkData::NewFromMalloc(data, size);
// TODO: this guy should be renamed to ImageFilter, or take SkEffectType as
// a parameter.
SkFlattenable* SkDeserializeFlattenable(const void* data, size_t size) {
SkOrderedReadBuffer buffer(data, size);
return buffer.readImageFilter();