diff options
author | 2014-12-09 08:27:37 -0800 | |
---|---|---|
committer | 2014-12-09 08:27:37 -0800 | |
commit | 303044579913eacc177d4b28a674121725c565bb (patch) | |
tree | c20269e86922d0153fdca65ff10a60075639941d /include | |
parent | 02b217f80b01a7dda8493422e5257c36a9ce8464 (diff) |
Revert of Replace EncodeBitmap with an interface. (patchset #12 id:210001 of https://codereview.chromium.org/784643002/)
Reason for revert:
Failing serialization tasks in DM:
http://build.chromium.org/p/client.skia/builders/Test-Win8-ShuttleA-GTX660-x86-Debug/builds/352/steps/dm/logs/stdio
Original issue's description:
> Replace EncodeBitmap with an interface.
>
> Gives more flexibility to the caller to decide whether to use the
> encoded data returned by refEncodedData().
>
> Provides an implementation that supports the old version of
> SkPicture::serialize().
>
> TODO: Update Chrome, so we can remove SK_LEGACY_ENCODE_BITMAP entirely
>
> BUG=skia:3190
>
> Committed: https://skia.googlesource.com/skia/+/0c4aba6edb9900c597359dfa49d3ce4a41bc5dd1
>
> Committed: https://skia.googlesource.com/skia/+/02b217f80b01a7dda8493422e5257c36a9ce8464
TBR=reed@google.com,rmistry@google.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:3190
Review URL: https://codereview.chromium.org/783393004
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkPicture.h | 20 | ||||
-rw-r--r-- | include/core/SkPixelSerializer.h | 52 | ||||
-rw-r--r-- | include/core/SkWriteBuffer.h | 24 |
3 files changed, 11 insertions, 85 deletions
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h index 88d8b05a4b..f764d346cc 100644 --- a/include/core/SkPicture.h +++ b/include/core/SkPicture.h @@ -24,7 +24,6 @@ class SkBBoxHierarchy; class SkCanvas; class SkData; class SkPictureData; -class SkPixelSerializer; class SkStream; class SkWStream; @@ -36,8 +35,6 @@ namespace SkRecords { class CollectLayers; }; -//#define SK_LEGACY_ENCODE_BITMAP - /** \class SkPicture The SkPicture class records the drawing commands made to a canvas, to @@ -144,30 +141,15 @@ public: * @param pixelRefOffset DEPRECATED -- caller assumes it will return 0. * @return SkData If non-NULL, holds encoded data representing the passed * in bitmap. The caller is responsible for calling unref(). - * - * TODO: No longer used by SkPicture (except when SK_LEGACY_ENCODE_BITMAP - * is defined. Still used by PDF though. Move into PDF. */ typedef SkData* (*EncodeBitmap)(size_t* pixelRefOffset, const SkBitmap& bm); -#ifdef SK_LEGACY_ENCODE_BITMAP /** * Serialize to a stream. If non NULL, encoder will be used to encode * any bitmaps in the picture. * encoder will never be called with a NULL pixelRefOffset. - * DEPRECATED - use serialize(SkWStream*, SkPixelSerializer* serializer) - * instead. - */ - void serialize(SkWStream* wStream, EncodeBitmap encoder) const; -#endif - - /** - * Serialize to a stream. If non NULL, serializer will be used to serialize - * any bitmaps in the picture. - * - * TODO: Use serializer to serialize SkImages as well. */ - void serialize(SkWStream*, SkPixelSerializer* serializer = NULL) const; + void serialize(SkWStream*, EncodeBitmap encoder = NULL) const; /** * Serialize to a buffer. diff --git a/include/core/SkPixelSerializer.h b/include/core/SkPixelSerializer.h deleted file mode 100644 index 8fc445c753..0000000000 --- a/include/core/SkPixelSerializer.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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, 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&, void* pixels, size_t rowBytes) = 0; -}; -#endif // SkPixelSerializer_DEFINED diff --git a/include/core/SkWriteBuffer.h b/include/core/SkWriteBuffer.h index 39739f2c24..4dbe17b0d9 100644 --- a/include/core/SkWriteBuffer.h +++ b/include/core/SkWriteBuffer.h @@ -12,7 +12,6 @@ #include "SkData.h" #include "SkPath.h" #include "SkPicture.h" -#include "SkPixelSerializer.h" #include "SkRefCnt.h" #include "SkWriter32.h" @@ -88,24 +87,21 @@ public: /** * Set an SkBitmapHeap to store bitmaps rather than flattening. * - * Incompatible with an SkPixelSerializer. If an SkPixelSerializer is set, - * setting an SkBitmapHeap will set the SkPixelSerializer to NULL in release - * and crash in debug. + * Incompatible with an EncodeBitmap function. If an EncodeBitmap function is set, setting an + * SkBitmapHeap will set the function to NULL in release mode and crash in debug. */ void setBitmapHeap(SkBitmapHeap*); /** - * Set an SkPixelSerializer to store an encoded representation of pixels, - * e.g. SkBitmaps. + * Provide a function to encode an SkBitmap to an SkData. writeBitmap will attempt to use + * bitmapEncoder to store the SkBitmap. If the reader does not provide a function to decode, it + * will not be able to restore SkBitmaps, but will still be able to read the rest of the stream. + * bitmapEncoder will never be called with a NULL pixelRefOffset. * - * Calls ref() on the serializer. - * - * TODO: Encode SkImage pixels as well. - * - * Incompatible with the SkBitmapHeap. If an encoder is set fBitmapHeap will - * be set to NULL in release and crash in debug. + * Incompatible with the SkBitmapHeap. If an encoder is set fBitmapHeap will be set to NULL in + * release and crash in debug. */ - void setPixelSerializer(SkPixelSerializer*); + void setBitmapEncoder(SkPicture::EncodeBitmap bitmapEncoder); private: bool isValidating() const { return SkToBool(fFlags & kValidation_Flag); } @@ -118,7 +114,7 @@ private: SkBitmapHeap* fBitmapHeap; SkRefCntSet* fTFSet; - SkAutoTUnref<SkPixelSerializer> fPixelSerializer; + SkPicture::EncodeBitmap fBitmapEncoder; }; #endif // SkWriteBuffer_DEFINED |