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. It also will query for EGL extensions if a
eglQueryString |
| 21 * implementation is provided. |
21 */ | 22 */ |
22 class SK_API GrGLExtensions { | 23 class SK_API GrGLExtensions { |
23 public: | 24 public: |
24 GrGLExtensions() : fInitialized(false), fStrings(new SkTArray<SkString>) {} | 25 GrGLExtensions() : fInitialized(false), fStrings(new SkTArray<SkString>) {} |
25 | 26 |
26 GrGLExtensions(const GrGLExtensions&); | 27 GrGLExtensions(const GrGLExtensions&); |
27 | 28 |
28 GrGLExtensions& operator=(const GrGLExtensions&); | 29 GrGLExtensions& operator=(const GrGLExtensions&); |
29 | 30 |
30 void swap(GrGLExtensions* that) { | 31 void swap(GrGLExtensions* that) { |
31 fStrings.swap(that->fStrings); | 32 fStrings.swap(that->fStrings); |
32 SkTSwap(fInitialized, that->fInitialized); | 33 SkTSwap(fInitialized, that->fInitialized); |
33 } | 34 } |
34 | 35 |
35 /** | 36 /** |
36 * We sometimes need to use this class without having yet created a GrGLInte
rface. This version | 37 * We sometimes need to use this class without having yet created a GrGLInte
rface. This version |
37 * of init expects that getString is always non-NULL while getIntegerv and g
etStringi are non- | 38 * of init expects that getString is always non-NULL while getIntegerv and g
etStringi are non- |
38 * NULL if on desktop GL with version 3.0 or higher. Otherwise it will fail. | 39 * NULL if on desktop GL with version 3.0 or higher. Otherwise it will fail. |
39 */ | 40 */ |
40 bool init(GrGLStandard standard, | 41 bool init(GrGLStandard standard, |
41 GrGLGetStringProc getString, | 42 GrGLGetStringProc getString, |
42 GrGLGetStringiProc getStringi, | 43 GrGLGetStringiProc getStringi, |
43 GrGLGetIntegervProc getIntegerv); | 44 GrGLGetIntegervProc getIntegerv, |
| 45 GrEGLQueryStringProc queryString, |
| 46 GrEGLDisplay eglDisplay); |
44 | 47 |
45 bool isInitialized() const { return fInitialized; } | 48 bool isInitialized() const { return fInitialized; } |
46 | 49 |
47 /** | 50 /** |
48 * Queries whether an extension is present. This will fail if init() has not
been called. | 51 * Queries whether an extension is present. This will fail if init() has not
been called. |
49 */ | 52 */ |
50 bool has(const char[]) const; | 53 bool has(const char[]) const; |
51 | 54 |
52 /** | 55 /** |
53 * Removes an extension if present. Returns true if the extension was presen
t before the call. | 56 * Removes an extension if present. Returns true if the extension was presen
t before the call. |
54 */ | 57 */ |
55 bool remove(const char[]); | 58 bool remove(const char[]); |
56 | 59 |
57 /** | 60 /** |
58 * Adds an extension to list | 61 * Adds an extension to list |
59 */ | 62 */ |
60 void add(const char[]); | 63 void add(const char[]); |
61 | 64 |
62 void reset() { fStrings->reset(); } | 65 void reset() { fStrings->reset(); } |
63 | 66 |
64 void print(const char* sep = "\n") const; | 67 void print(const char* sep = "\n") const; |
65 | 68 |
66 private: | 69 private: |
67 bool fInitialized; | 70 bool fInitialized; |
68 SkAutoTDelete<SkTArray<SkString> > fStrings; | 71 SkAutoTDelete<SkTArray<SkString> > fStrings; |
69 }; | 72 }; |
70 | 73 |
71 #endif | 74 #endif |
OLD | NEW |