summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-08-10 20:50:52 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-10 20:50:52 +0000
commitf42d570492e881600d6b0692fb2fe0c0ec89e181 (patch)
tree003f2d8381d3db5816e1a50dd9abe25188897279
parent994d8b4e363bb86128593a9000a17b0e79f849f5 (diff)
downloadpdfium-f42d570492e881600d6b0692fb2fe0c0ec89e181.tar.xz
Make CPDF_PSFunc::m_PS mutable.
Preferred over const_cast<> to show how that state is used. Change-Id: Ia6fe6bf46fb7fa8e701481b1604073b5d7f222fa Reviewed-on: https://pdfium-review.googlesource.com/39870 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
-rw-r--r--core/fpdfapi/page/cpdf_psfunc.cpp11
-rw-r--r--core/fpdfapi/page/cpdf_psfunc.h2
2 files changed, 6 insertions, 7 deletions
diff --git a/core/fpdfapi/page/cpdf_psfunc.cpp b/core/fpdfapi/page/cpdf_psfunc.cpp
index be0afe9659..13d76aeb10 100644
--- a/core/fpdfapi/page/cpdf_psfunc.cpp
+++ b/core/fpdfapi/page/cpdf_psfunc.cpp
@@ -21,14 +21,13 @@ bool CPDF_PSFunc::v_Init(const CPDF_Object* pObj,
}
bool CPDF_PSFunc::v_Call(const float* inputs, float* results) const {
- CPDF_PSEngine& PS = const_cast<CPDF_PSEngine&>(m_PS);
- PS.Reset();
+ m_PS.Reset();
for (uint32_t i = 0; i < m_nInputs; i++)
- PS.Push(inputs[i]);
- PS.Execute();
- if (PS.GetStackSize() < m_nOutputs)
+ m_PS.Push(inputs[i]);
+ m_PS.Execute();
+ if (m_PS.GetStackSize() < m_nOutputs)
return false;
for (uint32_t i = 0; i < m_nOutputs; i++)
- results[m_nOutputs - i - 1] = PS.Pop();
+ results[m_nOutputs - i - 1] = m_PS.Pop();
return true;
}
diff --git a/core/fpdfapi/page/cpdf_psfunc.h b/core/fpdfapi/page/cpdf_psfunc.h
index 459da5a599..1274c21d50 100644
--- a/core/fpdfapi/page/cpdf_psfunc.h
+++ b/core/fpdfapi/page/cpdf_psfunc.h
@@ -25,7 +25,7 @@ class CPDF_PSFunc : public CPDF_Function {
bool v_Call(const float* inputs, float* results) const override;
private:
- CPDF_PSEngine m_PS;
+ mutable CPDF_PSEngine m_PS; // Pre-initialized scratch space for v_Call().
};
#endif // CORE_FPDFAPI_PAGE_CPDF_PSFUNC_H_