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

Unified Diff: core/fpdfapi/page/cpdf_image.cpp

Issue 2489423002: Make CPDF_PageContentGenerator methods take object numbers (Closed)
Patch Set: Rebase past fix in separate CL Created 4 years, 1 month 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/fpdfapi/page/cpdf_image.h ('k') | core/fpdfapi/page/cpdf_imageobject.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/page/cpdf_image.cpp
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp
index 976d6d8c471bc4bcefc698597b8400c36ac31bfd..4048c9bb4e2d9e0883a67da68cbf45eee638409c 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -30,9 +30,6 @@ CPDF_Image::CPDF_Image(CPDF_Document* pDoc,
: m_pDocument(pDoc),
m_pStream(pStream.get()),
m_pOwnedStream(std::move(pStream)) {
- if (!m_pStream)
- return;
-
m_pOwnedDict =
ToDictionary(std::unique_ptr<CPDF_Object>(m_pStream->GetDict()->Clone()));
m_pDict = m_pOwnedDict.get();
@@ -42,9 +39,6 @@ CPDF_Image::CPDF_Image(CPDF_Document* pDoc,
CPDF_Image::CPDF_Image(CPDF_Document* pDoc, uint32_t dwStreamObjNum)
: m_pDocument(pDoc),
m_pStream(ToStream(pDoc->GetIndirectObject(dwStreamObjNum))) {
- if (!m_pStream)
- return;
-
m_pDict = m_pStream->GetDict();
FinishInitialization();
}
@@ -79,6 +73,14 @@ CPDF_Image* CPDF_Image::Clone() {
return pImage;
}
+void CPDF_Image::ConvertStreamToIndirectObject() {
+ if (!m_pStream->IsInline())
+ return;
+
+ ASSERT(m_pOwnedStream);
+ m_pDocument->AddIndirectObject(m_pOwnedStream.release());
+}
+
CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, uint32_t size) {
int32_t width;
int32_t height;
@@ -122,8 +124,10 @@ CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, uint32_t size) {
m_bIsMask = false;
m_Width = width;
m_Height = height;
- if (!m_pStream)
- m_pStream = new CPDF_Stream;
+ if (!m_pStream) {
+ m_pOwnedStream = pdfium::MakeUnique<CPDF_Stream>();
+ m_pStream = m_pOwnedStream.get();
+ }
return pDict;
}
@@ -334,9 +338,10 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) {
dest_offset = 0;
}
}
- if (!m_pStream)
- m_pStream = new CPDF_Stream;
-
+ if (!m_pStream) {
+ m_pOwnedStream = pdfium::MakeUnique<CPDF_Stream>();
+ m_pStream = m_pOwnedStream.get();
+ }
m_pStream->InitStream(dest_buf, dest_size, pDict);
m_bIsMask = pBitmap->IsAlphaMask();
m_Width = BitmapWidth;
« no previous file with comments | « core/fpdfapi/page/cpdf_image.h ('k') | core/fpdfapi/page/cpdf_imageobject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698