Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: include/core/SkPicture.h

Issue 784643002: Replace EncodeBitmap with an interface. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Undefine macro, fix callsites, define in chrome, leave EncodeBitmap for PDF. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/core/SkPicture.h
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index f764d346cc4b9e8f4b828809372cd8305516265c..3628b06d23cfe29773bdec881287722ec2d5214f 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -35,6 +35,14 @@ namespace SkRecords {
class CollectLayers;
};
+//#define SK_LEGACY_ENCODE_BITMAP
+
+#ifdef SK_LEGACY_ENCODE_BITMAP
+#include "SkPixelSerializer.h"
+#else
+class SkPixelSerializer;
+#endif
+
/** \class SkPicture
The SkPicture class records the drawing commands made to a canvas, to
@@ -144,12 +152,19 @@ public:
*/
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.
*/
- void serialize(SkWStream*, EncodeBitmap encoder = NULL) const;
+ void serialize(SkWStream* wStream, EncodeBitmap encoder) const {
+ EncodeBitmapSerializer serializer(encoder);
+ this->serialize(wStream, &serializer);
+ }
+#endif
+
+ void serialize(SkWStream*, SkPixelSerializer* serializer = NULL) const;
/**
* Serialize to a buffer.
@@ -295,6 +310,30 @@ private:
int fNumAADFEligibleConcavePaths;
} fAnalysis;
+#ifdef SK_LEGACY_ENCODE_BITMAP
+ // Helper to use the new API.
+ class EncodeBitmapSerializer : public SkPixelSerializer {
+ public:
+ explicit EncodeBitmapSerializer(EncodeBitmap encoder)
+ : fEncoder(encoder)
+ {
+ SkASSERT(fEncoder);
+ }
+
+ bool useEncodedData(SkData*) SK_OVERRIDE { return true; }
+
+ SkData* encodePixels(const SkImageInfo& info, void* pixels, size_t rowBytes) SK_OVERRIDE {
+ size_t unused;
+ SkBitmap bm;
+ bm.installPixels(info, pixels, rowBytes);
+ return fEncoder(&unused, bm);
+ }
+
+ private:
+ EncodeBitmap fEncoder;
+ };
+#endif
+
friend class SkPictureRecorder; // SkRecord-based constructor.
friend class GrLayerHoister; // access to fRecord
friend class ReplaceDraw;

Powered by Google App Engine
This is Rietveld 408576698