Revert "hide SkImageDeserializer"

This reverts commit 834fb8ed90.

Reason for revert: broke google3

Original change's description:
> hide SkImageDeserializer
> 
> Bug: skia:
> Change-Id: I1cd4e8c626628a3e6426afd7d6bae628d58989c3
> Reviewed-on: https://skia-review.googlesource.com/85743
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Mike Reed <reed@google.com>

TBR=reed@google.com,reed@chromium.org

Change-Id: I00679c8651817af1777785da6c8dac9411a2a7c2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/85880
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2017-12-15 17:26:48 +00:00 committed by Skia Commit-Bot
parent d7b3845f3d
commit 36d7178792
6 changed files with 32 additions and 47 deletions

View File

@ -14,7 +14,6 @@ struct SkIRect;
class SkData; class SkData;
class SkImage; class SkImage;
#ifdef SK_SUPPORT_LEGACY_IMAGEDESERIALIZER
class SK_API SkImageDeserializer { class SK_API SkImageDeserializer {
public: public:
virtual ~SkImageDeserializer() {} virtual ~SkImageDeserializer() {}
@ -33,6 +32,5 @@ public:
virtual sk_sp<SkImage> makeFromData(SkData*, const SkIRect* subset); virtual sk_sp<SkImage> makeFromData(SkData*, const SkIRect* subset);
virtual sk_sp<SkImage> makeFromMemory(const void* data, size_t length, const SkIRect* subset); virtual sk_sp<SkImage> makeFromMemory(const void* data, size_t length, const SkIRect* subset);
}; };
#endif
#endif #endif

View File

@ -19,9 +19,7 @@ class SkCanvas;
class SkData; class SkData;
struct SkDeserialProcs; struct SkDeserialProcs;
class SkImage; class SkImage;
#ifdef SK_SUPPORT_LEGACY_IMAGEDESERIALIZER
class SkImageDeserializer; class SkImageDeserializer;
#endif
class SkPath; class SkPath;
class SkPictureData; class SkPictureData;
class SkPixelSerializer; class SkPixelSerializer;
@ -60,15 +58,11 @@ public:
* Any serialized images in the stream will be passed the image-deserializer, or if that is * Any serialized images in the stream will be passed the image-deserializer, or if that is
* null, to the default deserializer that will call SkImage::MakeFromEncoded(). * null, to the default deserializer that will call SkImage::MakeFromEncoded().
*/ */
#ifdef SK_SUPPORT_LEGACY_IMAGEDESERIALIZER
static sk_sp<SkPicture> MakeFromStream(SkStream*, SkImageDeserializer*); static sk_sp<SkPicture> MakeFromStream(SkStream*, SkImageDeserializer*);
static sk_sp<SkPicture> MakeFromData(const SkData* data, SkImageDeserializer*);
static sk_sp<SkPicture> MakeFromData(const void* data, size_t size, SkImageDeserializer*);
#endif
static sk_sp<SkPicture> MakeFromStream(SkStream*); static sk_sp<SkPicture> MakeFromStream(SkStream*);
static sk_sp<SkPicture> MakeFromData(const SkData* data); static sk_sp<SkPicture> MakeFromData(const void* data, size_t size,
static sk_sp<SkPicture> MakeFromData(const void* data, size_t size); SkImageDeserializer* = nullptr);
static sk_sp<SkPicture> MakeFromData(const SkData* data, SkImageDeserializer* = nullptr);
static sk_sp<SkPicture> MakeFromStream(SkStream*, const SkDeserialProcs& procs); static sk_sp<SkPicture> MakeFromStream(SkStream*, const SkDeserialProcs& procs);
static sk_sp<SkPicture> MakeFromData(const SkData* data, const SkDeserialProcs& procs); static sk_sp<SkPicture> MakeFromData(const SkData* data, const SkDeserialProcs& procs);

View File

@ -9,6 +9,8 @@
#ifndef SkWriteBuffer_DEFINED #ifndef SkWriteBuffer_DEFINED
#define SkWriteBuffer_DEFINED #define SkWriteBuffer_DEFINED
#define SK_SUPPORT_LEGACY_SERIAL_BUFFER_OBJECTS
#include "SkData.h" #include "SkData.h"
#include "SkImage.h" #include "SkImage.h"
#include "SkPath.h" #include "SkPath.h"
@ -18,7 +20,9 @@
#include "SkWriter32.h" #include "SkWriter32.h"
#include "../private/SkTHash.h" #include "../private/SkTHash.h"
#ifdef SK_SUPPORT_LEGACY_SERIAL_BUFFER_OBJECTS
#include "SkPixelSerializer.h" #include "SkPixelSerializer.h"
#endif
class SkBitmap; class SkBitmap;
class SkDeduper; class SkDeduper;
@ -153,7 +157,9 @@ public:
SkFactorySet* setFactoryRecorder(SkFactorySet*); SkFactorySet* setFactoryRecorder(SkFactorySet*);
SkRefCntSet* setTypefaceRecorder(SkRefCntSet*); SkRefCntSet* setTypefaceRecorder(SkRefCntSet*);
#ifdef SK_SUPPORT_LEGACY_SERIAL_BUFFER_OBJECTS
void setPixelSerializer(sk_sp<SkPixelSerializer>); void setPixelSerializer(sk_sp<SkPixelSerializer>);
#endif
private: private:
const uint32_t fFlags; const uint32_t fFlags;
@ -165,7 +171,9 @@ private:
// Only used if we do not have an fFactorySet // Only used if we do not have an fFactorySet
SkTHashMap<SkString, uint32_t> fFlattenableDict; SkTHashMap<SkString, uint32_t> fFlattenableDict;
#ifdef SK_SUPPORT_LEGACY_SERIAL_BUFFER_OBJECTS
sk_sp<SkPixelSerializer> fPS; sk_sp<SkPixelSerializer> fPS;
#endif
}; };
#endif // SkWriteBuffer_DEFINED #endif // SkWriteBuffer_DEFINED

View File

@ -143,13 +143,18 @@ sk_sp<SkPicture> SkPicture::Forwardport(const SkPictInfo& info,
return r.finishRecordingAsPicture(); return r.finishRecordingAsPicture();
} }
#ifdef SK_SUPPORT_LEGACY_IMAGEDESERIALIZER
sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream, SkImageDeserializer* factory) { sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream, SkImageDeserializer* factory) {
SkDeserialProcs procs; SkDeserialProcs procs;
procs.fImageProc = ImageDeserializer_SkDeserialImageProc; procs.fImageProc = ImageDeserializer_SkDeserialImageProc;
procs.fImageCtx = factory; procs.fImageCtx = factory;
return MakeFromStream(stream, procs, nullptr); return MakeFromStream(stream, procs, nullptr);
} }
sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream) {
SkImageDeserializer factory;
return MakeFromStream(stream, &factory);
}
sk_sp<SkPicture> SkPicture::MakeFromData(const void* data, size_t size, sk_sp<SkPicture> SkPicture::MakeFromData(const void* data, size_t size,
SkImageDeserializer* factory) { SkImageDeserializer* factory) {
SkMemoryStream stream(data, size); SkMemoryStream stream(data, size);
@ -163,28 +168,6 @@ sk_sp<SkPicture> SkPicture::MakeFromData(const SkData* data, SkImageDeserializer
SkMemoryStream stream(data->data(), data->size()); SkMemoryStream stream(data->data(), data->size());
return MakeFromStream(&stream, factory); return MakeFromStream(&stream, factory);
} }
#endif
sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream) {
return MakeFromStream(stream, SkDeserialProcs(), nullptr);
}
sk_sp<SkPicture> SkPicture::MakeFromData(const void* data, size_t size) {
if (!data) {
return nullptr;
}
SkMemoryStream stream(data, size);
return MakeFromStream(&stream, SkDeserialProcs(), nullptr);
}
sk_sp<SkPicture> SkPicture::MakeFromData(const SkData* data) {
if (!data) {
return nullptr;
}
SkMemoryStream stream(data->data(), data->size());
return MakeFromStream(&stream, SkDeserialProcs(), nullptr);
}
sk_sp<SkPicture> SkPicture::MakeFromData(const SkData* data, const SkDeserialProcs& procs) { sk_sp<SkPicture> SkPicture::MakeFromData(const SkData* data, const SkDeserialProcs& procs) {
if (!data) { if (!data) {
@ -382,13 +365,24 @@ bool SkPicture::PictureIOSecurityPrecautionsEnabled() {
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
sk_sp<SkData> PixelSerializer_SkSerialImageProc(SkImage* img, void* ctx) { sk_sp<SkData> PixelSerializer_SkSerialImageProc(SkImage* img, void* ctx) {
SkASSERT(ctx); SkASSERT(ctx);
return img->encodeToData(static_cast<SkPixelSerializer*>(ctx)); return img->encodeToData(static_cast<SkPixelSerializer*>(ctx));
} }
sk_sp<SkImage> ImageDeserializer_SkDeserialImageProc(const void* data, size_t length, void* ctx) {
SkASSERT(ctx);
SkImageDeserializer* imd = static_cast<SkImageDeserializer*>(ctx);
const SkIRect* subset = nullptr;
return imd->makeFromMemory(data, length, subset);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef SK_SUPPORT_LEGACY_SERIAL_BUFFER_OBJECTS
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
void SkBinaryWriteBuffer::setPixelSerializer(sk_sp<SkPixelSerializer> ps) { void SkBinaryWriteBuffer::setPixelSerializer(sk_sp<SkPixelSerializer> ps) {
fPS = ps; fPS = ps;
if (ps) { if (ps) {
@ -400,13 +394,6 @@ void SkBinaryWriteBuffer::setPixelSerializer(sk_sp<SkPixelSerializer> ps) {
} }
} }
#ifdef SK_SUPPORT_LEGACY_IMAGEDESERIALIZER
sk_sp<SkImage> ImageDeserializer_SkDeserialImageProc(const void* data, size_t length, void* ctx) {
SkASSERT(ctx);
SkImageDeserializer* imd = static_cast<SkImageDeserializer*>(ctx);
const SkIRect* subset = nullptr;
return imd->makeFromMemory(data, length, subset);
}
void SkReadBuffer::setImageDeserializer(SkImageDeserializer* factory) { void SkReadBuffer::setImageDeserializer(SkImageDeserializer* factory) {
if (factory) { if (factory) {
fProcs.fImageProc = ImageDeserializer_SkDeserialImageProc; fProcs.fImageProc = ImageDeserializer_SkDeserialImageProc;

View File

@ -216,7 +216,7 @@ public:
void setDeserialProcs(const SkDeserialProcs& procs); void setDeserialProcs(const SkDeserialProcs& procs);
#ifdef SK_SUPPORT_LEGACY_IMAGEDESERIALIZER #ifdef SK_SUPPORT_LEGACY_SERIAL_BUFFER_OBJECTS
void setImageDeserializer(SkImageDeserializer* factory); void setImageDeserializer(SkImageDeserializer* factory);
#endif #endif

View File

@ -405,7 +405,6 @@ sk_sp<SkImage> MakeTextureFromMipMap(GrContext*, const SkImageInfo&, const GrMip
} }
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef SK_SUPPORT_LEGACY_IMAGEDESERIALIZER
#include "SkImageDeserializer.h" #include "SkImageDeserializer.h"
sk_sp<SkImage> SkImageDeserializer::makeFromData(SkData* data, const SkIRect* subset) { sk_sp<SkImage> SkImageDeserializer::makeFromData(SkData* data, const SkIRect* subset) {
@ -415,7 +414,6 @@ sk_sp<SkImage> SkImageDeserializer::makeFromMemory(const void* data, size_t leng
const SkIRect* subset) { const SkIRect* subset) {
return SkImage::MakeFromEncoded(SkData::MakeWithCopy(data, length), subset); return SkImage::MakeFromEncoded(SkData::MakeWithCopy(data, length), subset);
} }
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////