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

Unified Diff: experimental/webtry/main.cpp

Issue 688003002: fix issues with simultaneous configs and security jail on skfiddle (Closed) Base URL: https://skia.googlesource.com/skia@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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | experimental/webtry/webtry.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/webtry/main.cpp
diff --git a/experimental/webtry/main.cpp b/experimental/webtry/main.cpp
index f2a6f269b2b0a8c2a0605488bd1293e99d35e348..a83a60842d5de26b151b7d69cef000a5d8cdc98f 100644
--- a/experimental/webtry/main.cpp
+++ b/experimental/webtry/main.cpp
@@ -120,18 +120,11 @@ static void drawRaster(SkWStream* stream, SkImageInfo info) {
drawAndDump(surface, stream);
}
-static void drawGPU(SkWStream* stream, SkImageInfo info) {
+static void drawGPU(SkWStream* stream, GrContext* gr, SkImageInfo info) {
SkAutoTUnref<SkSurface> surface;
- GrContextFactory* grFactory = NULL;
-
- GrContext::Options grContextOpts;
- grFactory = new GrContextFactory(grContextOpts);
- GrContext* gr = grFactory->get(GrContextFactory::kMESA_GLContextType);
surface.reset(SkSurface::NewRenderTarget(gr,info));
drawAndDump(surface, stream);
-
- delete grFactory;
}
static void drawPDF(SkWStream* stream, SkImageInfo info) {
@@ -162,7 +155,7 @@ int main(int argc, char** argv) {
// make sure to open any needed output files before we set up the security
// jail
- SkWStream* streams[3];
+ SkWStream* streams[3] = {NULL, NULL, NULL};
if (FLAGS_raster) {
SkString outPath;
@@ -182,19 +175,34 @@ int main(int argc, char** argv) {
SkImageInfo info = SkImageInfo::MakeN32(FLAGS_width, FLAGS_height, kPremul_SkAlphaType);
+ GrContext *gr = NULL;
+ GrContextFactory* grFactory = NULL;
+
+ // need to set up the GPU context before we install system call restrictions
+ if (FLAGS_gpu) {
+
+ GrContext::Options grContextOpts;
+ grFactory = new GrContextFactory(grContextOpts);
+ gr = grFactory->get(GrContextFactory::kMESA_GLContextType);
+ }
+
setLimits();
if (!install_syscall_filter()) {
return 1;
}
- if (FLAGS_raster) {
+ if (NULL != streams[0]) {
drawRaster(streams[0], info);
}
- if (FLAGS_gpu) {
- drawGPU(streams[1], info);
+ if (NULL != streams[1]) {
+ drawGPU(streams[1], gr, info);
}
- if (FLAGS_pdf) {
+ if (NULL != streams[2]) {
drawPDF(streams[2], info);
}
+
+ if (gr) {
+ delete grFactory;
+ }
}
« no previous file with comments | « no previous file | experimental/webtry/webtry.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698