Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Unified Diff: core/src/fpdfapi/fpdf_parser/cpdf_stream.cpp

Issue 1783933003: Split CPDF_Stream/CPDF_StreamAcc into separate files (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/cpdf_parser.cpp ('k') | core/src/fpdfapi/fpdf_parser/cpdf_stream_acc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_parser/cpdf_stream.cpp
diff --git a/core/src/fpdfapi/fpdf_parser/cpdf_stream.cpp b/core/src/fpdfapi/fpdf_parser/cpdf_stream.cpp
index 45c946ab5f962c578cee273c8fc0452c2ef8595b..7faf9ddd44a46b0a01f729264f86e46846633663 100644
--- a/core/src/fpdfapi/fpdf_parser/cpdf_stream.cpp
+++ b/core/src/fpdfapi/fpdf_parser/cpdf_stream.cpp
@@ -7,6 +7,7 @@
#include "core/include/fpdfapi/cpdf_stream.h"
#include "core/include/fpdfapi/cpdf_dictionary.h"
+#include "core/include/fpdfapi/cpdf_stream_acc.h"
#include "core/include/fpdfapi/fpdf_parser_decode.h"
CPDF_Stream::CPDF_Stream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict)
@@ -134,99 +135,3 @@ CFX_WideString CPDF_Stream::GetUnicodeText() const {
return PDF_DecodeText(stream.GetData(), stream.GetSize());
}
-CPDF_StreamAcc::CPDF_StreamAcc()
- : m_pData(nullptr),
- m_dwSize(0),
- m_bNewBuf(FALSE),
- m_pImageParam(nullptr),
- m_pStream(nullptr),
- m_pSrcData(nullptr) {}
-
-void CPDF_StreamAcc::LoadAllData(const CPDF_Stream* pStream,
- FX_BOOL bRawAccess,
- FX_DWORD estimated_size,
- FX_BOOL bImageAcc) {
- if (!pStream)
- return;
-
- m_pStream = pStream;
- if (pStream->IsMemoryBased() &&
- (!pStream->GetDict()->KeyExist("Filter") || bRawAccess)) {
- m_dwSize = pStream->GetRawSize();
- m_pData = pStream->GetRawData();
- return;
- }
- uint8_t* pSrcData;
- FX_DWORD dwSrcSize = pStream->GetRawSize();
- if (dwSrcSize == 0)
- return;
-
- if (!pStream->IsMemoryBased()) {
- pSrcData = m_pSrcData = FX_Alloc(uint8_t, dwSrcSize);
- if (!pStream->ReadRawData(0, pSrcData, dwSrcSize))
- return;
- } else {
- pSrcData = pStream->GetRawData();
- }
- uint8_t* pDecryptedData = pSrcData;
- FX_DWORD dwDecryptedSize = dwSrcSize;
- if (!pStream->GetDict()->KeyExist("Filter") || bRawAccess) {
- m_pData = pDecryptedData;
- m_dwSize = dwDecryptedSize;
- } else {
- FX_BOOL bRet = PDF_DataDecode(
- pDecryptedData, dwDecryptedSize, m_pStream->GetDict(), m_pData,
- m_dwSize, m_ImageDecoder, m_pImageParam, estimated_size, bImageAcc);
- if (!bRet) {
- m_pData = pDecryptedData;
- m_dwSize = dwDecryptedSize;
- }
- }
- if (pSrcData != pStream->GetRawData() && pSrcData != m_pData) {
- FX_Free(pSrcData);
- }
- if (pDecryptedData != pSrcData && pDecryptedData != m_pData) {
- FX_Free(pDecryptedData);
- }
- m_pSrcData = nullptr;
- m_bNewBuf = m_pData != pStream->GetRawData();
-}
-
-CPDF_StreamAcc::~CPDF_StreamAcc() {
- if (m_bNewBuf) {
- FX_Free(m_pData);
- }
- FX_Free(m_pSrcData);
-}
-
-const uint8_t* CPDF_StreamAcc::GetData() const {
- if (m_bNewBuf) {
- return m_pData;
- }
- if (!m_pStream) {
- return nullptr;
- }
- return m_pStream->GetRawData();
-}
-
-FX_DWORD CPDF_StreamAcc::GetSize() const {
- if (m_bNewBuf) {
- return m_dwSize;
- }
- if (!m_pStream) {
- return 0;
- }
- return m_pStream->GetRawSize();
-}
-
-uint8_t* CPDF_StreamAcc::DetachData() {
- if (m_bNewBuf) {
- uint8_t* p = m_pData;
- m_pData = nullptr;
- m_dwSize = 0;
- return p;
- }
- uint8_t* p = FX_Alloc(uint8_t, m_dwSize);
- FXSYS_memcpy(p, m_pData, m_dwSize);
- return p;
-}
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/cpdf_parser.cpp ('k') | core/src/fpdfapi/fpdf_parser/cpdf_stream_acc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698