aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ethannicholas <ethannicholas@google.com>2016-06-13 10:20:52 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-06-13 10:20:52 -0700
commit2ec06c9b1c861d456b85ffe48b27e4dcae4800cb (patch)
treeeb91cfb06e8a5607a1071a9de0b51fd79011766f
parent76963e73704a42a18c29d6fbdcccb566e5c67658 (diff)
skiaserve no longer crashes when no X server is present
-rw-r--r--tools/skiaserve/Request.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index 97719e2bd2..c3eaaff387 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -71,8 +71,14 @@ SkCanvas* Request::getCanvas() {
#if SK_SUPPORT_GPU
GrContextFactory* factory = fContextFactory;
GLTestContext* gl = factory->getContextInfo(GrContextFactory::kNativeGL_ContextType,
- GrContextFactory::kNone_ContextOptions).glContext();
- gl->makeCurrent();
+ GrContextFactory::kNone_ContextOptions).glContext();
+ if (!gl) {
+ gl = factory->getContextInfo(GrContextFactory::kMESA_ContextType,
+ GrContextFactory::kNone_ContextOptions).glContext();
+ }
+ if (gl) {
+ gl->makeCurrent();
+ }
#endif
SkASSERT(fDebugCanvas);
@@ -115,10 +121,15 @@ SkData* Request::writeOutSkp() {
GrContext* Request::getContext() {
#if SK_SUPPORT_GPU
- return fContextFactory->get(GrContextFactory::kNativeGL_ContextType,
- GrContextFactory::kNone_ContextOptions);
+ GrContext* result = fContextFactory->get(GrContextFactory::kNativeGL_ContextType,
+ GrContextFactory::kNone_ContextOptions);
+ if (!result) {
+ result = fContextFactory->get(GrContextFactory::kMESA_ContextType,
+ GrContextFactory::kNone_ContextOptions);
+ }
+ return result;
#else
- return nullptr;
+ return nullptr;
#endif
}