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 | 8 |
9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
10 #include "core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h" | 10 #include "core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 int flags, | 33 int flags, |
34 IFSDK_PAUSE* pause) { | 34 IFSDK_PAUSE* pause) { |
35 if (!bitmap || !pause || pause->version != 1) | 35 if (!bitmap || !pause || pause->version != 1) |
36 return FPDF_RENDER_FAILED; | 36 return FPDF_RENDER_FAILED; |
37 | 37 |
38 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 38 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
39 if (!pPage) | 39 if (!pPage) |
40 return FPDF_RENDER_FAILED; | 40 return FPDF_RENDER_FAILED; |
41 | 41 |
42 CRenderContext* pContext = new CRenderContext; | 42 CRenderContext* pContext = new CRenderContext; |
43 pPage->SetPrivateData((void*)1, pContext, DropContext); | 43 pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext)); |
44 pContext->m_pDevice = new CFX_FxgeDevice; | 44 pContext->m_pDevice = new CFX_FxgeDevice; |
45 if (flags & FPDF_REVERSE_BYTE_ORDER) | 45 if (flags & FPDF_REVERSE_BYTE_ORDER) { |
46 ((CFX_FxgeDevice*)pContext->m_pDevice) | 46 ((CFX_FxgeDevice*)pContext->m_pDevice) |
47 ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); | 47 ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); |
48 else | 48 } else { |
49 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); | 49 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); |
| 50 } |
| 51 |
50 IFSDK_PAUSE_Adapter IPauseAdapter(pause); | 52 IFSDK_PAUSE_Adapter IPauseAdapter(pause); |
51 | |
52 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, | 53 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, |
53 rotate, flags, FALSE, &IPauseAdapter); | 54 rotate, flags, FALSE, &IPauseAdapter); |
54 | 55 |
55 if (pContext->m_pRenderer) { | 56 if (pContext->m_pRenderer) { |
56 return CPDF_ProgressiveRenderer::ToFPDFStatus( | 57 return CPDF_ProgressiveRenderer::ToFPDFStatus( |
57 pContext->m_pRenderer->GetStatus()); | 58 pContext->m_pRenderer->GetStatus()); |
58 } | 59 } |
59 return FPDF_RENDER_FAILED; | 60 return FPDF_RENDER_FAILED; |
60 } | 61 } |
61 | 62 |
62 DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page, | 63 DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page, |
63 IFSDK_PAUSE* pause) { | 64 IFSDK_PAUSE* pause) { |
64 if (!pause || pause->version != 1) | 65 if (!pause || pause->version != 1) |
65 return FPDF_RENDER_FAILED; | 66 return FPDF_RENDER_FAILED; |
66 | 67 |
67 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 68 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
68 if (!pPage) | 69 if (!pPage) |
69 return FPDF_RENDER_FAILED; | 70 return FPDF_RENDER_FAILED; |
70 | 71 |
71 CRenderContext* pContext = (CRenderContext*)pPage->GetPrivateData((void*)1); | 72 CRenderContext* pContext = |
| 73 static_cast<CRenderContext*>(pPage->GetRenderContext()); |
72 if (pContext && pContext->m_pRenderer) { | 74 if (pContext && pContext->m_pRenderer) { |
73 IFSDK_PAUSE_Adapter IPauseAdapter(pause); | 75 IFSDK_PAUSE_Adapter IPauseAdapter(pause); |
74 pContext->m_pRenderer->Continue(&IPauseAdapter); | 76 pContext->m_pRenderer->Continue(&IPauseAdapter); |
75 return CPDF_ProgressiveRenderer::ToFPDFStatus( | 77 return CPDF_ProgressiveRenderer::ToFPDFStatus( |
76 pContext->m_pRenderer->GetStatus()); | 78 pContext->m_pRenderer->GetStatus()); |
77 } | 79 } |
78 return FPDF_RENDER_FAILED; | 80 return FPDF_RENDER_FAILED; |
79 } | 81 } |
80 | 82 |
81 DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page) { | 83 DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page) { |
82 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 84 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
83 if (!pPage) | 85 if (!pPage) |
84 return; | 86 return; |
85 | 87 |
86 CRenderContext* pContext = (CRenderContext*)pPage->GetPrivateData((void*)1); | 88 CRenderContext* pContext = |
| 89 static_cast<CRenderContext*>(pPage->GetRenderContext()); |
87 if (!pContext) | 90 if (!pContext) |
88 return; | 91 return; |
89 | 92 |
90 pContext->m_pDevice->RestoreState(); | 93 pContext->m_pDevice->RestoreState(); |
91 delete pContext; | 94 pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>()); |
92 pPage->RemovePrivateData((void*)1); | |
93 } | 95 } |
OLD | NEW |