2017-05-31 13:45:19 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkRefCnt.h"
|
2020-07-13 20:13:31 +00:00
|
|
|
#include "include/gpu/GrDirectContext.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/gpu/gl/GrGLFunctions.h"
|
|
|
|
#include "include/gpu/gl/GrGLInterface.h"
|
|
|
|
#include "tools/gpu/gl/GLTestContext.h"
|
2017-05-31 13:45:19 +00:00
|
|
|
|
|
|
|
#include <EGL/egl.h>
|
2017-06-01 17:24:11 +00:00
|
|
|
#include <GLES2/gl2.h>
|
2017-05-31 13:45:19 +00:00
|
|
|
|
2018-05-22 20:44:53 +00:00
|
|
|
#include <sstream>
|
|
|
|
|
2020-07-13 20:13:31 +00:00
|
|
|
// create_direct_context implementation for EGL.
|
|
|
|
sk_sp<GrDirectContext> create_direct_context(
|
|
|
|
std::ostringstream& driverinfo,
|
|
|
|
std::unique_ptr<sk_gpu_test::GLTestContext>* glContext) {
|
2018-05-29 17:56:27 +00:00
|
|
|
glContext->reset(sk_gpu_test::CreatePlatformGLTestContext(kGLES_GrGLStandard));
|
|
|
|
if (!glContext) {
|
2017-05-31 13:45:19 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2018-05-29 17:56:27 +00:00
|
|
|
(*glContext)->makeCurrent();
|
2020-07-13 20:13:31 +00:00
|
|
|
sk_sp<GrDirectContext> result = (*glContext)->makeContext(GrContextOptions());
|
2018-05-29 17:56:27 +00:00
|
|
|
if (!result) {
|
|
|
|
glContext->reset();
|
2017-05-31 13:45:19 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-05-29 17:56:27 +00:00
|
|
|
driverinfo << "GL Version: " << glGetString(GL_VERSION) << "\n";
|
|
|
|
driverinfo << "GL Vendor: " << glGetString(GL_VENDOR) << "\n";
|
|
|
|
driverinfo << "GL Renderer: " << glGetString(GL_RENDERER) << "\n";
|
|
|
|
driverinfo << "GL Extensions: " << glGetString(GL_EXTENSIONS) << "\n";
|
2017-05-31 13:45:19 +00:00
|
|
|
|
2018-05-29 17:56:27 +00:00
|
|
|
return result;
|
2017-05-31 13:45:19 +00:00
|
|
|
}
|