| 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 "GrGLFunctions.h" | 11 #include "GrGLFunctions.h" |
| 12 #include "SkString.h" | 12 #include "SkString.h" |
| 13 #include "SkTArray.h" | 13 #include "SkTArray.h" |
| 14 | 14 |
| 15 struct GrGLInterface; | 15 struct GrGLInterface; |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * This helper queries the current GL context for its extensions, remembers them
, and can be | 18 * This helper queries the current GL context for its extensions, remembers them
, and can be |
| 19 * queried. It supports both glGetString- and glGetStringi-style extension strin
g APIs and will | 19 * queried. It supports both glGetString- and glGetStringi-style extension strin
g APIs and will |
| 20 * use the latter if it is available. | 20 * use the latter if it is available. |
| 21 */ | 21 */ |
| 22 class GrGLExtensions : public SkNoncopyable { | 22 class GrGLExtensions { |
| 23 public: | 23 public: |
| 24 GrGLExtensions() : fInitialized(false), fStrings(SkNEW(SkTArray<SkString>))
{} | 24 GrGLExtensions() : fInitialized(false), fStrings(SkNEW(SkTArray<SkString>))
{} |
| 25 | 25 |
| 26 GrGLExtensions(const GrGLExtensions&); |
| 27 |
| 28 GrGLExtensions& operator=(const GrGLExtensions&); |
| 29 |
| 26 void swap(GrGLExtensions* that) { | 30 void swap(GrGLExtensions* that) { |
| 27 fStrings.swap(&that->fStrings); | 31 fStrings.swap(&that->fStrings); |
| 32 SkTSwap(fInitialized, that->fInitialized); |
| 28 } | 33 } |
| 29 | 34 |
| 30 /** | 35 /** |
| 31 * We sometimes need to use this class without having yet created a GrGLInte
rface. This version | 36 * We sometimes need to use this class without having yet created a GrGLInte
rface. This version |
| 32 * of init expects that getString is always non-NULL while getIntegerv and g
etStringi are non- | 37 * of init expects that getString is always non-NULL while getIntegerv and g
etStringi are non- |
| 33 * NULL if on desktop GL with version 3.0 or higher. Otherwise it will fail. | 38 * NULL if on desktop GL with version 3.0 or higher. Otherwise it will fail. |
| 34 */ | 39 */ |
| 35 bool init(GrGLStandard standard, | 40 bool init(GrGLStandard standard, |
| 36 GrGLGetStringProc getString, | 41 GrGLGetStringProc getString, |
| 37 GrGLGetStringiProc getStringi, | 42 GrGLGetStringiProc getStringi, |
| 38 GrGLGetIntegervProc getIntegerv); | 43 GrGLGetIntegervProc getIntegerv); |
| 39 | 44 |
| 40 bool isInitialized() const { return fInitialized; } | 45 bool isInitialized() const { return fInitialized; } |
| 41 | 46 |
| 42 /** | 47 /** |
| 43 * Queries whether an extension is present. This will fail if init() has not
been called. | 48 * Queries whether an extension is present. This will fail if init() has not
been called. |
| 44 */ | 49 */ |
| 45 bool has(const char*) const; | 50 bool has(const char[]) const; |
| 51 |
| 52 /** |
| 53 * Removes an extension if present. Returns true if the extension was presen
t before the call. |
| 54 */ |
| 55 bool remove(const char[]); |
| 46 | 56 |
| 47 void reset() { fStrings->reset(); } | 57 void reset() { fStrings->reset(); } |
| 48 | 58 |
| 49 void print(const char* sep = "\n") const; | 59 void print(const char* sep = "\n") const; |
| 50 | 60 |
| 51 private: | 61 private: |
| 52 bool fInitialized; | 62 bool fInitialized; |
| 53 SkAutoTDelete<SkTArray<SkString> > fStrings; | 63 SkAutoTDelete<SkTArray<SkString> > fStrings; |
| 54 }; | 64 }; |
| 55 | 65 |
| 56 #endif | 66 #endif |
| OLD | NEW |