bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrGLExtensions_DEFINED |
| 9 | #define GrGLExtensions_DEFINED |
| 10 | |
bungeman | bf521ff | 2016-02-17 13:13:44 -0800 | [diff] [blame] | 11 | #include "../../private/SkTArray.h" |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 12 | #include "GrGLFunctions.h" |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 13 | #include "SkString.h" |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 14 | |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 15 | struct GrGLInterface; |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame^] | 16 | class SkJSONWriter; |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 17 | |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 18 | /** |
| 19 | * This helper queries the current GL context for its extensions, remembers them, and can be |
| 20 | * queried. It supports both glGetString- and glGetStringi-style extension string APIs and will |
bsalomon | b1a32ad | 2015-11-16 06:48:44 -0800 | [diff] [blame] | 21 | * use the latter if it is available. It also will query for EGL extensions if a eglQueryString |
| 22 | * implementation is provided. |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 23 | */ |
commit-bot@chromium.org | 0714360 | 2014-02-25 02:14:57 +0000 | [diff] [blame] | 24 | class SK_API GrGLExtensions { |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 25 | public: |
halcanary | 385fe4d | 2015-08-26 13:07:48 -0700 | [diff] [blame] | 26 | GrGLExtensions() : fInitialized(false), fStrings(new SkTArray<SkString>) {} |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 27 | |
commit-bot@chromium.org | d8ed851 | 2014-01-24 20:49:44 +0000 | [diff] [blame] | 28 | GrGLExtensions(const GrGLExtensions&); |
| 29 | |
| 30 | GrGLExtensions& operator=(const GrGLExtensions&); |
| 31 | |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 32 | void swap(GrGLExtensions* that) { |
bungeman | a3434d8 | 2015-09-07 12:45:52 -0700 | [diff] [blame] | 33 | fStrings.swap(that->fStrings); |
commit-bot@chromium.org | d8ed851 | 2014-01-24 20:49:44 +0000 | [diff] [blame] | 34 | SkTSwap(fInitialized, that->fInitialized); |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 35 | } |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 36 | |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 37 | /** |
| 38 | * We sometimes need to use this class without having yet created a GrGLInterface. This version |
| 39 | * of init expects that getString is always non-NULL while getIntegerv and getStringi are non- |
| 40 | * NULL if on desktop GL with version 3.0 or higher. Otherwise it will fail. |
| 41 | */ |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 42 | bool init(GrGLStandard standard, |
bsalomon | 9f2dc27 | 2016-02-08 07:22:17 -0800 | [diff] [blame] | 43 | GrGLFunction<GrGLGetStringProc> getString, |
| 44 | GrGLFunction<GrGLGetStringiProc> getStringi, |
| 45 | GrGLFunction<GrGLGetIntegervProc> getIntegerv, |
| 46 | GrGLFunction<GrEGLQueryStringProc> queryString = nullptr, |
bsalomon | a779ef1 | 2015-11-16 08:28:21 -0800 | [diff] [blame] | 47 | GrEGLDisplay eglDisplay = nullptr); |
skia.committer@gmail.com | 12eea2b | 2013-02-27 07:10:10 +0000 | [diff] [blame] | 48 | |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 49 | bool isInitialized() const { return fInitialized; } |
| 50 | |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 51 | /** |
| 52 | * Queries whether an extension is present. This will fail if init() has not been called. |
| 53 | */ |
commit-bot@chromium.org | d8ed851 | 2014-01-24 20:49:44 +0000 | [diff] [blame] | 54 | bool has(const char[]) const; |
| 55 | |
| 56 | /** |
| 57 | * Removes an extension if present. Returns true if the extension was present before the call. |
| 58 | */ |
| 59 | bool remove(const char[]); |
skia.committer@gmail.com | 12eea2b | 2013-02-27 07:10:10 +0000 | [diff] [blame] | 60 | |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 61 | /** |
| 62 | * Adds an extension to list |
| 63 | */ |
| 64 | void add(const char[]); |
| 65 | |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 66 | void reset() { fStrings->reset(); } |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 67 | |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame^] | 68 | void dumpJSON(SkJSONWriter*) const; |
bsalomon@google.com | 00142c4 | 2013-05-02 19:42:54 +0000 | [diff] [blame] | 69 | |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 70 | private: |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 71 | bool fInitialized; |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 72 | std::unique_ptr<SkTArray<SkString>> fStrings; |
bsalomon@google.com | 1744f97 | 2013-02-26 21:46:32 +0000 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | #endif |