summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_image.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-11-15 11:33:44 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-15 11:33:44 -0800
commit70c4afd5c3c5c44cd24f814423a23a6ef05bba02 (patch)
treecbe593d0b6c0bfc6fd5038bf60a77a94e49c69c9 /core/fpdfapi/page/cpdf_image.cpp
parentf16f6b8b52277348f5d571b7641bb0bbd5239589 (diff)
downloadpdfium-70c4afd5c3c5c44cd24f814423a23a6ef05bba02.tar.xz
Make AddIndirectObject() take a unique_ptr.
Add convenience routines to create and add object in one step. Review-Url: https://codereview.chromium.org/2489283003
Diffstat (limited to 'core/fpdfapi/page/cpdf_image.cpp')
-rw-r--r--core/fpdfapi/page/cpdf_image.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp
index 4048c9bb4e..e21d38a56f 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -78,7 +78,7 @@ void CPDF_Image::ConvertStreamToIndirectObject() {
return;
ASSERT(m_pOwnedStream);
- m_pDocument->AddIndirectObject(m_pOwnedStream.release());
+ m_pDocument->AddIndirectObject(std::move(m_pOwnedStream));
}
CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, uint32_t size) {
@@ -212,7 +212,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;
+ CPDF_Array* pCS = m_pDocument->NewIndirect<CPDF_Array>();
pCS->AddName("Indexed");
pCS->AddName("DeviceRGB");
pCS->AddInteger(iPalette - 1);
@@ -225,12 +225,11 @@ 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->NewIndirect<CPDF_Stream>(
pColorTable, iPalette * 3,
new CPDF_Dictionary(m_pDocument->GetByteStringPool()));
- pCS->AddReference(m_pDocument, m_pDocument->AddIndirectObject(pCTS));
- pDict->SetReferenceFor("ColorSpace", m_pDocument,
- m_pDocument->AddIndirectObject(pCS));
+ pCS->AddReference(m_pDocument, pCTS);
+ pDict->SetReferenceFor("ColorSpace", m_pDocument, pCS);
} else {
pDict->SetNameFor("ColorSpace", "DeviceGray");
}
@@ -282,9 +281,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->NewIndirect<CPDF_Stream>(mask_buf, mask_size, pMaskDict));
if (bDeleteMask)
delete pMaskBitmap;
}