Joe Gregorio | a8fabd3 | 2017-05-31 09:45:19 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "include/core/SkRefCnt.h" |
| 9 | #include "include/gpu/GrContext.h" |
| 10 | #include "include/gpu/gl/GrGLFunctions.h" |
| 11 | #include "include/gpu/gl/GrGLInterface.h" |
| 12 | #include "tools/gpu/gl/GLTestContext.h" |
Joe Gregorio | a8fabd3 | 2017-05-31 09:45:19 -0400 | [diff] [blame] | 13 | |
| 14 | #include <EGL/egl.h> |
Joe Gregorio | 97b10ac | 2017-06-01 13:24:11 -0400 | [diff] [blame] | 15 | #include <GLES2/gl2.h> |
Joe Gregorio | a8fabd3 | 2017-05-31 09:45:19 -0400 | [diff] [blame] | 16 | |
Ben Wagner | 5ec237d | 2018-05-22 16:44:53 -0400 | [diff] [blame] | 17 | #include <sstream> |
| 18 | |
Joe Gregorio | a8fabd3 | 2017-05-31 09:45:19 -0400 | [diff] [blame] | 19 | // create_grcontext implementation for EGL. |
Joe Gregorio | 8e9810c | 2018-05-29 13:56:27 -0400 | [diff] [blame] | 20 | sk_sp<GrContext> create_grcontext(std::ostringstream& driverinfo, |
| 21 | std::unique_ptr<sk_gpu_test::GLTestContext>* glContext) { |
| 22 | // We are leaking tc, but that's OK because fiddle is a short lived proces. |
| 23 | glContext->reset(sk_gpu_test::CreatePlatformGLTestContext(kGLES_GrGLStandard)); |
| 24 | if (!glContext) { |
| 25 | return nullptr; |
| 26 | } |
| 27 | (*glContext)->makeCurrent(); |
| 28 | sk_sp<GrContext> result = (*glContext)->makeGrContext(GrContextOptions()); |
| 29 | if (!result) { |
| 30 | glContext->reset(); |
Joe Gregorio | a8fabd3 | 2017-05-31 09:45:19 -0400 | [diff] [blame] | 31 | return nullptr; |
| 32 | } |
| 33 | |
Joe Gregorio | 8e9810c | 2018-05-29 13:56:27 -0400 | [diff] [blame] | 34 | driverinfo << "GL Version: " << glGetString(GL_VERSION) << "\n"; |
| 35 | driverinfo << "GL Vendor: " << glGetString(GL_VENDOR) << "\n"; |
| 36 | driverinfo << "GL Renderer: " << glGetString(GL_RENDERER) << "\n"; |
| 37 | driverinfo << "GL Extensions: " << glGetString(GL_EXTENSIONS) << "\n"; |
Joe Gregorio | a8fabd3 | 2017-05-31 09:45:19 -0400 | [diff] [blame] | 38 | |
Joe Gregorio | 8e9810c | 2018-05-29 13:56:27 -0400 | [diff] [blame] | 39 | return result; |
Joe Gregorio | a8fabd3 | 2017-05-31 09:45:19 -0400 | [diff] [blame] | 40 | } |