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 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 11 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
12 #include "../include/fpdfxfa/fpdfxfa_page.h" | 12 #include "../include/fpdfxfa/fpdfxfa_page.h" |
13 | 13 |
14 DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, | 14 DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, |
15 FPDF_PAGE page, | 15 FPDF_PAGE page, |
16 int start_x, | 16 int start_x, |
17 int start_y, | 17 int start_y, |
18 int size_x, | 18 int size_x, |
19 int size_y, | 19 int size_y, |
20 int rotate, | 20 int rotate, |
21 int flags, | 21 int flags, |
22 IFSDK_PAUSE* pause) { | 22 IFSDK_PAUSE* pause) { |
23 if (bitmap == NULL || page == NULL) | 23 if (!bitmap || !pause || pause->version != 1) |
24 return FPDF_RENDER_FAILED; | 24 return FPDF_RENDER_FAILED; |
25 | 25 |
26 if (!pause) | 26 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
27 return FPDF_RENDER_FAILED; | |
28 | |
29 if (pause->version != 1) | |
30 return FPDF_RENDER_FAILED; | |
31 | |
32 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); | |
33 if (!pPage) | 27 if (!pPage) |
34 return FPDF_RENDER_FAILED; | 28 return FPDF_RENDER_FAILED; |
35 | 29 |
36 CRenderContext* pContext = new CRenderContext; | 30 CRenderContext* pContext = new CRenderContext; |
37 pPage->SetPrivateData((void*)1, pContext, DropContext); | 31 pPage->SetPrivateData((void*)1, pContext, DropContext); |
38 #ifdef _SKIA_SUPPORT_ | 32 #ifdef _SKIA_SUPPORT_ |
39 pContext->m_pDevice = new CFX_SkiaDevice; | 33 pContext->m_pDevice = new CFX_SkiaDevice; |
40 if (flags & FPDF_REVERSE_BYTE_ORDER) | 34 if (flags & FPDF_REVERSE_BYTE_ORDER) |
41 ((CFX_SkiaDevice*)pContext->m_pDevice) | 35 ((CFX_SkiaDevice*)pContext->m_pDevice) |
42 ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); | 36 ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); |
(...skipping 16 matching lines...) Expand all Loading... |
59 CPDF_ProgressiveRenderer::RenderStatus status = | 53 CPDF_ProgressiveRenderer::RenderStatus status = |
60 CPDF_ProgressiveRenderer::Failed; | 54 CPDF_ProgressiveRenderer::Failed; |
61 status = pContext->m_pRenderer->GetStatus(); | 55 status = pContext->m_pRenderer->GetStatus(); |
62 return status; | 56 return status; |
63 } | 57 } |
64 return FPDF_RENDER_FAILED; | 58 return FPDF_RENDER_FAILED; |
65 } | 59 } |
66 | 60 |
67 DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page, | 61 DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page, |
68 IFSDK_PAUSE* pause) { | 62 IFSDK_PAUSE* pause) { |
69 if (page == NULL) | 63 if (!pause || pause->version != 1) |
70 return FPDF_RENDER_FAILED; | 64 return FPDF_RENDER_FAILED; |
71 | 65 |
72 if (!pause) | 66 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
73 return FPDF_RENDER_FAILED; | |
74 | |
75 if (pause->version != 1) | |
76 return FPDF_RENDER_FAILED; | |
77 | |
78 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); | |
79 if (!pPage) | 67 if (!pPage) |
80 return FPDF_RENDER_FAILED; | 68 return FPDF_RENDER_FAILED; |
81 | 69 |
82 CRenderContext* pContext = (CRenderContext*)pPage->GetPrivateData((void*)1); | 70 CRenderContext* pContext = (CRenderContext*)pPage->GetPrivateData((void*)1); |
83 if (pContext && pContext->m_pRenderer) { | 71 if (pContext && pContext->m_pRenderer) { |
84 IFSDK_PAUSE_Adapter IPauseAdapter(pause); | 72 IFSDK_PAUSE_Adapter IPauseAdapter(pause); |
85 pContext->m_pRenderer->Continue(&IPauseAdapter); | 73 pContext->m_pRenderer->Continue(&IPauseAdapter); |
86 | 74 |
87 CPDF_ProgressiveRenderer::RenderStatus status = | 75 CPDF_ProgressiveRenderer::RenderStatus status = |
88 CPDF_ProgressiveRenderer::Failed; | 76 CPDF_ProgressiveRenderer::Failed; |
89 status = pContext->m_pRenderer->GetStatus(); | 77 status = pContext->m_pRenderer->GetStatus(); |
90 return status; | 78 return status; |
91 } | 79 } |
92 return FPDF_RENDER_FAILED; | 80 return FPDF_RENDER_FAILED; |
93 } | 81 } |
94 | 82 |
95 DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page) { | 83 DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page) { |
96 if (!page) | 84 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
97 return; | |
98 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); | |
99 if (!pPage) | 85 if (!pPage) |
100 return; | 86 return; |
101 | 87 |
102 CRenderContext* pContext = (CRenderContext*)pPage->GetPrivateData((void*)1); | 88 CRenderContext* pContext = (CRenderContext*)pPage->GetPrivateData((void*)1); |
103 if (!pContext) | 89 if (!pContext) |
104 return; | 90 return; |
105 | 91 |
106 pContext->m_pDevice->RestoreState(); | 92 pContext->m_pDevice->RestoreState(); |
107 delete pContext; | 93 delete pContext; |
108 pPage->RemovePrivateData((void*)1); | 94 pPage->RemovePrivateData((void*)1); |
109 } | 95 } |
OLD | NEW |