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> |
| 10 |
9 #include "core/include/fxcodec/fx_codec.h" | 11 #include "core/include/fxcodec/fx_codec.h" |
10 #include "core/include/fxcrt/fx_safe_types.h" | 12 #include "core/include/fxcrt/fx_safe_types.h" |
11 #include "fpdfsdk/include/fsdk_define.h" | 13 #include "fpdfsdk/include/fsdk_define.h" |
12 #include "fpdfsdk/include/fsdk_mgr.h" | 14 #include "fpdfsdk/include/fsdk_mgr.h" |
13 #include "fpdfsdk/include/fsdk_rendercontext.h" | 15 #include "fpdfsdk/include/fsdk_rendercontext.h" |
14 #include "fpdfsdk/include/javascript/IJavaScript.h" | 16 #include "fpdfsdk/include/javascript/IJavaScript.h" |
15 #include "public/fpdf_ext.h" | 17 #include "public/fpdf_ext.h" |
16 #include "public/fpdf_progressive.h" | 18 #include "public/fpdf_progressive.h" |
17 #include "third_party/base/nonstd_unique_ptr.h" | |
18 #include "third_party/base/numerics/safe_conversions_impl.h" | 19 #include "third_party/base/numerics/safe_conversions_impl.h" |
19 | 20 |
20 UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc) { | 21 UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc) { |
21 return static_cast<UnderlyingDocumentType*>(doc); | 22 return static_cast<UnderlyingDocumentType*>(doc); |
22 } | 23 } |
23 | 24 |
24 FPDF_DOCUMENT FPDFDocumentFromUnderlying(UnderlyingDocumentType* doc) { | 25 FPDF_DOCUMENT FPDFDocumentFromUnderlying(UnderlyingDocumentType* doc) { |
25 return static_cast<FPDF_DOCUMENT>(doc); | 26 return static_cast<FPDF_DOCUMENT>(doc); |
26 } | 27 } |
27 | 28 |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 page2device.Transform(((FX_FLOAT)page_x), ((FX_FLOAT)page_y), device_x_f, | 600 page2device.Transform(((FX_FLOAT)page_x), ((FX_FLOAT)page_y), device_x_f, |
600 device_y_f); | 601 device_y_f); |
601 | 602 |
602 *device_x = FXSYS_round(device_x_f); | 603 *device_x = FXSYS_round(device_x_f); |
603 *device_y = FXSYS_round(device_y_f); | 604 *device_y = FXSYS_round(device_y_f); |
604 } | 605 } |
605 | 606 |
606 DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, | 607 DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, |
607 int height, | 608 int height, |
608 int alpha) { | 609 int alpha) { |
609 nonstd::unique_ptr<CFX_DIBitmap> pBitmap(new CFX_DIBitmap); | 610 std::unique_ptr<CFX_DIBitmap> pBitmap(new CFX_DIBitmap); |
610 if (!pBitmap->Create(width, height, alpha ? FXDIB_Argb : FXDIB_Rgb32)) { | 611 if (!pBitmap->Create(width, height, alpha ? FXDIB_Argb : FXDIB_Rgb32)) { |
611 return NULL; | 612 return NULL; |
612 } | 613 } |
613 return pBitmap.release(); | 614 return pBitmap.release(); |
614 } | 615 } |
615 | 616 |
616 DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, | 617 DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, |
617 int height, | 618 int height, |
618 int format, | 619 int format, |
619 void* first_scan, | 620 void* first_scan, |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 if (!buffer) { | 904 if (!buffer) { |
904 *buflen = len; | 905 *buflen = len; |
905 } else if (*buflen >= len) { | 906 } else if (*buflen >= len) { |
906 memcpy(buffer, utf16Name.c_str(), len); | 907 memcpy(buffer, utf16Name.c_str(), len); |
907 *buflen = len; | 908 *buflen = len; |
908 } else { | 909 } else { |
909 *buflen = -1; | 910 *buflen = -1; |
910 } | 911 } |
911 return (FPDF_DEST)pDestObj; | 912 return (FPDF_DEST)pDestObj; |
912 } | 913 } |
OLD | NEW |