2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef GrGLExtensions_DEFINED
9 #define GrGLExtensions_DEFINED
11 #include "include/core/SkString.h"
12 #include "include/gpu/gl/GrGLFunctions.h"
13 #include "include/private/SkTArray.h"
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
23 * use the latter if it is available. It also will query for EGL extensions if a eglQueryString
24 * implementation is provided.
26 class SK_API GrGLExtensions {
30 GrGLExtensions(const GrGLExtensions&);
32 GrGLExtensions& operator=(const GrGLExtensions&);
34 void swap(GrGLExtensions* that) {
36 swap(fStrings, that->fStrings);
37 swap(fInitialized, that->fInitialized);
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.
45 bool init(GrGLStandard standard,
46 GrGLFunction<GrGLGetStringFn> getString,
47 GrGLFunction<GrGLGetStringiFn> getStringi,
48 GrGLFunction<GrGLGetIntegervFn> getIntegerv,
49 GrGLFunction<GrEGLQueryStringFn> queryString = nullptr,
50 GrEGLDisplay eglDisplay = nullptr);
52 bool isInitialized() const { return fInitialized; }
55 * Queries whether an extension is present. This will fail if init() has not been called.
57 bool has(const char[]) const;
60 * Removes an extension if present. Returns true if the extension was present before the call.
62 bool remove(const char[]);
65 * Adds an extension to list
67 void add(const char[]);
69 void reset() { fStrings.reset(); }
71 void dumpJSON(SkJSONWriter*) const;
74 bool fInitialized = false;
75 SkTArray<SkString> fStrings;