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 "../../public/fpdf_progressive.h" | 7 #include "../../public/fpdf_progressive.h" |
8 #include "../../public/fpdfview.h" | 8 #include "../../public/fpdfview.h" |
9 #include "../include/fsdk_define.h" | 9 #include "../include/fsdk_define.h" |
10 #include "../include/fsdk_rendercontext.h" | 10 #include "../include/fsdk_rendercontext.h" |
11 | 11 |
12 DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start( FPDF_BITMAP bitmap, FPDF_PAGE
page, | 12 DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start( FPDF_BITMAP bitmap, FPDF_PAGE
page, |
13 » » » » » » » » » »
» » » int start_x, int start_y, int size_x, | 13 int start_x, int start_y, in
t size_x, |
14 » » » » » » » » » »
» » int size_y, int rotate, int flags, | 14 int size_y, int rotate, int
flags, |
15 » » » » » » » » » »
» » » IFSDK_PAUSE * pause ) | 15 IFSDK_PAUSE * pause ) |
16 { | 16 { |
17 » if (bitmap == NULL || page == NULL) | 17 if (bitmap == NULL || page == NULL) |
18 » » return FPDF_RENDER_FAILED; | 18 return FPDF_RENDER_FAILED; |
19 | 19 |
20 » if (!pause) | 20 if (!pause) |
21 » » return FPDF_RENDER_FAILED; | 21 return FPDF_RENDER_FAILED; |
22 | 22 |
23 » if (pause->version !=1) | 23 if (pause->version !=1) |
24 » » return FPDF_RENDER_FAILED; | 24 return FPDF_RENDER_FAILED; |
25 | 25 |
26 » CPDF_Page* pPage = (CPDF_Page*)page; | 26 CPDF_Page* pPage = (CPDF_Page*)page; |
27 » CRenderContext* pContext = new CRenderContext; | 27 CRenderContext* pContext = new CRenderContext; |
28 » pPage->SetPrivateData((void*)1, pContext, DropContext); | 28 pPage->SetPrivateData((void*)1, pContext, DropContext); |
29 #ifdef _SKIA_SUPPORT_ | 29 #ifdef _SKIA_SUPPORT_ |
30 » pContext->m_pDevice = new CFX_SkiaDevice; | 30 pContext->m_pDevice = new CFX_SkiaDevice; |
31 » if (flags & FPDF_REVERSE_BYTE_ORDER) | 31 if (flags & FPDF_REVERSE_BYTE_ORDER) |
32 » » ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bi
tmap,0,TRUE); | 32 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap,0,T
RUE); |
33 » else | 33 else |
34 » » ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bi
tmap); | 34 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); |
35 #else | 35 #else |
36 » pContext->m_pDevice = new CFX_FxgeDevice; | 36 pContext->m_pDevice = new CFX_FxgeDevice; |
37 » if (flags & FPDF_REVERSE_BYTE_ORDER) | 37 if (flags & FPDF_REVERSE_BYTE_ORDER) |
38 » » ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bi
tmap,0,TRUE); | 38 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap,0,T
RUE); |
39 » else | 39 else |
40 » » ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bi
tmap); | 40 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); |
41 #endif | 41 #endif |
42 » IFSDK_PAUSE_Adapter IPauseAdapter(pause); | 42 IFSDK_PAUSE_Adapter IPauseAdapter(pause); |
43 | 43 |
44 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, | 44 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, |
45 rotate, flags,FALSE, &IPauseAdapter); | 45 rotate, flags,FALSE, &IPauseAdapter); |
46 | 46 |
47 » if ( pContext->m_pRenderer ) | 47 if (pContext->m_pRenderer) |
48 » { | 48 return CPDF_ProgressiveRenderer::ToFPDFStatus(pContext->m_pRenderer->Get
Status()); |
49 » » CPDF_ProgressiveRenderer::RenderStatus status = CPDF_Progressive
Renderer::Failed; | 49 |
50 » » status = pContext->m_pRenderer->GetStatus(); | 50 return FPDF_RENDER_FAILED; |
51 » » return status; | |
52 » } | |
53 » return FPDF_RENDER_FAILED; | |
54 } | 51 } |
55 | 52 |
56 DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page,IFSDK_PAUSE * paus
e) | 53 DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page,IFSDK_PAUSE * paus
e) |
57 { | 54 { |
58 » if (page == NULL) | 55 if (page == NULL) |
59 » » return FPDF_RENDER_FAILED; | 56 return FPDF_RENDER_FAILED; |
60 | 57 |
61 » if (!pause) | 58 if (!pause) |
62 » » return FPDF_RENDER_FAILED; | 59 return FPDF_RENDER_FAILED; |
63 | 60 |
64 » if (pause->version !=1) | 61 if (pause->version !=1) |
65 » » return FPDF_RENDER_FAILED; | 62 return FPDF_RENDER_FAILED; |
66 | 63 |
67 » CPDF_Page* pPage = (CPDF_Page*)page; | 64 CPDF_Page* pPage = (CPDF_Page*)page; |
68 | 65 CRenderContext * pContext = (CRenderContext*)pPage->GetPrivateData((void*)1)
; |
69 //» FXMT_CSLOCK_OBJ(&pPage->m_PageLock); | 66 if (pContext && pContext->m_pRenderer) |
70 | 67 { |
71 » CRenderContext * pContext = (CRenderContext*)pPage->GetPrivateData((void
*)1); | 68 IFSDK_PAUSE_Adapter IPauseAdapter(pause); |
72 » if (pContext && pContext->m_pRenderer) | 69 pContext->m_pRenderer->Continue(&IPauseAdapter); |
73 » { | 70 return CPDF_ProgressiveRenderer::ToFPDFStatus(pContext->m_pRenderer->Get
Status()); |
74 » » IFSDK_PAUSE_Adapter IPauseAdapter(pause); | 71 } |
75 » » pContext->m_pRenderer->Continue(&IPauseAdapter); | 72 return FPDF_RENDER_FAILED; |
76 | |
77 » » CPDF_ProgressiveRenderer::RenderStatus status = CPDF_Progressive
Renderer::Failed; | |
78 » » status = pContext->m_pRenderer->GetStatus(); | |
79 » » return status; | |
80 » } | |
81 » return FPDF_RENDER_FAILED; | |
82 } | 73 } |
83 | 74 |
84 | 75 |
85 DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page) | 76 DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page) |
86 { | 77 { |
87 » if (page == NULL) return; | 78 if (!page) |
88 » CPDF_Page* pPage = (CPDF_Page*)page; | 79 return; |
89 | 80 |
90 //» FXMT_CSLOCK_OBJ(&pPage->m_PageLock); | 81 CPDF_Page* pPage = (CPDF_Page*)page; |
| 82 CRenderContext * pContext = (CRenderContext*)pPage->GetPrivateData((void*)1)
; |
| 83 if (!pContext) |
| 84 return; |
91 | 85 |
92 » CRenderContext * pContext = (CRenderContext*)pPage->GetPrivateData((void
*)1); | 86 pContext->m_pDevice->RestoreState(); |
93 » if (pContext) | 87 delete pContext; |
94 » { | 88 pPage->RemovePrivateData((void*)1); |
95 » » pContext->m_pDevice->RestoreState(); | |
96 » » delete pContext; | |
97 » » pPage->RemovePrivateData((void*)1); | |
98 » } | |
99 } | 89 } |
100 | 90 |
OLD | NEW |