diff options
-rw-r--r-- | constants/transparency.h | 16 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_pageobjectholder.cpp | 15 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 12 |
3 files changed, 32 insertions, 11 deletions
diff --git a/constants/transparency.h b/constants/transparency.h index 6ae79c949d..22a89c33c4 100644 --- a/constants/transparency.h +++ b/constants/transparency.h @@ -32,6 +32,22 @@ constexpr char kSaturation[] = "Saturation"; constexpr char kColor[] = "Color"; constexpr char kLuminosity[] = "Luminosity"; +// PDF 1.7 spec, table 7.10. +// Entries in a soft-mask dictionary. + +constexpr char kSoftMaskSubType[] = "S"; +constexpr char kAlpha[] = "Alpha"; +constexpr char kG[] = "G"; +constexpr char kBC[] = "BC"; +constexpr char kTR[] = "TR"; + +// PDF 1.7 spec, table 7.13. +// Additional entries specific to a transparency group attributes dictionary. + +constexpr char kGroupSubType[] = "S"; +constexpr char kTransparency[] = "Transparency"; +constexpr char kI[] = "I"; + } // namespace transparency } // namespace pdfium diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.cpp b/core/fpdfapi/page/cpdf_pageobjectholder.cpp index 3c998d2424..d8858279ca 100644 --- a/core/fpdfapi/page/cpdf_pageobjectholder.cpp +++ b/core/fpdfapi/page/cpdf_pageobjectholder.cpp @@ -9,6 +9,7 @@ #include <algorithm> #include <utility> +#include "constants/transparency.h" #include "core/fpdfapi/page/cpdf_allstates.h" #include "core/fpdfapi/page/cpdf_contentparser.h" #include "core/fpdfapi/page/cpdf_pageobject.h" @@ -69,20 +70,20 @@ CFX_FloatRect CPDF_PageObjectHolder::CalcBoundingBox() const { } void CPDF_PageObjectHolder::LoadTransInfo() { - if (!m_pFormDict) { + if (!m_pFormDict) return; - } + CPDF_Dictionary* pGroup = m_pFormDict->GetDictFor("Group"); - if (!pGroup) { + if (!pGroup) return; - } - if (pGroup->GetStringFor("S") != "Transparency") { + + if (pGroup->GetStringFor(pdfium::transparency::kGroupSubType) != + pdfium::transparency::kTransparency) { return; } m_iTransparency |= PDFTRANS_GROUP; - if (pGroup->GetIntegerFor("I")) { + if (pGroup->GetIntegerFor(pdfium::transparency::kI)) m_iTransparency |= PDFTRANS_ISOLATED; - } } size_t CPDF_PageObjectHolder::GetPageObjectCount() const { diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 3672729f2e..0f054ef578 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -13,6 +13,7 @@ #include <utility> #include <vector> +#include "constants/transparency.h" #include "core/fpdfapi/font/cpdf_font.h" #include "core/fpdfapi/font/cpdf_type3char.h" #include "core/fpdfapi/font/cpdf_type3font.h" @@ -2530,12 +2531,13 @@ RetainPtr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask( if (!pSMaskDict) return nullptr; - CPDF_Stream* pGroup = pSMaskDict->GetStreamFor("G"); + CPDF_Stream* pGroup = pSMaskDict->GetStreamFor(pdfium::transparency::kG); if (!pGroup) return nullptr; std::unique_ptr<CPDF_Function> pFunc; - CPDF_Object* pFuncObj = pSMaskDict->GetDirectObjectFor("TR"); + CPDF_Object* pFuncObj = + pSMaskDict->GetDirectObjectFor(pdfium::transparency::kTR); if (pFuncObj && (pFuncObj->IsDictionary() || pFuncObj->IsStream())) pFunc = CPDF_Function::Load(pFuncObj); @@ -2547,7 +2549,9 @@ RetainPtr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask( form.ParseContent(); CFX_DefaultRenderDevice bitmap_device; - bool bLuminosity = pSMaskDict->GetStringFor("S") != "Alpha"; + bool bLuminosity = + pSMaskDict->GetStringFor(pdfium::transparency::kSoftMaskSubType) != + pdfium::transparency::kAlpha; int width = pClipRect->right - pClipRect->left; int height = pClipRect->bottom - pClipRect->top; FXDIB_Format format; @@ -2629,7 +2633,7 @@ FX_ARGB CPDF_RenderStatus::GetBackColor(const CPDF_Dictionary* pSMaskDict, const CPDF_Dictionary* pGroupDict, int* pCSFamily) { static constexpr FX_ARGB kDefaultColor = ArgbEncode(255, 0, 0, 0); - CPDF_Array* pBC = pSMaskDict->GetArrayFor("BC"); + const CPDF_Array* pBC = pSMaskDict->GetArrayFor(pdfium::transparency::kBC); if (!pBC) return kDefaultColor; |