Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Unified Diff: fpdfsdk/src/fpdfview.cpp

Issue 1406543004: Introduce CPDFPageFromFPDFPage() (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/src/fpdftext.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/fpdfview.cpp
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index 17f52ec26339b8ba6a30348dc6a22c6fa9eff1fb..b2c5618a5205de0aed2da0fbd853e8bb1a7be6b1 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -20,6 +20,10 @@ CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) {
return static_cast<CPDF_Document*>(doc);
}
+CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) {
+ return static_cast<CPDF_Page*>(page);
+}
+
CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) {
if (pFileAccess)
m_FileAccess = *pFileAccess;
@@ -284,15 +288,13 @@ DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
}
DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page) {
- if (!page)
- return 0.0;
- return ((CPDF_Page*)page)->GetPageWidth();
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ return pPage ? pPage->GetPageWidth() : 0.0;
}
DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page) {
- if (!page)
- return 0.0;
- return ((CPDF_Page*)page)->GetPageHeight();
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ return pPage ? pPage->GetPageHeight() : 0.0;
}
void DropContext(void* data) {
@@ -312,9 +314,9 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
int size_y,
int rotate,
int flags) {
- if (page == NULL)
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
return;
- CPDF_Page* pPage = (CPDF_Page*)page;
CRenderContext* pContext = new CRenderContext;
pPage->SetPrivateData((void*)1, pContext, DropContext);
@@ -472,10 +474,11 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
int size_y,
int rotate,
int flags) {
- if (bitmap == NULL || page == NULL)
+ if (!bitmap)
+ return;
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
return;
- CPDF_Page* pPage = (CPDF_Page*)page;
-
CRenderContext* pContext = new CRenderContext;
pPage->SetPrivateData((void*)1, pContext, DropContext);
#ifdef _SKIA_SUPPORT_
@@ -570,10 +573,11 @@ DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page,
double page_y,
int* device_x,
int* device_y) {
- if (page == NULL || device_x == NULL || device_y == NULL)
+ if (!device_x || !device_y)
+ return;
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
return;
- CPDF_Page* pPage = (CPDF_Page*)page;
-
CPDF_Matrix page2device;
pPage->GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y,
rotate);
@@ -681,8 +685,8 @@ void FPDF_RenderPage_Retail(CRenderContext* pContext,
int flags,
FX_BOOL bNeedToRestore,
IFSDK_PAUSE_Adapter* pause) {
- CPDF_Page* pPage = (CPDF_Page*)page;
- if (pPage == NULL)
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
return;
if (!pContext->m_pOptions)
« no previous file with comments | « fpdfsdk/src/fpdftext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698