OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../include/fpdf_progressive.h" | 7 #include "../include/fpdf_progressive.h" |
8 #include "../include/fsdk_define.h" | 8 #include "../include/fsdk_define.h" |
9 #include "../include/fpdfview.h" | 9 #include "../include/fpdfview.h" |
10 #include "../include/fsdk_rendercontext.h" | 10 #include "../include/fsdk_rendercontext.h" |
11 | 11 |
12 extern void (*Func_RenderPage)( CRenderContext*, FPDF_PAGE page, int start_x, in
t start_y, int size_x, int size_y, | 12 extern void (*Func_RenderPage)(CRenderContext*, |
13 » » » » » » int rotate, int flags,FX_BOOL bN
eedToRestore, IFSDK_PAUSE_Adapter * pause ); | 13 FPDF_PAGE page, |
| 14 int start_x, |
| 15 int start_y, |
| 16 int size_x, |
| 17 int size_y, |
| 18 int rotate, |
| 19 int flags, |
| 20 FX_BOOL bNeedToRestore, |
| 21 IFSDK_PAUSE_Adapter* pause); |
14 | 22 |
15 extern void DropContext(void* data); | 23 extern void DropContext(void* data); |
16 | 24 |
17 DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start( FPDF_BITMAP bitmap, FPDF_PAGE
page, | 25 DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, |
18 » » » » » » » » » »
» » » int start_x, int start_y, int size_x, | 26 FPDF_PAGE page, |
19 » » » » » » » » » »
» » int size_y, int rotate, int flags, | 27 int start_x, |
20 » » » » » » » » » »
» » » IFSDK_PAUSE * pause ) | 28 int start_y, |
21 { | 29 int size_x, |
22 » if (bitmap == NULL || page == NULL) | 30 int size_y, |
23 » » return FPDF_RENDER_FAILED; | 31 int rotate, |
| 32 int flags, |
| 33 IFSDK_PAUSE* pause) { |
| 34 if (bitmap == NULL || page == NULL) |
| 35 return FPDF_RENDER_FAILED; |
24 | 36 |
25 » if (!pause) | 37 if (!pause) |
26 » » return FPDF_RENDER_FAILED; | 38 return FPDF_RENDER_FAILED; |
27 | 39 |
28 » if (pause->version !=1) | 40 if (pause->version != 1) |
29 » » return FPDF_RENDER_FAILED; | 41 return FPDF_RENDER_FAILED; |
30 | 42 |
31 » CPDF_Page* pPage = (CPDF_Page*)page; | 43 CPDF_Page* pPage = (CPDF_Page*)page; |
32 » | 44 |
33 //» FXMT_CSLOCK_OBJ(&pPage->m_PageLock); | 45 //» FXMT_CSLOCK_OBJ(&pPage->m_PageLock); |
34 » | 46 |
35 » CRenderContext* pContext = FX_NEW CRenderContext; | 47 CRenderContext* pContext = FX_NEW CRenderContext; |
36 » pPage->SetPrivateData((void*)1, pContext, DropContext ); | 48 pPage->SetPrivateData((void*)1, pContext, DropContext); |
37 #ifdef _SKIA_SUPPORT_ | 49 #ifdef _SKIA_SUPPORT_ |
38 » pContext->m_pDevice = FX_NEW CFX_SkiaDevice; | 50 pContext->m_pDevice = FX_NEW CFX_SkiaDevice; |
39 » if (flags & FPDF_REVERSE_BYTE_ORDER) | 51 if (flags & FPDF_REVERSE_BYTE_ORDER) |
40 » » ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bi
tmap,0,TRUE); | 52 ((CFX_SkiaDevice*)pContext->m_pDevice) |
41 » else | 53 ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); |
42 » » ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bi
tmap); | 54 else |
| 55 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); |
43 #else | 56 #else |
44 » pContext->m_pDevice = FX_NEW CFX_FxgeDevice; | 57 pContext->m_pDevice = FX_NEW CFX_FxgeDevice; |
45 » if (flags & FPDF_REVERSE_BYTE_ORDER) | 58 if (flags & FPDF_REVERSE_BYTE_ORDER) |
46 » » ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bi
tmap,0,TRUE); | 59 ((CFX_FxgeDevice*)pContext->m_pDevice) |
47 » else | 60 ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); |
48 » » ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bi
tmap); | 61 else |
| 62 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); |
49 #endif | 63 #endif |
50 » IFSDK_PAUSE_Adapter IPauseAdapter(pause); | 64 IFSDK_PAUSE_Adapter IPauseAdapter(pause); |
51 » | |
52 » if (flags & FPDF_NO_CATCH) | |
53 » » Func_RenderPage(pContext, page, start_x, start_y, size_x, size_y
, rotate, flags,FALSE, &IPauseAdapter); | |
54 » else { | |
55 » » try { | |
56 » » » Func_RenderPage(pContext, page, start_x, start_y, size_x
, size_y, rotate, flags,FALSE, &IPauseAdapter); | |
57 » » » } | |
58 » » catch (...){} | |
59 » } | |
60 | 65 |
61 » if ( pContext->m_pRenderer ) | 66 if (flags & FPDF_NO_CATCH) |
62 » { | 67 Func_RenderPage(pContext, |
63 » » CPDF_ProgressiveRenderer::RenderStatus status = CPDF_Progressive
Renderer::Failed; | 68 page, |
64 » » status = pContext->m_pRenderer->GetStatus(); | 69 start_x, |
65 » » return status; | 70 start_y, |
66 » } | 71 size_x, |
67 » return FPDF_RENDER_FAILED; | 72 size_y, |
| 73 rotate, |
| 74 flags, |
| 75 FALSE, |
| 76 &IPauseAdapter); |
| 77 else { |
| 78 try { |
| 79 Func_RenderPage(pContext, |
| 80 page, |
| 81 start_x, |
| 82 start_y, |
| 83 size_x, |
| 84 size_y, |
| 85 rotate, |
| 86 flags, |
| 87 FALSE, |
| 88 &IPauseAdapter); |
| 89 } catch (...) { |
| 90 } |
| 91 } |
| 92 |
| 93 if (pContext->m_pRenderer) { |
| 94 CPDF_ProgressiveRenderer::RenderStatus status = |
| 95 CPDF_ProgressiveRenderer::Failed; |
| 96 status = pContext->m_pRenderer->GetStatus(); |
| 97 return status; |
| 98 } |
| 99 return FPDF_RENDER_FAILED; |
68 } | 100 } |
69 | 101 |
70 DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page,IFSDK_PAUSE * paus
e) | 102 DLLEXPORT int STDCALL |
71 { | 103 FPDF_RenderPage_Continue(FPDF_PAGE page, IFSDK_PAUSE* pause) { |
72 » if (page == NULL) | 104 if (page == NULL) |
73 » » return FPDF_RENDER_FAILED; | 105 return FPDF_RENDER_FAILED; |
74 | 106 |
75 » if (!pause) | 107 if (!pause) |
76 » » return FPDF_RENDER_FAILED; | 108 return FPDF_RENDER_FAILED; |
77 » | |
78 » if (pause->version !=1) | |
79 » » return FPDF_RENDER_FAILED; | |
80 | 109 |
81 » CPDF_Page* pPage = (CPDF_Page*)page; | 110 if (pause->version != 1) |
| 111 return FPDF_RENDER_FAILED; |
82 | 112 |
83 //» FXMT_CSLOCK_OBJ(&pPage->m_PageLock); | 113 CPDF_Page* pPage = (CPDF_Page*)page; |
84 | 114 |
85 » CRenderContext * pContext = (CRenderContext*)pPage->GetPrivateData((void
*)1); | 115 //» FXMT_CSLOCK_OBJ(&pPage->m_PageLock); |
86 » if (pContext && pContext->m_pRenderer) | |
87 » { | |
88 » » IFSDK_PAUSE_Adapter IPauseAdapter(pause); | |
89 » » pContext->m_pRenderer->Continue(&IPauseAdapter); | |
90 | 116 |
91 » » CPDF_ProgressiveRenderer::RenderStatus status = CPDF_Progressive
Renderer::Failed; | 117 CRenderContext* pContext = (CRenderContext*)pPage->GetPrivateData((void*)1); |
92 » » status = pContext->m_pRenderer->GetStatus(); | 118 if (pContext && pContext->m_pRenderer) { |
93 » » return status; | 119 IFSDK_PAUSE_Adapter IPauseAdapter(pause); |
94 » } | 120 pContext->m_pRenderer->Continue(&IPauseAdapter); |
95 » return FPDF_RENDER_FAILED; | 121 |
| 122 CPDF_ProgressiveRenderer::RenderStatus status = |
| 123 CPDF_ProgressiveRenderer::Failed; |
| 124 status = pContext->m_pRenderer->GetStatus(); |
| 125 return status; |
| 126 } |
| 127 return FPDF_RENDER_FAILED; |
96 } | 128 } |
97 | 129 |
| 130 DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page) { |
| 131 if (page == NULL) |
| 132 return; |
| 133 CPDF_Page* pPage = (CPDF_Page*)page; |
98 | 134 |
99 DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page) | 135 //» FXMT_CSLOCK_OBJ(&pPage->m_PageLock); |
100 { | |
101 » if (page == NULL) return; | |
102 » CPDF_Page* pPage = (CPDF_Page*)page; | |
103 | 136 |
104 //» FXMT_CSLOCK_OBJ(&pPage->m_PageLock); | 137 CRenderContext* pContext = (CRenderContext*)pPage->GetPrivateData((void*)1); |
105 | 138 if (pContext) { |
106 » CRenderContext * pContext = (CRenderContext*)pPage->GetPrivateData((void
*)1); | 139 pContext->m_pDevice->RestoreState(); |
107 » if (pContext) | 140 delete pContext; |
108 » { | 141 pPage->RemovePrivateData((void*)1); |
109 » » pContext->m_pDevice->RestoreState(); | 142 } |
110 » » delete pContext; | |
111 » » pPage->RemovePrivateData((void*)1); | |
112 » } | |
113 } | 143 } |
114 | |
OLD | NEW |