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

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

Issue 2498223005: Make CPDF_Array take unique_ptrs (Closed)
Patch Set: nits 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/font/cpdf_fontencoding.cpp ('k') | core/fpdfapi/page/cpdf_streamcontentparser.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 e21d38a56f9fe7fa65c3cd30460843796ec10b6d..1c3aa89ff2f16f2d5a3103b53d315cdad29635a0 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -17,6 +17,9 @@
#include "core/fpdfapi/parser/cpdf_boolean.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_document.h"
+#include "core/fpdfapi/parser/cpdf_name.h"
+#include "core/fpdfapi/parser/cpdf_number.h"
+#include "core/fpdfapi/parser/cpdf_reference.h"
#include "core/fpdfapi/parser/cpdf_string.h"
#include "core/fpdfapi/render/cpdf_pagerendercache.h"
#include "core/fpdfapi/render/render_int.h"
@@ -107,8 +110,8 @@ CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, uint32_t size) {
csname = "DeviceCMYK";
CPDF_Array* pDecode = new CPDF_Array;
for (int n = 0; n < 4; n++) {
- pDecode->AddInteger(1);
- pDecode->AddInteger(0);
+ pDecode->AddNew<CPDF_Number>(1);
+ pDecode->AddNew<CPDF_Number>(0);
}
pDict->SetFor("Decode", pDecode);
}
@@ -181,15 +184,15 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) {
pDict->SetFor("ImageMask", new CPDF_Boolean(true));
if (reset_a == 0) {
CPDF_Array* pArray = new CPDF_Array;
- pArray->AddInteger(1);
- pArray->AddInteger(0);
+ pArray->AddNew<CPDF_Number>(1);
+ pArray->AddNew<CPDF_Number>(0);
pDict->SetFor("Decode", pArray);
}
} else {
CPDF_Array* pCS = new CPDF_Array;
- pCS->AddName("Indexed");
- pCS->AddName("DeviceRGB");
- pCS->AddInteger(1);
+ pCS->AddNew<CPDF_Name>("Indexed");
+ pCS->AddNew<CPDF_Name>("DeviceRGB");
+ pCS->AddNew<CPDF_Number>(1);
CFX_ByteString ct;
FX_CHAR* pBuf = ct.GetBuffer(6);
pBuf[0] = (FX_CHAR)reset_r;
@@ -199,7 +202,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) {
pBuf[4] = (FX_CHAR)set_g;
pBuf[5] = (FX_CHAR)set_b;
ct.ReleaseBuffer(6);
- pCS->Add(new CPDF_String(ct, true));
+ pCS->AddNew<CPDF_String>(ct, true);
pDict->SetFor("ColorSpace", pCS);
}
pDict->SetIntegerFor("BitsPerComponent", 1);
@@ -213,9 +216,9 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) {
int32_t iPalette = pBitmap->GetPaletteSize();
if (iPalette > 0) {
CPDF_Array* pCS = m_pDocument->NewIndirect<CPDF_Array>();
- pCS->AddName("Indexed");
- pCS->AddName("DeviceRGB");
- pCS->AddInteger(iPalette - 1);
+ pCS->AddNew<CPDF_Name>("Indexed");
+ pCS->AddNew<CPDF_Name>("DeviceRGB");
+ pCS->AddNew<CPDF_Number>(iPalette - 1);
uint8_t* pColorTable = FX_Alloc2D(uint8_t, iPalette, 3);
uint8_t* ptr = pColorTable;
for (int32_t i = 0; i < iPalette; i++) {
@@ -228,7 +231,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) {
CPDF_Stream* pCTS = m_pDocument->NewIndirect<CPDF_Stream>(
pColorTable, iPalette * 3,
new CPDF_Dictionary(m_pDocument->GetByteStringPool()));
- pCS->AddReference(m_pDocument, pCTS);
+ pCS->AddNew<CPDF_Reference>(m_pDocument, pCTS->GetObjNum());
pDict->SetReferenceFor("ColorSpace", m_pDocument, pCS);
} else {
pDict->SetNameFor("ColorSpace", "DeviceGray");
« no previous file with comments | « core/fpdfapi/font/cpdf_fontencoding.cpp ('k') | core/fpdfapi/page/cpdf_streamcontentparser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698