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"
|
|
|
|
|
2014-01-17 15:05:38 +00:00
|
|
|
struct GrGLInterface;
|
|
|
|
|
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:
|
2015-08-26 20:07:48 +00:00
|
|
|
GrGLExtensions() : fInitialized(false), fStrings(new SkTArray<SkString>) {}
|
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) {
|
2015-09-07 19:45:52 +00:00
|
|
|
fStrings.swap(that->fStrings);
|
2014-01-24 20:49:44 +00:00
|
|
|
SkTSwap(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,
|
2016-02-08 15:22:17 +00:00
|
|
|
GrGLFunction<GrGLGetStringProc> getString,
|
|
|
|
GrGLFunction<GrGLGetStringiProc> getStringi,
|
|
|
|
GrGLFunction<GrGLGetIntegervProc> getIntegerv,
|
|
|
|
GrGLFunction<GrEGLQueryStringProc> 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[]);
|
|
|
|
|
2014-01-17 15:05:38 +00:00
|
|
|
void reset() { fStrings->reset(); }
|
2013-02-26 21:46:32 +00:00
|
|
|
|
2013-05-02 19:42:54 +00:00
|
|
|
void print(const char* sep = "\n") const;
|
|
|
|
|
2013-02-26 21:46:32 +00:00
|
|
|
private:
|
2014-01-17 15:05:38 +00:00
|
|
|
bool fInitialized;
|
2016-10-27 16:30:08 +00:00
|
|
|
std::unique_ptr<SkTArray<SkString>> fStrings;
|
2013-02-26 21:46:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|