Debian Codegraph @

include/gpu/ganesh/gl/GrGLExtensions.h

raw
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
11 #include "include/core/SkString.h"
12 #include "include/gpu/ganesh/gl/GrGLFunctions.h"
13 #include "include/gpu/ganesh/gl/GrGLTypes.h"
14 #include "include/private/base/SkAPI.h"
15 #include "include/private/base/SkTArray.h"
16
17 #include <utility>
18
19 class SkJSONWriter;
20
21 /**
22 * This helper queries the current GL context for its extensions, remembers them, and can be
23 * queried. It supports both glGetString- and glGetStringi-style extension string APIs and will
24 * use the latter if it is available. It also will query for EGL extensions if a eglQueryString
25 * implementation is provided.
26 */
27 class SK_API GrGLExtensions {
28 public:
29 GrGLExtensions() {}
30
31 GrGLExtensions(const GrGLExtensions&);
32
33 GrGLExtensions& operator=(const GrGLExtensions&);
34
35 void swap(GrGLExtensions* that) {
36 using std::swap;
37 swap(fStrings, that->fStrings);
38 swap(fInitialized, that->fInitialized);
39 }
40
41 /**
42 * We sometimes need to use this class without having yet created a GrGLInterface. This version
43 * of init expects that getString is always non-NULL while getIntegerv and getStringi are non-
44 * NULL if on desktop GL with version 3.0 or higher. Otherwise it will fail.
45 */
46 bool init(GrGLStandard standard,
47 GrGLFunction<GrGLGetStringFn> getString,
48 GrGLFunction<GrGLGetStringiFn> getStringi,
49 GrGLFunction<GrGLGetIntegervFn> getIntegerv,
50 GrGLFunction<GrEGLQueryStringFn> queryString = nullptr,
51 GrEGLDisplay eglDisplay = nullptr);
52
53 bool isInitialized() const { return fInitialized; }
54
55 /**
56 * Queries whether an extension is present. This will fail if init() has not been called.
57 */
58 bool has(const char[]) const;
59
60 /**
61 * Removes an extension if present. Returns true if the extension was present before the call.
62 */
63 bool remove(const char[]);
64
65 /**
66 * Adds an extension to list
67 */
68 void add(const char[]);
69
70 void reset() { fStrings.clear(); }
71
72 void dumpJSON(SkJSONWriter*) const;
73
74 private:
75 bool fInitialized = false;
76 skia_private::TArray<SkString> fStrings;
77 };
78
79 #endif