aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkSerializationHelpers.h
blob: 8bb2a41d950069b913ba31e63637ae8c6ed08202 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkSerializationHelpers_DEFINED
#define SkSerializationHelpers_DEFINED

class SkBitmap;
class SkStream;
class SkWStream;

namespace SkSerializationHelpers {
    /**
     *  Function to encode an SkBitmap to an SkWStream. A function with this signature can be passed
     *  to SkPicture::serialize() and SkOrderedWriteBuffer. The function should return true if it
     *  succeeds. Otherwise it should return false so that SkOrderedWriteBuffer can switch to
     *  another method of storing SkBitmaps.
     */
    typedef bool (*EncodeBitmap)(SkWStream*, const SkBitmap&);

    /**
     *  Function to decode an SkBitmap from an SkStream. A function with this signature can be
     *  passed to the SkStream constructor for SkPicture and SkOrderedReadBuffer to decode SkBitmaps
     *  which were previously encoded. The function should return true if it succeeds. Otherwise it
     *  should return false so that SkOrderedReadBuffer can skip the data and provide a dummy
     *  SkBitmap.
     */
    typedef bool (*DecodeBitmap)(SkStream*, SkBitmap*);
}

#endif // SkSerializationHelpers_DEFINED