Merge to XFA: Kill Func_Renderpage global function pointer.
authorTom Sepez <tsepez@chromium.org>
Wed, 15 Jul 2015 23:35:53 +0000 (16:35 -0700)
committerTom Sepez <tsepez@chromium.org>
Wed, 15 Jul 2015 23:35:53 +0000 (16:35 -0700)
(cherry picked from commit e3db14f4d0e11ed30bd7e014ffa8cea9d6fb93ad)
Original Review URL: https://codereview.chromium.org/1233203004 .

R=thestig@chromium.org
TBR=thestig@chromium.org

Review URL: https://codereview.chromium.org/1236383003 .

fpdfsdk/include/fsdk_define.h
fpdfsdk/src/fpdf_progressive.cpp
fpdfsdk/src/fpdfview.cpp
xfa/include/fwl/adapter/fwl_adaptertimermgr.h

index bbf75e5..e1ab176 100644 (file)
@@ -7,47 +7,26 @@
 #ifndef FPDFSDK_INCLUDE_FSDK_DEFINE_H_
 #define FPDFSDK_INCLUDE_FSDK_DEFINE_H_
 
-#ifdef _WIN32
-#include <tchar.h>
-#include <math.h>
-#endif
-
 #include "../../core/include/fpdfapi/fpdf_module.h"
 #include "../../core/include/fpdfapi/fpdf_pageobj.h"
 #include "../../core/include/fpdfapi/fpdf_parser.h"
-#include "../../core/include/fpdfapi/fpdf_parser.h"
 #include "../../core/include/fpdfapi/fpdf_render.h"
 #include "../../core/include/fpdfapi/fpdf_serial.h"
 #include "../../core/include/fpdfapi/fpdfapi.h"
 #include "../../core/include/fpdfdoc/fpdf_doc.h"
 #include "../../core/include/fpdfdoc/fpdf_vt.h"
+#include "../../core/include/fxge/fx_ge.h"
+#include "../../core/include/fxge/fx_ge_win32.h"
+#include "../../public/fpdfview.h"
+#include "../../xfa/include/fwl/adapter/fwl_adaptertimermgr.h"
 #include "../../xfa/include/fxbarcode/BC_BarCode.h"
-#include "../../xfa/include/fxjse/fxjse.h"
-#include "../../xfa/include/fxgraphics/fx_graphics.h"
 #include "../../xfa/include/fxfa/fxfa.h"
-#include "../../xfa/include/fwl/core/fwl_error.h"
-#include "../../xfa/include/fwl/core/fwl_timer.h"
-#include "../../xfa/include/fwl/adapter/fwl_adaptertimermgr.h"
-
-
-#ifndef FX_GetAValue
-/** @brief It retrieves an intensity value for the alpha component of a #FX_ARGB value. */
-#define FX_GetAValue(argb)                     ((argb & 0xFF000000) >> 24)
-#endif
-
-#ifndef FX_GetRValue
-/** @brief It retrieves an intensity value for the red component of a #FX_ARGB value. */
-#define FX_GetRValue(argb)                     ((argb & 0x00FF0000) >> 16)
-#endif
-
-#ifndef FX_GetGValue
-/** @brief It retrieves an intensity value for the green component of a #FX_ARGB value. */
-#define FX_GetGValue(argb)                     ((argb & 0x0000FF00) >> 8)
-#endif
+#include "../../xfa/include/fxgraphics/fx_graphics.h"
+#include "../../xfa/include/fxjse/fxjse.h"
 
-#ifndef FX_GetBValue
-/** @brief It retrieves an intensity value for the blue component of a #FX_ARGB value. */
-#define FX_GetBValue(argb)                     (argb & 0x000000FF)
+#ifdef _WIN32
+#include <tchar.h>
+#include <math.h>
 #endif
 
 #ifndef FX_ARGBTOCOLORREF
@@ -61,8 +40,8 @@
 #endif
 
 typedef unsigned int FX_UINT;
-
-#include "../../public/fpdfview.h"
+class CRenderContext;
+class IFSDK_PAUSE_Adapter;
 
 class CPDF_CustomAccess final : public IFX_FileRead
 {
@@ -106,8 +85,12 @@ protected:
        FX_FILESIZE             m_nCurPos;
 };
 
-void           FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable);
-FPDF_BOOL      FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy);
-
+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, FPDF_PAGE page,
+                            int start_x, int start_y, int size_x, int size_y,
+                            int rotate, int flags, FX_BOOL bNeedToRestore,
+                            IFSDK_PAUSE_Adapter* pause);
 
 #endif  // FPDFSDK_INCLUDE_FSDK_DEFINE_H_
index f94bce0..f47cd7d 100644 (file)
 #include "../include/fpdfxfa/fpdfxfa_doc.h"
 #include "../include/fpdfxfa/fpdfxfa_page.h"
 
-extern void (*Func_RenderPage)( CRenderContext*, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y,
-                                               int rotate, int flags,FX_BOOL bNeedToRestore, IFSDK_PAUSE_Adapter * pause );
-
-extern void DropContext(void* data);
-
 DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start( FPDF_BITMAP bitmap, FPDF_PAGE page,
                                                                                                        int start_x, int start_y, int size_x,
                                                                                                    int size_y, int rotate, int flags,
@@ -53,7 +48,8 @@ DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start( FPDF_BITMAP bitmap, FPDF_PAGE
 #endif
        IFSDK_PAUSE_Adapter IPauseAdapter(pause);
 
-       Func_RenderPage(pContext, page, start_x, start_y, size_x, size_y, rotate, flags,FALSE, &IPauseAdapter);
+    FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
+                           rotate, flags,FALSE, &IPauseAdapter);
 
        if ( pContext->m_pRenderer )
        {
index 80a9fa5..1fbdb74 100644 (file)
@@ -449,11 +449,6 @@ void DropContext(void* data)
        delete (CRenderContext*)data;
 }
 
-void FPDF_RenderPage_Retail(CRenderContext* pContext, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y,
-                                               int rotate, int flags,FX_BOOL bNeedToRestore, IFSDK_PAUSE_Adapter * pause  );
-void (*Func_RenderPage)(CRenderContext*, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y,
-                                               int rotate, int flags,FX_BOOL bNeedToRestore, IFSDK_PAUSE_Adapter * pause  ) = FPDF_RenderPage_Retail;
-
 #if defined(_DEBUG) || defined(DEBUG)
 #define DEBUG_TRACE
 #endif
@@ -490,7 +485,8 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int
        else
            pContext->m_pDevice = FX_NEW CFX_WindowsDevice(dc);
 
-       Func_RenderPage(pContext, page, start_x, start_y, size_x, size_y, rotate, flags,TRUE,NULL);
+       FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
+                           rotate, flags, TRUE, NULL);
 
        if (bBackgroundAlphaNeeded)
        {
@@ -573,7 +569,8 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int
 #endif
 
        // output to bitmap device
-       Func_RenderPage(pContext, page, start_x - rect.left, start_y - rect.top, size_x, size_y, rotate, flags);
+       FPDF_RenderPage_Retail(pContext, page, start_x - rect.left,
+                           start_y - rect.top, size_x, size_y, rotate, flags);
 
 #ifdef DEBUG_TRACE
        CPDF_ModuleMgr::Get()->ReportError(999, "Finished PDF rendering");
@@ -641,7 +638,8 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page,
                ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap);
 #endif
 
-       Func_RenderPage(pContext, page, start_x, start_y, size_x, size_y, rotate, flags,TRUE,NULL);
+       FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
+                           rotate, flags, TRUE, NULL);
 
        delete pContext;
        pPage->RemovePrivateData((void*)1);
@@ -659,17 +657,9 @@ DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document)
 {
        if (!document)
                return;
+
        CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document;
        delete pDoc;
-
-//     CPDF_Parser* pParser = (CPDF_Parser*)pDoc->GetParser();
-//     if (pParser == NULL)
-//     {
-//             delete pDoc;
-//             return;
-//     }
-//     delete pParser;
-//     delete pDoc;
 }
 
 DLLEXPORT unsigned long STDCALL FPDF_GetLastError()
@@ -771,14 +761,14 @@ DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap)
 }
 
 void FPDF_RenderPage_Retail(CRenderContext* pContext, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y,
-                                               int rotate, int flags,FX_BOOL bNeedToRestore, IFSDK_PAUSE_Adapter * pause )
+                            int rotate, int flags,FX_BOOL bNeedToRestore, IFSDK_PAUSE_Adapter * pause )
 {
        CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
        if (pPage == NULL) return;
 
        if (!pContext->m_pOptions)
                pContext->m_pOptions = new CPDF_RenderOptions;
-//     CPDF_RenderOptions options;
+
        if (flags & FPDF_LCD_TEXT)
                pContext->m_pOptions->m_Flags |= RENDER_CLEARTYPE;
        else
@@ -797,12 +787,9 @@ void FPDF_RenderPage_Retail(CRenderContext* pContext, FPDF_PAGE page, int start_
                pContext->m_pOptions->m_BackColor = 0xffffff;
        }
        const CPDF_OCContext::UsageType usage = (flags & FPDF_PRINTING) ? CPDF_OCContext::Print : CPDF_OCContext::View;
-
        pContext->m_pOptions->m_AddFlags = flags >> 8;
-
        pContext->m_pOptions->m_pOCContext = new CPDF_OCContext(pPage->m_pDocument, usage);
 
-
        CFX_AffineMatrix matrix;
        pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
 
@@ -828,7 +815,7 @@ void FPDF_RenderPage_Retail(CRenderContext* pContext, FPDF_PAGE page, int start_
        pContext->m_pRenderer->Start(pContext->m_pContext, pContext->m_pDevice, pContext->m_pOptions, pause);
        if (bNeedToRestore)
        {
-         pContext->m_pDevice->RestoreState();
+               pContext->m_pDevice->RestoreState();
        }
 
 //#endif
index f3dce81..d0e9f0e 100644 (file)
@@ -7,6 +7,9 @@
 #ifndef _FWL_ADAPTER_TIMERMGR_H\r
 #define _FWL_ADAPTER_TIMERMGR_H\r
 \r
+#include "../core/fwl_error.h"\r
+#include "../core/fwl_timer.h"\r
+\r
 class IFWL_Timer;\r
 \r
 class IFWL_AdapterTimerMgr\r