| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "GrGLAssembleInterface.h" | 10 #include "GrGLAssembleInterface.h" |
| 11 #include "GrGLUtil.h" | 11 #include "GrGLUtil.h" |
| 12 | 12 |
| 13 #define GET_PROC(F) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F) | 13 #define GET_PROC(F) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "gl" #F) |
| 14 #define GET_PROC_SUFFIX(F, S) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "
gl" #F #S) | 14 #define GET_PROC_SUFFIX(F, S) functions->f ## F = (GrGL ## F ## Proc) get(ctx, "
gl" #F #S) |
| 15 #define GET_PROC_LOCAL(F) GrGL ## F ## Proc F = (GrGL ## F ## Proc) get(ctx, "gl
" #F) | 15 #define GET_PROC_LOCAL(F) GrGL ## F ## Proc F = (GrGL ## F ## Proc) get(ctx, "gl
" #F) |
| 16 | 16 |
| 17 // The glStencilThenCover* methods are a new addition to NV_path_rendering. They | |
| 18 // aren't available on all drivers. In the event that they are not present, this | |
| 19 // function can be used to add methods to the given GrGLInterface that emulate | |
| 20 // them using the existing glStencil*/glCover* methods. | |
| 21 static void emulate_nvpr_stencil_then_cover(GrGLInterface*); | |
| 22 | |
| 23 const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) { | 17 const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) { |
| 24 GET_PROC_LOCAL(GetString); | 18 GET_PROC_LOCAL(GetString); |
| 25 GET_PROC_LOCAL(GetStringi); | 19 GET_PROC_LOCAL(GetStringi); |
| 26 GET_PROC_LOCAL(GetIntegerv); | 20 GET_PROC_LOCAL(GetIntegerv); |
| 27 | 21 |
| 28 // GetStringi may be NULL depending on the GL version. | 22 // GetStringi may be NULL depending on the GL version. |
| 29 if (NULL == GetString || NULL == GetIntegerv) { | 23 if (NULL == GetString || NULL == GetIntegerv) { |
| 30 return NULL; | 24 return NULL; |
| 31 } | 25 } |
| 32 | 26 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 GET_PROC_SUFFIX(PathStencilFunc, NV); | 232 GET_PROC_SUFFIX(PathStencilFunc, NV); |
| 239 GET_PROC_SUFFIX(StencilFillPath, NV); | 233 GET_PROC_SUFFIX(StencilFillPath, NV); |
| 240 GET_PROC_SUFFIX(StencilStrokePath, NV); | 234 GET_PROC_SUFFIX(StencilStrokePath, NV); |
| 241 GET_PROC_SUFFIX(StencilFillPathInstanced, NV); | 235 GET_PROC_SUFFIX(StencilFillPathInstanced, NV); |
| 242 GET_PROC_SUFFIX(StencilStrokePathInstanced, NV); | 236 GET_PROC_SUFFIX(StencilStrokePathInstanced, NV); |
| 243 GET_PROC_SUFFIX(PathTexGen, NV); | 237 GET_PROC_SUFFIX(PathTexGen, NV); |
| 244 GET_PROC_SUFFIX(CoverFillPath, NV); | 238 GET_PROC_SUFFIX(CoverFillPath, NV); |
| 245 GET_PROC_SUFFIX(CoverStrokePath, NV); | 239 GET_PROC_SUFFIX(CoverStrokePath, NV); |
| 246 GET_PROC_SUFFIX(CoverFillPathInstanced, NV); | 240 GET_PROC_SUFFIX(CoverFillPathInstanced, NV); |
| 247 GET_PROC_SUFFIX(CoverStrokePathInstanced, NV); | 241 GET_PROC_SUFFIX(CoverStrokePathInstanced, NV); |
| 242 // NV_path_rendering v1.2 (These methods may not be present) |
| 248 GET_PROC_SUFFIX(StencilThenCoverFillPath, NV); | 243 GET_PROC_SUFFIX(StencilThenCoverFillPath, NV); |
| 249 GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV); | 244 GET_PROC_SUFFIX(StencilThenCoverStrokePath, NV); |
| 250 GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV); | 245 GET_PROC_SUFFIX(StencilThenCoverFillPathInstanced, NV); |
| 251 GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV); | 246 GET_PROC_SUFFIX(StencilThenCoverStrokePathInstanced, NV); |
| 247 // NV_path_rendering v1.3 (These methods may not be present) |
| 252 GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV); | 248 GET_PROC_SUFFIX(ProgramPathFragmentInputGen, NV); |
| 253 | |
| 254 if (NULL == interface->fFunctions.fStencilThenCoverFillPath || | |
| 255 NULL == interface->fFunctions.fStencilThenCoverStrokePath || | |
| 256 NULL == interface->fFunctions.fStencilThenCoverFillPathInstanced || | |
| 257 NULL == interface->fFunctions.fStencilThenCoverFillPathInstanced) { | |
| 258 emulate_nvpr_stencil_then_cover(interface); | |
| 259 } | |
| 260 } | 249 } |
| 261 | 250 |
| 262 if (extensions.has("GL_EXT_debug_marker")) { | 251 if (extensions.has("GL_EXT_debug_marker")) { |
| 263 GET_PROC_SUFFIX(InsertEventMarker, EXT); | 252 GET_PROC_SUFFIX(InsertEventMarker, EXT); |
| 264 GET_PROC_SUFFIX(PushGroupMarker, EXT); | 253 GET_PROC_SUFFIX(PushGroupMarker, EXT); |
| 265 GET_PROC_SUFFIX(PopGroupMarker, EXT); | 254 GET_PROC_SUFFIX(PopGroupMarker, EXT); |
| 266 } | 255 } |
| 267 | 256 |
| 268 if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_invalidate_subdata"))
{ | 257 if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_invalidate_subdata"))
{ |
| 269 GET_PROC(InvalidateBufferData); | 258 GET_PROC(InvalidateBufferData); |
| 270 GET_PROC(InvalidateBufferSubData); | 259 GET_PROC(InvalidateBufferSubData); |
| 271 GET_PROC(InvalidateFramebuffer); | 260 GET_PROC(InvalidateFramebuffer); |
| 272 GET_PROC(InvalidateSubFramebuffer); | 261 GET_PROC(InvalidateSubFramebuffer); |
| 273 GET_PROC(InvalidateTexImage); | 262 GET_PROC(InvalidateTexImage); |
| 274 GET_PROC(InvalidateTexSubImage); | 263 GET_PROC(InvalidateTexSubImage); |
| 275 } | 264 } |
| 276 | 265 |
| 277 if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_program_interface_quer
y")) { | 266 if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_program_interface_quer
y")) { |
| 278 GET_PROC(GetProgramResourceLocation); | 267 GET_PROC(GetProgramResourceLocation); |
| 279 } | 268 } |
| 280 | 269 |
| 281 interface->fStandard = kGL_GrGLStandard; | 270 interface->fStandard = kGL_GrGLStandard; |
| 282 interface->fExtensions.swap(&extensions); | 271 interface->fExtensions.swap(&extensions); |
| 283 | 272 |
| 284 return interface; | 273 return interface; |
| 285 } | 274 } |
| 286 | |
| 287 static GrGLStencilFillPathProc gStencilFillPath; | |
| 288 static GrGLCoverFillPathProc gCoverFillPath; | |
| 289 static GrGLvoid GR_GL_FUNCTION_TYPE stencil_then_cover_fill_path( | |
| 290 GrGLuint path, GrGLenum fillMode, | |
| 291 GrGLuint mask, GrGLenum coverMode) { | |
| 292 gStencilFillPath(path, fillMode, mask); | |
| 293 gCoverFillPath(path, coverMode); | |
| 294 } | |
| 295 | |
| 296 | |
| 297 static GrGLStencilStrokePathProc gStencilStrokePath; | |
| 298 static GrGLCoverStrokePathProc gCoverStrokePath; | |
| 299 static GrGLvoid GR_GL_FUNCTION_TYPE stencil_then_cover_stroke_path( | |
| 300 GrGLuint path, GrGLint reference, | |
| 301 GrGLuint mask, GrGLenum coverMode) { | |
| 302 gStencilStrokePath(path, reference, mask); | |
| 303 gCoverStrokePath(path, coverMode); | |
| 304 } | |
| 305 | |
| 306 static GrGLStencilFillPathInstancedProc gStencilFillPathInstanced; | |
| 307 static GrGLCoverFillPathInstancedProc gCoverFillPathInstanced; | |
| 308 static GrGLvoid GR_GL_FUNCTION_TYPE stencil_then_cover_fill_path_instanced( | |
| 309 GrGLsizei numPaths, GrGLenum pathNameTyp
e, | |
| 310 const GrGLvoid *paths, GrGLuint pathBase
, | |
| 311 GrGLenum fillMode, GrGLuint mask, | |
| 312 GrGLenum coverMode, GrGLenum transformTy
pe, | |
| 313 const GrGLfloat *transformValues) { | |
| 314 gStencilFillPathInstanced(numPaths, pathNameType, paths, pathBase, | |
| 315 fillMode, mask, transformType, transformValues); | |
| 316 gCoverFillPathInstanced(numPaths, pathNameType, paths, pathBase, | |
| 317 coverMode, transformType, transformValues); | |
| 318 } | |
| 319 | |
| 320 static GrGLStencilStrokePathInstancedProc gStencilStrokePathInstanced; | |
| 321 static GrGLCoverStrokePathInstancedProc gCoverStrokePathInstanced; | |
| 322 static GrGLvoid GR_GL_FUNCTION_TYPE stencil_then_cover_stroke_path_instanced( | |
| 323 GrGLsizei numPaths, GrGLenum pathNameTyp
e, | |
| 324 const GrGLvoid *paths, GrGLuint pathBase
, | |
| 325 GrGLint reference, GrGLuint mask, | |
| 326 GrGLenum coverMode, GrGLenum transformTy
pe, | |
| 327 const GrGLfloat *transformValues) { | |
| 328 gStencilStrokePathInstanced(numPaths, pathNameType, paths, pathBase, | |
| 329 reference, mask, transformType, transformValues)
; | |
| 330 gCoverStrokePathInstanced(numPaths, pathNameType, paths, pathBase, | |
| 331 coverMode, transformType, transformValues); | |
| 332 } | |
| 333 | |
| 334 static void emulate_nvpr_stencil_then_cover(GrGLInterface* interface) { | |
| 335 if (NULL == gStencilFillPath) { | |
| 336 gStencilFillPath = (GrGLStencilFillPathProc)interface->fFunctions.fStenc
ilFillPath; | |
| 337 } | |
| 338 if (NULL == gCoverFillPath) { | |
| 339 gCoverFillPath = (GrGLCoverFillPathProc)interface->fFunctions.fCoverFill
Path; | |
| 340 } | |
| 341 if (NULL == gStencilStrokePath) { | |
| 342 gStencilStrokePath = (GrGLStencilStrokePathProc)interface->fFunctions.fS
tencilStrokePath; | |
| 343 } | |
| 344 if (NULL == gCoverStrokePath) { | |
| 345 gCoverStrokePath = (GrGLCoverStrokePathProc)interface->fFunctions.fCover
StrokePath; | |
| 346 } | |
| 347 if (NULL == gStencilFillPathInstanced) { | |
| 348 gStencilFillPathInstanced = (GrGLStencilFillPathInstancedProc) | |
| 349 interface->fFunctions.fStencilFillPathInstanced; | |
| 350 } | |
| 351 if (NULL == gCoverFillPathInstanced) { | |
| 352 gCoverFillPathInstanced = (GrGLCoverFillPathInstancedProc) | |
| 353 interface->fFunctions.fCoverFillPathInstanced; | |
| 354 } | |
| 355 if (NULL == gStencilStrokePathInstanced) { | |
| 356 gStencilStrokePathInstanced = (GrGLStencilStrokePathInstancedProc) | |
| 357 interface->fFunctions.fStencilStrokePathInstanced; | |
| 358 } | |
| 359 if (NULL == gCoverStrokePathInstanced) { | |
| 360 gCoverStrokePathInstanced = (GrGLCoverStrokePathInstancedProc) | |
| 361 interface->fFunctions.fCoverStrokePathInstanced; | |
| 362 } | |
| 363 | |
| 364 if (interface->fFunctions.fStencilFillPath != gStencilFillPath || | |
| 365 interface->fFunctions.fCoverFillPath != gCoverFillPath || | |
| 366 interface->fFunctions.fStencilStrokePath != gStencilStrokePath || | |
| 367 interface->fFunctions.fCoverStrokePath != gCoverStrokePath || | |
| 368 interface->fFunctions.fStencilFillPathInstanced != gStencilFillPathInsta
nced || | |
| 369 interface->fFunctions.fCoverFillPathInstanced != gCoverFillPathInstanced
|| | |
| 370 interface->fFunctions.fStencilStrokePathInstanced != gStencilStrokePathI
nstanced || | |
| 371 interface->fFunctions.fCoverStrokePathInstanced != gCoverStrokePathInsta
nced) { | |
| 372 // While not every windowing system requires GetProcAddress to return | |
| 373 // the same addresses in different contexts, it is guaranteed to do so | |
| 374 // in any context that supports NV_path_rendering. | |
| 375 SkFAIL("GetProcAddress returned different addresses for the same nvpr fu
nctions"); | |
| 376 return; | |
| 377 } | |
| 378 | |
| 379 interface->fFunctions.fStencilThenCoverFillPath = &stencil_then_cover_fill_p
ath; | |
| 380 interface->fFunctions.fStencilThenCoverStrokePath = &stencil_then_cover_stro
ke_path; | |
| 381 interface->fFunctions.fStencilThenCoverFillPathInstanced = &stencil_then_cov
er_fill_path_instanced; | |
| 382 interface->fFunctions.fStencilThenCoverStrokePathInstanced = &stencil_then_c
over_stroke_path_instanced; | |
| 383 } | |
| OLD | NEW |