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

Unified Diff: core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp

Issue 2000973002: Make CPDF_Function::Load() return an unique_ptr. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: fix build, nits Created 4 years, 7 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/fpdf_page/cpdf_shadingpattern.h ('k') | core/fpdfapi/fpdf_page/fpdf_page_doc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
diff --git a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
index b7174b4451140934ea95d7dd59594729f0a006ed..1636e17f4fabf552764b503b9e0934dbb3700d58 100644
--- a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
@@ -6,6 +6,7 @@
#include "core/fpdfapi/fpdf_page/cpdf_shadingpattern.h"
+#include "core/fpdfapi/fpdf_page/pageint.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
@@ -34,28 +35,22 @@ CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc,
m_bShadingObj(bShading),
m_pShadingObj(pPatternObj),
m_pCS(nullptr),
- m_pCountedCS(nullptr),
- m_nFuncs(0) {
+ m_pCountedCS(nullptr) {
if (!bShading) {
CPDF_Dictionary* pDict = m_pPatternObj->GetDict();
m_Pattern2Form = pDict->GetMatrixBy("Matrix");
m_pShadingObj = pDict->GetDirectObjectBy("Shading");
m_Pattern2Form.Concat(parentMatrix);
}
- for (size_t i = 0; i < FX_ArraySize(m_pFunctions); ++i)
- m_pFunctions[i] = nullptr;
}
CPDF_ShadingPattern::~CPDF_ShadingPattern() {
- for (size_t i = 0; i < m_nFuncs; ++i)
- delete m_pFunctions[i];
-
CPDF_ColorSpace* pCS = m_pCountedCS ? m_pCountedCS->get() : nullptr;
if (pCS && m_pDocument)
m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray());
}
-FX_BOOL CPDF_ShadingPattern::Load() {
+bool CPDF_ShadingPattern::Load() {
if (m_ShadingType != kInvalidShading)
return TRUE;
@@ -64,21 +59,15 @@ FX_BOOL CPDF_ShadingPattern::Load() {
if (!pShadingDict)
return FALSE;
- if (m_nFuncs) {
- for (size_t i = 0; i < m_nFuncs; i++)
- delete m_pFunctions[i];
- m_nFuncs = 0;
- }
+ m_pFunctions.clear();
CPDF_Object* pFunc = pShadingDict->GetDirectObjectBy("Function");
if (pFunc) {
if (CPDF_Array* pArray = pFunc->AsArray()) {
- m_nFuncs = std::min<size_t>(pArray->GetCount(), 4);
-
- for (size_t i = 0; i < m_nFuncs; i++)
+ m_pFunctions.resize(std::min<size_t>(pArray->GetCount(), 4));
+ for (size_t i = 0; i < m_pFunctions.size(); ++i)
m_pFunctions[i] = CPDF_Function::Load(pArray->GetDirectObjectAt(i));
} else {
- m_pFunctions[0] = CPDF_Function::Load(pFunc);
- m_nFuncs = 1;
+ m_pFunctions.push_back(CPDF_Function::Load(pFunc));
}
}
CPDF_Object* pCSObj = pShadingDict->GetDirectObjectBy("ColorSpace");
« no previous file with comments | « core/fpdfapi/fpdf_page/cpdf_shadingpattern.h ('k') | core/fpdfapi/fpdf_page/fpdf_page_doc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698