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

Side by Side Diff: fpdfsdk/fpdfview.cpp

Issue 2381723002: Replace std::unique_ptr.reset() with WrapUnique assignment. (Closed)
Patch Set: build Created 4 years, 2 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/fpdfdoc_unittest.cpp ('k') | fpdfsdk/fpdfxfa/fpdfxfa_app.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 #include <utility>
10 11
11 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" 12 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
14 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" 15 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h"
15 #include "core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h" 16 #include "core/fpdfapi/fpdf_render/include/cpdf_progressiverenderer.h"
16 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" 17 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h"
17 #include "core/fpdfapi/include/cpdf_modulemgr.h" 18 #include "core/fpdfapi/include/cpdf_modulemgr.h"
18 #include "core/fpdfapi/include/cpdf_pagerendercontext.h" 19 #include "core/fpdfapi/include/cpdf_pagerendercontext.h"
19 #include "core/fpdfdoc/include/cpdf_annotlist.h" 20 #include "core/fpdfdoc/include/cpdf_annotlist.h"
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 int size_y, 839 int size_y,
839 int rotate, 840 int rotate,
840 int flags, 841 int flags,
841 FX_BOOL bNeedToRestore, 842 FX_BOOL bNeedToRestore,
842 IFSDK_PAUSE_Adapter* pause) { 843 IFSDK_PAUSE_Adapter* pause) {
843 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); 844 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
844 if (!pPage) 845 if (!pPage)
845 return; 846 return;
846 847
847 if (!pContext->m_pOptions) 848 if (!pContext->m_pOptions)
848 pContext->m_pOptions.reset(new CPDF_RenderOptions); 849 pContext->m_pOptions = WrapUnique(new CPDF_RenderOptions);
849 850
850 if (flags & FPDF_LCD_TEXT) 851 if (flags & FPDF_LCD_TEXT)
851 pContext->m_pOptions->m_Flags |= RENDER_CLEARTYPE; 852 pContext->m_pOptions->m_Flags |= RENDER_CLEARTYPE;
852 else 853 else
853 pContext->m_pOptions->m_Flags &= ~RENDER_CLEARTYPE; 854 pContext->m_pOptions->m_Flags &= ~RENDER_CLEARTYPE;
854 if (flags & FPDF_NO_NATIVETEXT) 855 if (flags & FPDF_NO_NATIVETEXT)
855 pContext->m_pOptions->m_Flags |= RENDER_NO_NATIVETEXT; 856 pContext->m_pOptions->m_Flags |= RENDER_NO_NATIVETEXT;
856 if (flags & FPDF_RENDER_LIMITEDIMAGECACHE) 857 if (flags & FPDF_RENDER_LIMITEDIMAGECACHE)
857 pContext->m_pOptions->m_Flags |= RENDER_LIMITEDIMAGECACHE; 858 pContext->m_pOptions->m_Flags |= RENDER_LIMITEDIMAGECACHE;
858 if (flags & FPDF_RENDER_FORCEHALFTONE) 859 if (flags & FPDF_RENDER_FORCEHALFTONE)
(...skipping 18 matching lines...) Expand all
877 pContext->m_pOptions->m_pOCContext = 878 pContext->m_pOptions->m_pOCContext =
878 new CPDF_OCContext(pPage->m_pDocument, usage); 879 new CPDF_OCContext(pPage->m_pDocument, usage);
879 880
880 CFX_Matrix matrix; 881 CFX_Matrix matrix;
881 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate); 882 pPage->GetDisplayMatrix(matrix, start_x, start_y, size_x, size_y, rotate);
882 883
883 pContext->m_pDevice->SaveState(); 884 pContext->m_pDevice->SaveState();
884 pContext->m_pDevice->SetClip_Rect( 885 pContext->m_pDevice->SetClip_Rect(
885 FX_RECT(start_x, start_y, start_x + size_x, start_y + size_y)); 886 FX_RECT(start_x, start_y, start_x + size_x, start_y + size_y));
886 887
887 pContext->m_pContext.reset(new CPDF_RenderContext(pPage)); 888 pContext->m_pContext = WrapUnique(new CPDF_RenderContext(pPage));
888 pContext->m_pContext->AppendLayer(pPage, &matrix); 889 pContext->m_pContext->AppendLayer(pPage, &matrix);
889 890
890 if (flags & FPDF_ANNOT) { 891 if (flags & FPDF_ANNOT) {
891 pContext->m_pAnnots.reset(new CPDF_AnnotList(pPage)); 892 pContext->m_pAnnots = WrapUnique(new CPDF_AnnotList(pPage));
892 FX_BOOL bPrinting = pContext->m_pDevice->GetDeviceClass() != FXDC_DISPLAY; 893 FX_BOOL bPrinting = pContext->m_pDevice->GetDeviceClass() != FXDC_DISPLAY;
893 pContext->m_pAnnots->DisplayAnnots(pPage, pContext->m_pContext.get(), 894 pContext->m_pAnnots->DisplayAnnots(pPage, pContext->m_pContext.get(),
894 bPrinting, &matrix, FALSE, nullptr); 895 bPrinting, &matrix, FALSE, nullptr);
895 } 896 }
896 897
897 pContext->m_pRenderer.reset(new CPDF_ProgressiveRenderer( 898 pContext->m_pRenderer = WrapUnique(new CPDF_ProgressiveRenderer(
898 pContext->m_pContext.get(), pContext->m_pDevice.get(), 899 pContext->m_pContext.get(), pContext->m_pDevice.get(),
899 pContext->m_pOptions.get())); 900 pContext->m_pOptions.get()));
900 pContext->m_pRenderer->Start(pause); 901 pContext->m_pRenderer->Start(pause);
901 if (bNeedToRestore) 902 if (bNeedToRestore)
902 pContext->m_pDevice->RestoreState(false); 903 pContext->m_pDevice->RestoreState(false);
903 } 904 }
904 905
905 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, 906 DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document,
906 int page_index, 907 int page_index,
907 double* width, 908 double* width,
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 if (!buffer) { 1124 if (!buffer) {
1124 *buflen = len; 1125 *buflen = len;
1125 } else if (*buflen >= len) { 1126 } else if (*buflen >= len) {
1126 memcpy(buffer, utf16Name.c_str(), len); 1127 memcpy(buffer, utf16Name.c_str(), len);
1127 *buflen = len; 1128 *buflen = len;
1128 } else { 1129 } else {
1129 *buflen = -1; 1130 *buflen = -1;
1130 } 1131 }
1131 return (FPDF_DEST)pDestObj; 1132 return (FPDF_DEST)pDestObj;
1132 } 1133 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfdoc_unittest.cpp ('k') | fpdfsdk/fpdfxfa/fpdfxfa_app.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698