Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cfx_codec_memory.h
Go to the documentation of this file.
1// Copyright 2018 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CORE_FXCODEC_CFX_CODEC_MEMORY_H_
6#define CORE_FXCODEC_CFX_CODEC_MEMORY_H_
7
8#include <memory>
9
10#include "core/fxcrt/fx_memory_wrappers.h"
11#include "core/fxcrt/retain_ptr.h"
12#include "third_party/base/containers/span.h"
13
14class CFX_CodecMemory final : public Retainable {
15 public:
17
18 // Returns a span over the unconsumed contents of the buffer.
19 pdfium::span<uint8_t> GetUnconsumedSpan() {
20 return GetBufferSpan().subspan(pos_);
21 }
22
23 pdfium::span<uint8_t> GetBufferSpan() { return {buffer_.get(), size_}; }
24 size_t GetSize() const { return size_; }
25 size_t GetPosition() const { return pos_; }
26 bool IsEOF() const { return pos_ >= size_; }
27 size_t ReadBlock(pdfium::span<uint8_t> buffer);
28
29 // Sets the cursor position to |pos| if possible.
30 bool Seek(size_t pos);
31
32 // Try to change the size of the buffer, keep the old one on failure.
33 bool TryResize(size_t new_buffer_size);
34
35 // Schlep the bytes down the buffer.
36 void Consume(size_t consumed);
37
38 private:
39 explicit CFX_CodecMemory(size_t buffer_size);
40 ~CFX_CodecMemory() override;
41
42 std::unique_ptr<uint8_t, FxFreeDeleter> buffer_;
43 size_t size_ = 0;
44 size_t pos_ = 0;
45};
46
47#endif // CORE_FXCODEC_CFX_CODEC_MEMORY_H_
bool TryResize(size_t new_buffer_size)
bool IsEOF() const
pdfium::span< uint8_t > GetBufferSpan()
size_t GetSize() const
~CFX_CodecMemory() override
size_t ReadBlock(pdfium::span< uint8_t > buffer)
pdfium::span< uint8_t > GetUnconsumedSpan()
bool Seek(size_t pos)
size_t GetPosition() const
void Consume(size_t consumed)
virtual void BmpReadScanline(uint32_t row_num, pdfium::span< const uint8_t > row_buf)=0
virtual bool BmpInputImagePositionBuf(uint32_t rcd_pos)=0
static bool Input(ProgressiveDecoderIface::Context *pContext, RetainPtr< CFX_CodecMemory > codec_memory)
static Status ReadHeader(ProgressiveDecoderIface::Context *pContext, int32_t *width, int32_t *height, bool *tb_flag, int32_t *components, int32_t *pal_num, const std::vector< uint32_t > **palette, CFX_DIBAttribute *pAttribute)
BmpDecoder(const BmpDecoder &)=delete
static Status LoadImage(ProgressiveDecoderIface::Context *pContext)
static std::unique_ptr< ProgressiveDecoderIface::Context > StartDecode(Delegate *pDelegate)
static FX_FILESIZE GetAvailInput(ProgressiveDecoderIface::Context *pContext)
BmpDecoder & operator=(const BmpDecoder &)=delete
UnownedPtr< BmpDecoder::Delegate > const m_pDelegate
CFX_BmpContext(BmpDecoder::Delegate *pDelegate)
CFX_BmpDecompressor m_Bmp
CFX_BmpDecompressor(const CFX_BmpContext *context)
const std::vector< uint32_t > * palette() const
void SetInputBuffer(RetainPtr< CFX_CodecMemory > codec_memory)
virtual FX_FILESIZE GetAvailInput(Context *pContext) const =0
virtual bool Input(Context *pContext, RetainPtr< CFX_CodecMemory > codec_memory)=0
virtual ~ProgressiveDecoderIface()=default
#define FX_FILESIZE
Definition fx_types.h:19
#define CONSTRUCT_VIA_MAKE_RETAIN
Definition retain_ptr.h:224
uint16_t bcBitCount
Definition fx_bmp.h:26
uint16_t bcWidth
Definition fx_bmp.h:23
uint16_t bcHeight
Definition fx_bmp.h:24
uint16_t bcPlanes
Definition fx_bmp.h:25
uint32_t bcSize
Definition fx_bmp.h:22
uint32_t bfSize
Definition fx_bmp.h:15
uint32_t bfOffBits
Definition fx_bmp.h:18
uint16_t bfReserved2
Definition fx_bmp.h:17
uint16_t bfType
Definition fx_bmp.h:14
uint16_t bfReserved1
Definition fx_bmp.h:16
uint32_t biClrUsed
Definition fx_bmp.h:39
int32_t biWidth
Definition fx_bmp.h:31
uint32_t biSizeImage
Definition fx_bmp.h:36
uint16_t biPlanes
Definition fx_bmp.h:33
int32_t biHeight
Definition fx_bmp.h:32
uint16_t biBitCount
Definition fx_bmp.h:34
uint32_t biCompression
Definition fx_bmp.h:35
int32_t biYPelsPerMeter
Definition fx_bmp.h:38
uint32_t biSize
Definition fx_bmp.h:30
uint32_t biClrImportant
Definition fx_bmp.h:40
int32_t biXPelsPerMeter
Definition fx_bmp.h:37