summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_progressive.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-25 14:58:09 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-25 14:58:09 -0700
commit1e2c557e0fa0e47c8bafdb31c833ea4f90f5fedd (patch)
tree86c90cdb10f3c478570934816a56070ed6d51260 /fpdfsdk/fpdf_progressive.cpp
parentedfd3c3d6a56bee2456e96df4b945c095ea3a290 (diff)
downloadpdfium-1e2c557e0fa0e47c8bafdb31c833ea4f90f5fedd.tar.xz
Remove CFX_PrivateData from CPDF_Page
CFX_PrivateData served two purposes here: The first was to hold an opaque pointer to the corresponding page structure in the next higher layer, of which it knows no details. Introduce an empty CPDF_Page::View class to represent this higher class, so as to get type safety while preserving layering. The second was to hold an opaque render context, which it also happened to own. Make this a CFX_Deletable to help with management. Also remove an unused inheritance from CFX_PrivateData in CPDF_Annot. Review-Url: https://codereview.chromium.org/2008553008
Diffstat (limited to 'fpdfsdk/fpdf_progressive.cpp')
-rw-r--r--fpdfsdk/fpdf_progressive.cpp18
1 files changed, 10 insertions, 8 deletions
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>());
}