2013-02-26 21:46:32 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GrGLExtensions_DEFINED
|
|
|
|
#define GrGLExtensions_DEFINED
|
|
|
|
|
2016-02-17 21:13:44 +00:00
|
|
|
#include "../../private/SkTArray.h"
|
2014-01-17 15:05:38 +00:00
|
|
|
#include "GrGLFunctions.h"
|
2013-02-26 21:46:32 +00:00
|
|
|
#include "SkString.h"
|
|
|
|
|
2018-06-18 19:11:00 +00:00
|
|
|
#include <utility>
|
|
|
|
|
2014-01-17 15:05:38 +00:00
|
|
|
struct GrGLInterface;
|
2017-08-10 14:23:25 +00:00
|
|
|
class SkJSONWriter;
|
2014-01-17 15:05:38 +00:00
|
|
|
|
2013-02-26 21:46:32 +00:00
|
|
|
/**
|
|
|
|
* This helper queries the current GL context for its extensions, remembers them, and can be
|
|
|
|
* queried. It supports both glGetString- and glGetStringi-style extension string APIs and will
|
2015-11-16 14:48:44 +00:00
|
|
|
* use the latter if it is available. It also will query for EGL extensions if a eglQueryString
|
|
|
|
* implementation is provided.
|
2013-02-26 21:46:32 +00:00
|
|
|
*/
|
2014-02-25 02:14:57 +00:00
|
|
|
class SK_API GrGLExtensions {
|
2013-02-26 21:46:32 +00:00
|
|
|
public:
|
2018-03-21 16:49:56 +00:00
|
|
|
GrGLExtensions() {}
|
2014-01-17 15:05:38 +00:00
|
|
|
|
2014-01-24 20:49:44 +00:00
|
|
|
GrGLExtensions(const GrGLExtensions&);
|
|
|
|
|
|
|
|
GrGLExtensions& operator=(const GrGLExtensions&);
|
|
|
|
|
2014-01-17 15:05:38 +00:00
|
|
|
void swap(GrGLExtensions* that) {
|
2018-06-18 19:11:00 +00:00
|
|
|
using std::swap;
|
|
|
|
swap(fStrings, that->fStrings);
|
|
|
|
swap(fInitialized, that->fInitialized);
|
2013-02-26 21:46:32 +00:00
|
|
|
}
|
2014-01-17 15:05:38 +00:00
|
|
|
|
2013-02-26 21:46:32 +00:00
|
|
|
/**
|
|
|
|
* We sometimes need to use this class without having yet created a GrGLInterface. This version
|
|
|
|
* of init expects that getString is always non-NULL while getIntegerv and getStringi are non-
|
|
|
|
* NULL if on desktop GL with version 3.0 or higher. Otherwise it will fail.
|
|
|
|
*/
|
2014-01-16 16:35:09 +00:00
|
|
|
bool init(GrGLStandard standard,
|
2018-08-24 14:26:42 +00:00
|
|
|
GrGLFunction<GrGLGetStringFn> getString,
|
|
|
|
GrGLFunction<GrGLGetStringiFn> getStringi,
|
|
|
|
GrGLFunction<GrGLGetIntegervFn> getIntegerv,
|
|
|
|
GrGLFunction<GrEGLQueryStringFn> queryString = nullptr,
|
2015-11-16 16:28:21 +00:00
|
|
|
GrEGLDisplay eglDisplay = nullptr);
|
2013-02-27 07:10:10 +00:00
|
|
|
|
2014-01-17 15:05:38 +00:00
|
|
|
bool isInitialized() const { return fInitialized; }
|
|
|
|
|
2013-02-26 21:46:32 +00:00
|
|
|
/**
|
|
|
|
* Queries whether an extension is present. This will fail if init() has not been called.
|
|
|
|
*/
|
2014-01-24 20:49:44 +00:00
|
|
|
bool has(const char[]) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes an extension if present. Returns true if the extension was present before the call.
|
|
|
|
*/
|
|
|
|
bool remove(const char[]);
|
2013-02-27 07:10:10 +00:00
|
|
|
|
2014-02-21 18:45:30 +00:00
|
|
|
/**
|
|
|
|
* Adds an extension to list
|
|
|
|
*/
|
|
|
|
void add(const char[]);
|
|
|
|
|
2018-03-21 16:49:56 +00:00
|
|
|
void reset() { fStrings.reset(); }
|
2013-02-26 21:46:32 +00:00
|
|
|
|
2017-08-10 14:23:25 +00:00
|
|
|
void dumpJSON(SkJSONWriter*) const;
|
2013-05-02 19:42:54 +00:00
|
|
|
|
2013-02-26 21:46:32 +00:00
|
|
|
private:
|
2018-03-21 16:49:56 +00:00
|
|
|
bool fInitialized = false;
|
|
|
|
SkTArray<SkString> fStrings;
|
2013-02-26 21:46:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|