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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 pPage->SetPrivateData((void*)1, pContext, DropContext); | 542 pPage->SetPrivateData((void*)1, pContext, DropContext); |
543 | 543 |
544 #if !defined(_WIN32_WCE) | 544 #if !defined(_WIN32_WCE) |
545 CFX_DIBitmap* pBitmap = nullptr; | 545 CFX_DIBitmap* pBitmap = nullptr; |
546 FX_BOOL bBackgroundAlphaNeeded = pPage->BackgroundAlphaNeeded(); | 546 FX_BOOL bBackgroundAlphaNeeded = pPage->BackgroundAlphaNeeded(); |
547 FX_BOOL bHasImageMask = pPage->HasImageMask(); | 547 FX_BOOL bHasImageMask = pPage->HasImageMask(); |
548 if (bBackgroundAlphaNeeded || bHasImageMask) { | 548 if (bBackgroundAlphaNeeded || bHasImageMask) { |
549 pBitmap = new CFX_DIBitmap; | 549 pBitmap = new CFX_DIBitmap; |
550 pBitmap->Create(size_x, size_y, FXDIB_Argb); | 550 pBitmap->Create(size_x, size_y, FXDIB_Argb); |
551 pBitmap->Clear(0x00ffffff); | 551 pBitmap->Clear(0x00ffffff); |
552 #ifdef _SKIA_SUPPORT_ | |
553 pContext->m_pDevice = new CFX_SkiaDevice; | |
554 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap); | |
555 #else | |
556 pContext->m_pDevice = new CFX_FxgeDevice; | 552 pContext->m_pDevice = new CFX_FxgeDevice; |
557 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap); | 553 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)pBitmap); |
558 #endif | |
559 } else { | 554 } else { |
560 pContext->m_pDevice = new CFX_WindowsDevice(dc); | 555 pContext->m_pDevice = new CFX_WindowsDevice(dc); |
561 } | 556 } |
562 | 557 |
563 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, | 558 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, |
564 rotate, flags, TRUE, NULL); | 559 rotate, flags, TRUE, NULL); |
565 | 560 |
566 if (bBackgroundAlphaNeeded || bHasImageMask) { | 561 if (bBackgroundAlphaNeeded || bHasImageMask) { |
567 if (pBitmap) { | 562 if (pBitmap) { |
568 CFX_WindowsDevice WinDC(dc); | 563 CFX_WindowsDevice WinDC(dc); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 int size_y, | 636 int size_y, |
642 int rotate, | 637 int rotate, |
643 int flags) { | 638 int flags) { |
644 if (!bitmap) | 639 if (!bitmap) |
645 return; | 640 return; |
646 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 641 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
647 if (!pPage) | 642 if (!pPage) |
648 return; | 643 return; |
649 CRenderContext* pContext = new CRenderContext; | 644 CRenderContext* pContext = new CRenderContext; |
650 pPage->SetPrivateData((void*)1, pContext, DropContext); | 645 pPage->SetPrivateData((void*)1, pContext, DropContext); |
651 #ifdef _SKIA_SUPPORT_ | |
652 pContext->m_pDevice = new CFX_SkiaDevice(); | |
653 | |
654 if (flags & FPDF_REVERSE_BYTE_ORDER) | |
655 ((CFX_SkiaDevice*)pContext->m_pDevice) | |
656 ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); | |
657 else | |
658 ((CFX_SkiaDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); | |
659 #else | |
660 pContext->m_pDevice = new CFX_FxgeDevice; | 646 pContext->m_pDevice = new CFX_FxgeDevice; |
661 | 647 |
662 if (flags & FPDF_REVERSE_BYTE_ORDER) | 648 if (flags & FPDF_REVERSE_BYTE_ORDER) |
663 ((CFX_FxgeDevice*)pContext->m_pDevice) | 649 ((CFX_FxgeDevice*)pContext->m_pDevice) |
664 ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); | 650 ->Attach((CFX_DIBitmap*)bitmap, 0, TRUE); |
665 else | 651 else |
666 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); | 652 ((CFX_FxgeDevice*)pContext->m_pDevice)->Attach((CFX_DIBitmap*)bitmap); |
667 #endif | |
668 | 653 |
669 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, | 654 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, |
670 rotate, flags, TRUE, NULL); | 655 rotate, flags, TRUE, NULL); |
671 | 656 |
672 delete pContext; | 657 delete pContext; |
673 pPage->RemovePrivateData((void*)1); | 658 pPage->RemovePrivateData((void*)1); |
674 } | 659 } |
675 | 660 |
676 #ifdef _SKIA_SUPPORT_ | 661 #ifdef _SKIA_SUPPORT_ |
677 DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page, | 662 DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page, |
678 int size_x, | 663 int size_x, |
679 int size_y) { | 664 int size_y) { |
680 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 665 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
681 if (!pPage) | 666 if (!pPage) |
682 return nullptr; | 667 return nullptr; |
683 std::unique_ptr<CRenderContext> pContext(new CRenderContext); | 668 std::unique_ptr<CRenderContext> pContext(new CRenderContext); |
684 pPage->SetPrivateData((void*)1, pContext.get(), DropContext); | 669 pPage->SetPrivateData((void*)1, pContext.get(), DropContext); |
685 CFX_SkiaDevice* skDevice = new CFX_SkiaDevice(); | 670 CFX_FxgeDevice* skDevice = new CFX_FxgeDevice; |
686 FPDF_RECORDER recorder = skDevice->CreateRecorder(size_x, size_y); | 671 FPDF_RECORDER recorder = skDevice->CreateRecorder(size_x, size_y); |
687 pContext->m_pDevice = skDevice; | 672 pContext->m_pDevice = skDevice; |
688 | 673 |
689 FPDF_RenderPage_Retail(pContext.get(), page, 0, 0, size_x, size_y, 0, 0, TRUE, | 674 FPDF_RenderPage_Retail(pContext.get(), page, 0, 0, size_x, size_y, 0, 0, TRUE, |
690 NULL); | 675 NULL); |
691 pPage->RemovePrivateData((void*)1); | 676 pPage->RemovePrivateData((void*)1); |
692 return recorder; | 677 return recorder; |
693 } | 678 } |
694 #endif | 679 #endif |
695 | 680 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 } | 813 } |
829 | 814 |
830 DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, | 815 DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, |
831 int left, | 816 int left, |
832 int top, | 817 int top, |
833 int width, | 818 int width, |
834 int height, | 819 int height, |
835 FPDF_DWORD color) { | 820 FPDF_DWORD color) { |
836 if (!bitmap) | 821 if (!bitmap) |
837 return; | 822 return; |
838 #ifdef _SKIA_SUPPORT_ | |
839 CFX_SkiaDevice device; | |
840 #else | |
841 CFX_FxgeDevice device; | 823 CFX_FxgeDevice device; |
842 #endif | |
843 device.Attach((CFX_DIBitmap*)bitmap); | 824 device.Attach((CFX_DIBitmap*)bitmap); |
844 if (!((CFX_DIBitmap*)bitmap)->HasAlpha()) | 825 if (!((CFX_DIBitmap*)bitmap)->HasAlpha()) |
845 color |= 0xFF000000; | 826 color |= 0xFF000000; |
846 FX_RECT rect(left, top, left + width, top + height); | 827 FX_RECT rect(left, top, left + width, top + height); |
847 device.FillRect(&rect, color); | 828 device.FillRect(&rect, color); |
848 } | 829 } |
849 | 830 |
850 DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap) { | 831 DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap) { |
851 return bitmap ? ((CFX_DIBitmap*)bitmap)->GetBuffer() : nullptr; | 832 return bitmap ? ((CFX_DIBitmap*)bitmap)->GetBuffer() : nullptr; |
852 } | 833 } |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 if (!buffer) { | 1143 if (!buffer) { |
1163 *buflen = len; | 1144 *buflen = len; |
1164 } else if (*buflen >= len) { | 1145 } else if (*buflen >= len) { |
1165 memcpy(buffer, utf16Name.c_str(), len); | 1146 memcpy(buffer, utf16Name.c_str(), len); |
1166 *buflen = len; | 1147 *buflen = len; |
1167 } else { | 1148 } else { |
1168 *buflen = -1; | 1149 *buflen = -1; |
1169 } | 1150 } |
1170 return (FPDF_DEST)pDestObj; | 1151 return (FPDF_DEST)pDestObj; |
1171 } | 1152 } |
OLD | NEW |