SkPixelSerializer: remove deprecated virtual
Review URL: https://codereview.chromium.org/1512333002
This commit is contained in:
parent
1acabf3787
commit
9907371f0a
@ -32,16 +32,12 @@ public:
|
||||
* Call to get the client's version of encoding these pixels. If it
|
||||
* returns NULL, serialize the raw pixels.
|
||||
*/
|
||||
SkData* encode(const SkPixmap& pixmap) {
|
||||
SkData* data = this->onEncode(pixmap);
|
||||
return data ? data : this->onEncodePixels(
|
||||
pixmap.info(), pixmap.addr(), pixmap.rowBytes());
|
||||
}
|
||||
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 encodePixels).
|
||||
* another version serialized (e.g. the result of this->encode()).
|
||||
*/
|
||||
virtual bool onUseEncodedData(const void* data, size_t len) = 0;
|
||||
|
||||
@ -49,15 +45,6 @@ protected:
|
||||
* If you want to encode these pixels, return the encoded data as an SkData
|
||||
* Return null if you want to serialize the raw pixels.
|
||||
*/
|
||||
// NOTE: onEncodePixels() is deprecated and removed in a later CL.
|
||||
// Subclasses should implement onEncode() instead. Subclasses
|
||||
// should implement at least one of onEncodePixels() or
|
||||
// onUseEncodedData().
|
||||
virtual SkData* onEncodePixels(const SkImageInfo&,
|
||||
const void* /*pixels*/,
|
||||
size_t /*rowBytes*/) {
|
||||
return nullptr;
|
||||
}
|
||||
virtual SkData* onEncode(const SkPixmap&) { return nullptr; }
|
||||
virtual SkData* onEncode(const SkPixmap&) = 0;
|
||||
};
|
||||
#endif // SkPixelSerializer_DEFINED
|
||||
|
@ -169,7 +169,7 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
SkData* onEncodePixels(const SkImageInfo&, const void*, size_t) override {
|
||||
SkData* onEncode(const SkPixmap&) override {
|
||||
fDidEncode = true;
|
||||
return fFunc();
|
||||
}
|
||||
|
@ -222,6 +222,19 @@ SkBitmap create_string_bitmap(int w, int h, SkColor c, int x, int y,
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
bool PngPixelSerializer::onUseEncodedData(const void*, size_t) { return true; }
|
||||
SkData* PngPixelSerializer::onEncode(const SkPixmap& pixmap) {
|
||||
SkBitmap bm;
|
||||
if (!bm.installPixels(pixmap.info(),
|
||||
const_cast<void*>(pixmap.addr()),
|
||||
pixmap.rowBytes(),
|
||||
pixmap.ctable(),
|
||||
nullptr, nullptr)) {
|
||||
return nullptr;
|
||||
}
|
||||
return SkImageEncoder::EncodeData(bm, SkImageEncoder::kPNG_Type, 100);
|
||||
}
|
||||
|
||||
void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const SkPaint& origPaint,
|
||||
SkScalar x, SkScalar y) {
|
||||
SkPaint paint(origPaint);
|
||||
|
@ -118,12 +118,8 @@ namespace sk_tool_utils {
|
||||
// used.
|
||||
class PngPixelSerializer : public SkPixelSerializer {
|
||||
public:
|
||||
bool onUseEncodedData(const void*, size_t) override { return true; }
|
||||
SkData* onEncodePixels(const SkImageInfo& info, const void* pixels,
|
||||
size_t rowBytes) override {
|
||||
return SkImageEncoder::EncodeData(info, pixels, rowBytes,
|
||||
SkImageEncoder::kPNG_Type, 100);
|
||||
}
|
||||
bool onUseEncodedData(const void*, size_t) override;
|
||||
SkData* onEncode(const SkPixmap&) override;
|
||||
};
|
||||
|
||||
// A helper for inserting a drawtext call into a SkTextBlobBuilder
|
||||
|
Loading…
Reference in New Issue
Block a user