Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #include <sys/time.h> | 1 #include <sys/time.h> |
| 2 #include <sys/resource.h> | 2 #include <sys/resource.h> |
| 3 | 3 |
| 4 #include "SkCanvas.h" | 4 #include "SkCanvas.h" |
| 5 #include "SkCommandLineFlags.h" | 5 #include "SkCommandLineFlags.h" |
| 6 #include "SkData.h" | 6 #include "SkData.h" |
| 7 #include "SkForceLinking.h" | 7 #include "SkForceLinking.h" |
| 8 #include "SkGraphics.h" | 8 #include "SkGraphics.h" |
| 9 #include "SkImageDecoder.h" | 9 #include "SkImageDecoder.h" |
| 10 #include "SkImageEncoder.h" | 10 #include "SkImageEncoder.h" |
| 11 #include "SkImageInfo.h" | 11 #include "SkImageInfo.h" |
| 12 #include "SkStream.h" | 12 #include "SkStream.h" |
| 13 #include "SkSurface.h" | 13 #include "SkSurface.h" |
| 14 | 14 |
| 15 # | |
|
jcgregorio
2014/09/09 19:19:11
stray?
humper
2014/09/09 19:21:23
Acknowledged.
humper
2014/09/09 19:21:23
Done.
| |
| 15 #include "seccomp_bpf.h" | 16 #include "seccomp_bpf.h" |
| 16 | 17 |
| 17 __SK_FORCE_IMAGE_DECODER_LINKING; | 18 __SK_FORCE_IMAGE_DECODER_LINKING; |
| 18 | 19 |
| 19 DEFINE_string(out, "", "Filename of the PNG to write to."); | 20 DEFINE_string(out, "", "Filename of the PNG to write to."); |
| 20 DEFINE_string(source, "", "Filename of the source image."); | 21 DEFINE_string(source, "", "Filename of the source image."); |
| 21 | 22 |
| 22 // Defined in template.cpp. | 23 // Defined in template.cpp. |
| 23 extern SkBitmap source; | 24 extern SkBitmap source; |
| 24 | 25 |
| 25 static bool install_syscall_filter() { | 26 static bool install_syscall_filter() { |
| 27 | |
| 28 #ifdef SK_BUILD_FOR_UNIX | |
| 26 struct sock_filter filter[] = { | 29 struct sock_filter filter[] = { |
| 27 /* Grab the system call number. */ | 30 /* Grab the system call number. */ |
| 28 EXAMINE_SYSCALL, | 31 EXAMINE_SYSCALL, |
| 29 /* List allowed syscalls. */ | 32 /* List allowed syscalls. */ |
| 30 ALLOW_SYSCALL(exit_group), | 33 ALLOW_SYSCALL(exit_group), |
| 31 ALLOW_SYSCALL(exit), | 34 ALLOW_SYSCALL(exit), |
| 32 ALLOW_SYSCALL(fstat), | 35 ALLOW_SYSCALL(fstat), |
| 33 ALLOW_SYSCALL(read), | 36 ALLOW_SYSCALL(read), |
| 34 ALLOW_SYSCALL(write), | 37 ALLOW_SYSCALL(write), |
| 35 ALLOW_SYSCALL(close), | 38 ALLOW_SYSCALL(close), |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 57 perror("prctl(SECCOMP)"); | 60 perror("prctl(SECCOMP)"); |
| 58 goto failed; | 61 goto failed; |
| 59 } | 62 } |
| 60 return true; | 63 return true; |
| 61 | 64 |
| 62 failed: | 65 failed: |
| 63 if (errno == EINVAL) { | 66 if (errno == EINVAL) { |
| 64 fprintf(stderr, "SECCOMP_FILTER is not available. :(\n"); | 67 fprintf(stderr, "SECCOMP_FILTER is not available. :(\n"); |
| 65 } | 68 } |
| 66 return false; | 69 return false; |
| 70 #else | |
| 71 return true; | |
| 72 #endif /* SK_BUILD_FOR_UNIX */ | |
| 67 } | 73 } |
| 68 | 74 |
| 69 static void setLimits() { | 75 static void setLimits() { |
| 70 struct rlimit n; | 76 struct rlimit n; |
| 71 | 77 |
| 72 // Limit to 5 seconds of CPU. | 78 // Limit to 5 seconds of CPU. |
| 73 n.rlim_cur = 5; | 79 n.rlim_cur = 5; |
| 74 n.rlim_max = 5; | 80 n.rlim_max = 5; |
| 75 if (setrlimit(RLIMIT_CPU, &n)) { | 81 if (setrlimit(RLIMIT_CPU, &n)) { |
| 76 perror("setrlimit(RLIMIT_CPU)"); | 82 perror("setrlimit(RLIMIT_CPU)"); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 | 123 |
| 118 // Write out the image as a PNG. | 124 // Write out the image as a PNG. |
| 119 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); | 125 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); |
| 120 SkAutoTUnref<SkData> data(image->encode(SkImageEncoder::kPNG_Type, 100)); | 126 SkAutoTUnref<SkData> data(image->encode(SkImageEncoder::kPNG_Type, 100)); |
| 121 if (NULL == data.get()) { | 127 if (NULL == data.get()) { |
| 122 printf("Failed to encode\n"); | 128 printf("Failed to encode\n"); |
| 123 exit(1); | 129 exit(1); |
| 124 } | 130 } |
| 125 stream.write(data->data(), data->size()); | 131 stream.write(data->data(), data->size()); |
| 126 } | 132 } |
| OLD | NEW |