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

Unified Diff: src/codec/SkCodec_libgif.h

Issue 1022673011: Creating a new wrapper for gif decoder (Closed) Base URL: https://skia.googlesource.com/skia.git@ico-real
Patch Set: Added comments and do while loop Created 5 years, 9 months 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
« no previous file with comments | « src/codec/SkCodec.cpp ('k') | src/codec/SkCodec_libgif.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkCodec_libgif.h
diff --git a/src/codec/SkCodec_libgif.h b/src/codec/SkCodec_libgif.h
new file mode 100644
index 0000000000000000000000000000000000000000..de59c6c32a4d1f511a14571c8f3213d60294e935
--- /dev/null
+++ b/src/codec/SkCodec_libgif.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkCodec.h"
+#include "SkImageInfo.h"
+
+#include "gif_lib.h"
+
+/*
+ *
+ * This class implements the decoding for gif images
+ *
+ */
+class SkGifCodec : public SkCodec {
+public:
+
+ /*
+ * Checks the start of the stream to see if the image is a gif
+ */
+ static bool IsGif(SkStream*);
+
+ /*
+ * Assumes IsGif was called and returned true
+ * Creates a gif decoder
+ * Reads enough of the stream to determine the image format
+ */
+ static SkCodec* NewFromStream(SkStream*);
+
+
+protected:
+
+ /*
+ * Initiates the gif decode
+ */
+ Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&,
+ SkPMColor*, int32_t*) override;
+
+ SkEncodedFormat onGetEncodedFormat() const override {
+ return kGIF_SkEncodedFormat;
+ }
+
+private:
+
+ /*
+ * This function cleans up the gif object after the decode completes
+ * It is used in a SkAutoTCallIProc template
+ */
+ static int32_t CloseGif(GifFileType* gif);
+
+ /*
+ * Frees any extension data used in the decode
+ * Used in a SkAutoTCallVProc
+ */
+ static void FreeExtension(SavedImage* image);
+
+ /*
+ * Creates an instance of the decoder
+ * Called only by NewFromStream
+ *
+ * @param srcInfo contains the source width and height
+ * @param stream the stream of image data
+ * @param gif pointer to library type that manages gif decode
+ * takes ownership
+ */
+ SkGifCodec(const SkImageInfo& srcInfo, SkStream* stream, GifFileType* gif);
+
+ SkAutoTCallIProc<GifFileType, CloseGif> fGif; // owned
+
+ typedef SkCodec INHERITED;
+};
« no previous file with comments | « src/codec/SkCodec.cpp ('k') | src/codec/SkCodec_libgif.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698