summaryrefslogtreecommitdiffstats
path: root/app/gfx
diff options
context:
space:
mode:
Diffstat (limited to 'app/gfx')
-rw-r--r--app/gfx/gl/gl_context.cc16
-rw-r--r--app/gfx/gl/gl_context.h4
-rw-r--r--app/gfx/gl/gl_context_stub.h1
3 files changed, 21 insertions, 0 deletions
diff --git a/app/gfx/gl/gl_context.cc b/app/gfx/gl/gl_context.cc
index d9b81f3..1d79072 100644
--- a/app/gfx/gl/gl_context.cc
+++ b/app/gfx/gl/gl_context.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <string>
+
#include "app/gfx/gl/gl_context.h"
#include "app/gfx/gl/gl_bindings.h"
#include "app/gfx/gl/gl_implementation.h"
@@ -9,6 +11,19 @@
namespace gfx {
+bool GLContext::HasExtension(const char* name) {
+ DCHECK(IsCurrent());
+
+ std::string extensions(reinterpret_cast<const char*>(
+ glGetString(GL_EXTENSIONS)));
+ extensions += " ";
+
+ std::string delimited_name(name);
+ delimited_name += " ";
+
+ return extensions.find(delimited_name) != std::string::npos;
+}
+
bool GLContext::InitializeCommon() {
if (!MakeCurrent())
return false;
@@ -19,4 +34,5 @@ bool GLContext::InitializeCommon() {
return true;
}
+
} // namespace gfx
diff --git a/app/gfx/gl/gl_context.h b/app/gfx/gl/gl_context.h
index e14e7460..656a0d3 100644
--- a/app/gfx/gl/gl_context.h
+++ b/app/gfx/gl/gl_context.h
@@ -41,6 +41,10 @@ class GLContext {
// Get the underlying platform specific GL context "handle".
virtual void* GetHandle() = 0;
+ // Returns whether the current context supports the named extension. The
+ // context must be current.
+ virtual bool HasExtension(const char* name);
+
static bool InitializeOneOff();
#if !defined(OS_MACOSX)
diff --git a/app/gfx/gl/gl_context_stub.h b/app/gfx/gl/gl_context_stub.h
index 222bf7b..b5189ae 100644
--- a/app/gfx/gl/gl_context_stub.h
+++ b/app/gfx/gl/gl_context_stub.h
@@ -23,6 +23,7 @@ class StubGLContext : public gfx::GLContext {
virtual void SwapBuffers() {}
virtual gfx::Size GetSize() { return size_; }
virtual void* GetHandle() { return NULL; }
+ virtual bool HasExtension(const char* name) { return false; }
void SetSize(const gfx::Size& size) { size_ = size; }