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

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

Issue 2419173002: Update CPDF_IndirectObjectHolder APIs for unique objects (Closed)
Patch Set: Fix issues Created 4 years, 2 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/fpdfapi/page/cpdf_docpagedata.cpp ('k') | core/fpdfapi/parser/cfdf_document.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 50768c50587bc51ad21108b337a1f14a3c9dec3e..2755381de49a315b59ba20a5c484885c02e9ab9e 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -204,7 +204,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) {
} else if (bpp == 8) {
int32_t iPalette = pBitmap->GetPaletteSize();
if (iPalette > 0) {
- CPDF_Array* pCS = new CPDF_Array;
+ UniqueArray pCS(new CPDF_Array);
pCS->AddName("Indexed");
pCS->AddName("DeviceRGB");
pCS->AddInteger(iPalette - 1);
@@ -217,12 +217,12 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) {
ptr[2] = (uint8_t)argb;
ptr += 3;
}
- CPDF_Stream* pCTS = new CPDF_Stream(
+ CPDF_Stream* pCTS = m_pDocument->AddIndirectStream(
pColorTable, iPalette * 3,
new CPDF_Dictionary(m_pDocument->GetByteStringPool()));
- pCS->AddReference(m_pDocument, m_pDocument->AddIndirectObject(pCTS));
+ pCS->AddReference(m_pDocument, pCTS->GetObjNum());
pDict->SetReferenceFor("ColorSpace", m_pDocument,
- m_pDocument->AddIndirectObject(pCS));
+ m_pDocument->AddIndirectObject(std::move(pCS)));
} else {
pDict->SetNameFor("ColorSpace", "DeviceGray");
}
@@ -274,9 +274,9 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) {
}
}
pMaskDict->SetIntegerFor("Length", mask_size);
- pDict->SetReferenceFor("SMask", m_pDocument,
- m_pDocument->AddIndirectObject(new CPDF_Stream(
- mask_buf, mask_size, pMaskDict)));
+ pDict->SetReferenceFor(
+ "SMask", m_pDocument,
+ m_pDocument->AddIndirectStream(mask_buf, mask_size, pMaskDict));
if (bDeleteMask)
delete pMaskBitmap;
}
« no previous file with comments | « core/fpdfapi/page/cpdf_docpagedata.cpp ('k') | core/fpdfapi/parser/cfdf_document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698