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

Side by Side Diff: experimental/webtry/main.cpp

Issue 638003008: Re-land ganesh checkbox. I needed to increase the size of the address (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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 | « no previous file | experimental/webtry/res/js/webtry.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include <sys/time.h> 1 #include <sys/time.h>
2 #include <sys/resource.h> 2 #include <sys/resource.h>
3 3
4 #include "GrContextFactory.h"
5
4 #include "SkCanvas.h" 6 #include "SkCanvas.h"
5 #include "SkCommandLineFlags.h" 7 #include "SkCommandLineFlags.h"
6 #include "SkData.h" 8 #include "SkData.h"
7 #include "SkForceLinking.h" 9 #include "SkForceLinking.h"
8 #include "SkGraphics.h" 10 #include "SkGraphics.h"
9 #include "SkImageDecoder.h" 11 #include "SkImageDecoder.h"
10 #include "SkImageEncoder.h" 12 #include "SkImageEncoder.h"
11 #include "SkImageInfo.h" 13 #include "SkImageInfo.h"
12 #include "SkOSFile.h" 14 #include "SkOSFile.h"
13 #include "SkStream.h" 15 #include "SkStream.h"
14 #include "SkSurface.h" 16 #include "SkSurface.h"
15 17
16 #include "seccomp_bpf.h" 18 #include "seccomp_bpf.h"
17 19
18 __SK_FORCE_IMAGE_DECODER_LINKING; 20 __SK_FORCE_IMAGE_DECODER_LINKING;
19 21
20 DEFINE_string(out, "", "Filename of the PNG to write to."); 22 DEFINE_string(out, "", "Filename of the PNG to write to.");
21 DEFINE_string(source, "", "Filename of the source image."); 23 DEFINE_string(source, "", "Filename of the source image.");
22 DEFINE_int32(width, 256, "Width of output image."); 24 DEFINE_int32(width, 256, "Width of output image.");
23 DEFINE_int32(height, 256, "Height of output image."); 25 DEFINE_int32(height, 256, "Height of output image.");
26 DEFINE_bool(gpu, false, "Use GPU (Mesa) rendering.");
24 27
25 // Defined in template.cpp. 28 // Defined in template.cpp.
26 extern SkBitmap source; 29 extern SkBitmap source;
27 30
28 static bool install_syscall_filter() { 31 static bool install_syscall_filter() {
29 32
30 #ifndef SK_UNSAFE_BUILD_DESKTOP_ONLY 33 #ifndef SK_UNSAFE_BUILD_DESKTOP_ONLY
31 struct sock_filter filter[] = { 34 struct sock_filter filter[] = {
32 /* Grab the system call number. */ 35 /* Grab the system call number. */
33 EXAMINE_SYSCALL, 36 EXAMINE_SYSCALL,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 static void setLimits() { 81 static void setLimits() {
79 struct rlimit n; 82 struct rlimit n;
80 83
81 // Limit to 5 seconds of CPU. 84 // Limit to 5 seconds of CPU.
82 n.rlim_cur = 5; 85 n.rlim_cur = 5;
83 n.rlim_max = 5; 86 n.rlim_max = 5;
84 if (setrlimit(RLIMIT_CPU, &n)) { 87 if (setrlimit(RLIMIT_CPU, &n)) {
85 perror("setrlimit(RLIMIT_CPU)"); 88 perror("setrlimit(RLIMIT_CPU)");
86 } 89 }
87 90
88 // Limit to 50M of Address space. 91 // Limit to 150M of Address space.
89 n.rlim_cur = 50000000; 92 n.rlim_cur = 150000000;
90 n.rlim_max = 50000000; 93 n.rlim_max = 150000000;
91 if (setrlimit(RLIMIT_AS, &n)) { 94 if (setrlimit(RLIMIT_AS, &n)) {
92 perror("setrlimit(RLIMIT_CPU)"); 95 perror("setrlimit(RLIMIT_CPU)");
93 } 96 }
94 } 97 }
95 98
96 extern void draw(SkCanvas* canvas); 99 extern void draw(SkCanvas* canvas);
97 100
98 int main(int argc, char** argv) { 101 int main(int argc, char** argv) {
99 SkCommandLineFlags::Parse(argc, argv); 102 SkCommandLineFlags::Parse(argc, argv);
100 SkAutoGraphics init; 103 SkAutoGraphics init;
(...skipping 11 matching lines...) Expand all
112 115
113 SkString sourcePath = SkOSPath::Join(sourceDir, FLAGS_source[0]); 116 SkString sourcePath = SkOSPath::Join(sourceDir, FLAGS_source[0]);
114 if (!SkImageDecoder::DecodeFile(sourcePath.c_str(), &source)) { 117 if (!SkImageDecoder::DecodeFile(sourcePath.c_str(), &source)) {
115 perror("Unable to read the source image."); 118 perror("Unable to read the source image.");
116 } 119 }
117 } 120 }
118 121
119 SkFILEWStream stream(FLAGS_out[0]); 122 SkFILEWStream stream(FLAGS_out[0]);
120 123
121 SkImageInfo info = SkImageInfo::MakeN32(FLAGS_width, FLAGS_height, kPremul_S kAlphaType); 124 SkImageInfo info = SkImageInfo::MakeN32(FLAGS_width, FLAGS_height, kPremul_S kAlphaType);
122 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); 125
123 SkCanvas* canvas = surface->getCanvas(); 126 SkCanvas* canvas;
127 SkAutoTUnref<SkSurface> surface;
128
129 GrContextFactory* grFactory = NULL;
130
131 if (FLAGS_gpu) {
132 GrContext::Options grContextOpts;
133 grFactory = new GrContextFactory(grContextOpts);
134 GrContext* gr = grFactory->get(GrContextFactory::kMESA_GLContextType);
135 surface.reset(SkSurface::NewRenderTarget(gr,info));
136 } else {
137 surface.reset(SkSurface::NewRaster(info));
138 }
139
140 canvas = surface->getCanvas();
124 141
125 setLimits(); 142 setLimits();
126 143
127 if (!install_syscall_filter()) { 144 if (!install_syscall_filter()) {
128 return 1; 145 return 1;
129 } 146 }
130 147
131 draw(canvas); 148 draw(canvas);
132 149
133 // Write out the image as a PNG. 150 // Write out the image as a PNG.
134 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); 151 SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
135 SkAutoTUnref<SkData> data(image->encode(SkImageEncoder::kPNG_Type, 100)); 152 SkAutoTUnref<SkData> data(image->encode(SkImageEncoder::kPNG_Type, 100));
136 if (NULL == data.get()) { 153 if (NULL == data.get()) {
137 printf("Failed to encode\n"); 154 printf("Failed to encode\n");
138 exit(1); 155 exit(1);
139 } 156 }
140 stream.write(data->data(), data->size()); 157 stream.write(data->data(), data->size());
158 delete grFactory;
141 } 159 }
OLDNEW
« no previous file with comments | « no previous file | experimental/webtry/res/js/webtry.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698