| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 GrGLExtensions_DEFINED | 8 #ifndef GrGLExtensions_DEFINED |
| 9 #define GrGLExtensions_DEFINED | 9 #define GrGLExtensions_DEFINED |
| 10 | 10 |
| 11 #include "GrGLInterface.h" | 11 #include "GrGLInterface.h" |
| 12 #include "SkString.h" | 12 #include "SkString.h" |
| 13 #include "SkTArray.h" | 13 #include "SkTArray.h" |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * This helper queries the current GL context for its extensions, remembers them
, and can be | 16 * This helper queries the current GL context for its extensions, remembers them
, and can be |
| 17 * queried. It supports both glGetString- and glGetStringi-style extension strin
g APIs and will | 17 * queried. It supports both glGetString- and glGetStringi-style extension strin
g APIs and will |
| 18 * use the latter if it is available. | 18 * use the latter if it is available. |
| 19 */ | 19 */ |
| 20 class GrGLExtensions { | 20 class GrGLExtensions { |
| 21 public: | 21 public: |
| 22 bool init(GrGLBinding binding, const GrGLInterface* iface) { | 22 bool init(const GrGLInterface* iface) { |
| 23 SkASSERT(binding & iface->fBindingsExported); | 23 return this->init(iface->fStandard, |
| 24 return this->init(binding, iface->fGetString, iface->fGetStringi, iface-
>fGetIntegerv); | 24 iface->fGetString, |
| 25 iface->fGetStringi, |
| 26 iface->fGetIntegerv); |
| 25 } | 27 } |
| 26 /** | 28 /** |
| 27 * We sometimes need to use this class without having yet created a GrGLInte
rface. This version | 29 * We sometimes need to use this class without having yet created a GrGLInte
rface. This version |
| 28 * of init expects that getString is always non-NULL while getIntegerv and g
etStringi are non- | 30 * of init expects that getString is always non-NULL while getIntegerv and g
etStringi are non- |
| 29 * NULL if on desktop GL with version 3.0 or higher. Otherwise it will fail. | 31 * NULL if on desktop GL with version 3.0 or higher. Otherwise it will fail. |
| 30 */ | 32 */ |
| 31 bool init(GrGLBinding binding, | 33 bool init(GrGLStandard standard, |
| 32 GrGLGetStringProc getString, | 34 GrGLGetStringProc getString, |
| 33 GrGLGetStringiProc getStringi, | 35 GrGLGetStringiProc getStringi, |
| 34 GrGLGetIntegervProc getIntegerv); | 36 GrGLGetIntegervProc getIntegerv); |
| 35 | 37 |
| 36 /** | 38 /** |
| 37 * Queries whether an extension is present. This will fail if init() has not
been called. | 39 * Queries whether an extension is present. This will fail if init() has not
been called. |
| 38 */ | 40 */ |
| 39 bool has(const char*) const; | 41 bool has(const char*) const; |
| 40 | 42 |
| 41 void reset() { fStrings.reset(); } | 43 void reset() { fStrings.reset(); } |
| 42 | 44 |
| 43 void print(const char* sep = "\n") const; | 45 void print(const char* sep = "\n") const; |
| 44 | 46 |
| 45 private: | 47 private: |
| 46 SkTArray<SkString> fStrings; | 48 SkTArray<SkString> fStrings; |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 #endif | 51 #endif |
| OLD | NEW |