OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium 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 #include <limits.h> | 5 #include <limits.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <list> | 10 #include <list> |
11 #include <sstream> | 11 #include <sstream> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "../fpdfsdk/include/fpdf_dataavail.h" | 16 #include "../fpdfsdk/include/fpdf_dataavail.h" |
17 #include "../fpdfsdk/include/fpdf_ext.h" | 17 #include "../fpdfsdk/include/fpdf_ext.h" |
18 #include "../fpdfsdk/include/fpdfformfill.h" | 18 #include "../fpdfsdk/include/fpdfformfill.h" |
19 #include "../fpdfsdk/include/fpdftext.h" | 19 #include "../fpdfsdk/include/fpdftext.h" |
20 #include "../fpdfsdk/include/fpdfview.h" | 20 #include "../fpdfsdk/include/fpdfview.h" |
21 #include "../core/include/fxcrt/fx_system.h" | 21 #include "../core/include/fxcrt/fx_system.h" |
22 #include "v8/include/v8.h" | 22 #include "v8/include/v8.h" |
23 #include "v8/include/libplatform/libplatform.h" | |
23 | 24 |
24 #ifdef _WIN32 | 25 #ifdef _WIN32 |
25 #define snprintf _snprintf | 26 #define snprintf _snprintf |
26 #define PATH_SEPARATOR '\\' | 27 #define PATH_SEPARATOR '\\' |
27 #else | 28 #else |
28 #define PATH_SEPARATOR '/' | 29 #define PATH_SEPARATOR '/' |
29 #endif | 30 #endif |
30 | 31 |
31 enum OutputFormat { | 32 enum OutputFormat { |
32 OUTPUT_NONE, | 33 OUTPUT_NONE, |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 printf("--scale=<number> - scale output size by number (e.g. 0.5)\n"); | 491 printf("--scale=<number> - scale output size by number (e.g. 0.5)\n"); |
491 printf("--ppm - write page images <pdf-name>.<page-number>.ppm\n"); | 492 printf("--ppm - write page images <pdf-name>.<page-number>.ppm\n"); |
492 #ifdef _WIN32 | 493 #ifdef _WIN32 |
493 printf("--bmp - write page images <pdf-name>.<page-number>.bmp\n"); | 494 printf("--bmp - write page images <pdf-name>.<page-number>.bmp\n"); |
494 printf("--emf - write page meta files <pdf-name>.<page-number>.emf\n"); | 495 printf("--emf - write page meta files <pdf-name>.<page-number>.emf\n"); |
495 #endif | 496 #endif |
496 return 1; | 497 return 1; |
497 } | 498 } |
498 | 499 |
499 v8::V8::InitializeICU(); | 500 v8::V8::InitializeICU(); |
501 v8::Platform* platform = v8::platform::CreateDefaultPlatform(); | |
502 v8::V8::InitializePlatform(platform); | |
503 v8::V8::Initialize(); | |
500 | 504 |
501 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 505 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
502 v8::StartupData natives; | 506 v8::StartupData natives; |
503 v8::StartupData snapshot; | 507 v8::StartupData snapshot; |
504 if (!GetExternalData(options, "natives_blob.bin", &natives) || | 508 if (!GetExternalData(options, "natives_blob.bin", &natives) || |
505 !GetExternalData(options, "snapshot_blob.bin", &snapshot)) { | 509 !GetExternalData(options, "snapshot_blob.bin", &snapshot)) { |
506 return 1; | 510 return 1; |
507 } | 511 } |
508 v8::V8::SetNativesDataBlob(&natives); | 512 v8::V8::SetNativesDataBlob(&natives); |
509 v8::V8::SetSnapshotDataBlob(&snapshot); | 513 v8::V8::SetSnapshotDataBlob(&snapshot); |
(...skipping 12 matching lines...) Expand all Loading... | |
522 std::string filename = files.front(); | 526 std::string filename = files.front(); |
523 files.pop_front(); | 527 files.pop_front(); |
524 size_t file_length = 0; | 528 size_t file_length = 0; |
525 char* file_contents = GetFileContents(filename.c_str(), &file_length); | 529 char* file_contents = GetFileContents(filename.c_str(), &file_length); |
526 if (!file_contents) | 530 if (!file_contents) |
527 continue; | 531 continue; |
528 RenderPdf(filename, file_contents, file_length, options); | 532 RenderPdf(filename, file_contents, file_length, options); |
529 free(file_contents); | 533 free(file_contents); |
530 } | 534 } |
531 | 535 |
532 FPDF_DestroyLibrary(); | 536 FPDF_DestroyLibrary(); |
Will Harris
2015/02/04 23:56:45
is a V8:Dispose() needed here?
jam
2015/02/04 23:59:07
no idea, i'm just moving code from the other file
| |
537 v8::V8::ShutdownPlatform(); | |
538 delete platform; | |
533 | 539 |
534 return 0; | 540 return 0; |
535 } | 541 } |
OLD | NEW |