OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrGLInterface_DEFINED | 8 #ifndef GrGLInterface_DEFINED |
9 #define GrGLInterface_DEFINED | 9 #define GrGLInterface_DEFINED |
10 | 10 |
11 #include "GrGLFunctions.h" | 11 #include "GrGLFunctions.h" |
12 #include "GrGLExtensions.h" | |
12 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
13 | 14 |
14 //////////////////////////////////////////////////////////////////////////////// | 15 //////////////////////////////////////////////////////////////////////////////// |
15 | 16 |
16 /** | 17 /** |
17 * Classifies GL contexts by which standard they implement (currently as Desktop | |
18 * vs. ES). | |
19 */ | |
20 enum GrGLStandard { | |
21 kNone_GrGLStandard, | |
22 kGL_GrGLStandard, | |
23 kGLES_GrGLStandard, | |
24 }; | |
25 | |
26 // Temporary alias until Chromium can be updated. | |
27 static const GrGLStandard kES2_GrGLBinding = kGLES_GrGLStandard; | |
28 | |
29 //////////////////////////////////////////////////////////////////////////////// | |
30 | |
31 /** | |
32 * Rather than depend on platform-specific GL headers and libraries, we require | 18 * Rather than depend on platform-specific GL headers and libraries, we require |
33 * the client to provide a struct of GL function pointers. This struct can be | 19 * the client to provide a struct of GL function pointers. This struct can be |
34 * specified per-GrContext as a parameter to GrContext::Create. If NULL is | 20 * specified per-GrContext as a parameter to GrContext::Create. If NULL is |
35 * passed to Create then a "default" GL interface is created. If the default is | 21 * passed to Create then a "default" GL interface is created. If the default is |
36 * also NULL GrContext creation will fail. | 22 * also NULL GrContext creation will fail. |
37 * | 23 * |
38 * The default interface is returned by GrGLDefaultInterface. This function's | 24 * The default interface is returned by GrGLDefaultInterface. This function's |
39 * implementation is platform-specific. Several have been provided, along with | 25 * implementation is platform-specific. Several have been provided, along with |
40 * an implementation that simply returns NULL. | 26 * an implementation that simply returns NULL. |
41 * | 27 * |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 // Validates that the GrGLInterface supports its advertised standard. This m eans the necessary | 105 // Validates that the GrGLInterface supports its advertised standard. This m eans the necessary |
120 // function pointers have been initialized for both the GL version and any a dvertised | 106 // function pointers have been initialized for both the GL version and any a dvertised |
121 // extensions. | 107 // extensions. |
122 bool validate() const; | 108 bool validate() const; |
123 | 109 |
124 // Indicates the type of GL implementation | 110 // Indicates the type of GL implementation |
125 union { | 111 union { |
126 GrGLStandard fStandard; | 112 GrGLStandard fStandard; |
127 GrGLStandard fBindingsExported; // Legacy name, will be remove when Chro mium is updated. | 113 GrGLStandard fBindingsExported; // Legacy name, will be remove when Chro mium is updated. |
128 }; | 114 }; |
129 | 115 |
robertphillips
2014/01/16 17:13:11
Do we want to make fExtensions protected if using
bsalomon
2014/01/16 18:28:45
We can't. The factory functions need access to it.
| |
116 GrGLExtensions fExtensions; | |
117 | |
118 // This wrapper and const hackery is necessary because the factories in Chro mium do not yet | |
119 // initialize fExtensions. | |
120 bool hasExtension(const char ext[]) const { | |
121 if (!fExtensions.isInitialized()) { | |
122 GrGLExtensions* extensions = const_cast<GrGLExtensions*>(&fExtension s); | |
123 if (!extensions->init(fStandard, fGetString, fGetStringi, fGetIntege rv)) { | |
124 return false; | |
125 } | |
126 } | |
127 return fExtensions.has(ext); | |
128 } | |
129 | |
130 GLPtr<GrGLActiveTextureProc> fActiveTexture; | 130 GLPtr<GrGLActiveTextureProc> fActiveTexture; |
131 GLPtr<GrGLAttachShaderProc> fAttachShader; | 131 GLPtr<GrGLAttachShaderProc> fAttachShader; |
132 GLPtr<GrGLBeginQueryProc> fBeginQuery; | 132 GLPtr<GrGLBeginQueryProc> fBeginQuery; |
133 GLPtr<GrGLBindAttribLocationProc> fBindAttribLocation; | 133 GLPtr<GrGLBindAttribLocationProc> fBindAttribLocation; |
134 GLPtr<GrGLBindBufferProc> fBindBuffer; | 134 GLPtr<GrGLBindBufferProc> fBindBuffer; |
135 GLPtr<GrGLBindFragDataLocationProc> fBindFragDataLocation; | 135 GLPtr<GrGLBindFragDataLocationProc> fBindFragDataLocation; |
136 GLPtr<GrGLBindFragDataLocationIndexedProc> fBindFragDataLocationIndexed; | 136 GLPtr<GrGLBindFragDataLocationIndexedProc> fBindFragDataLocationIndexed; |
137 GLPtr<GrGLBindFramebufferProc> fBindFramebuffer; | 137 GLPtr<GrGLBindFramebufferProc> fBindFramebuffer; |
138 GLPtr<GrGLBindRenderbufferProc> fBindRenderbuffer; | 138 GLPtr<GrGLBindRenderbufferProc> fBindRenderbuffer; |
139 GLPtr<GrGLBindTextureProc> fBindTexture; | 139 GLPtr<GrGLBindTextureProc> fBindTexture; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 | 344 |
345 // Per-GL func callback | 345 // Per-GL func callback |
346 #if GR_GL_PER_GL_FUNC_CALLBACK | 346 #if GR_GL_PER_GL_FUNC_CALLBACK |
347 GrGLInterfaceCallbackProc fCallback; | 347 GrGLInterfaceCallbackProc fCallback; |
348 GrGLInterfaceCallbackData fCallbackData; | 348 GrGLInterfaceCallbackData fCallbackData; |
349 #endif | 349 #endif |
350 | 350 |
351 }; | 351 }; |
352 | 352 |
353 #endif | 353 #endif |
OLD | NEW |