summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_page
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-09-21 19:10:19 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-21 19:10:19 -0700
commitbb577af2f17467a55c04fbff21a8f0ec1016601a (patch)
tree5a5321b1aff1bcc6ee6dc19928aa729a4ddc9a3d /core/fpdfapi/fpdf_page
parent7149abce42b211ad3c0eaa39a340825acd41a1ec (diff)
downloadpdfium-bb577af2f17467a55c04fbff21a8f0ec1016601a.tar.xz
Remove some objnum locals with AddIndirectObject
Also, it's idempotent, so simplify some logic in callers to not care if objnum is zero. The alternate forms are rarely used, using the objnum form makes it clear that SetReferenceFor() can't possibly register the object as a side-effect. Review-Url: https://codereview.chromium.org/2361713002
Diffstat (limited to 'core/fpdfapi/fpdf_page')
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_image.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_image.cpp b/core/fpdfapi/fpdf_page/cpdf_image.cpp
index 32b69bf9cb..4112ad86ee 100644
--- a/core/fpdfapi/fpdf_page/cpdf_image.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_image.cpp
@@ -201,7 +201,6 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) {
int32_t iPalette = pBitmap->GetPaletteSize();
if (iPalette > 0) {
CPDF_Array* pCS = new CPDF_Array;
- m_pDocument->AddIndirectObject(pCS);
pCS->AddName("Indexed");
pCS->AddName("DeviceRGB");
pCS->AddInteger(iPalette - 1);
@@ -216,9 +215,9 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) {
}
CPDF_Stream* pCTS =
new CPDF_Stream(pColorTable, iPalette * 3, new CPDF_Dictionary);
- m_pDocument->AddIndirectObject(pCTS);
- pCS->AddReference(m_pDocument, pCTS);
- pDict->SetReferenceFor("ColorSpace", m_pDocument, pCS);
+ pCS->AddReference(m_pDocument, m_pDocument->AddIndirectObject(pCTS));
+ pDict->SetReferenceFor("ColorSpace", m_pDocument,
+ m_pDocument->AddIndirectObject(pCS));
} else {
pDict->SetNameFor("ColorSpace", "DeviceGray");
}
@@ -269,13 +268,11 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) {
}
}
pMaskDict->SetIntegerFor("Length", mask_size);
-
- CPDF_Stream* pMaskStream = new CPDF_Stream(mask_buf, mask_size, pMaskDict);
- m_pDocument->AddIndirectObject(pMaskStream);
- pDict->SetReferenceFor("SMask", m_pDocument, pMaskStream);
- if (bDeleteMask) {
+ pDict->SetReferenceFor("SMask", m_pDocument,
+ m_pDocument->AddIndirectObject(new CPDF_Stream(
+ mask_buf, mask_size, pMaskDict)));
+ if (bDeleteMask)
delete pMaskBitmap;
- }
}
if (opType == 0) {
if (iCompress & PDF_IMAGE_LOSSLESS_COMPRESS) {