1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_image_decoders_nsJXLDecoder_h
8 #define mozilla_image_decoders_nsJXLDecoder_h
12 #include "SurfacePipe.h"
14 #include "jxl/decode_cxx.h"
15 #include "jxl/thread_parallel_runner_cxx.h"
17 #include "mozilla/Telemetry.h"
19 namespace mozilla::image
{
22 class nsJXLDecoder final
: public Decoder
{
24 virtual ~nsJXLDecoder();
26 DecoderType
GetType() const override
{ return DecoderType::JXL
; }
29 LexerResult
DoDecode(SourceBufferIterator
& aIterator
,
30 IResumable
* aOnResume
) override
;
33 friend class DecoderFactory
;
35 // Decoders should only be instantiated via DecoderFactory.
36 explicit nsJXLDecoder(RasterImage
* aImage
);
38 size_t PreferredThreadCount();
40 enum class State
{ JXL_DATA
, FINISHED_JXL_DATA
};
42 LexerTransition
<State
> ReadJXLData(const char* aData
, size_t aLength
);
43 LexerTransition
<State
> FinishedJXLData();
45 StreamingLexer
<State
> mLexer
;
46 JxlDecoderPtr mDecoder
;
47 JxlThreadParallelRunnerPtr mParallelRunner
;
48 Vector
<uint8_t> mBuffer
;
49 Vector
<uint8_t> mOutBuffer
;
53 } // namespace mozilla::image
55 #endif // mozilla_image_decoders_nsJXLDecoder_h