skia2/include/core/SkPixelSerializer.h
reed c9e190ddac Revert of change pixel-serializer to support reencoding existing data (patchset #5 id:80001 of https://codereview.chromium.org/1373683003/ )
Reason for revert:
Need to somehow get access to encoders in chrome -- link error on the roll since SkImageEncoder is not built as part of chrome.

Original issue's description:
> change pixel-serializer to support reencoding existing data
>
> Trying to evolve this interface so it can
> - support rich set of backend-encoders (including ones like ETC1 that can cheaply convert to KXT
> - allow for encoding images as well as bitmaps (e.g. for picture serialization)
> - perhaps replace SkImageEncoder as an API (assuming we create a factory that returns a serializer given a format)
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/13f48dc85aa68a60da66aaf39c93d527d11d1278

TBR=scroggo@google.com,msarett@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:

Review URL: https://codereview.chromium.org/1371983003
2015-09-28 09:58:41 -07:00

53 lines
1.5 KiB
C++

/*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkPixelSerializer_DEFINED
#define SkPixelSerializer_DEFINED
#include "SkRefCnt.h"
class SkData;
struct SkImageInfo;
/**
* Interface for serializing pixels, e.g. SkBitmaps in an SkPicture.
*/
class SkPixelSerializer : public SkRefCnt {
public:
virtual ~SkPixelSerializer() {}
/**
* Call to determine if the client wants to serialize the encoded data. If
* false, serialize another version (e.g. the result of encodePixels).
*/
bool useEncodedData(const void* data, size_t len) {
return this->onUseEncodedData(data, len);
}
/**
* Call to get the client's version of encoding these pixels. If it
* returns NULL, serialize the raw pixels.
*/
SkData* encodePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes) {
return this->onEncodePixels(info, pixels, rowBytes);
}
protected:
/**
* Return true if you want to serialize the encoded data, false if you want
* another version serialized (e.g. the result of encodePixels).
*/
virtual bool onUseEncodedData(const void* data, size_t len) = 0;
/**
* If you want to encode these pixels, return the encoded data as an SkData
* Return null if you want to serialize the raw pixels.
*/
virtual SkData* onEncodePixels(const SkImageInfo&, const void* pixels, size_t rowBytes) = 0;
};
#endif // SkPixelSerializer_DEFINED