michael@0: /* michael@0: * Copyright 2013 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef GrGLExtensions_DEFINED michael@0: #define GrGLExtensions_DEFINED michael@0: michael@0: #include "GrGLFunctions.h" michael@0: #include "SkString.h" michael@0: #include "SkTArray.h" michael@0: michael@0: struct GrGLInterface; michael@0: michael@0: /** michael@0: * This helper queries the current GL context for its extensions, remembers them, and can be michael@0: * queried. It supports both glGetString- and glGetStringi-style extension string APIs and will michael@0: * use the latter if it is available. michael@0: */ michael@0: class SK_API GrGLExtensions { michael@0: public: michael@0: GrGLExtensions() : fInitialized(false), fStrings(SkNEW(SkTArray)) {} michael@0: michael@0: GrGLExtensions(const GrGLExtensions&); michael@0: michael@0: GrGLExtensions& operator=(const GrGLExtensions&); michael@0: michael@0: void swap(GrGLExtensions* that) { michael@0: fStrings.swap(&that->fStrings); michael@0: SkTSwap(fInitialized, that->fInitialized); michael@0: } michael@0: michael@0: /** michael@0: * We sometimes need to use this class without having yet created a GrGLInterface. This version michael@0: * of init expects that getString is always non-NULL while getIntegerv and getStringi are non- michael@0: * NULL if on desktop GL with version 3.0 or higher. Otherwise it will fail. michael@0: */ michael@0: bool init(GrGLStandard standard, michael@0: GrGLGetStringProc getString, michael@0: GrGLGetStringiProc getStringi, michael@0: GrGLGetIntegervProc getIntegerv); michael@0: michael@0: bool isInitialized() const { return fInitialized; } michael@0: michael@0: /** michael@0: * Queries whether an extension is present. This will fail if init() has not been called. michael@0: */ michael@0: bool has(const char[]) const; michael@0: michael@0: /** michael@0: * Removes an extension if present. Returns true if the extension was present before the call. michael@0: */ michael@0: bool remove(const char[]); michael@0: michael@0: /** michael@0: * Adds an extension to list michael@0: */ michael@0: void add(const char[]); michael@0: michael@0: void reset() { fStrings->reset(); } michael@0: michael@0: void print(const char* sep = "\n") const; michael@0: michael@0: private: michael@0: bool fInitialized; michael@0: SkAutoTDelete > fStrings; michael@0: }; michael@0: michael@0: #endif