| 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/fpdfview.h" | 7 #include "public/fpdfview.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 int rotate, | 637 int rotate, |
| 638 int flags) { | 638 int flags) { |
| 639 if (!bitmap) | 639 if (!bitmap) |
| 640 return; | 640 return; |
| 641 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 641 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
| 642 if (!pPage) | 642 if (!pPage) |
| 643 return; | 643 return; |
| 644 CRenderContext* pContext = new CRenderContext; | 644 CRenderContext* pContext = new CRenderContext; |
| 645 pPage->SetPrivateData((void*)1, pContext, DropContext); | 645 pPage->SetPrivateData((void*)1, pContext, DropContext); |
| 646 #ifdef _SKIA_SUPPORT_ | 646 #ifdef _SKIA_SUPPORT_ |
| 647 pContext->m_pDevice = new CFX_SkiaDevice; | 647 pContext->m_pDevice = new CFX_SkiaDevice(); |
| 648 | 648 |
| 649 if (flags & FPDF_REVERSE_BYTE_ORDER) | 649 if (flags & FPDF_REVERSE_BYTE_ORDER) |
| 650 ((CFX_SkiaDevice*)pContext->m_pDevice) | 650 ((CFX_SkiaDevice*)pContext->m_pDevice) |
| 651 ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); | 651 ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); |
| 652 else | 652 else |
| 653 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); | 653 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); |
| 654 #else | 654 #else |
| 655 pContext->m_pDevice = new CFX_FxgeDevice; | 655 pContext->m_pDevice = new CFX_FxgeDevice; |
| 656 | 656 |
| 657 if (flags & FPDF_REVERSE_BYTE_ORDER) | 657 if (flags & FPDF_REVERSE_BYTE_ORDER) |
| 658 ((CFX_FxgeDevice*)pContext->m_pDevice) | 658 ((CFX_FxgeDevice*)pContext->m_pDevice) |
| 659 ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); | 659 ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); |
| 660 else | 660 else |
| 661 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); | 661 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); |
| 662 #endif | 662 #endif |
| 663 | 663 |
| 664 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, | 664 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, |
| 665 rotate, flags, TRUE, NULL); | 665 rotate, flags, TRUE, NULL); |
| 666 | 666 |
| 667 delete pContext; | 667 delete pContext; |
| 668 pPage->RemovePrivateData((void*)1); | 668 pPage->RemovePrivateData((void*)1); |
| 669 } | 669 } |
| 670 | 670 |
| 671 #ifdef _SKIA_SUPPORT_ |
| 672 DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page, |
| 673 int size_x, |
| 674 int size_y) { |
| 675 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
| 676 if (!pPage) |
| 677 return nullptr; |
| 678 std::unique_ptr<CRenderContext> pContext(new CRenderContext); |
| 679 pPage->SetPrivateData((void*)1, pContext.get(), DropContext); |
| 680 CFX_SkiaDevice* skDevice = new CFX_SkiaDevice(); |
| 681 FPDF_RECORDER recorder = skDevice->CreateRecorder(size_x, size_y); |
| 682 pContext->m_pDevice = skDevice; |
| 683 |
| 684 FPDF_RenderPage_Retail(pContext.get(), page, 0, 0, size_x, size_y, 0, 0, TRUE, |
| 685 NULL); |
| 686 pPage->RemovePrivateData((void*)1); |
| 687 return recorder; |
| 688 } |
| 689 #endif |
| 690 |
| 671 DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) { | 691 DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) { |
| 672 if (!page) | 692 if (!page) |
| 673 return; | 693 return; |
| 674 #ifdef PDF_ENABLE_XFA | 694 #ifdef PDF_ENABLE_XFA |
| 675 CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; | 695 CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; |
| 676 pPage->Release(); | 696 pPage->Release(); |
| 677 #else // PDF_ENABLE_XFA | 697 #else // PDF_ENABLE_XFA |
| 678 CPDFSDK_PageView* pPageView = | 698 CPDFSDK_PageView* pPageView = |
| 679 (CPDFSDK_PageView*)(((CPDF_Page*)page))->GetPrivateData((void*)page); | 699 (CPDFSDK_PageView*)(((CPDF_Page*)page))->GetPrivateData((void*)page); |
| 680 if (pPageView && pPageView->IsLocked()) { | 700 if (pPageView && pPageView->IsLocked()) { |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 if (!buffer) { | 1155 if (!buffer) { |
| 1136 *buflen = len; | 1156 *buflen = len; |
| 1137 } else if (*buflen >= len) { | 1157 } else if (*buflen >= len) { |
| 1138 memcpy(buffer, utf16Name.c_str(), len); | 1158 memcpy(buffer, utf16Name.c_str(), len); |
| 1139 *buflen = len; | 1159 *buflen = len; |
| 1140 } else { | 1160 } else { |
| 1141 *buflen = -1; | 1161 *buflen = -1; |
| 1142 } | 1162 } |
| 1143 return (FPDF_DEST)pDestObj; | 1163 return (FPDF_DEST)pDestObj; |
| 1144 } | 1164 } |
| OLD | NEW |