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

Unified Diff: core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp

Issue 1422513004: Merge to XFA: Add type cast definitions for CPDF_Stream. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 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
Index: core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
index fecd6da9b24616629894e38bcd5f472a3a08e057..6af3ab4ce6fb2b25889d5ed1bc7a5237f3d655c5 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
@@ -765,7 +765,7 @@ CPDF_DIBSource* CPDF_DIBSource::LoadMask(FX_DWORD& MatteColor) {
CPDF_Stream* pSoftMask = m_pDict->GetStream(FX_BSTRC("SMask"));
if (pSoftMask) {
CPDF_Array* pMatte = pSoftMask->GetDict()->GetArray(FX_BSTRC("Matte"));
- if (pMatte != NULL && m_pColorSpace &&
+ if (pMatte && m_pColorSpace &&
(FX_DWORD)m_pColorSpace->CountComponents() <= m_nComponents) {
FX_FLOAT* pColor = FX_Alloc(FX_FLOAT, m_nComponents);
for (FX_DWORD i = 0; i < m_nComponents; i++) {
@@ -779,14 +779,12 @@ CPDF_DIBSource* CPDF_DIBSource::LoadMask(FX_DWORD& MatteColor) {
}
return LoadMaskDIB(pSoftMask);
}
- CPDF_Object* pMask = m_pDict->GetElementValue(FX_BSTRC("Mask"));
- if (pMask == NULL) {
- return NULL;
- }
- if (pMask->GetType() == PDFOBJ_STREAM) {
- return LoadMaskDIB((CPDF_Stream*)pMask);
- }
- return NULL;
+
+ if (CPDF_Stream* pStream =
+ ToStream(m_pDict->GetElementValue(FX_BSTRC("Mask"))))
+ return LoadMaskDIB(pStream);
+
+ return nullptr;
}
int CPDF_DIBSource::StratLoadMask() {
m_MatteColor = 0XFFFFFFFF;
@@ -807,14 +805,9 @@ int CPDF_DIBSource::StratLoadMask() {
}
return StartLoadMaskDIB();
}
- m_pMaskStream = m_pDict->GetElementValue(FX_BSTRC("Mask"));
- if (m_pMaskStream == NULL) {
- return 1;
- }
- if (m_pMaskStream->GetType() == PDFOBJ_STREAM) {
- return StartLoadMaskDIB();
- }
- return 1;
+
+ m_pMaskStream = ToStream(m_pDict->GetElementValue(FX_BSTRC("Mask")));
+ return m_pMaskStream ? StartLoadMaskDIB() : 1;
}
int CPDF_DIBSource::ContinueLoadMaskDIB(IFX_Pause* pPause) {
if (m_pMask == NULL) {
@@ -849,17 +842,16 @@ CPDF_DIBSource* CPDF_DIBSource::LoadMaskDIB(CPDF_Stream* pMask) {
}
int CPDF_DIBSource::StartLoadMaskDIB() {
m_pMask = new CPDF_DIBSource;
- int ret = m_pMask->StartLoadDIBSource(
- m_pDocument, (CPDF_Stream*)m_pMaskStream, FALSE, NULL, NULL, TRUE);
+ int ret = m_pMask->StartLoadDIBSource(m_pDocument, m_pMaskStream, FALSE,
+ nullptr, nullptr, TRUE);
if (ret == 2) {
- if (m_Status == 0) {
+ if (m_Status == 0)
m_Status = 2;
- }
return 2;
}
if (!ret) {
delete m_pMask;
- m_pMask = NULL;
+ m_pMask = nullptr;
return 1;
}
return 1;

Powered by Google App Engine
This is Rietveld 408576698