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

Side by Side Diff: include/core/SkPixelSerializer.h

Issue 784643002: Replace EncodeBitmap with an interface. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years 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
« no previous file with comments | « include/core/SkPicture.h ('k') | include/core/SkWriteBuffer.h » ('j') | 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 2014 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 #ifndef SkPixelSerializer_DEFINED
9 #define SkPixelSerializer_DEFINED
10
11 #include "SkRefCnt.h"
12
13 class SkData;
14 struct SkImageInfo;
15
16 /**
17 * Interface for serializing pixels, e.g. SkBitmaps in an SkPicture.
18 */
19 class SkPixelSerializer : public SkRefCnt {
20 public:
21 virtual ~SkPixelSerializer() {}
22
23 /**
24 * Call to determine if the client wants to serialize the encoded data. If
25 * false, serialize another version (e.g. the result of encodePixels).
26 */
27 bool useEncodedData(const void* data, size_t len) {
28 return this->onUseEncodedData(data, len);
29 }
30
31 /**
32 * Call to get the client's version of encoding these pixels. If it
33 * returns NULL, serialize the raw pixels.
34 */
35 SkData* encodePixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
36 return this->onEncodePixels(info, pixels, rowBytes);
37 }
38
39 protected:
40 /**
41 * Return true if you want to serialize the encoded data, false if you want
42 * another version serialized (e.g. the result of encodePixels).
43 */
44 virtual bool onUseEncodedData(const void* data, size_t len) = 0;
45
46 /**
47 * If you want to encode these pixels, return the encoded data as an SkData
48 * Return null if you want to serialize the raw pixels.
49 */
50 virtual SkData* onEncodePixels(const SkImageInfo&, void* pixels, size_t rowB ytes) = 0;
51 };
52 #endif // SkPixelSerializer_DEFINED
OLDNEW
« no previous file with comments | « include/core/SkPicture.h ('k') | include/core/SkWriteBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698