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