summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_page.cpp1
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_page.h14
-rw-r--r--core/fpdfdoc/include/fpdf_doc.h2
-rw-r--r--fpdfsdk/fpdf_progressive.cpp18
-rw-r--r--fpdfsdk/fpdfview.cpp40
-rw-r--r--fpdfsdk/fsdk_mgr.cpp4
-rw-r--r--fpdfsdk/include/fsdk_define.h1
-rw-r--r--fpdfsdk/include/fsdk_mgr.h3
-rw-r--r--fpdfsdk/include/fsdk_rendercontext.h5
9 files changed, 50 insertions, 38 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_page.cpp b/core/fpdfapi/fpdf_page/cpdf_page.cpp
index 6b0609ff00..441bbfe28b 100644
--- a/core/fpdfapi/fpdf_page/cpdf_page.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_page.cpp
@@ -21,6 +21,7 @@ CPDF_Page::CPDF_Page(CPDF_Document* pDocument,
bool bPageCache)
: m_PageWidth(100),
m_PageHeight(100),
+ m_pView(nullptr),
m_pPageRender(bPageCache ? new CPDF_PageRenderCache(this) : nullptr) {
m_pFormDict = pPageDict;
m_pDocument = pDocument;
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_page.h b/core/fpdfapi/fpdf_page/include/cpdf_page.h
index 7f4430187a..99734889af 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_page.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_page.h
@@ -19,8 +19,10 @@ class CPDF_Document;
class CPDF_Object;
class CPDF_PageRenderCache;
-class CPDF_Page : public CPDF_PageObjectHolder, public CFX_PrivateData {
+class CPDF_Page : public CPDF_PageObjectHolder {
public:
+ class View {}; // Caller implements as desired, empty here due to layering.
+
CPDF_Page(CPDF_Document* pDocument,
CPDF_Dictionary* pPageDict,
bool bPageCache);
@@ -42,6 +44,14 @@ class CPDF_Page : public CPDF_PageObjectHolder, public CFX_PrivateData {
CPDF_Object* GetPageAttr(const CFX_ByteString& name) const;
CPDF_PageRenderCache* GetRenderCache() const { return m_pPageRender.get(); }
+ CFX_Deletable* GetRenderContext() const { return m_pRenderContext.get(); }
+ void SetRenderContext(std::unique_ptr<CFX_Deletable> pContext) {
+ m_pRenderContext = std::move(pContext);
+ }
+
+ View* GetView() const { return m_pView; }
+ void SetView(View* pView) { m_pView = pView; }
+
protected:
friend class CPDF_ContentParser;
@@ -50,7 +60,9 @@ class CPDF_Page : public CPDF_PageObjectHolder, public CFX_PrivateData {
FX_FLOAT m_PageWidth;
FX_FLOAT m_PageHeight;
CFX_Matrix m_PageMatrix;
+ View* m_pView;
std::unique_ptr<CPDF_PageRenderCache> m_pPageRender;
+ std::unique_ptr<CFX_Deletable> m_pRenderContext;
};
#endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_PAGE_H_
diff --git a/core/fpdfdoc/include/fpdf_doc.h b/core/fpdfdoc/include/fpdf_doc.h
index 3ee583d778..8c7ce4eeab 100644
--- a/core/fpdfdoc/include/fpdf_doc.h
+++ b/core/fpdfdoc/include/fpdf_doc.h
@@ -317,7 +317,7 @@ class CPDF_Link {
#define ANNOTFLAG_LOCKED 0x0080
#define ANNOTFLAG_TOGGLENOVIEW 0x0100
-class CPDF_Annot : public CFX_PrivateData {
+class CPDF_Annot {
public:
enum AppearanceMode { Normal, Rollover, Down };
diff --git a/fpdfsdk/fpdf_progressive.cpp b/fpdfsdk/fpdf_progressive.cpp
index d42d954bb9..90e8402bf8 100644
--- a/fpdfsdk/fpdf_progressive.cpp
+++ b/fpdfsdk/fpdf_progressive.cpp
@@ -40,15 +40,16 @@ DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap,
return FPDF_RENDER_FAILED;
CRenderContext* pContext = new CRenderContext;
- pPage->SetPrivateData((void*)1, pContext, DropContext);
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext));
pContext->m_pDevice = new CFX_FxgeDevice;
- if (flags & FPDF_REVERSE_BYTE_ORDER)
+ if (flags & FPDF_REVERSE_BYTE_ORDER) {
((CFX_FxgeDevice*)pContext->m_pDevice)
->Attach((CFX_DIBitmap*)bitmap, 0, TRUE);
- else
+ } else {
((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap);
- IFSDK_PAUSE_Adapter IPauseAdapter(pause);
+ }
+ IFSDK_PAUSE_Adapter IPauseAdapter(pause);
FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
rotate, flags, FALSE, &IPauseAdapter);
@@ -68,7 +69,8 @@ DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page,
if (!pPage)
return FPDF_RENDER_FAILED;
- CRenderContext* pContext = (CRenderContext*)pPage->GetPrivateData((void*)1);
+ CRenderContext* pContext =
+ static_cast<CRenderContext*>(pPage->GetRenderContext());
if (pContext && pContext->m_pRenderer) {
IFSDK_PAUSE_Adapter IPauseAdapter(pause);
pContext->m_pRenderer->Continue(&IPauseAdapter);
@@ -83,11 +85,11 @@ DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page) {
if (!pPage)
return;
- CRenderContext* pContext = (CRenderContext*)pPage->GetPrivateData((void*)1);
+ CRenderContext* pContext =
+ static_cast<CRenderContext*>(pPage->GetRenderContext());
if (!pContext)
return;
pContext->m_pDevice->RestoreState();
- delete pContext;
- pPage->RemovePrivateData((void*)1);
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>());
}
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index cdcaba4318..bf7ae0f5c2 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -517,10 +517,6 @@ DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page) {
return pPage ? pPage->GetPageHeight() : 0.0;
}
-void DropContext(void* data) {
- delete (CRenderContext*)data;
-}
-
#if defined(_WIN32)
DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
FPDF_PAGE page,
@@ -535,7 +531,7 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
return;
CRenderContext* pContext = new CRenderContext;
- pPage->SetPrivateData((void*)1, pContext, DropContext);
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext));
#if !defined(_WIN32_WCE)
CFX_DIBitmap* pBitmap = nullptr;
@@ -619,8 +615,7 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
if (bBackgroundAlphaNeeded || bHasImageMask)
delete pBitmap;
- delete pContext;
- pPage->RemovePrivateData((void*)1);
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>());
}
#endif // defined(_WIN32)
@@ -634,24 +629,25 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
int flags) {
if (!bitmap)
return;
+
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return;
+
CRenderContext* pContext = new CRenderContext;
- pPage->SetPrivateData((void*)1, pContext, DropContext);
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext));
pContext->m_pDevice = new CFX_FxgeDevice;
-
- if (flags & FPDF_REVERSE_BYTE_ORDER)
+ if (flags & FPDF_REVERSE_BYTE_ORDER) {
((CFX_FxgeDevice*)pContext->m_pDevice)
->Attach((CFX_DIBitmap*)bitmap, 0, TRUE);
- else
+ } else {
((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap);
+ }
FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
- rotate, flags, TRUE, NULL);
+ rotate, flags, TRUE, nullptr);
- delete pContext;
- pPage->RemovePrivateData((void*)1);
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>());
}
#ifdef _SKIA_SUPPORT_
@@ -661,33 +657,33 @@ DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page,
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return nullptr;
- std::unique_ptr<CRenderContext> pContext(new CRenderContext);
- pPage->SetPrivateData((void*)1, pContext.get(), DropContext);
+
+ CRenderContext* pContext = new CRenderContext;
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext));
CFX_FxgeDevice* skDevice = new CFX_FxgeDevice;
FPDF_RECORDER recorder = skDevice->CreateRecorder(size_x, size_y);
pContext->m_pDevice = skDevice;
-
FPDF_RenderPage_Retail(pContext.get(), page, 0, 0, size_x, size_y, 0, 0, TRUE,
- NULL);
- pPage->RemovePrivateData((void*)1);
+ nullptr);
+ pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>());
return recorder;
}
#endif
DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) {
+ UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
if (!page)
return;
#ifdef PDF_ENABLE_XFA
- CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
pPage->Release();
#else // PDF_ENABLE_XFA
CPDFSDK_PageView* pPageView =
- (CPDFSDK_PageView*)(((CPDF_Page*)page))->GetPrivateData((void*)page);
+ static_cast<CPDFSDK_PageView*>(pPage->GetView());
if (pPageView && pPageView->IsLocked()) {
pPageView->TakeOverPage();
return;
}
- delete (CPDF_Page*)page;
+ delete pPage;
#endif // PDF_ENABLE_XFA
}
diff --git a/fpdfsdk/fsdk_mgr.cpp b/fpdfsdk/fsdk_mgr.cpp
index fac98d8aa3..83fee907d2 100644
--- a/fpdfsdk/fsdk_mgr.cpp
+++ b/fpdfsdk/fsdk_mgr.cpp
@@ -480,7 +480,7 @@ CPDFSDK_PageView::CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,
#endif // PDF_ENABLE_XFA
}
#ifndef PDF_ENABLE_XFA
- m_page->SetPrivateData((void*)m_page, (void*)this, nullptr);
+ m_page->SetView(this);
#endif // PDF_ENABLE_XFA
}
@@ -493,7 +493,7 @@ CPDFSDK_PageView::~CPDFSDK_PageView() {
m_fxAnnotArray.clear();
m_pAnnotList.reset();
#ifndef PDF_ENABLE_XFA
- m_page->RemovePrivateData((void*)m_page);
+ m_page->SetView(nullptr);
if (m_bTakeOverPage) {
delete m_page;
}
diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h
index f3ed2da00f..536e35886f 100644
--- a/fpdfsdk/include/fsdk_define.h
+++ b/fpdfsdk/include/fsdk_define.h
@@ -109,7 +109,6 @@ FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc);
CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page);
-void DropContext(void* data);
void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable);
FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy);
void FPDF_RenderPage_Retail(CRenderContext* pContext,
diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h
index ca46a069f1..a47f230c92 100644
--- a/fpdfsdk/include/fsdk_mgr.h
+++ b/fpdfsdk/include/fsdk_mgr.h
@@ -11,6 +11,7 @@
#include <memory>
#include <vector>
+#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "fpdfsdk/cfx_systemhandler.h"
#include "fpdfsdk/include/fsdk_actionhandler.h"
@@ -530,7 +531,7 @@ class CPDFSDK_Document {
FX_BOOL m_bBeingDestroyed;
};
-class CPDFSDK_PageView final {
+class CPDFSDK_PageView final : public CPDF_Page::View {
public:
CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page);
~CPDFSDK_PageView();
diff --git a/fpdfsdk/include/fsdk_rendercontext.h b/fpdfsdk/include/fsdk_rendercontext.h
index f984a64583..1bcd076466 100644
--- a/fpdfsdk/include/fsdk_rendercontext.h
+++ b/fpdfsdk/include/fsdk_rendercontext.h
@@ -8,14 +8,15 @@
#define FPDFSDK_INCLUDE_FSDK_RENDERCONTEXT_H_
#include "core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h"
+#include "core/fxcrt/include/fx_basic.h"
#include "fpdfsdk/include/fsdk_define.h"
#include "public/fpdf_progressive.h"
// Everything about rendering is put here: for OOM recovery
-class CRenderContext {
+class CRenderContext : public CFX_Deletable {
public:
CRenderContext() { Clear(); }
- ~CRenderContext();
+ ~CRenderContext() override;
void Clear();