1// Copyright 2019 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5package main 6 7const ASSEMBLE_INTERFACE_GL_ES = `/* 8 * Copyright 2019 Google LLC 9 * 10 * Use of this source code is governed by a BSD-style license that can be 11 * found in the LICENSE file. 12 * 13 * THIS FILE IS AUTOGENERATED 14 * Make edits to tools/gpu/gl/interface/templates.go or they will 15 * be overwritten. 16 */ 17 18#include "include/gpu/gl/GrGLAssembleHelpers.h" 19#include "include/gpu/gl/GrGLAssembleInterface.h" 20#include "src/gpu/gl/GrGLUtil.h" 21 22#define GET_PROC(F) functions->f##F = (GrGL##F##Fn*)get(ctx, "gl" #F) 23#define GET_PROC_SUFFIX(F, S) functions->f##F = (GrGL##F##Fn*)get(ctx, "gl" #F #S) 24#define GET_PROC_LOCAL(F) GrGL##F##Fn* F = (GrGL##F##Fn*)get(ctx, "gl" #F) 25 26#define GET_EGL_PROC_SUFFIX(F, S) functions->fEGL##F = (GrEGL##F##Fn*)get(ctx, "egl" #F #S) 27 28#if SK_DISABLE_GL_ES_INTERFACE 29sk_sp<const GrGLInterface> GrGLMakeAssembledGLESInterface(void *ctx, GrGLGetProc get) { 30 return nullptr; 31} 32#else 33sk_sp<const GrGLInterface> GrGLMakeAssembledGLESInterface(void *ctx, GrGLGetProc get) { 34 GET_PROC_LOCAL(GetString); 35 if (nullptr == GetString) { 36 return nullptr; 37 } 38 39 const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION)); 40 GrGLVersion glVer = GrGLGetVersionFromString(verStr); 41 42 if (glVer < GR_GL_VER(2,0)) { 43 return nullptr; 44 } 45 46 GET_PROC_LOCAL(GetIntegerv); 47 GET_PROC_LOCAL(GetStringi); 48 GrEGLQueryStringFn* queryString; 49 GrEGLDisplay display; 50 GrGetEGLQueryAndDisplay(&queryString, &display, ctx, get); 51 GrGLExtensions extensions; 52 if (!extensions.init(kGLES_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString, 53 display)) { 54 return nullptr; 55 } 56 57 sk_sp<GrGLInterface> interface(new GrGLInterface); 58 GrGLInterface::Functions* functions = &interface->fFunctions; 59 60 // Autogenerated content follows 61[[content]] 62 // End autogenerated content 63 // TODO(kjlubick): Do we want a feature that removes the extension if it doesn't have 64 // the function? This is common on some low-end GPUs. 65 66 if (extensions.has("GL_KHR_debug")) { 67 // In general we have a policy against removing extension strings when the driver does 68 // not provide function pointers for an advertised extension. However, because there is a 69 // known device that advertises GL_KHR_debug but fails to provide the functions and this is 70 // a debugging- only extension we've made an exception. This also can happen when using 71 // APITRACE. 72 if (!interface->fFunctions.fDebugMessageControl) { 73 extensions.remove("GL_KHR_debug"); 74 } 75 } 76 interface->fStandard = kGLES_GrGLStandard; 77 interface->fExtensions.swap(&extensions); 78 79 return interface; 80} 81#endif 82` 83 84const ASSEMBLE_INTERFACE_GL = `/* 85 * Copyright 2019 Google LLC 86 * 87 * Use of this source code is governed by a BSD-style license that can be 88 * found in the LICENSE file. 89 * 90 * THIS FILE IS AUTOGENERATED 91 * Make edits to tools/gpu/gl/interface/templates.go or they will 92 * be overwritten. 93 */ 94 95#include "include/gpu/gl/GrGLAssembleHelpers.h" 96#include "include/gpu/gl/GrGLAssembleInterface.h" 97#include "src/gpu/gl/GrGLUtil.h" 98 99#define GET_PROC(F) functions->f##F = (GrGL##F##Fn*)get(ctx, "gl" #F) 100#define GET_PROC_SUFFIX(F, S) functions->f##F = (GrGL##F##Fn*)get(ctx, "gl" #F #S) 101#define GET_PROC_LOCAL(F) GrGL##F##Fn* F = (GrGL##F##Fn*)get(ctx, "gl" #F) 102 103#define GET_EGL_PROC_SUFFIX(F, S) functions->fEGL##F = (GrEGL##F##Fn*)get(ctx, "egl" #F #S) 104 105#if SK_DISABLE_GL_INTERFACE 106sk_sp<const GrGLInterface> GrGLMakeAssembledGLInterface(void *ctx, GrGLGetProc get) { 107 return nullptr; 108} 109#else 110sk_sp<const GrGLInterface> GrGLMakeAssembledGLInterface(void *ctx, GrGLGetProc get) { 111 GET_PROC_LOCAL(GetString); 112 GET_PROC_LOCAL(GetStringi); 113 GET_PROC_LOCAL(GetIntegerv); 114 115 // GetStringi may be nullptr depending on the GL version. 116 if (nullptr == GetString || nullptr == GetIntegerv) { 117 return nullptr; 118 } 119 120 const char* versionString = (const char*) GetString(GR_GL_VERSION); 121 GrGLVersion glVer = GrGLGetVersionFromString(versionString); 122 123 if (glVer < GR_GL_VER(2,0) || GR_GL_INVALID_VER == glVer) { 124 // This is our minimum for non-ES GL. 125 return nullptr; 126 } 127 128 GrEGLQueryStringFn* queryString; 129 GrEGLDisplay display; 130 GrGetEGLQueryAndDisplay(&queryString, &display, ctx, get); 131 GrGLExtensions extensions; 132 if (!extensions.init(kGL_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString, 133 display)) { 134 return nullptr; 135 } 136 137 sk_sp<GrGLInterface> interface(new GrGLInterface()); 138 GrGLInterface::Functions* functions = &interface->fFunctions; 139 140 // Autogenerated content follows 141[[content]] 142 // End autogenerated content 143 interface->fStandard = kGL_GrGLStandard; 144 interface->fExtensions.swap(&extensions); 145 146 return interface; 147} 148#endif 149` 150 151const ASSEMBLE_INTERFACE_WEBGL = `/* 152 * Copyright 2019 Google LLC 153 * 154 * Use of this source code is governed by a BSD-style license that can be 155 * found in the LICENSE file. 156 * 157 * THIS FILE IS AUTOGENERATED 158 * Make edits to tools/gpu/gl/interface/templates.go or they will 159 * be overwritten. 160 */ 161 162#include "include/gpu/gl/GrGLAssembleHelpers.h" 163#include "include/gpu/gl/GrGLAssembleInterface.h" 164#include "src/gpu/gl/GrGLUtil.h" 165 166#define GET_PROC(F) functions->f##F = (GrGL##F##Fn*)get(ctx, "gl" #F) 167#define GET_PROC_SUFFIX(F, S) functions->f##F = (GrGL##F##Fn*)get(ctx, "gl" #F #S) 168#define GET_PROC_LOCAL(F) GrGL##F##Fn* F = (GrGL##F##Fn*)get(ctx, "gl" #F) 169 170#define GET_EGL_PROC_SUFFIX(F, S) functions->fEGL##F = (GrEGL##F##Fn*)get(ctx, "egl" #F #S) 171 172#if SK_DISABLE_WEBGL_INTERFACE 173sk_sp<const GrGLInterface> GrGLMakeAssembledWebGLInterface(void *ctx, GrGLGetProc get) { 174 return nullptr; 175} 176#else 177sk_sp<const GrGLInterface> GrGLMakeAssembledWebGLInterface(void *ctx, GrGLGetProc get) { 178 GET_PROC_LOCAL(GetString); 179 if (nullptr == GetString) { 180 return nullptr; 181 } 182 183 const char* verStr = reinterpret_cast<const char*>(GetString(GR_GL_VERSION)); 184 GrGLVersion glVer = GrGLGetVersionFromString(verStr); 185 186 if (glVer < GR_GL_VER(1,0)) { 187 return nullptr; 188 } 189 190 GET_PROC_LOCAL(GetIntegerv); 191 GET_PROC_LOCAL(GetStringi); 192 GrEGLQueryStringFn* queryString; 193 GrEGLDisplay display; 194 GrGetEGLQueryAndDisplay(&queryString, &display, ctx, get); 195 GrGLExtensions extensions; 196 if (!extensions.init(kWebGL_GrGLStandard, GetString, GetStringi, GetIntegerv, queryString, 197 display)) { 198 return nullptr; 199 } 200 201 sk_sp<GrGLInterface> interface(new GrGLInterface); 202 GrGLInterface::Functions* functions = &interface->fFunctions; 203 204 // Autogenerated content follows 205[[content]] 206 // End autogenerated content 207 208 interface->fStandard = kWebGL_GrGLStandard; 209 interface->fExtensions.swap(&extensions); 210 211 return interface; 212} 213#endif 214` 215 216const VALIDATE_INTERFACE = `/* 217 * Copyright 2011 Google Inc. 218 * 219 * Use of this source code is governed by a BSD-style license that can be 220 * found in the LICENSE file. 221 * 222 * THIS FILE IS AUTOGENERATED 223 * Make edits to tools/gpu/gl/interface/templates.go or they will 224 * be overwritten. 225 */ 226 227#include "include/gpu/gl/GrGLExtensions.h" 228#include "include/gpu/gl/GrGLInterface.h" 229#include "src/gpu/gl/GrGLUtil.h" 230 231#include <stdio.h> 232 233GrGLInterface::GrGLInterface() { 234 fStandard = kNone_GrGLStandard; 235} 236 237#define RETURN_FALSE_INTERFACE \ 238 SkDEBUGF("%s:%d GrGLInterface::validate() failed.\n", __FILE__, __LINE__); \ 239 return false 240 241bool GrGLInterface::validate() const { 242 243 if (kNone_GrGLStandard == fStandard) { 244 RETURN_FALSE_INTERFACE; 245 } 246 247 if (!fExtensions.isInitialized()) { 248 RETURN_FALSE_INTERFACE; 249 } 250 251 GrGLVersion glVer = GrGLGetVersion(this); 252 if (GR_GL_INVALID_VER == glVer) { 253 RETURN_FALSE_INTERFACE; 254 } 255 // Autogenerated content follows 256[[content]] 257 // End autogenerated content 258 return true; 259} 260 261#if GR_TEST_UTILS 262 263void GrGLInterface::abandon() const { 264 const_cast<GrGLInterface*>(this)->fFunctions = GrGLInterface::Functions(); 265} 266 267#endif // GR_TEST_UTILS 268` 269