2017-12-05 20:11:24 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkSerialProcs_DEFINED
|
|
|
|
#define SkSerialProcs_DEFINED
|
|
|
|
|
|
|
|
#include "SkImage.h"
|
|
|
|
#include "SkPicture.h"
|
|
|
|
#include "SkTypeface.h"
|
|
|
|
|
|
|
|
/**
|
2017-12-08 15:31:52 +00:00
|
|
|
* A serial-proc is asked to serialize the specified object (e.g. picture or image).
|
|
|
|
* If a data object is returned, it will be used (even if it is zero-length).
|
|
|
|
* If null is returned, then Skia will take its default action.
|
2017-12-13 19:17:29 +00:00
|
|
|
*
|
|
|
|
* The default action for pictures is to use Skia's internal format.
|
|
|
|
* The default action for images is to encode using PNG.
|
|
|
|
* The default action for typefaces is to use Skia's internal format.
|
2017-12-05 20:11:24 +00:00
|
|
|
*/
|
|
|
|
|
2017-12-08 15:31:52 +00:00
|
|
|
typedef sk_sp<SkData> (*SkSerialPictureProc)(SkPicture*, void* ctx);
|
|
|
|
typedef sk_sp<SkData> (*SkSerialImageProc)(SkImage*, void* ctx);
|
|
|
|
typedef sk_sp<SkData> (*SkSerialTypefaceProc)(SkTypeface*, void* ctx);
|
2017-12-05 20:11:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A deserial-proc is given the serialized form previously returned by the corresponding
|
|
|
|
* serial-proc, and should return the re-constituted object. In case of an error, the proc
|
|
|
|
* can return nullptr.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef sk_sp<SkPicture> (*SkDeserialPictureProc)(const void* data, size_t length, void* ctx);
|
|
|
|
typedef sk_sp<SkImage> (*SkDeserialImageProc)(const void* data, size_t length, void* ctx);
|
|
|
|
typedef sk_sp<SkTypeface> (*SkDeserialTypefaceProc)(const void* data, size_t length, void* ctx);
|
|
|
|
|
2017-12-20 19:12:07 +00:00
|
|
|
struct SK_API SkSerialProcs {
|
2017-12-05 20:11:24 +00:00
|
|
|
SkSerialPictureProc fPictureProc = nullptr;
|
|
|
|
void* fPictureCtx = nullptr;
|
|
|
|
|
|
|
|
SkSerialImageProc fImageProc = nullptr;
|
|
|
|
void* fImageCtx = nullptr;
|
|
|
|
|
|
|
|
SkSerialTypefaceProc fTypefaceProc = nullptr;
|
|
|
|
void* fTypefaceCtx = nullptr;
|
|
|
|
};
|
|
|
|
|
2017-12-20 19:12:07 +00:00
|
|
|
struct SK_API SkDeserialProcs {
|
2017-12-05 20:11:24 +00:00
|
|
|
SkDeserialPictureProc fPictureProc = nullptr;
|
|
|
|
void* fPictureCtx = nullptr;
|
|
|
|
|
|
|
|
SkDeserialImageProc fImageProc = nullptr;
|
|
|
|
void* fImageCtx = nullptr;
|
|
|
|
|
|
|
|
SkDeserialTypefaceProc fTypefaceProc = nullptr;
|
|
|
|
void* fTypefaceCtx = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|