egl_context.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #include "include/core/SkRefCnt.h"
  8. #include "include/gpu/GrContext.h"
  9. #include "include/gpu/gl/GrGLFunctions.h"
  10. #include "include/gpu/gl/GrGLInterface.h"
  11. #include "tools/gpu/gl/GLTestContext.h"
  12. #include <EGL/egl.h>
  13. #include <GLES2/gl2.h>
  14. #include <sstream>
  15. // create_grcontext implementation for EGL.
  16. sk_sp<GrContext> create_grcontext(std::ostringstream& driverinfo,
  17. std::unique_ptr<sk_gpu_test::GLTestContext>* glContext) {
  18. // We are leaking tc, but that's OK because fiddle is a short lived proces.
  19. glContext->reset(sk_gpu_test::CreatePlatformGLTestContext(kGLES_GrGLStandard));
  20. if (!glContext) {
  21. return nullptr;
  22. }
  23. (*glContext)->makeCurrent();
  24. sk_sp<GrContext> result = (*glContext)->makeGrContext(GrContextOptions());
  25. if (!result) {
  26. glContext->reset();
  27. return nullptr;
  28. }
  29. driverinfo << "GL Version: " << glGetString(GL_VERSION) << "\n";
  30. driverinfo << "GL Vendor: " << glGetString(GL_VENDOR) << "\n";
  31. driverinfo << "GL Renderer: " << glGetString(GL_RENDERER) << "\n";
  32. driverinfo << "GL Extensions: " << glGetString(GL_EXTENSIONS) << "\n";
  33. return result;
  34. }