GrGLAssembleInterface.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright 2014 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/GrGLAssembleHelpers.h"
  8. #include "include/gpu/gl/GrGLAssembleInterface.h"
  9. #include "src/gpu/gl/GrGLUtil.h"
  10. #define GET_PROC_LOCAL(F) GrGL##F##Fn* F = (GrGL##F##Fn*)get(ctx, "gl" #F)
  11. sk_sp<const GrGLInterface> GrGLMakeAssembledInterface(void *ctx, GrGLGetProc get) {
  12. GET_PROC_LOCAL(GetString);
  13. if (nullptr == GetString) {
  14. return nullptr;
  15. }
  16. const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION));
  17. if (nullptr == verStr) {
  18. return nullptr;
  19. }
  20. GrGLStandard standard = GrGLGetStandardInUseFromString(verStr);
  21. // standard can be unused (optimzed away) if SK_ASSUME_GL_ES is set
  22. sk_ignore_unused_variable(standard);
  23. if (GR_IS_GR_GL_ES(standard)) {
  24. return GrGLMakeAssembledGLESInterface(ctx, get);
  25. } else if (GR_IS_GR_GL(standard)) {
  26. return GrGLMakeAssembledGLInterface(ctx, get);
  27. } else if (GR_IS_GR_WEBGL(standard)) {
  28. return GrGLMakeAssembledWebGLInterface(ctx, get);
  29. }
  30. return nullptr;
  31. }
  32. SK_API const GrGLInterface* GrGLAssembleInterface(void *ctx, GrGLGetProc get) {
  33. return GrGLMakeAssembledInterface(ctx, get).release();
  34. }