| OLD | NEW |
| (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 struct SkImageInfo; | |
| 14 | |
| 15 /** | |
| 16 * Interface for serializing pixels, e.g. SkBitmaps in an SkPicture. | |
| 17 */ | |
| 18 class SkPixelSerializer : public SkRefCnt { | |
| 19 public: | |
| 20 /** | |
| 21 * Call to determine if the client wants to serialize the encoded data. If | |
| 22 * false, serialize another version (e.g. the result of encodePixels). | |
| 23 */ | |
| 24 bool useEncodedData(const void* data, size_t len) { | |
| 25 return this->onUseEncodedData(data, len); | |
| 26 } | |
| 27 | |
| 28 /** | |
| 29 * Call to get the client's version of encoding these pixels. If it | |
| 30 * returns NULL, serialize the raw pixels. | |
| 31 */ | |
| 32 SkData* encodePixels(const SkImageInfo& info, void* pixels, size_t rowBytes)
{ | |
| 33 return this->onEncodePixels(info, pixels, rowBytes); | |
| 34 } | |
| 35 | |
| 36 protected: | |
| 37 /** | |
| 38 * Return true if you want to serialize the encoded data, false if you want | |
| 39 * another version serialized (e.g. the result of encodePixels). | |
| 40 */ | |
| 41 virtual bool onUseEncodedData(const void* data, size_t len) = 0; | |
| 42 | |
| 43 /** | |
| 44 * If you want to encode these pixels, return the encoded data as an SkData | |
| 45 * Return null if you want to serialize the raw pixels. | |
| 46 */ | |
| 47 virtual SkData* onEncodePixels(const SkImageInfo&, void* pixels, size_t rowB
ytes) = 0; | |
| 48 }; | |
| 49 #endif // SkPixelSerializer_DEFINED | |
| OLD | NEW |