summaryrefslogtreecommitdiffstats
path: root/image/decoders/nsWebPDecoder.h
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-03 08:48:48 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-03 08:48:48 -0500
commitc6856f968b8c85502f14c6c3412b00a05fc0c0de (patch)
treec0720fdf31018c72fcb69134f2e9667d16970c3a /image/decoders/nsWebPDecoder.h
parent36f73c8cd27e62cbd3e85939d6fe11a240e3416f (diff)
parent1e1fb5ea2504e548bc17521bdb273c9e59b9cf01 (diff)
downloadUXP-c6856f968b8c85502f14c6c3412b00a05fc0c0de.tar
UXP-c6856f968b8c85502f14c6c3412b00a05fc0c0de.tar.gz
UXP-c6856f968b8c85502f14c6c3412b00a05fc0c0de.tar.lz
UXP-c6856f968b8c85502f14c6c3412b00a05fc0c0de.tar.xz
UXP-c6856f968b8c85502f14c6c3412b00a05fc0c0de.zip
Merge branch 'master' into configurebuild-work
Diffstat (limited to 'image/decoders/nsWebPDecoder.h')
-rw-r--r--image/decoders/nsWebPDecoder.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/image/decoders/nsWebPDecoder.h b/image/decoders/nsWebPDecoder.h
new file mode 100644
index 000000000..5b3951cfc
--- /dev/null
+++ b/image/decoders/nsWebPDecoder.h
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_image_decoders_nsWebPDecoder_h
+#define mozilla_image_decoders_nsWebPDecoder_h
+
+#include "Decoder.h"
+#include "webp/demux.h"
+#include "StreamingLexer.h"
+#include "SurfacePipe.h"
+
+namespace mozilla {
+namespace image {
+class RasterImage;
+
+class nsWebPDecoder : public Decoder
+{
+public:
+ virtual ~nsWebPDecoder();
+
+protected:
+ LexerResult DoDecode(SourceBufferIterator& aIterator,
+ IResumable* aOnResume) override;
+
+private:
+ friend class DecoderFactory;
+
+ // Decoders should only be instantiated via DecoderFactory.
+ explicit nsWebPDecoder(RasterImage* aImage);
+
+ enum class State
+ {
+ WEBP_DATA,
+ FINISHED_WEBP_DATA
+ };
+
+ LexerTransition<State> ReadHeader(const char* aData, size_t aLength);
+ LexerTransition<State> ReadPayload(const char* aData, size_t aLength);
+ LexerTransition<State> FinishedData();
+
+ nsresult CreateFrame(const nsIntRect& aFrameRect);
+ void EndFrame();
+
+ nsresult GetDataBuffer(const uint8_t*& aData, size_t& aLength);
+ nsresult SaveDataBuffer(const uint8_t* aData, size_t aLength);
+
+ LexerTransition<State> ReadSingle(const uint8_t* aData, size_t aLength,
+ bool aAppend, const IntRect& aFrameRect);
+
+ LexerTransition<State> ReadMultiple(const uint8_t* aData, size_t aLength);
+
+ StreamingLexer<State> mLexer;
+
+ /// The SurfacePipe used to write to the output surface.
+ SurfacePipe mPipe;
+
+ /// The buffer used to accumulate data until the complete WebP header is received.
+ Vector<uint8_t> mData;
+
+ /// The libwebp output buffer descriptor pointing to the decoded data.
+ WebPDecBuffer mBuffer;
+
+ /// The libwebp incremental decoder descriptor, wraps mBuffer.
+ WebPIDecoder* mDecoder;
+
+ /// Blend method for the current frame.
+ BlendMethod mBlend;
+
+ /// Disposal method for the current frame.
+ DisposalMethod mDisposal;
+
+ /// Frame timeout for the current frame;
+ FrameTimeout mTimeout;
+
+ /// Surface format for the current frame.
+ gfx::SurfaceFormat mFormat;
+
+ /// The last row of decoded pixels written to mPipe.
+ int mLastRow;
+
+ /// Number of decoded frames.
+ uint32_t mCurrentFrame;
+};
+
+} // namespace image
+} // namespace mozilla
+
+#endif // mozilla_image_decoders_nsWebPDecoder_h