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