Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: fpdfsdk/fpdfview.cpp

Issue 2180443002: Use actual type instead CFX_Deletable (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: one more fix Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/fpdf_progressive.cpp ('k') | fpdfsdk/fsdk_pauseadapter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" 11 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 12 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
14 #include "core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h"
14 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" 15 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h"
15 #include "core/fpdfapi/include/cpdf_modulemgr.h" 16 #include "core/fpdfapi/include/cpdf_modulemgr.h"
17 #include "core/fpdfapi/include/cpdf_pagerendercontext.h"
16 #include "core/fxcodec/include/fx_codec.h" 18 #include "core/fxcodec/include/fx_codec.h"
19 #include "core/fxcrt/include/fx_memory.h"
17 #include "core/fxcrt/include/fx_safe_types.h" 20 #include "core/fxcrt/include/fx_safe_types.h"
18 #include "core/fxge/include/fx_ge.h" 21 #include "core/fxge/include/fx_ge.h"
19 #include "fpdfsdk/include/fsdk_define.h" 22 #include "fpdfsdk/include/fsdk_define.h"
20 #include "fpdfsdk/include/fsdk_mgr.h" 23 #include "fpdfsdk/include/fsdk_mgr.h"
21 #include "fpdfsdk/include/fsdk_rendercontext.h" 24 #include "fpdfsdk/include/fsdk_pauseadapter.h"
22 #include "fpdfsdk/javascript/ijs_runtime.h" 25 #include "fpdfsdk/javascript/ijs_runtime.h"
23 #include "public/fpdf_ext.h" 26 #include "public/fpdf_ext.h"
24 #include "public/fpdf_progressive.h" 27 #include "public/fpdf_progressive.h"
25 #include "third_party/base/numerics/safe_conversions_impl.h" 28 #include "third_party/base/numerics/safe_conversions_impl.h"
26 29
27 #ifdef PDF_ENABLE_XFA 30 #ifdef PDF_ENABLE_XFA
28 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h" 31 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h"
29 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" 32 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
30 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" 33 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h"
31 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" 34 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h"
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 int start_x, 558 int start_x,
556 int start_y, 559 int start_y,
557 int size_x, 560 int size_x,
558 int size_y, 561 int size_y,
559 int rotate, 562 int rotate,
560 int flags) { 563 int flags) {
561 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); 564 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
562 if (!pPage) 565 if (!pPage)
563 return; 566 return;
564 567
565 CRenderContext* pContext = new CRenderContext; 568 CPDF_PageRenderContext* pContext = new CPDF_PageRenderContext;
566 pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext)); 569 pPage->SetRenderContext(WrapUnique(pContext));
567 570
568 CFX_DIBitmap* pBitmap = nullptr; 571 CFX_DIBitmap* pBitmap = nullptr;
569 FX_BOOL bBackgroundAlphaNeeded = pPage->BackgroundAlphaNeeded(); 572 FX_BOOL bBackgroundAlphaNeeded = pPage->BackgroundAlphaNeeded();
570 FX_BOOL bHasImageMask = pPage->HasImageMask(); 573 FX_BOOL bHasImageMask = pPage->HasImageMask();
571 if (bBackgroundAlphaNeeded || bHasImageMask) { 574 if (bBackgroundAlphaNeeded || bHasImageMask) {
572 pBitmap = new CFX_DIBitmap; 575 pBitmap = new CFX_DIBitmap;
573 pBitmap->Create(size_x, size_y, FXDIB_Argb); 576 pBitmap->Create(size_x, size_y, FXDIB_Argb);
574 pBitmap->Clear(0x00ffffff); 577 pBitmap->Clear(0x00ffffff);
575 CFX_FxgeDevice* pDevice = new CFX_FxgeDevice; 578 CFX_FxgeDevice* pDevice = new CFX_FxgeDevice;
576 pContext->m_pDevice = pDevice; 579 pContext->m_pDevice.reset(pDevice);
577 pDevice->Attach(pBitmap, false, nullptr, false); 580 pDevice->Attach(pBitmap, false, nullptr, false);
578 } else { 581 } else {
579 pContext->m_pDevice = new CFX_WindowsDevice(dc); 582 pContext->m_pDevice.reset(new CFX_WindowsDevice(dc));
580 } 583 }
581 584
582 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, 585 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
583 rotate, flags, TRUE, nullptr); 586 rotate, flags, TRUE, nullptr);
584 587
585 if (bBackgroundAlphaNeeded || bHasImageMask) { 588 if (bBackgroundAlphaNeeded || bHasImageMask) {
586 if (pBitmap) { 589 if (pBitmap) {
587 CFX_WindowsDevice WinDC(dc); 590 CFX_WindowsDevice WinDC(dc);
588 591
589 if (WinDC.GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) { 592 if (WinDC.GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) {
590 CFX_DIBitmap* pDst = new CFX_DIBitmap; 593 CFX_DIBitmap* pDst = new CFX_DIBitmap;
591 int pitch = pBitmap->GetPitch(); 594 int pitch = pBitmap->GetPitch();
592 pDst->Create(size_x, size_y, FXDIB_Rgb32); 595 pDst->Create(size_x, size_y, FXDIB_Rgb32);
593 FXSYS_memset(pDst->GetBuffer(), -1, pitch * size_y); 596 FXSYS_memset(pDst->GetBuffer(), -1, pitch * size_y);
594 pDst->CompositeBitmap(0, 0, size_x, size_y, pBitmap, 0, 0, 597 pDst->CompositeBitmap(0, 0, size_x, size_y, pBitmap, 0, 0,
595 FXDIB_BLEND_NORMAL, nullptr, FALSE, nullptr); 598 FXDIB_BLEND_NORMAL, nullptr, FALSE, nullptr);
596 WinDC.StretchDIBits(pDst, 0, 0, size_x, size_y); 599 WinDC.StretchDIBits(pDst, 0, 0, size_x, size_y);
597 delete pDst; 600 delete pDst;
598 } else { 601 } else {
599 WinDC.SetDIBits(pBitmap, 0, 0); 602 WinDC.SetDIBits(pBitmap, 0, 0);
600 } 603 }
601 } 604 }
602 } 605 }
603 if (bBackgroundAlphaNeeded || bHasImageMask) 606 if (bBackgroundAlphaNeeded || bHasImageMask)
604 delete pBitmap; 607 delete pBitmap;
605 608
606 pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>()); 609 pPage->SetRenderContext(std::unique_ptr<CPDF_PageRenderContext>());
607 } 610 }
608 #endif // defined(_WIN32) 611 #endif // defined(_WIN32)
609 612
610 DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, 613 DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
611 FPDF_PAGE page, 614 FPDF_PAGE page,
612 int start_x, 615 int start_x,
613 int start_y, 616 int start_y,
614 int size_x, 617 int size_x,
615 int size_y, 618 int size_y,
616 int rotate, 619 int rotate,
617 int flags) { 620 int flags) {
618 if (!bitmap) 621 if (!bitmap)
619 return; 622 return;
620 623
621 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); 624 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
622 if (!pPage) 625 if (!pPage)
623 return; 626 return;
624 627
625 CRenderContext* pContext = new CRenderContext; 628 CPDF_PageRenderContext* pContext = new CPDF_PageRenderContext;
626 pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext)); 629 pPage->SetRenderContext(WrapUnique(pContext));
627 CFX_FxgeDevice* pDevice = new CFX_FxgeDevice; 630 CFX_FxgeDevice* pDevice = new CFX_FxgeDevice;
628 pContext->m_pDevice = pDevice; 631 pContext->m_pDevice.reset(pDevice);
629 CFX_DIBitmap* pBitmap = CFXBitmapFromFPDFBitmap(bitmap); 632 CFX_DIBitmap* pBitmap = CFXBitmapFromFPDFBitmap(bitmap);
630 pDevice->Attach(pBitmap, !!(flags & FPDF_REVERSE_BYTE_ORDER), nullptr, false); 633 pDevice->Attach(pBitmap, !!(flags & FPDF_REVERSE_BYTE_ORDER), nullptr, false);
631 634
632 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y, 635 FPDF_RenderPage_Retail(pContext, page, start_x, start_y, size_x, size_y,
633 rotate, flags, TRUE, nullptr); 636 rotate, flags, TRUE, nullptr);
634 637
635 pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>()); 638 pPage->SetRenderContext(std::unique_ptr<CPDF_PageRenderContext>());
636 } 639 }
637 640
638 #ifdef _SKIA_SUPPORT_ 641 #ifdef _SKIA_SUPPORT_
639 DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page, 642 DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page,
640 int size_x, 643 int size_x,
641 int size_y) { 644 int size_y) {
642 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); 645 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
643 if (!pPage) 646 if (!pPage)
644 return nullptr; 647 return nullptr;
645 648
646 CRenderContext* pContext = new CRenderContext; 649 CPDF_PageRenderContext* pContext = new CPDF_PageRenderContext;
647 pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>(pContext)); 650 pPage->SetRenderContext(WrapUnique(pContext));
648 CFX_FxgeDevice* skDevice = new CFX_FxgeDevice; 651 CFX_FxgeDevice* skDevice = new CFX_FxgeDevice;
649 FPDF_RECORDER recorder = skDevice->CreateRecorder(size_x, size_y); 652 FPDF_RECORDER recorder = skDevice->CreateRecorder(size_x, size_y);
650 pContext->m_pDevice = skDevice; 653 pContext->m_pDevice.reset(skDevice);
651 FPDF_RenderPage_Retail(pContext, page, 0, 0, size_x, size_y, 0, 0, TRUE, 654 FPDF_RenderPage_Retail(pContext, page, 0, 0, size_x, size_y, 0, 0, TRUE,
652 nullptr); 655 nullptr);
653 pPage->SetRenderContext(std::unique_ptr<CFX_Deletable>()); 656 pPage->SetRenderContext(std::unique_ptr<CPDF_PageRenderContext>());
654 return recorder; 657 return recorder;
655 } 658 }
656 #endif 659 #endif
657 660
658 DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) { 661 DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) {
659 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); 662 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
660 if (!page) 663 if (!page)
661 return; 664 return;
662 #ifdef PDF_ENABLE_XFA 665 #ifdef PDF_ENABLE_XFA
663 pPage->Release(); 666 pPage->Release();
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 } 823 }
821 824
822 DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap) { 825 DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap) {
823 return bitmap ? CFXBitmapFromFPDFBitmap(bitmap)->GetPitch() : 0; 826 return bitmap ? CFXBitmapFromFPDFBitmap(bitmap)->GetPitch() : 0;
824 } 827 }
825 828
826 DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap) { 829 DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap) {
827 delete CFXBitmapFromFPDFBitmap(bitmap); 830 delete CFXBitmapFromFPDFBitmap(bitmap);
828 } 831 }
829 832
830 void FPDF_RenderPage_Retail(CRenderContext* pContext, 833 void FPDF_RenderPage_Retail(CPDF_PageRenderContext* pContext,
831 FPDF_PAGE page, 834 FPDF_PAGE page,
832 int start_x, 835 int start_x,
833 int start_y, 836 int start_y,
834 int size_x, 837 int size_x,
835 int size_y, 838 int size_y,
836 int rotate, 839 int rotate,
837 int flags, 840 int flags,
838 FX_BOOL bNeedToRestore, 841 FX_BOOL bNeedToRestore,
839 IFSDK_PAUSE_Adapter* pause) { 842 IFSDK_PAUSE_Adapter* pause) {
840 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); 843 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
841 if (!pPage) 844 if (!pPage)
842 return; 845 return;
843 846
844 if (!pContext->m_pOptions) 847 if (!pContext->m_pOptions)
845 pContext->m_pOptions = new CPDF_RenderOptions; 848 pContext->m_pOptions.reset(new CPDF_RenderOptions);
846 849
847 if (flags & FPDF_LCD_TEXT) 850 if (flags & FPDF_LCD_TEXT)
848 pContext->m_pOptions->m_Flags |= RENDER_CLEARTYPE; 851 pContext->m_pOptions->m_Flags |= RENDER_CLEARTYPE;
849 else 852 else
850 pContext->m_pOptions->m_Flags &= ~RENDER_CLEARTYPE; 853 pContext->m_pOptions->m_Flags &= ~RENDER_CLEARTYPE;
851 if (flags & FPDF_NO_NATIVETEXT) 854 if (flags & FPDF_NO_NATIVETEXT)
852 pContext->m_pOptions->m_Flags |= RENDER_NO_NATIVETEXT; 855 pContext->m_pOptions->m_Flags |= RENDER_NO_NATIVETEXT;
853 if (flags & FPDF_RENDER_LIMITEDIMAGECACHE) 856 if (flags & FPDF_RENDER_LIMITEDIMAGECACHE)
854 pContext->m_pOptions->m_Flags |= RENDER_LIMITEDIMAGECACHE; 857 pContext->m_pOptions->m_Flags |= RENDER_LIMITEDIMAGECACHE;
855 if (flags & FPDF_RENDER_FORCEHALFTONE) 858 if (flags & FPDF_RENDER_FORCEHALFTONE)
(...skipping 18 matching lines...) Expand all
874 pContext->m_pOptions->m_pOCContext = 877 pContext->m_pOptions->m_pOCContext =
875 new CPDF_OCContext(pPage->m_pDocument, usage); 878 new CPDF_OCContext(pPage->m_pDocument, usage);
876 879
877 CFX_Matrix matrix; 880 CFX_Matrix matrix;
878 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); 881 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
879 882
880 pContext->m_pDevice->SaveState(); 883 pContext->m_pDevice->SaveState();
881 pContext->m_pDevice->SetClip_Rect( 884 pContext->m_pDevice->SetClip_Rect(
882 FX_RECT(start_x, start_y, start_x + size_x, start_y + size_y)); 885 FX_RECT(start_x, start_y, start_x + size_x, start_y + size_y));
883 886
884 pContext->m_pContext = new CPDF_RenderContext(pPage); 887 pContext->m_pContext.reset(new CPDF_RenderContext(pPage));
885 pContext->m_pContext->AppendLayer(pPage, &matrix); 888 pContext->m_pContext->AppendLayer(pPage, &matrix);
886 889
887 if (flags & FPDF_ANNOT) { 890 if (flags & FPDF_ANNOT) {
888 pContext->m_pAnnots = new CPDF_AnnotList(pPage); 891 pContext->m_pAnnots.reset(new CPDF_AnnotList(pPage));
889 FX_BOOL bPrinting = pContext->m_pDevice->GetDeviceClass() != FXDC_DISPLAY; 892 FX_BOOL bPrinting = pContext->m_pDevice->GetDeviceClass() != FXDC_DISPLAY;
890 pContext->m_pAnnots->DisplayAnnots(pPage, pContext->m_pContext, bPrinting, 893 pContext->m_pAnnots->DisplayAnnots(pPage, pContext->m_pContext.get(),
891 &matrix, TRUE, nullptr); 894 bPrinting, &matrix, TRUE, nullptr);
892 } 895 }
893 896
894 pContext->m_pRenderer = new CPDF_ProgressiveRenderer( 897 pContext->m_pRenderer.reset(new CPDF_ProgressiveRenderer(
895 pContext->m_pContext, pContext->m_pDevice, pContext->m_pOptions); 898 pContext->m_pContext.get(), pContext->m_pDevice.get(),
899 pContext->m_pOptions.get()));
896 pContext->m_pRenderer->Start(pause); 900 pContext->m_pRenderer->Start(pause);
897 if (bNeedToRestore) 901 if (bNeedToRestore)
898 pContext->m_pDevice->RestoreState(false); 902 pContext->m_pDevice->RestoreState(false);
899 } 903 }
900 904
901 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, 905 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
902 int page_index, 906 int page_index,
903 double* width, 907 double* width,
904 double* height) { 908 double* height) {
905 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document); 909 UnderlyingDocumentType* pDoc = UnderlyingFromFPDFDocument(document);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 if (!buffer) { 1123 if (!buffer) {
1120 *buflen = len; 1124 *buflen = len;
1121 } else if (*buflen >= len) { 1125 } else if (*buflen >= len) {
1122 memcpy(buffer, utf16Name.c_str(), len); 1126 memcpy(buffer, utf16Name.c_str(), len);
1123 *buflen = len; 1127 *buflen = len;
1124 } else { 1128 } else {
1125 *buflen = -1; 1129 *buflen = -1;
1126 } 1130 }
1127 return (FPDF_DEST)pDestObj; 1131 return (FPDF_DEST)pDestObj;
1128 } 1132 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdf_progressive.cpp ('k') | fpdfsdk/fsdk_pauseadapter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698