summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/page/cpdf_generalstate.cpp9
-rw-r--r--core/fpdfapi/render/cpdf_dibtransferfunc.cpp6
-rw-r--r--core/fpdfapi/render/cpdf_dibtransferfunc.h3
-rw-r--r--core/fpdfapi/render/cpdf_docrenderdata.cpp8
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_transferfunc.h14
6 files changed, 26 insertions, 16 deletions
diff --git a/core/fpdfapi/page/cpdf_generalstate.cpp b/core/fpdfapi/page/cpdf_generalstate.cpp
index 6f4062fb65..845cedd496 100644
--- a/core/fpdfapi/page/cpdf_generalstate.cpp
+++ b/core/fpdfapi/page/cpdf_generalstate.cpp
@@ -304,17 +304,18 @@ CPDF_GeneralState::StateData::StateData(const StateData& that)
m_Matrix = that.m_Matrix;
m_SMaskMatrix = that.m_SMaskMatrix;
- if (that.m_pTransferFunc && that.m_pTransferFunc->m_pPDFDoc) {
+ if (that.m_pTransferFunc && that.m_pTransferFunc->GetDocument()) {
CPDF_DocRenderData* pDocCache =
- that.m_pTransferFunc->m_pPDFDoc->GetRenderData();
+ that.m_pTransferFunc->GetDocument()->GetRenderData();
if (pDocCache)
m_pTransferFunc = pDocCache->GetTransferFunc(m_pTR.Get());
}
}
CPDF_GeneralState::StateData::~StateData() {
- if (m_pTransferFunc && m_pTransferFunc->m_pPDFDoc) {
- CPDF_DocRenderData* pDocCache = m_pTransferFunc->m_pPDFDoc->GetRenderData();
+ if (m_pTransferFunc && m_pTransferFunc->GetDocument()) {
+ CPDF_DocRenderData* pDocCache =
+ m_pTransferFunc->GetDocument()->GetRenderData();
if (pDocCache) {
m_pTransferFunc.Reset(); // Give up our reference first.
pDocCache->MaybePurgeTransferFunc(m_pTR.Get());
diff --git a/core/fpdfapi/render/cpdf_dibtransferfunc.cpp b/core/fpdfapi/render/cpdf_dibtransferfunc.cpp
index d72ad48cf1..3b0e8b25a9 100644
--- a/core/fpdfapi/render/cpdf_dibtransferfunc.cpp
+++ b/core/fpdfapi/render/cpdf_dibtransferfunc.cpp
@@ -14,9 +14,9 @@
CPDF_DIBTransferFunc::CPDF_DIBTransferFunc(
const RetainPtr<CPDF_TransferFunc>& pTransferFunc)
: m_pTransferFunc(pTransferFunc) {
- m_RampR = pTransferFunc->m_Samples;
- m_RampG = &pTransferFunc->m_Samples[256];
- m_RampB = &pTransferFunc->m_Samples[512];
+ m_RampR = pTransferFunc->GetSamples();
+ m_RampG = &pTransferFunc->GetSamples()[256];
+ m_RampB = &pTransferFunc->GetSamples()[512];
}
CPDF_DIBTransferFunc::~CPDF_DIBTransferFunc() {}
diff --git a/core/fpdfapi/render/cpdf_dibtransferfunc.h b/core/fpdfapi/render/cpdf_dibtransferfunc.h
index 442811b97e..34f5bb1abe 100644
--- a/core/fpdfapi/render/cpdf_dibtransferfunc.h
+++ b/core/fpdfapi/render/cpdf_dibtransferfunc.h
@@ -9,6 +9,7 @@
#include <vector>
+#include "core/fxcrt/unowned_ptr.h"
#include "core/fxge/dib/cfx_filtereddib.h"
#include "core/fxge/fx_dib.h"
@@ -35,10 +36,10 @@ class CPDF_DIBTransferFunc : public CFX_FilteredDIB {
explicit CPDF_DIBTransferFunc(
const RetainPtr<CPDF_TransferFunc>& pTransferFunc);
+ RetainPtr<CPDF_TransferFunc> m_pTransferFunc;
const uint8_t* m_RampR;
const uint8_t* m_RampG;
const uint8_t* m_RampB;
- RetainPtr<CPDF_TransferFunc> m_pTransferFunc;
};
#endif // CORE_FPDFAPI_RENDER_CPDF_DIBTRANSFERFUNC_H_
diff --git a/core/fpdfapi/render/cpdf_docrenderdata.cpp b/core/fpdfapi/render/cpdf_docrenderdata.cpp
index 3b16013bc5..6480688f21 100644
--- a/core/fpdfapi/render/cpdf_docrenderdata.cpp
+++ b/core/fpdfapi/render/cpdf_docrenderdata.cpp
@@ -104,23 +104,23 @@ RetainPtr<CPDF_TransferFunc> CPDF_DocRenderData::GetTransferFunc(
if (o != v)
bIdentity = false;
for (int i = 0; i < 3; ++i)
- pTransfer->m_Samples[i * 256 + v] = o;
+ pTransfer->GetSamples()[i * 256 + v] = o;
continue;
}
for (int i = 0; i < 3; ++i) {
if (!pFuncs[i] || pFuncs[i]->CountOutputs() > kMaxOutputs) {
- pTransfer->m_Samples[i * 256 + v] = v;
+ pTransfer->GetSamples()[i * 256 + v] = v;
continue;
}
pFuncs[i]->Call(&input, 1, output, &noutput);
int o = FXSYS_round(output[0] * 255);
if (o != v)
bIdentity = false;
- pTransfer->m_Samples[i * 256 + v] = o;
+ pTransfer->GetSamples()[i * 256 + v] = o;
}
}
- pTransfer->m_bIdentity = bIdentity;
+ pTransfer->SetIdentity(bIdentity);
return pTransfer;
}
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index 2fa0beba47..f2ddced6b1 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -84,7 +84,7 @@ bool CPDF_ImageRenderer::StartRenderDIBSource() {
if (!state.GetTransferFunc())
state.SetTransferFunc(m_pRenderStatus->GetTransferFunc(state.GetTR()));
- if (state.GetTransferFunc() && !state.GetTransferFunc()->m_bIdentity) {
+ if (state.GetTransferFunc() && !state.GetTransferFunc()->GetIdentity()) {
m_pDIBSource = m_Loader.m_pBitmap =
state.GetTransferFunc()->TranslateImage(m_Loader.m_pBitmap);
if (m_Loader.m_bCached && m_Loader.m_pMask)
diff --git a/core/fpdfapi/render/cpdf_transferfunc.h b/core/fpdfapi/render/cpdf_transferfunc.h
index 40f83ea9a9..d7e21fcfef 100644
--- a/core/fpdfapi/render/cpdf_transferfunc.h
+++ b/core/fpdfapi/render/cpdf_transferfunc.h
@@ -22,13 +22,21 @@ class CPDF_TransferFunc : public Retainable {
FX_COLORREF TranslateColor(FX_COLORREF src) const;
RetainPtr<CFX_DIBSource> TranslateImage(const RetainPtr<CFX_DIBSource>& pSrc);
- UnownedPtr<CPDF_Document> const m_pPDFDoc;
- bool m_bIdentity;
- uint8_t m_Samples[256 * 3];
+ const CPDF_Document* GetDocument() const { return m_pPDFDoc.Get(); }
+
+ const uint8_t* GetSamples() const { return m_Samples; }
+ uint8_t* GetSamples() { return m_Samples; }
+
+ bool GetIdentity() const { return m_bIdentity; }
+ void SetIdentity(bool identity) { m_bIdentity = identity; }
private:
explicit CPDF_TransferFunc(CPDF_Document* pDoc);
~CPDF_TransferFunc() override;
+
+ UnownedPtr<CPDF_Document> const m_pPDFDoc;
+ bool m_bIdentity;
+ uint8_t m_Samples[256 * 3];
};
#endif // CORE_FPDFAPI_RENDER_CPDF_TRANSFERFUNC_H_