Chromium Code Reviews| 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..297fc07657715e735b2957754c38b3b3caa67663 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,13 +805,12 @@ int CPDF_DIBSource::StratLoadMask() { |
| } |
| return StartLoadMaskDIB(); |
| } |
| + |
| m_pMaskStream = m_pDict->GetElementValue(FX_BSTRC("Mask")); |
| - if (m_pMaskStream == NULL) { |
| + if (!m_pMaskStream) |
|
Tom Sepez
2015/10/22 17:16:45
nit: maybe
return ToStream(m_pMaskStream) ? Sta
dsinclair
2015/10/22 17:42:56
Done.
|
| return 1; |
| - } |
| - if (m_pMaskStream->GetType() == PDFOBJ_STREAM) { |
| + if (m_pMaskStream->IsStream()) |
| return StartLoadMaskDIB(); |
| - } |
| return 1; |
| } |
| int CPDF_DIBSource::ContinueLoadMaskDIB(IFX_Pause* pPause) { |
| @@ -849,17 +846,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, ToStream(m_pMaskStream), |
|
Tom Sepez
2015/10/22 17:16:45
I worry about this. At line 809, we may have assi
dsinclair
2015/10/22 17:42:56
Done. There are 2 assignments and this one usage.
Tom Sepez
2015/10/22 19:11:55
Ok. Looks like were type safe.
|
| + 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; |