diff options
author | 2012-02-10 21:01:00 +0000 | |
---|---|---|
committer | 2012-02-10 21:01:00 +0000 | |
commit | dd182cbca60a7f0003330c01dfc64f69f56aea90 (patch) | |
tree | 19e01a17322afef55c47163c963e32a3678ca385 /src/gpu/gl/GrGLContextInfo.h | |
parent | 5eb7b8cf34a554a793f5e8122236a957cfb1b85f (diff) |
Move GL-specific source code to make room for D3D back end.
git-svn-id: http://skia.googlecode.com/svn/trunk@3165 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl/GrGLContextInfo.h')
-rw-r--r-- | src/gpu/gl/GrGLContextInfo.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/gpu/gl/GrGLContextInfo.h b/src/gpu/gl/GrGLContextInfo.h new file mode 100644 index 0000000000..cac8959861 --- /dev/null +++ b/src/gpu/gl/GrGLContextInfo.h @@ -0,0 +1,68 @@ +#include "GrGLInterface.h" +#include "GrGLSL.h" + +#include "SkString.h" + +/** + * Encapsulates information about an OpenGL context including the GrGLInterface + * used to make GL calls, the OpenGL version, the GrGLBinding type of the + * context, and GLSL version. + */ +class GrGLContextInfo { +public: + + /** + * Default constructor, creates an uninitialized GrGLContextInfo + */ + GrGLContextInfo(); + + /** + * Creates a GrGLContextInfo from a GrGLInterface and the currently + * bound OpenGL context accesible by the GrGLInterface. + */ + GrGLContextInfo(const GrGLInterface* interface); + + /** + * Copies a GrGLContextInfo + */ + GrGLContextInfo(const GrGLContextInfo& ctx); + + ~GrGLContextInfo(); + + /** + * Copies a GrGLContextInfo + */ + GrGLContextInfo& operator = (const GrGLContextInfo& ctx); + + /** + * Initializes a GrGLContextInfo from a GrGLInterface and the currently + * bound OpenGL context accessible by the GrGLInterface. + */ + bool initialize(const GrGLInterface* interface); + bool isInitialized() const; + + const GrGLInterface* interface() const { return fInterface; } + GrGLBinding binding() const { return fBindingInUse; } + GrGLVersion version() const { return fGLVersion; } + GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; } + + /** + * Checks for extension support using a cached copy of the GL_EXTENSIONS + * string. + */ + bool hasExtension(const char* ext) const { + if (!this->isInitialized()) { + return false; + } + return GrGLHasExtensionFromString(ext, fExtensionString.c_str()); + } + +private: + void reset(); + + const GrGLInterface* fInterface; + GrGLBinding fBindingInUse; + GrGLVersion fGLVersion; + GrGLSLGeneration fGLSLGeneration; + SkString fExtensionString; +}; |