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
|
|
|
|
|
|
|
|
#include "GrGLInterface.h"
|
|
|
|
#include "SkString.h"
|
|
|
|
#include "SkTArray.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* use the latter if it is available.
|
|
|
|
*/
|
|
|
|
class GrGLExtensions {
|
|
|
|
public:
|
|
|
|
bool init(GrGLBinding binding, const GrGLInterface* iface) {
|
2013-08-17 00:02:59 +00:00
|
|
|
SkASSERT(binding & iface->fBindingsExported);
|
2013-02-26 21:46:32 +00:00
|
|
|
return this->init(binding, iface->fGetString, iface->fGetStringi, iface->fGetIntegerv);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
bool init(GrGLBinding binding,
|
|
|
|
GrGLGetStringProc getString,
|
|
|
|
GrGLGetStringiProc getStringi,
|
|
|
|
GrGLGetIntegervProc getIntegerv);
|
2013-02-27 07:10:10 +00:00
|
|
|
|
2013-02-26 21:46:32 +00:00
|
|
|
/**
|
|
|
|
* Queries whether an extension is present. This will fail if init() has not been called.
|
|
|
|
*/
|
|
|
|
bool has(const char*) const;
|
2013-02-27 07:10:10 +00:00
|
|
|
|
2013-02-26 21:46:32 +00:00
|
|
|
void reset() { fStrings.reset(); }
|
|
|
|
|
2013-05-02 19:42:54 +00:00
|
|
|
void print(const char* sep = "\n") const;
|
|
|
|
|
2013-02-26 21:46:32 +00:00
|
|
|
private:
|
|
|
|
SkTArray<SkString> fStrings;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|