summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-05-26 20:15:19 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-26 20:15:19 -0700
commitbefa4506dc9d2a679c526aff96c09bcb0e9daecb (patch)
tree3c1d3e11d9802b2db95e35f4ab81ff449492ee10 /fpdfsdk
parent7aed76f53137a71491040c776ab2f8931e91061b (diff)
downloadpdfium-befa4506dc9d2a679c526aff96c09bcb0e9daecb.tar.xz
Remove default arguments from CFX_FxgeDevice.
Remove unused dithering code. Review-Url: https://codereview.chromium.org/2010813003
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdf_progressive.cpp11
-rw-r--r--fpdfsdk/fpdfformfill.cpp181
-rw-r--r--fpdfsdk/fpdfview.cpp38
-rw-r--r--fpdfsdk/include/fsdk_define.h2
4 files changed, 118 insertions, 114 deletions
diff --git a/fpdfsdk/fpdf_progressive.cpp b/fpdfsdk/fpdf_progressive.cpp
index c66807cc91..efde1eb029 100644
--- a/fpdfsdk/fpdf_progressive.cpp
+++ b/fpdfsdk/fpdf_progressive.cpp
@@ -42,13 +42,10 @@ DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap,
CRenderContext* pContext = new CRenderContext;
pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext));
- pContext->m_pDevice = new CFX_FxgeDevice;
- if (flags & FPDF_REVERSE_BYTE_ORDER) {
- ((CFX_FxgeDevice*)pContext->m_pDevice)
- ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE);
- } else {
- ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap);
- }
+ CFX_FxgeDevice* pDevice = new CFX_FxgeDevice;
+ pContext->m_pDevice = pDevice;
+ CFX_DIBitmap* pBitmap = CFXBitmapFromFPDFBitmap(bitmap);
+ pDevice->Attach(pBitmap, !!(flags & FPDF_REVERSE_BYTE_ORDER), nullptr, false);
IFSDK_PAUSE_Adapter IPauseAdapter(pause);
FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index 6bcb605794..2631eb3e4f 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -55,6 +55,94 @@ FPDF_STRINGHANDLE ToFPDFStringHandle(std::vector<CFX_ByteString>* strings) {
}
#endif // PDF_ENABLE_XFA
+void FFLCommon(FPDF_FORMHANDLE hHandle,
+ FPDF_BITMAP bitmap,
+ FPDF_RECORDER recorder,
+ FPDF_PAGE page,
+ int start_x,
+ int start_y,
+ int size_x,
+ int size_y,
+ int rotate,
+ int flags) {
+ if (!hHandle)
+ return;
+
+ UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
+ if (!pPage)
+ return;
+
+#ifndef PDF_ENABLE_XFA
+ CPDF_RenderOptions options;
+ if (flags & FPDF_LCD_TEXT)
+ options.m_Flags |= RENDER_CLEARTYPE;
+ else
+ options.m_Flags &= ~RENDER_CLEARTYPE;
+ // Grayscale output
+ if (flags & FPDF_GRAYSCALE) {
+ options.m_ColorMode = RENDER_COLOR_GRAY;
+ options.m_ForeColor = 0;
+ options.m_BackColor = 0xffffff;
+ }
+ options.m_AddFlags = flags >> 8;
+ options.m_pOCContext =
+ new CPDF_OCContext(pPage->m_pDocument, CPDF_OCContext::View);
+#else // PDF_ENABLE_XFA
+ CPDFXFA_Document* pDocument = pPage->GetDocument();
+ if (!pDocument)
+ return;
+ CPDF_Document* pPDFDoc = pDocument->GetPDFDoc();
+ if (!pPDFDoc)
+ return;
+ CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
+ CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument();
+ if (!pFXDoc)
+ return;
+#endif // PDF_ENABLE_XFA
+
+ CFX_Matrix matrix;
+ pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
+
+ FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y);
+
+ std::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice);
+#ifdef _SKIA_SUPPORT_
+ pDevice->AttachRecorder(static_cast<SkPictureRecorder*>(recorder));
+#endif
+ pDevice->Attach(CFXBitmapFromFPDFBitmap(bitmap), false, nullptr, false);
+ pDevice->SaveState();
+ pDevice->SetClip_Rect(clip);
+
+#ifndef PDF_ENABLE_XFA
+ if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage))
+ pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options);
+#else // PDF_ENABLE_XFA
+ CPDF_RenderOptions options;
+ if (flags & FPDF_LCD_TEXT)
+ options.m_Flags |= RENDER_CLEARTYPE;
+ else
+ options.m_Flags &= ~RENDER_CLEARTYPE;
+
+ // Grayscale output
+ if (flags & FPDF_GRAYSCALE) {
+ options.m_ColorMode = RENDER_COLOR_GRAY;
+ options.m_ForeColor = 0;
+ options.m_BackColor = 0xffffff;
+ }
+ options.m_AddFlags = flags >> 8;
+ options.m_pOCContext = new CPDF_OCContext(pPDFDoc, CPDF_OCContext::View);
+
+ if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage))
+ pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip);
+#endif // PDF_ENABLE_XFA
+
+ pDevice->RestoreState(false);
+ delete options.m_pOCContext;
+#ifdef PDF_ENABLE_XFA
+ options.m_pOCContext = NULL;
+#endif // PDF_ENABLE_XFA
+}
+
} // namespace
DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
@@ -293,94 +381,6 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) {
return pSDKDoc->KillFocusAnnot(0);
}
-static void FFLCommon(FPDF_FORMHANDLE hHandle,
- FPDF_BITMAP bitmap,
- FPDF_RECORDER recorder,
- FPDF_PAGE page,
- int start_x,
- int start_y,
- int size_x,
- int size_y,
- int rotate,
- int flags) {
- if (!hHandle)
- return;
-
- UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
- if (!pPage)
- return;
-
-#ifndef PDF_ENABLE_XFA
- CPDF_RenderOptions options;
- if (flags & FPDF_LCD_TEXT)
- options.m_Flags |= RENDER_CLEARTYPE;
- else
- options.m_Flags &= ~RENDER_CLEARTYPE;
- // Grayscale output
- if (flags & FPDF_GRAYSCALE) {
- options.m_ColorMode = RENDER_COLOR_GRAY;
- options.m_ForeColor = 0;
- options.m_BackColor = 0xffffff;
- }
- options.m_AddFlags = flags >> 8;
- options.m_pOCContext =
- new CPDF_OCContext(pPage->m_pDocument, CPDF_OCContext::View);
-#else // PDF_ENABLE_XFA
- CPDFXFA_Document* pDocument = pPage->GetDocument();
- if (!pDocument)
- return;
- CPDF_Document* pPDFDoc = pDocument->GetPDFDoc();
- if (!pPDFDoc)
- return;
- CPDFDoc_Environment* pEnv = (CPDFDoc_Environment*)hHandle;
- CPDFSDK_Document* pFXDoc = pEnv->GetSDKDocument();
- if (!pFXDoc)
- return;
-#endif // PDF_ENABLE_XFA
-
- CFX_Matrix matrix;
- pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
-
- FX_RECT clip(start_x, start_y, start_x + size_x, start_y + size_y);
-
- std::unique_ptr<CFX_FxgeDevice> pDevice(new CFX_FxgeDevice);
-#ifdef _SKIA_SUPPORT_
- pDevice->AttachRecorder(static_cast<SkPictureRecorder*>(recorder));
-#endif
- pDevice->Attach((CFX_DIBitmap*)bitmap);
- pDevice->SaveState();
- pDevice->SetClip_Rect(clip);
-
-#ifndef PDF_ENABLE_XFA
- if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage))
- pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options);
-#else // PDF_ENABLE_XFA
- CPDF_RenderOptions options;
- if (flags & FPDF_LCD_TEXT)
- options.m_Flags |= RENDER_CLEARTYPE;
- else
- options.m_Flags &= ~RENDER_CLEARTYPE;
-
- // Grayscale output
- if (flags & FPDF_GRAYSCALE) {
- options.m_ColorMode = RENDER_COLOR_GRAY;
- options.m_ForeColor = 0;
- options.m_BackColor = 0xffffff;
- }
- options.m_AddFlags = flags >> 8;
- options.m_pOCContext = new CPDF_OCContext(pPDFDoc, CPDF_OCContext::View);
-
- if (CPDFSDK_PageView* pPageView = pFXDoc->GetPageView(pPage))
- pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, clip);
-#endif // PDF_ENABLE_XFA
-
- pDevice->RestoreState(false);
- delete options.m_pOCContext;
-#ifdef PDF_ENABLE_XFA
- options.m_pOCContext = NULL;
-#endif // PDF_ENABLE_XFA
-}
-
DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
FPDF_BITMAP bitmap,
FPDF_PAGE page,
@@ -464,7 +464,7 @@ DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document,
CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode();
uint32_t len = bsCpText.GetLength() / sizeof(unsigned short);
- if (wsText == NULL) {
+ if (!wsText) {
*size = len;
return;
}
@@ -483,8 +483,9 @@ DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document,
FPDF_WIDGET hWidget,
FPDF_WIDESTRING wsText,
FPDF_DWORD* size) {
- if (NULL == hWidget || NULL == document)
+ if (!hWidget || !document)
return;
+
CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic &&
pDocument->GetDocType() != XFA_DOCTYPE_Static)
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index 7797165bc2..24cd8ef5c4 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -74,6 +74,10 @@ CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) {
#endif // PDF_ENABLE_XFA
}
+CFX_DIBitmap* CFXBitmapFromFPDFBitmap(FPDF_BITMAP bitmap) {
+ return static_cast<CFX_DIBitmap*>(bitmap);
+}
+
#ifdef PDF_ENABLE_XFA
CFPDF_FileStream::CFPDF_FileStream(FPDF_FILEHANDLER* pFS) {
m_pFS = pFS;
@@ -544,14 +548,15 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
pBitmap = new CFX_DIBitmap;
pBitmap->Create(size_x, size_y, FXDIB_Argb);
pBitmap->Clear(0x00ffffff);
- pContext->m_pDevice = new CFX_FxgeDevice;
- ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap);
+ CFX_FxgeDevice* pDevice = new CFX_FxgeDevice;
+ pContext->m_pDevice = pDevice;
+ pDevice->Attach(pBitmap, false, nullptr, false);
} else {
pContext->m_pDevice = new CFX_WindowsDevice(dc);
}
FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
- rotate, flags, TRUE, NULL);
+ rotate, flags, TRUE, nullptr);
if (bBackgroundAlphaNeeded || bHasImageMask) {
if (pBitmap) {
@@ -595,13 +600,10 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
CRenderContext* pContext = new CRenderContext;
pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext));
- pContext->m_pDevice = new CFX_FxgeDevice;
- if (flags & FPDF_REVERSE_BYTE_ORDER) {
- ((CFX_FxgeDevice*)pContext->m_pDevice)
- ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE);
- } else {
- ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap);
- }
+ CFX_FxgeDevice* pDevice = new CFX_FxgeDevice;
+ pContext->m_pDevice = pDevice;
+ CFX_DIBitmap* pBitmap = CFXBitmapFromFPDFBitmap(bitmap);
+ pDevice->Attach(pBitmap, !!(flags & FPDF_REVERSE_BYTE_ORDER), nullptr, false);
FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
rotate, flags, TRUE, nullptr);
@@ -771,32 +773,34 @@ DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap,
FPDF_DWORD color) {
if (!bitmap)
return;
+
CFX_FxgeDevice device;
- device.Attach((CFX_DIBitmap*)bitmap);
- if (!((CFX_DIBitmap*)bitmap)->HasAlpha())
+ CFX_DIBitmap* pBitmap = CFXBitmapFromFPDFBitmap(bitmap);
+ device.Attach(pBitmap, false, nullptr, false);
+ if (!pBitmap->HasAlpha())
color |= 0xFF000000;
FX_RECT rect(left, top, left + width, top + height);
device.FillRect(&rect, color);
}
DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap) {
- return bitmap ? ((CFX_DIBitmap*)bitmap)->GetBuffer() : nullptr;
+ return bitmap ? CFXBitmapFromFPDFBitmap(bitmap)->GetBuffer() : nullptr;
}
DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap) {
- return bitmap ? ((CFX_DIBitmap*)bitmap)->GetWidth() : 0;
+ return bitmap ? CFXBitmapFromFPDFBitmap(bitmap)->GetWidth() : 0;
}
DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap) {
- return bitmap ? ((CFX_DIBitmap*)bitmap)->GetHeight() : 0;
+ return bitmap ? CFXBitmapFromFPDFBitmap(bitmap)->GetHeight() : 0;
}
DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap) {
- return bitmap ? ((CFX_DIBitmap*)bitmap)->GetPitch() : 0;
+ return bitmap ? CFXBitmapFromFPDFBitmap(bitmap)->GetPitch() : 0;
}
DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap) {
- delete (CFX_DIBitmap*)bitmap;
+ delete CFXBitmapFromFPDFBitmap(bitmap);
}
void FPDF_RenderPage_Retail(CRenderContext* pContext,
diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h
index a8a02d665e..4a470206d3 100644
--- a/fpdfsdk/include/fsdk_define.h
+++ b/fpdfsdk/include/fsdk_define.h
@@ -108,6 +108,8 @@ FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc);
CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page);
+CFX_DIBitmap* CFXBitmapFromFPDFBitmap(FPDF_BITMAP bitmap);
+
void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable);
FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy);
void FPDF_RenderPage_Retail(CRenderContext* pContext,