summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/render')
-rw-r--r--core/fpdfapi/render/cpdf_imageloader.cpp22
-rw-r--r--core/fpdfapi/render/cpdf_imageloader.h16
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp27
3 files changed, 39 insertions, 26 deletions
diff --git a/core/fpdfapi/render/cpdf_imageloader.cpp b/core/fpdfapi/render/cpdf_imageloader.cpp
index 157bc48d1b..d7b7bb8354 100644
--- a/core/fpdfapi/render/cpdf_imageloader.cpp
+++ b/core/fpdfapi/render/cpdf_imageloader.cpp
@@ -12,14 +12,12 @@
#include "core/fpdfapi/render/cpdf_imagecacheentry.h"
#include "core/fpdfapi/render/cpdf_pagerendercache.h"
#include "core/fpdfapi/render/cpdf_renderstatus.h"
+#include "core/fpdfapi/render/cpdf_transferfunc.h"
+#include "core/fxge/dib/cfx_dibitmap.h"
-CPDF_ImageLoader::CPDF_ImageLoader()
- : m_MatteColor(0),
- m_bCached(false),
- m_pCache(nullptr),
- m_pImageObject(nullptr) {}
+CPDF_ImageLoader::CPDF_ImageLoader() = default;
-CPDF_ImageLoader::~CPDF_ImageLoader() {}
+CPDF_ImageLoader::~CPDF_ImageLoader() = default;
bool CPDF_ImageLoader::Start(CPDF_ImageObject* pImage,
CPDF_PageRenderCache* pCache,
@@ -52,6 +50,18 @@ bool CPDF_ImageLoader::Continue(PauseIndicatorIface* pPause,
return ret;
}
+RetainPtr<CFX_DIBBase> CPDF_ImageLoader::TranslateImage(
+ const RetainPtr<CPDF_TransferFunc>& pTransferFunc) {
+ ASSERT(pTransferFunc);
+ ASSERT(!pTransferFunc->GetIdentity());
+
+ m_pBitmap = pTransferFunc->TranslateImage(m_pBitmap);
+ if (m_bCached && m_pMask)
+ m_pMask = m_pMask->Clone(nullptr);
+ m_bCached = false;
+ return m_pBitmap;
+}
+
void CPDF_ImageLoader::HandleFailure() {
if (m_pCache) {
CPDF_ImageCacheEntry* entry = m_pCache->GetCurImageCacheEntry();
diff --git a/core/fpdfapi/render/cpdf_imageloader.h b/core/fpdfapi/render/cpdf_imageloader.h
index de29d0e2a9..7586d69cc2 100644
--- a/core/fpdfapi/render/cpdf_imageloader.h
+++ b/core/fpdfapi/render/cpdf_imageloader.h
@@ -16,6 +16,7 @@
class CPDF_ImageObject;
class CPDF_PageRenderCache;
class CPDF_RenderStatus;
+class CPDF_TransferFunc;
class PauseIndicatorIface;
class CPDF_ImageLoader {
@@ -31,14 +32,21 @@ class CPDF_ImageLoader {
CPDF_RenderStatus* pRenderStatus);
bool Continue(PauseIndicatorIface* pPause, CPDF_RenderStatus* pRenderStatus);
- RetainPtr<CFX_DIBBase> m_pBitmap;
- RetainPtr<CFX_DIBBase> m_pMask;
- uint32_t m_MatteColor;
- bool m_bCached;
+ RetainPtr<CFX_DIBBase> TranslateImage(
+ const RetainPtr<CPDF_TransferFunc>& pTransferFunc);
+
+ const RetainPtr<CFX_DIBBase>& GetBitmap() const { return m_pBitmap; }
+ const RetainPtr<CFX_DIBBase>& GetMask() const { return m_pMask; }
+ uint32_t MatteColor() const { return m_MatteColor; }
private:
void HandleFailure();
+ RetainPtr<CFX_DIBBase> m_pBitmap;
+ RetainPtr<CFX_DIBBase> m_pMask;
+ uint32_t m_MatteColor = 0;
+ bool m_bCached = false;
+
UnownedPtr<CPDF_PageRenderCache> m_pCache;
UnownedPtr<CPDF_ImageObject> m_pImageObject;
};
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index 33aca42ee1..cd68322644 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -70,28 +70,23 @@ bool CPDF_ImageRenderer::StartLoadDIBBase() {
}
bool CPDF_ImageRenderer::StartRenderDIBBase() {
- if (!m_Loader.m_pBitmap)
+ if (!m_Loader.GetBitmap())
return false;
CPDF_GeneralState& state = m_pImageObject->m_GeneralState;
m_BitmapAlpha = FXSYS_round(255 * state.GetFillAlpha());
- m_pDIBBase = m_Loader.m_pBitmap;
+ m_pDIBBase = m_Loader.GetBitmap();
if (m_pRenderStatus->GetRenderOptions().ColorModeIs(
CPDF_RenderOptions::kAlpha) &&
- !m_Loader.m_pMask) {
+ !m_Loader.GetMask()) {
return StartBitmapAlpha();
}
if (state.GetTR()) {
if (!state.GetTransferFunc())
state.SetTransferFunc(m_pRenderStatus->GetTransferFunc(state.GetTR()));
- if (state.GetTransferFunc() && !state.GetTransferFunc()->GetIdentity()) {
- m_pDIBBase = m_Loader.m_pBitmap =
- state.GetTransferFunc()->TranslateImage(m_Loader.m_pBitmap);
- if (m_Loader.m_bCached && m_Loader.m_pMask)
- m_Loader.m_pMask = m_Loader.m_pMask->Clone(nullptr);
- m_Loader.m_bCached = false;
- }
+ if (state.GetTransferFunc() && !state.GetTransferFunc()->GetIdentity())
+ m_pDIBBase = m_Loader.TranslateImage(state.GetTransferFunc());
}
m_FillArgb = 0;
m_bPatternColor = false;
@@ -127,7 +122,7 @@ bool CPDF_ImageRenderer::StartRenderDIBBase() {
else if (m_pImageObject->GetImage()->IsInterpol())
m_Flags |= FXDIB_INTERPOL;
- if (m_Loader.m_pMask)
+ if (m_Loader.GetMask())
return DrawMaskedImage();
if (m_bPatternColor)
@@ -242,11 +237,11 @@ void CPDF_ImageRenderer::CalculateDrawImage(
m_Flags, true, FXDIB_BLEND_NORMAL)) {
image_render.Continue(nullptr);
}
- if (m_Loader.m_MatteColor == 0xffffffff)
+ if (m_Loader.MatteColor() == 0xffffffff)
return;
- int matte_r = FXARGB_R(m_Loader.m_MatteColor);
- int matte_g = FXARGB_G(m_Loader.m_MatteColor);
- int matte_b = FXARGB_B(m_Loader.m_MatteColor);
+ int matte_r = FXARGB_R(m_Loader.MatteColor());
+ int matte_g = FXARGB_G(m_Loader.MatteColor());
+ int matte_b = FXARGB_B(m_Loader.MatteColor());
for (int row = 0; row < rect.Height(); row++) {
uint8_t* dest_scan = pBitmapDevice1->GetBitmap()->GetWritableScanline(row);
const uint8_t* mask_scan = pBitmapDevice2->GetBitmap()->GetScanline(row);
@@ -359,7 +354,7 @@ bool CPDF_ImageRenderer::DrawMaskedImage() {
#else
bitmap_device2.GetBitmap()->Clear(0);
#endif
- CalculateDrawImage(&bitmap_device1, &bitmap_device2, m_Loader.m_pMask,
+ CalculateDrawImage(&bitmap_device1, &bitmap_device2, m_Loader.GetMask(),
&new_matrix, rect);
#ifdef _SKIA_SUPPORT_
m_pRenderStatus->GetRenderDevice()->SetBitsWithMask(