GrGLMakeNativeInterface_glfw.cpp 756 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * Copyright 2016 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/gpu/gl/GrGLAssembleInterface.h"
  8. #include "include/gpu/gl/GrGLInterface.h"
  9. #include "src/gpu/gl/GrGLUtil.h"
  10. #include <GLFW/glfw3.h>
  11. static GrGLFuncPtr glfw_get(void* ctx, const char name[]) {
  12. SkASSERT(nullptr == ctx);
  13. SkASSERT(glfwGetCurrentContext());
  14. return glfwGetProcAddress(name);
  15. }
  16. sk_sp<const GrGLInterface> GrGLMakeNativeInterface() {
  17. if (nullptr == glfwGetCurrentContext()) {
  18. return nullptr;
  19. }
  20. return GrGLMakeAssembledInterface(nullptr, glfw_get);
  21. }
  22. const GrGLInterface* GrGLCreateNativeInterface() { return GrGLMakeNativeInterface().release(); }