OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 #ifndef GrGLInterface_DEFINED | 8 #ifndef GrGLInterface_DEFINED |
11 #define GrGLInterface_DEFINED | 9 #define GrGLInterface_DEFINED |
12 | 10 |
13 #include "GrGLFunctions.h" | 11 #include "GrGLFunctions.h" |
14 #include "GrRefCnt.h" | 12 #include "SkRefCnt.h" |
15 | 13 |
16 //////////////////////////////////////////////////////////////////////////////// | 14 //////////////////////////////////////////////////////////////////////////////// |
17 | 15 |
18 /** | 16 /** |
19 * Classifies GL contexts (currently as Desktop vs. ES2). This is a bitfield. | 17 * Classifies GL contexts (currently as Desktop vs. ES2). This is a bitfield. |
20 * A GrGLInterface (defined below) may support multiple bindings. | 18 * A GrGLInterface (defined below) may support multiple bindings. |
21 */ | 19 */ |
22 enum GrGLBinding { | 20 enum GrGLBinding { |
23 kNone_GrGLBinding = 0x0, | 21 kNone_GrGLBinding = 0x0, |
24 | 22 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 * GrContext uses the following interface to make all calls into OpenGL. When a | 101 * GrContext uses the following interface to make all calls into OpenGL. When a |
104 * GrContext is created it is given a GrGLInterface. The interface's function | 102 * GrContext is created it is given a GrGLInterface. The interface's function |
105 * pointers must be valid for the OpenGL context associated with the GrContext. | 103 * pointers must be valid for the OpenGL context associated with the GrContext. |
106 * On some platforms, such as Windows, function pointers for OpenGL extensions | 104 * On some platforms, such as Windows, function pointers for OpenGL extensions |
107 * may vary between OpenGL contexts. So the caller must be careful to use a | 105 * may vary between OpenGL contexts. So the caller must be careful to use a |
108 * GrGLInterface initialized for the correct context. All functions that should | 106 * GrGLInterface initialized for the correct context. All functions that should |
109 * be available based on the OpenGL's version and extension string must be | 107 * be available based on the OpenGL's version and extension string must be |
110 * non-NULL or GrContext creation will fail. This can be tested with the | 108 * non-NULL or GrContext creation will fail. This can be tested with the |
111 * validate() method when the OpenGL context has been made current. | 109 * validate() method when the OpenGL context has been made current. |
112 */ | 110 */ |
113 struct SK_API GrGLInterface : public GrRefCnt { | 111 struct SK_API GrGLInterface : public SkRefCnt { |
114 private: | 112 private: |
115 // simple wrapper class that exists only to initialize a pointer to NULL | 113 // simple wrapper class that exists only to initialize a pointer to NULL |
116 template <typename FNPTR_TYPE> class GLPtr { | 114 template <typename FNPTR_TYPE> class GLPtr { |
117 public: | 115 public: |
118 GLPtr() : fPtr(NULL) {} | 116 GLPtr() : fPtr(NULL) {} |
119 GLPtr operator =(FNPTR_TYPE ptr) { fPtr = ptr; return *this; } | 117 GLPtr operator =(FNPTR_TYPE ptr) { fPtr = ptr; return *this; } |
120 operator FNPTR_TYPE() const { return fPtr; } | 118 operator FNPTR_TYPE() const { return fPtr; } |
121 private: | 119 private: |
122 FNPTR_TYPE fPtr; | 120 FNPTR_TYPE fPtr; |
123 }; | 121 }; |
124 | 122 |
125 typedef GrRefCnt INHERITED; | 123 typedef SkRefCnt INHERITED; |
126 | 124 |
127 public: | 125 public: |
128 SK_DECLARE_INST_COUNT(GrGLInterface) | 126 SK_DECLARE_INST_COUNT(GrGLInterface) |
129 | 127 |
130 GrGLInterface(); | 128 GrGLInterface(); |
131 | 129 |
132 // Validates that the GrGLInterface supports a binding. This means that | 130 // Validates that the GrGLInterface supports a binding. This means that |
133 // the GrGLinterface advertises the binding in fBindingsExported and all | 131 // the GrGLinterface advertises the binding in fBindingsExported and all |
134 // the necessary function pointers have been initialized. The interface is | 132 // the necessary function pointers have been initialized. The interface is |
135 // validated for the current OpenGL context. | 133 // validated for the current OpenGL context. |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 | 351 |
354 // Per-GL func callback | 352 // Per-GL func callback |
355 #if GR_GL_PER_GL_FUNC_CALLBACK | 353 #if GR_GL_PER_GL_FUNC_CALLBACK |
356 GrGLInterfaceCallbackProc fCallback; | 354 GrGLInterfaceCallbackProc fCallback; |
357 GrGLInterfaceCallbackData fCallbackData; | 355 GrGLInterfaceCallbackData fCallbackData; |
358 #endif | 356 #endif |
359 | 357 |
360 }; | 358 }; |
361 | 359 |
362 #endif | 360 #endif |
OLD | NEW |