Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkPixelSerializer.h
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 #include "SkPixmap.h"
13 
14 class SkData;
15 
19 class SkPixelSerializer : public SkRefCnt {
20 public:
21  virtual ~SkPixelSerializer() {}
22 
27  bool useEncodedData(const void* data, size_t len) {
28  return this->onUseEncodedData(data, len);
29  }
30 
35  SkData* encode(const SkPixmap& pixmap) { return this->onEncode(pixmap); }
36 
37 protected:
42  virtual bool onUseEncodedData(const void* data, size_t len) = 0;
43 
48  virtual SkData* onEncode(const SkPixmap&) = 0;
49 };
50 #endif // SkPixelSerializer_DEFINED
Pairs SkImageInfo with actual pixels and rowbytes.
Definition: SkPixmap.h:23
Definition: SkRefCnt.h:125
bool useEncodedData(const void *data, size_t len)
Call to determine if the client wants to serialize the encoded data.
Definition: SkPixelSerializer.h:27
SkData holds an immutable data buffer.
Definition: SkData.h:22
virtual SkData * onEncode(const SkPixmap &)=0
If you want to encode these pixels, return the encoded data as an SkData Return null if you want to s...
Interface for serializing pixels, e.g.
Definition: SkPixelSerializer.h:19
virtual bool onUseEncodedData(const void *data, size_t len)=0
Return true if you want to serialize the encoded data, false if you want another version serialized (...
SkData * encode(const SkPixmap &pixmap)
Call to get the client's version of encoding these pixels.
Definition: SkPixelSerializer.h:35