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