Support using OpenGL ES context on desktop
Support using OpenGL ES context on desktop for unix and Android platforms. This
is mainly useful in development.
Add --gpuAPI flag to gm, dm, bench, bench_pictures and render_pictures. The
possible parameters for the flag are "gl" and "gles".
R=bsalomon@google.com, mtklein@google.com, robertphillips@google.com
Author: kkinnunen@nvidia.com
Review URL: https://codereview.chromium.org/319043005
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index 5c3b790..016ad2d 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -50,6 +50,11 @@
static const char kDefaultsConfigStr[] = "defaults";
+#if SK_SUPPORT_GPU
+static const char kGpuAPINameGL[] = "gl";
+static const char kGpuAPINameGLES[] = "gles";
+#endif
+
///////////////////////////////////////////////////////////////////////////////
class Iter {
@@ -227,6 +232,10 @@
DEFINE_string(forceDither, "default", "Force dithering: true, false, or default?");
DEFINE_bool(forceBlend, false, "Force alpha blending?");
+DEFINE_string(gpuAPI, "", "Force use of specific gpu API. Using \"gl\" "
+ "forces OpenGL API. Using \"gles\" forces OpenGL ES API. "
+ "Defaults to empty string, which selects the API native to the "
+ "system.");
DEFINE_int32(gpuCacheBytes, -1, "GPU cache size limit in bytes. 0 to disable cache.");
DEFINE_int32(gpuCacheCount, -1, "GPU cache size limit in object count. 0 to disable cache.");
@@ -348,11 +357,24 @@
}
#if SK_SUPPORT_GPU
+ GrGLStandard gpuAPI = kNone_GrGLStandard;
+ if (1 == FLAGS_gpuAPI.count()) {
+ if (FLAGS_gpuAPI.contains(kGpuAPINameGL)) {
+ gpuAPI = kGL_GrGLStandard;
+ } else if (FLAGS_gpuAPI.contains(kGpuAPINameGLES)) {
+ gpuAPI = kGLES_GrGLStandard;
+ } else {
+ SkDebugf("Selected gpu API could not be used. Using the default.\n");
+ }
+ } else if (FLAGS_gpuAPI.count() > 1) {
+ SkDebugf("Selected gpu API could not be used. Using the default.\n");
+ }
+
for (int i = 0; i < configs.count(); ++i) {
const Config& config = gConfigs[configs[i]];
if (Benchmark::kGPU_Backend == config.backend) {
- GrContext* context = gContextFactory.get(config.contextType);
+ GrContext* context = gContextFactory.get(config.contextType, gpuAPI);
if (NULL == context) {
SkDebugf("GrContext could not be created for config %s. Config will be skipped.\n",
config.name);
@@ -412,7 +434,7 @@
if (Benchmark::kGPU_Backend != config.backend) {
continue;
}
- GrContext* context = gContextFactory.get(config.contextType);
+ GrContext* context = gContextFactory.get(config.contextType, gpuAPI);
if (NULL == context) {
continue;
}
@@ -458,7 +480,7 @@
#if SK_SUPPORT_GPU
SkGLContextHelper* glContext = NULL;
if (Benchmark::kGPU_Backend == config.backend) {
- context = gContextFactory.get(config.contextType);
+ context = gContextFactory.get(config.contextType, gpuAPI);
if (NULL == context) {
continue;
}