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

Side by Side Diff: tools/PictureRenderingFlags.cpp

Issue 319043005: Support using OpenGL ES context on desktop (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix the crash, tested on xoom Created 6 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "PictureRenderingFlags.h" 8 #include "PictureRenderingFlags.h"
9 9
10 #include "CopyTilesRenderer.h" 10 #include "CopyTilesRenderer.h"
11 #include "PictureRenderer.h" 11 #include "PictureRenderer.h"
12 #include "picture_utils.h" 12 #include "picture_utils.h"
13 #include "SkCommandLineFlags.h" 13 #include "SkCommandLineFlags.h"
14 #include "SkData.h" 14 #include "SkData.h"
15 #include "SkImage.h" 15 #include "SkImage.h"
16 #include "SkImageDecoder.h" 16 #include "SkImageDecoder.h"
17 #include "SkString.h" 17 #include "SkString.h"
18 18
19 // Alphabetized list of flags used by this file or bench_ and render_pictures. 19 // Alphabetized list of flags used by this file or bench_ and render_pictures.
20 DEFINE_string(bbh, "none", "bbhType [width height]: Set the bounding box hierarc hy type to " 20 DEFINE_string(bbh, "none", "bbhType [width height]: Set the bounding box hierarc hy type to "
21 "be used. Accepted values are: none, rtree, quadtree, grid. " 21 "be used. Accepted values are: none, rtree, quadtree, grid. "
22 "Not compatible with --pipe. With value " 22 "Not compatible with --pipe. With value "
23 "'grid', width and height must be specified. 'grid' can " 23 "'grid', width and height must be specified. 'grid' can "
24 "only be used with modes tile, record, and " 24 "only be used with modes tile, record, and "
25 "playbackCreation."); 25 "playbackCreation.");
26 26
27 27
28 #if SK_SUPPORT_GPU 28 #if SK_SUPPORT_GPU
29 static const char kGpuAPINameGL[] = "gl";
30 static const char kGpuAPINameGLES[] = "gles";
29 #define GPU_CONFIG_STRING "|gpu|msaa4|msaa16|nvprmsaa4|nvprmsaa16" 31 #define GPU_CONFIG_STRING "|gpu|msaa4|msaa16|nvprmsaa4|nvprmsaa16"
30 #else 32 #else
31 #define GPU_CONFIG_STRING "" 33 #define GPU_CONFIG_STRING ""
32 #endif 34 #endif
33 #if SK_ANGLE 35 #if SK_ANGLE
34 #define ANGLE_CONFIG_STRING "|angle" 36 #define ANGLE_CONFIG_STRING "|angle"
35 #else 37 #else
36 #define ANGLE_CONFIG_STRING "" 38 #define ANGLE_CONFIG_STRING ""
37 #endif 39 #endif
38 #if SK_MESA 40 #if SK_MESA
(...skipping 28 matching lines...) Expand all
67 "rerecord: (Only in render_pictures) Record the picture as a new s kp,\n" 69 "rerecord: (Only in render_pictures) Record the picture as a new s kp,\n"
68 "\twith the bitmaps PNG encoded.\n"); 70 "\twith the bitmaps PNG encoded.\n");
69 DEFINE_int32(multi, 1, "Set the number of threads for multi threaded drawing. " 71 DEFINE_int32(multi, 1, "Set the number of threads for multi threaded drawing. "
70 "If > 1, requires tiled rendering."); 72 "If > 1, requires tiled rendering.");
71 DEFINE_bool(pipe, false, "Use SkGPipe rendering. Currently incompatible with \"m ode\"."); 73 DEFINE_bool(pipe, false, "Use SkGPipe rendering. Currently incompatible with \"m ode\".");
72 DEFINE_string2(readPath, r, "", "skp files or directories of skp files to proces s."); 74 DEFINE_string2(readPath, r, "", "skp files or directories of skp files to proces s.");
73 DEFINE_double(scale, 1, "Set the scale factor."); 75 DEFINE_double(scale, 1, "Set the scale factor.");
74 DEFINE_string(tiles, "", "Used with --mode copyTile to specify number of tiles p er larger tile " 76 DEFINE_string(tiles, "", "Used with --mode copyTile to specify number of tiles p er larger tile "
75 "in the x and y directions."); 77 "in the x and y directions.");
76 DEFINE_string(viewport, "", "width height: Set the viewport."); 78 DEFINE_string(viewport, "", "width height: Set the viewport.");
79 #if SK_SUPPORT_GPU
80 DEFINE_string(gpuAPI, "", "Force use of specific gpu API. Using \"gl\" "
81 "forces OpenGL API. Using \"gles\" forces OpenGL ES API. "
82 "Defaults to empty string, which selects the API native to the "
83 "system.");
84 #endif
77 85
78 sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) { 86 sk_tools::PictureRenderer* parseRenderer(SkString& error, PictureTool tool) {
79 error.reset(); 87 error.reset();
80 88
81 if (FLAGS_multi <= 0) { 89 if (FLAGS_multi <= 0) {
82 error.printf("--multi must be > 0, was %i", FLAGS_multi); 90 error.printf("--multi must be > 0, was %i", FLAGS_multi);
83 return NULL; 91 return NULL;
84 } 92 }
85 93
86 bool useTiles = false; 94 bool useTiles = false;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 262 }
255 SkISize viewport; 263 SkISize viewport;
256 viewport.fWidth = atoi(FLAGS_viewport[0]); 264 viewport.fWidth = atoi(FLAGS_viewport[0]);
257 viewport.fHeight = atoi(FLAGS_viewport[1]); 265 viewport.fHeight = atoi(FLAGS_viewport[1]);
258 renderer->setViewport(viewport); 266 renderer->setViewport(viewport);
259 } 267 }
260 268
261 sk_tools::PictureRenderer::SkDeviceTypes deviceType = 269 sk_tools::PictureRenderer::SkDeviceTypes deviceType =
262 sk_tools::PictureRenderer::kBitmap_DeviceType; 270 sk_tools::PictureRenderer::kBitmap_DeviceType;
263 #if SK_SUPPORT_GPU 271 #if SK_SUPPORT_GPU
272 GrGLStandard gpuAPI = kNone_GrGLStandard;
273 if (1 == FLAGS_gpuAPI.count()) {
274 if (FLAGS_gpuAPI.contains(kGpuAPINameGL)) {
275 gpuAPI = kGL_GrGLStandard;
276 } else if (FLAGS_gpuAPI.contains(kGpuAPINameGLES)) {
277 gpuAPI = kGLES_GrGLStandard;
278 } else {
279 error.printf("--gpuAPI invalid api value.\n");
280 return NULL;
281 }
282 } else if (FLAGS_gpuAPI.count() > 1) {
283 error.printf("--gpuAPI invalid api value.\n");
284 return NULL;
285 }
286
264 int sampleCount = 0; 287 int sampleCount = 0;
265 #endif 288 #endif
266 if (FLAGS_config.count() > 0) { 289 if (FLAGS_config.count() > 0) {
267 if (0 == strcmp(FLAGS_config[0], "8888")) { 290 if (0 == strcmp(FLAGS_config[0], "8888")) {
268 deviceType = sk_tools::PictureRenderer::kBitmap_DeviceType; 291 deviceType = sk_tools::PictureRenderer::kBitmap_DeviceType;
269 } 292 }
270 #if SK_SUPPORT_GPU 293 #if SK_SUPPORT_GPU
271 else if (0 == strcmp(FLAGS_config[0], "gpu")) { 294 else if (0 == strcmp(FLAGS_config[0], "gpu")) {
272 deviceType = sk_tools::PictureRenderer::kGPU_DeviceType; 295 deviceType = sk_tools::PictureRenderer::kGPU_DeviceType;
273 if (FLAGS_multi > 1) { 296 if (FLAGS_multi > 1) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 error.printf("Mesa not compatible with multithreaded tiling.\n") ; 346 error.printf("Mesa not compatible with multithreaded tiling.\n") ;
324 return NULL; 347 return NULL;
325 } 348 }
326 } 349 }
327 #endif 350 #endif
328 #endif 351 #endif
329 else { 352 else {
330 error.printf("%s is not a valid mode for --config\n", FLAGS_config[0 ]); 353 error.printf("%s is not a valid mode for --config\n", FLAGS_config[0 ]);
331 return NULL; 354 return NULL;
332 } 355 }
333 renderer->setDeviceType(deviceType); 356 #if SK_SUPPORT_GPU
357 if (!renderer->setDeviceType(deviceType, gpuAPI)) {
358 #else
359 if (!renderer->setDeviceType(deviceType)) {
360 #endif
361 error.printf("Could not create backend for --config %s\n", FLAGS_con fig[0]);
362 return NULL;
363 }
334 #if SK_SUPPORT_GPU 364 #if SK_SUPPORT_GPU
335 renderer->setSampleCount(sampleCount); 365 renderer->setSampleCount(sampleCount);
336 #endif 366 #endif
337 } 367 }
338 368
339 369
340 sk_tools::PictureRenderer::BBoxHierarchyType bbhType 370 sk_tools::PictureRenderer::BBoxHierarchyType bbhType
341 = sk_tools::PictureRenderer::kNone_BBoxHierarchyType; 371 = sk_tools::PictureRenderer::kNone_BBoxHierarchyType;
342 if (FLAGS_bbh.count() > 0) { 372 if (FLAGS_bbh.count() > 0) {
343 const char* type = FLAGS_bbh[0]; 373 const char* type = FLAGS_bbh[0];
(...skipping 24 matching lines...) Expand all
368 if (FLAGS_pipe && sk_tools::PictureRenderer::kNone_BBoxHierarchyType != bbhType) { 398 if (FLAGS_pipe && sk_tools::PictureRenderer::kNone_BBoxHierarchyType != bbhType) {
369 error.printf("--pipe and --bbh cannot be used together\n"); 399 error.printf("--pipe and --bbh cannot be used together\n");
370 return NULL; 400 return NULL;
371 } 401 }
372 } 402 }
373 renderer->setBBoxHierarchyType(bbhType); 403 renderer->setBBoxHierarchyType(bbhType);
374 renderer->setScaleFactor(SkDoubleToScalar(FLAGS_scale)); 404 renderer->setScaleFactor(SkDoubleToScalar(FLAGS_scale));
375 405
376 return renderer.detach(); 406 return renderer.detach();
377 } 407 }
OLDNEW
« src/gpu/gl/GrGLAssembleGLESInterface.h ('K') | « tools/PictureRenderer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698