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