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 "SkRefCnt.h" | 12 #include "SkRefCnt.h" |
13 | 13 |
14 //////////////////////////////////////////////////////////////////////////////// | 14 //////////////////////////////////////////////////////////////////////////////// |
15 | 15 |
16 /** | 16 /** |
17 * Classifies GL contexts (currently as Desktop vs. ES2). This is a bitfield. | 17 * Classifies GL contexts by which standard they implement (currently as Desktop |
18 * A GrGLInterface (defined below) may support multiple bindings. | 18 * vs. ES). |
19 */ | 19 */ |
20 enum GrGLBinding { | 20 enum GrGLStandard { |
21 kNone_GrGLBinding = 0x0, | 21 kNone_GrGLStandard, |
22 | 22 kGL_GrGLStandard, |
23 kDesktop_GrGLBinding = 0x01, | 23 kGLES_GrGLStandard, |
24 kES_GrGLBinding = 0x02, // ES2+ only | |
25 | |
26 // for iteration of GrGLBindings | |
27 kFirstGrGLBinding = kDesktop_GrGLBinding, | |
28 kLastGrGLBinding = kES_GrGLBinding | |
29 }; | 24 }; |
30 | 25 |
31 // Temporary alias until Chromium can be updated. | 26 // Temporary alias until Chromium can be updated. |
32 static const GrGLBinding kES2_GrGLBinding = kES_GrGLBinding; | 27 static const GrGLStandard kES2_GrGLBinding = kGLES_GrGLStandard; |
33 | 28 |
34 //////////////////////////////////////////////////////////////////////////////// | 29 //////////////////////////////////////////////////////////////////////////////// |
35 | 30 |
36 /** | 31 /** |
37 * Rather than depend on platform-specific GL headers and libraries, we require | 32 * Rather than depend on platform-specific GL headers and libraries, we require |
38 * the client to provide a struct of GL function pointers. This struct can be | 33 * the client to provide a struct of GL function pointers. This struct can be |
39 * specified per-GrContext as a parameter to GrContext::Create. If NULL is | 34 * specified per-GrContext as a parameter to GrContext::Create. If NULL is |
40 * passed to Create then a "default" GL interface is created. If the default is | 35 * passed to Create then a "default" GL interface is created. If the default is |
41 * also NULL GrContext creation will fail. | 36 * also NULL GrContext creation will fail. |
42 * | 37 * |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 FNPTR_TYPE fPtr; | 109 FNPTR_TYPE fPtr; |
115 }; | 110 }; |
116 | 111 |
117 typedef SkRefCnt INHERITED; | 112 typedef SkRefCnt INHERITED; |
118 | 113 |
119 public: | 114 public: |
120 SK_DECLARE_INST_COUNT(GrGLInterface) | 115 SK_DECLARE_INST_COUNT(GrGLInterface) |
121 | 116 |
122 GrGLInterface(); | 117 GrGLInterface(); |
123 | 118 |
124 // Validates that the GrGLInterface supports a binding. This means that | 119 // Validates that the GrGLInterface supports its advertised standard. This m
eans the necessary |
125 // the GrGLinterface advertises the binding in fBindingsExported and all | 120 // function pointers have been initialized for both the GL version and any a
dvertised |
126 // the necessary function pointers have been initialized. The interface is | 121 // extensions. |
127 // validated for the current OpenGL context. | 122 bool validate() const; |
128 bool validate(GrGLBinding binding) const; | |
129 | 123 |
130 // Indicator variable specifying the type of GL implementation | 124 // Indicates the type of GL implementation |
131 // exported: GLES2 and/or Desktop. | 125 union { |
132 GrGLBinding fBindingsExported; | 126 GrGLStandard fStandard; |
| 127 GrGLStandard fBindingsExported; // Legacy name, will be remove when Chro
mium is updated. |
| 128 }; |
133 | 129 |
134 GLPtr<GrGLActiveTextureProc> fActiveTexture; | 130 GLPtr<GrGLActiveTextureProc> fActiveTexture; |
135 GLPtr<GrGLAttachShaderProc> fAttachShader; | 131 GLPtr<GrGLAttachShaderProc> fAttachShader; |
136 GLPtr<GrGLBeginQueryProc> fBeginQuery; | 132 GLPtr<GrGLBeginQueryProc> fBeginQuery; |
137 GLPtr<GrGLBindAttribLocationProc> fBindAttribLocation; | 133 GLPtr<GrGLBindAttribLocationProc> fBindAttribLocation; |
138 GLPtr<GrGLBindBufferProc> fBindBuffer; | 134 GLPtr<GrGLBindBufferProc> fBindBuffer; |
139 GLPtr<GrGLBindFragDataLocationProc> fBindFragDataLocation; | 135 GLPtr<GrGLBindFragDataLocationProc> fBindFragDataLocation; |
140 GLPtr<GrGLBindFragDataLocationIndexedProc> fBindFragDataLocationIndexed; | 136 GLPtr<GrGLBindFragDataLocationIndexedProc> fBindFragDataLocationIndexed; |
141 GLPtr<GrGLBindFramebufferProc> fBindFramebuffer; | 137 GLPtr<GrGLBindFramebufferProc> fBindFramebuffer; |
142 GLPtr<GrGLBindRenderbufferProc> fBindRenderbuffer; | 138 GLPtr<GrGLBindRenderbufferProc> fBindRenderbuffer; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 | 344 |
349 // Per-GL func callback | 345 // Per-GL func callback |
350 #if GR_GL_PER_GL_FUNC_CALLBACK | 346 #if GR_GL_PER_GL_FUNC_CALLBACK |
351 GrGLInterfaceCallbackProc fCallback; | 347 GrGLInterfaceCallbackProc fCallback; |
352 GrGLInterfaceCallbackData fCallbackData; | 348 GrGLInterfaceCallbackData fCallbackData; |
353 #endif | 349 #endif |
354 | 350 |
355 }; | 351 }; |
356 | 352 |
357 #endif | 353 #endif |
OLD | NEW |