From ad905158b86269686f94ea76d1b700f68ea377d5 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Mon, 12 Feb 2018 20:43:53 +0000 Subject: Convert CFX_BmpDecompressor to use CFX_MemoryStream This also adds a Seek method to CFX_MemoryStream BUG=pdfium:1007 Change-Id: I2c7e1d3b6d8aff36e302014cb2e8ffc0f23ef7c4 Reviewed-on: https://pdfium-review.googlesource.com/26230 Commit-Queue: Ryan Harrison Reviewed-by: Lei Zhang --- core/fxcrt/cfx_memorystream.cpp | 8 ++++++++ core/fxcrt/cfx_memorystream.h | 3 +++ 2 files changed, 11 insertions(+) (limited to 'core/fxcrt') diff --git a/core/fxcrt/cfx_memorystream.cpp b/core/fxcrt/cfx_memorystream.cpp index 345b381226..dcd21f073f 100644 --- a/core/fxcrt/cfx_memorystream.cpp +++ b/core/fxcrt/cfx_memorystream.cpp @@ -148,6 +148,14 @@ bool CFX_MemoryStream::WriteBlock(const void* buffer, return true; } +bool CFX_MemoryStream::Seek(size_t pos) { + if (pos > m_nCurSize) + return false; + + m_nCurPos = pos; + return true; +} + void CFX_MemoryStream::EstimateSize(size_t nInitSize, size_t nGrowSize) { if (m_dwFlags & Type::kConsecutive) { if (m_Blocks.empty()) { diff --git a/core/fxcrt/cfx_memorystream.h b/core/fxcrt/cfx_memorystream.h index ef66080420..a56a2dbe2c 100644 --- a/core/fxcrt/cfx_memorystream.h +++ b/core/fxcrt/cfx_memorystream.h @@ -28,6 +28,9 @@ class CFX_MemoryStream : public IFX_SeekableStream { bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override; bool Flush() override; + // Sets the cursor position to |pos| if possible + bool Seek(size_t pos); + bool IsConsecutive() const { return !!(m_dwFlags & Type::kConsecutive); } uint8_t* GetBuffer() const { -- cgit v1.2.3