summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-04-03 14:05:17 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-03 21:47:59 +0000
commit3a1d9b48cb5485cdb93f1cc9857e5d829868629c (patch)
tree9f49629c7bb9a73357821841da549ac9149d7b12 /core/fpdfapi/page
parentac35589d5d1a593497cf28d91ab6a236f25833c3 (diff)
downloadpdfium-3a1d9b48cb5485cdb93f1cc9857e5d829868629c.tar.xz
RefCount CPDF_TransferFunc all the time.
Prefer internal reference counts over ad-hoc schemes. Change-Id: I8d420e9e9827ac39fdc0bc8146a532caeee10f26 Reviewed-on: https://pdfium-review.googlesource.com/3615 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r--core/fpdfapi/page/cpdf_generalstate.cpp11
-rw-r--r--core/fpdfapi/page/cpdf_generalstate.h6
2 files changed, 10 insertions, 7 deletions
diff --git a/core/fpdfapi/page/cpdf_generalstate.cpp b/core/fpdfapi/page/cpdf_generalstate.cpp
index dd5c5af878..513e5ff7a5 100644
--- a/core/fpdfapi/page/cpdf_generalstate.cpp
+++ b/core/fpdfapi/page/cpdf_generalstate.cpp
@@ -124,12 +124,13 @@ void CPDF_GeneralState::SetTR(CPDF_Object* pObject) {
m_Ref.GetPrivateCopy()->m_pTR = pObject;
}
-CPDF_TransferFunc* CPDF_GeneralState::GetTransferFunc() const {
+CFX_RetainPtr<CPDF_TransferFunc> CPDF_GeneralState::GetTransferFunc() const {
const StateData* pData = m_Ref.GetObject();
return pData ? pData->m_pTransferFunc : nullptr;
}
-void CPDF_GeneralState::SetTransferFunc(CPDF_TransferFunc* pFunc) {
+void CPDF_GeneralState::SetTransferFunc(
+ const CFX_RetainPtr<CPDF_TransferFunc>& pFunc) {
m_Ref.GetPrivateCopy()->m_pTransferFunc = pFunc;
}
@@ -277,7 +278,9 @@ CPDF_GeneralState::StateData::StateData(const StateData& that)
CPDF_GeneralState::StateData::~StateData() {
if (m_pTransferFunc && m_pTransferFunc->m_pPDFDoc) {
CPDF_DocRenderData* pDocCache = m_pTransferFunc->m_pPDFDoc->GetRenderData();
- if (pDocCache)
- pDocCache->ReleaseTransferFunc(m_pTR);
+ if (pDocCache) {
+ m_pTransferFunc.Reset(); // Give up our reference first.
+ pDocCache->MaybePurgeTransferFunc(m_pTR);
+ }
}
}
diff --git a/core/fpdfapi/page/cpdf_generalstate.h b/core/fpdfapi/page/cpdf_generalstate.h
index 1c5ddee4e0..8de5a36ca6 100644
--- a/core/fpdfapi/page/cpdf_generalstate.h
+++ b/core/fpdfapi/page/cpdf_generalstate.h
@@ -41,8 +41,8 @@ class CPDF_GeneralState {
CPDF_Object* GetTR() const;
void SetTR(CPDF_Object* pObject);
- CPDF_TransferFunc* GetTransferFunc() const;
- void SetTransferFunc(CPDF_TransferFunc* pFunc);
+ CFX_RetainPtr<CPDF_TransferFunc> GetTransferFunc() const;
+ void SetTransferFunc(const CFX_RetainPtr<CPDF_TransferFunc>& pFunc);
void SetBlendMode(const CFX_ByteString& mode);
@@ -88,7 +88,7 @@ class CPDF_GeneralState {
float m_StrokeAlpha;
float m_FillAlpha;
CPDF_Object* m_pTR;
- CPDF_TransferFunc* m_pTransferFunc;
+ CFX_RetainPtr<CPDF_TransferFunc> m_pTransferFunc;
CFX_Matrix m_Matrix;
int m_RenderIntent;
bool m_StrokeAdjust;