diff options
author | Lei Zhang <thestig@chromium.org> | 2017-09-19 14:18:48 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-09-20 01:28:25 +0000 |
commit | 4b8d363ceed5437ee6a23563f69ba0a73d90413c (patch) | |
tree | f46c67c8a23318ea2d71035ca60355998e9daf20 /core/fxcodec/codec/ccodec_scanlinedecoder.cpp | |
parent | 89bf9ce294d83669922443dd17391e8c38e720a8 (diff) | |
download | pdfium-4b8d363ceed5437ee6a23563f69ba0a73d90413c.tar.xz |
Move CCodec_ScanlineDecoder to its own file.
Change-Id: Icacf877e2b66ca7d49637dcf9eaec0f99bcdd8bb
Reviewed-on: https://pdfium-review.googlesource.com/14390
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcodec/codec/ccodec_scanlinedecoder.cpp')
-rw-r--r-- | core/fxcodec/codec/ccodec_scanlinedecoder.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/core/fxcodec/codec/ccodec_scanlinedecoder.cpp b/core/fxcodec/codec/ccodec_scanlinedecoder.cpp new file mode 100644 index 0000000000..55b9a2a87d --- /dev/null +++ b/core/fxcodec/codec/ccodec_scanlinedecoder.cpp @@ -0,0 +1,73 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "core/fxcodec/codec/ccodec_scanlinedecoder.h" + +#include "core/fxcrt/ifx_pauseindicator.h" + +CCodec_ScanlineDecoder::CCodec_ScanlineDecoder() + : CCodec_ScanlineDecoder(0, 0, 0, 0, 0, 0, 0) {} + +CCodec_ScanlineDecoder::CCodec_ScanlineDecoder(int nOrigWidth, + int nOrigHeight, + int nOutputWidth, + int nOutputHeight, + int nComps, + int nBpc, + uint32_t nPitch) + : m_OrigWidth(nOrigWidth), + m_OrigHeight(nOrigHeight), + m_OutputWidth(nOutputWidth), + m_OutputHeight(nOutputHeight), + m_nComps(nComps), + m_bpc(nBpc), + m_Pitch(nPitch), + m_NextLine(-1), + m_pLastScanline(nullptr) {} + +CCodec_ScanlineDecoder::~CCodec_ScanlineDecoder() {} + +const uint8_t* CCodec_ScanlineDecoder::GetScanline(int line) { + if (m_NextLine == line + 1) + return m_pLastScanline; + + if (m_NextLine < 0 || m_NextLine > line) { + if (!v_Rewind()) + return nullptr; + m_NextLine = 0; + } + while (m_NextLine < line) { + ReadNextLine(); + m_NextLine++; + } + m_pLastScanline = ReadNextLine(); + m_NextLine++; + return m_pLastScanline; +} + +bool CCodec_ScanlineDecoder::SkipToScanline(int line, + IFX_PauseIndicator* pPause) { + if (m_NextLine == line || m_NextLine == line + 1) + return false; + + if (m_NextLine < 0 || m_NextLine > line) { + v_Rewind(); + m_NextLine = 0; + } + m_pLastScanline = nullptr; + while (m_NextLine < line) { + m_pLastScanline = ReadNextLine(); + m_NextLine++; + if (pPause && pPause->NeedToPauseNow()) { + return true; + } + } + return false; +} + +uint8_t* CCodec_ScanlineDecoder::ReadNextLine() { + return v_GetNextLine(); +} |