64778d9f27
This reverts commit dc799550e2
.
Reason for revert: need to fix sites in Document_none
Original change's description:
> Change image encode api to return sk_sp
>
> Bug: skia:
> Change-Id: I238289bc630be27795cb1384955dd6e887597c05
> Reviewed-on: https://skia-review.googlesource.com/22208
> Commit-Queue: Mike Reed <reed@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>
TBR=scroggo@google.com,fmalita@chromium.org,reed@google.com
Change-Id: Id7f67027e5f1405a60fdbde29863cdf8daef0cb7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/22280
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
51 lines
1.4 KiB
C++
51 lines
1.4 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"
|
|
#include "SkPixmap.h"
|
|
|
|
class SkData;
|
|
|
|
/**
|
|
* 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* encode(const SkPixmap& pixmap) { return this->onEncode(pixmap); }
|
|
|
|
protected:
|
|
/**
|
|
* Return true if you want to serialize the encoded data, false if you want
|
|
* another version serialized (e.g. the result of this->encode()).
|
|
*/
|
|
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* onEncode(const SkPixmap&) = 0;
|
|
};
|
|
#endif // SkPixelSerializer_DEFINED
|