summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/page/cpdf_image.cpp12
-rw-r--r--core/fpdfapi/page/cpdf_image.h6
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.cpp95
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.h12
-rw-r--r--core/fpdfapi/render/cpdf_imagecacheentry.cpp41
-rw-r--r--core/fpdfapi/render/cpdf_imagecacheentry.h12
6 files changed, 27 insertions, 151 deletions
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp
index 813ee2b0ed..6b0bfd7d6d 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -324,17 +324,11 @@ void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) {
pPage->GetRenderCache()->ResetBitmap(m_pStream.Get(), pBitmap);
}
-std::unique_ptr<CFX_DIBSource> CPDF_Image::LoadDIBSource(CFX_DIBSource** ppMask,
- uint32_t* pMatteColor,
- bool bStdCS,
- uint32_t GroupFamily,
- bool bLoadMask) const {
+std::unique_ptr<CFX_DIBSource> CPDF_Image::LoadDIBSource() const {
auto source = pdfium::MakeUnique<CPDF_DIBSource>();
- if (!source->Load(m_pDocument, m_pStream.Get(),
- reinterpret_cast<CPDF_DIBSource**>(ppMask), pMatteColor,
- nullptr, nullptr, bStdCS, GroupFamily, bLoadMask)) {
+ if (!source->Load(m_pDocument, m_pStream.Get()))
return nullptr;
- }
+
return std::move(source);
}
diff --git a/core/fpdfapi/page/cpdf_image.h b/core/fpdfapi/page/cpdf_image.h
index 6591897d1e..1909498102 100644
--- a/core/fpdfapi/page/cpdf_image.h
+++ b/core/fpdfapi/page/cpdf_image.h
@@ -44,11 +44,7 @@ class CPDF_Image {
bool IsMask() const { return m_bIsMask; }
bool IsInterpol() const { return m_bInterpolate; }
- std::unique_ptr<CFX_DIBSource> LoadDIBSource(CFX_DIBSource** ppMask = nullptr,
- uint32_t* pMatteColor = nullptr,
- bool bStdCS = false,
- uint32_t GroupFamily = 0,
- bool bLoadMask = false) const;
+ std::unique_ptr<CFX_DIBSource> LoadDIBSource() const;
void SetImage(const CFX_DIBitmap* pDIBitmap);
void SetJpegImage(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile);
diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp
index c84adfe1ec..33a8d930a5 100644
--- a/core/fpdfapi/render/cpdf_dibsource.cpp
+++ b/core/fpdfapi/render/cpdf_dibsource.cpp
@@ -134,23 +134,15 @@ CPDF_DIBSource::~CPDF_DIBSource() {
}
}
-bool CPDF_DIBSource::Load(CPDF_Document* pDoc,
- const CPDF_Stream* pStream,
- CPDF_DIBSource** ppMask,
- uint32_t* pMatteColor,
- CPDF_Dictionary* pFormResources,
- CPDF_Dictionary* pPageResources,
- bool bStdCS,
- uint32_t GroupFamily,
- bool bLoadMask) {
- if (!pStream) {
+bool CPDF_DIBSource::Load(CPDF_Document* pDoc, const CPDF_Stream* pStream) {
+ if (!pStream)
return false;
- }
+
m_pDocument = pDoc;
m_pDict = pStream->GetDict();
- if (!m_pDict) {
+ if (!m_pDict)
return false;
- }
+
m_pStream = pStream;
m_Width = m_pDict->GetIntegerFor("Width");
m_Height = m_pDict->GetIntegerFor("Height");
@@ -158,28 +150,27 @@ bool CPDF_DIBSource::Load(CPDF_Document* pDoc,
m_Height > kMaxImageDimension) {
return false;
}
- m_GroupFamily = GroupFamily;
- m_bLoadMask = bLoadMask;
- if (!LoadColorInfo(m_pStream->IsInline() ? pFormResources : nullptr,
- pPageResources)) {
+ m_GroupFamily = 0;
+ m_bLoadMask = false;
+ if (!LoadColorInfo(nullptr, nullptr))
return false;
- }
- if (m_bDoBpcCheck && (m_bpc == 0 || m_nComponents == 0)) {
+
+ if (m_bDoBpcCheck && (m_bpc == 0 || m_nComponents == 0))
return false;
- }
+
FX_SAFE_UINT32 src_size =
CalculatePitch8(m_bpc, m_nComponents, m_Width) * m_Height;
- if (!src_size.IsValid()) {
+ if (!src_size.IsValid())
return false;
- }
+
m_pStreamAcc = pdfium::MakeUnique<CPDF_StreamAcc>();
m_pStreamAcc->LoadAllData(pStream, false, src_size.ValueOrDie(), true);
- if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData()) {
+ if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData())
return false;
- }
- if (!CreateDecoder()) {
+
+ if (!CreateDecoder())
return false;
- }
+
if (m_bImageMask) {
m_bpp = 1;
m_bpc = 1;
@@ -193,30 +184,21 @@ bool CPDF_DIBSource::Load(CPDF_Document* pDoc,
m_bpp = 24;
}
FX_SAFE_UINT32 pitch = CalculatePitch32(m_bpp, m_Width);
- if (!pitch.IsValid()) {
+ if (!pitch.IsValid())
return false;
- }
+
m_pLineBuf = FX_Alloc(uint8_t, pitch.ValueOrDie());
- if (m_pColorSpace && bStdCS) {
- m_pColorSpace->EnableStdConversion(true);
- }
LoadPalette();
if (m_bColorKey) {
m_bpp = 32;
m_AlphaFlag = 2;
pitch = CalculatePitch32(m_bpp, m_Width);
- if (!pitch.IsValid()) {
+ if (!pitch.IsValid())
return false;
- }
+
m_pMaskedLine = FX_Alloc(uint8_t, pitch.ValueOrDie());
}
m_Pitch = pitch.ValueOrDie();
- if (ppMask) {
- *ppMask = LoadMask(*pMatteColor);
- }
- if (m_pColorSpace && bStdCS) {
- m_pColorSpace->EnableStdConversion(false);
- }
return true;
}
@@ -710,31 +692,6 @@ void CPDF_DIBSource::LoadJpxBitmap() {
m_bpc = 8;
}
-CPDF_DIBSource* CPDF_DIBSource::LoadMask(uint32_t& MatteColor) {
- MatteColor = 0xFFFFFFFF;
- CPDF_Stream* pSoftMask = m_pDict->GetStreamFor("SMask");
- if (pSoftMask) {
- CPDF_Array* pMatte = pSoftMask->GetDict()->GetArrayFor("Matte");
- if (pMatte && m_pColorSpace &&
- m_pColorSpace->CountComponents() <= m_nComponents) {
- std::vector<FX_FLOAT> colors(m_nComponents);
- for (uint32_t i = 0; i < m_nComponents; i++) {
- colors[i] = pMatte->GetFloatAt(i);
- }
- FX_FLOAT R, G, B;
- m_pColorSpace->GetRGB(colors.data(), R, G, B);
- MatteColor = FXARGB_MAKE(0, FXSYS_round(R * 255), FXSYS_round(G * 255),
- FXSYS_round(B * 255));
- }
- return LoadMaskDIB(pSoftMask);
- }
-
- if (CPDF_Stream* pStream = ToStream(m_pDict->GetDirectObjectFor("Mask")))
- return LoadMaskDIB(pStream);
-
- return nullptr;
-}
-
int CPDF_DIBSource::StratLoadMask() {
m_MatteColor = 0XFFFFFFFF;
m_pMaskStream = m_pDict->GetStreamFor("SMask");
@@ -783,16 +740,6 @@ CPDF_DIBSource* CPDF_DIBSource::DetachMask() {
return pDIBSource;
}
-CPDF_DIBSource* CPDF_DIBSource::LoadMaskDIB(CPDF_Stream* pMask) {
- CPDF_DIBSource* pMaskSource = new CPDF_DIBSource;
- if (!pMaskSource->Load(m_pDocument, pMask, nullptr, nullptr, nullptr, nullptr,
- true)) {
- delete pMaskSource;
- return nullptr;
- }
- return pMaskSource;
-}
-
int CPDF_DIBSource::StartLoadMaskDIB() {
m_pMask = new CPDF_DIBSource;
int ret = m_pMask->StartLoadDIBSource(m_pDocument, m_pMaskStream, false,
diff --git a/core/fpdfapi/render/cpdf_dibsource.h b/core/fpdfapi/render/cpdf_dibsource.h
index 8369d2a1be..d5820d8bae 100644
--- a/core/fpdfapi/render/cpdf_dibsource.h
+++ b/core/fpdfapi/render/cpdf_dibsource.h
@@ -42,15 +42,7 @@ class CPDF_DIBSource : public CFX_DIBSource {
CPDF_DIBSource();
~CPDF_DIBSource() override;
- bool Load(CPDF_Document* pDoc,
- const CPDF_Stream* pStream,
- CPDF_DIBSource** ppMask,
- uint32_t* pMatteColor,
- CPDF_Dictionary* pFormResources,
- CPDF_Dictionary* pPageResources,
- bool bStdCS = false,
- uint32_t GroupFamily = 0,
- bool bLoadMask = false);
+ bool Load(CPDF_Document* pDoc, const CPDF_Stream* pStream);
// CFX_DIBSource
bool SkipToScanline(int line, IFX_Pause* pPause) const override;
@@ -85,8 +77,6 @@ class CPDF_DIBSource : public CFX_DIBSource {
bool LoadColorInfo(const CPDF_Dictionary* pFormResources,
const CPDF_Dictionary* pPageResources);
DIB_COMP_DATA* GetDecodeAndMaskArray(bool& bDefaultDecode, bool& bColorKey);
- CPDF_DIBSource* LoadMask(uint32_t& MatteColor);
- CPDF_DIBSource* LoadMaskDIB(CPDF_Stream* pMask);
void LoadJpxBitmap();
void LoadPalette();
int CreateDecoder();
diff --git a/core/fpdfapi/render/cpdf_imagecacheentry.cpp b/core/fpdfapi/render/cpdf_imagecacheentry.cpp
index 84efd925c8..f11cae888d 100644
--- a/core/fpdfapi/render/cpdf_imagecacheentry.cpp
+++ b/core/fpdfapi/render/cpdf_imagecacheentry.cpp
@@ -45,47 +45,6 @@ static uint32_t FPDF_ImageCache_EstimateImageSize(const CFX_DIBSource* pDIB) {
: 0;
}
-bool CPDF_ImageCacheEntry::GetCachedBitmap(CFX_DIBSource*& pBitmap,
- CFX_DIBSource*& pMask,
- uint32_t& MatteColor,
- CPDF_Dictionary* pPageResources,
- bool bStdCS,
- uint32_t GroupFamily,
- bool bLoadMask,
- CPDF_RenderStatus* pRenderStatus,
- int32_t downsampleWidth,
- int32_t downsampleHeight) {
- if (m_pCachedBitmap) {
- pBitmap = m_pCachedBitmap.get();
- pMask = m_pCachedMask.get();
- MatteColor = m_MatteColor;
- return true;
- }
- if (!pRenderStatus)
- return false;
-
- CPDF_RenderContext* pContext = pRenderStatus->GetContext();
- CPDF_PageRenderCache* pPageRenderCache = pContext->GetPageCache();
- m_dwTimeCount = pPageRenderCache->GetTimeCount();
- std::unique_ptr<CPDF_DIBSource> pSrc = pdfium::MakeUnique<CPDF_DIBSource>();
- CPDF_DIBSource* pMaskSrc = nullptr;
- if (!pSrc->Load(m_pDocument, m_pStream, &pMaskSrc, &MatteColor,
- pRenderStatus->m_pFormResource, pPageResources, bStdCS,
- GroupFamily, bLoadMask)) {
- pBitmap = nullptr;
- return false;
- }
- m_MatteColor = MatteColor;
- m_pCachedBitmap = std::move(pSrc);
- if (pMaskSrc)
- m_pCachedMask = pdfium::WrapUnique<CFX_DIBSource>(pMaskSrc);
-
- pBitmap = m_pCachedBitmap.get();
- pMask = m_pCachedMask.get();
- CalcSize();
- return false;
-}
-
CFX_DIBSource* CPDF_ImageCacheEntry::DetachBitmap() {
CFX_DIBSource* pDIBSource = m_pCurBitmap;
m_pCurBitmap = nullptr;
diff --git a/core/fpdfapi/render/cpdf_imagecacheentry.h b/core/fpdfapi/render/cpdf_imagecacheentry.h
index e4481e0d73..d11fe94c29 100644
--- a/core/fpdfapi/render/cpdf_imagecacheentry.h
+++ b/core/fpdfapi/render/cpdf_imagecacheentry.h
@@ -25,16 +25,6 @@ class CPDF_ImageCacheEntry {
~CPDF_ImageCacheEntry();
void Reset(const CFX_DIBitmap* pBitmap);
- bool GetCachedBitmap(CFX_DIBSource*& pBitmap,
- CFX_DIBSource*& pMask,
- uint32_t& MatteColor,
- CPDF_Dictionary* pPageResources,
- bool bStdCS,
- uint32_t GroupFamily,
- bool bLoadMask,
- CPDF_RenderStatus* pRenderStatus,
- int32_t downsampleWidth,
- int32_t downsampleHeight);
uint32_t EstimateSize() const { return m_dwCacheSize; }
uint32_t GetTimeCount() const { return m_dwTimeCount; }
CPDF_Stream* GetStream() const { return m_pStream; }
@@ -56,6 +46,7 @@ class CPDF_ImageCacheEntry {
private:
void ContinueGetCachedBitmap();
+ void CalcSize();
CPDF_RenderStatus* m_pRenderStatus;
CPDF_Document* m_pDocument;
@@ -65,7 +56,6 @@ class CPDF_ImageCacheEntry {
std::unique_ptr<CFX_DIBSource> m_pCachedBitmap;
std::unique_ptr<CFX_DIBSource> m_pCachedMask;
uint32_t m_dwCacheSize;
- void CalcSize();
};
#endif // CORE_FPDFAPI_RENDER_CPDF_IMAGECACHEENTRY_H_