blob: 881c6f75c2c383fb97e477f22682b65c9a73e6a6 [file] [log] [blame]
Joe Gregorioa8fabd32017-05-31 09:45:19 -04001/*
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 Kleinc0bd9f92019-04-23 12:05:21 -05008#include "include/core/SkRefCnt.h"
Robert Phillipsf4f80112020-07-13 16:13:31 -04009#include "include/gpu/GrDirectContext.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/gpu/gl/GrGLFunctions.h"
11#include "include/gpu/gl/GrGLInterface.h"
12#include "tools/gpu/gl/GLTestContext.h"
Joe Gregorioa8fabd32017-05-31 09:45:19 -040013
14#include <EGL/egl.h>
Joe Gregorio97b10ac2017-06-01 13:24:11 -040015#include <GLES2/gl2.h>
Joe Gregorioa8fabd32017-05-31 09:45:19 -040016
Ben Wagner5ec237d2018-05-22 16:44:53 -040017#include <sstream>
18
Robert Phillipsf4f80112020-07-13 16:13:31 -040019// create_direct_context implementation for EGL.
20sk_sp<GrDirectContext> create_direct_context(
21 std::ostringstream& driverinfo,
22 std::unique_ptr<sk_gpu_test::GLTestContext>* glContext) {
Joe Gregorio8e9810c2018-05-29 13:56:27 -040023 glContext->reset(sk_gpu_test::CreatePlatformGLTestContext(kGLES_GrGLStandard));
24 if (!glContext) {
25 return nullptr;
26 }
27 (*glContext)->makeCurrent();
Robert Phillipsf4f80112020-07-13 16:13:31 -040028 sk_sp<GrDirectContext> result = (*glContext)->makeContext(GrContextOptions());
Joe Gregorio8e9810c2018-05-29 13:56:27 -040029 if (!result) {
30 glContext->reset();
Joe Gregorioa8fabd32017-05-31 09:45:19 -040031 return nullptr;
32 }
33
Joe Gregorio8e9810c2018-05-29 13:56:27 -040034 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 Gregorioa8fabd32017-05-31 09:45:19 -040038
Joe Gregorio8e9810c2018-05-29 13:56:27 -040039 return result;
Joe Gregorioa8fabd32017-05-31 09:45:19 -040040}