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