summaryrefslogtreecommitdiffstats
path: root/content/gpu/gpu_info_collector.cc
diff options
context:
space:
mode:
Diffstat (limited to 'content/gpu/gpu_info_collector.cc')
-rw-r--r--content/gpu/gpu_info_collector.cc31
1 files changed, 19 insertions, 12 deletions
diff --git a/content/gpu/gpu_info_collector.cc b/content/gpu/gpu_info_collector.cc
index 07a5f1c..80c98fa 100644
--- a/content/gpu/gpu_info_collector.cc
+++ b/content/gpu/gpu_info_collector.cc
@@ -18,13 +18,7 @@
namespace {
-// This creates an offscreen GL context for gl queries. Returned GLContext
-// should be deleted in FinalizeGLContext.
-gfx::GLContext* InitializeGLContext() {
- if (!gfx::GLSurface::InitializeOneOff()) {
- LOG(ERROR) << "gfx::GLContext::InitializeOneOff() failed";
- return NULL;
- }
+gfx::GLSurface* InitializeGLSurface() {
scoped_ptr<gfx::GLSurface> surface(gfx::GLSurface::CreateOffscreenGLSurface(
gfx::Size(1, 1)));
if (!surface.get()) {
@@ -32,15 +26,19 @@ gfx::GLContext* InitializeGLContext() {
return NULL;
}
- scoped_ptr<gfx::GLContext> context(gfx::GLContext::CreateGLContext(
- surface.release(),
- NULL));
+ return surface.release();
+}
+
+gfx::GLContext* InitializeGLContext(gfx::GLSurface* surface) {
+
+ scoped_ptr<gfx::GLContext> context(gfx::GLContext::CreateGLContext(NULL,
+ surface));
if (!context.get()) {
LOG(ERROR) << "gfx::GLContext::CreateGLContext failed";
return NULL;
}
- if (!context->MakeCurrent()) {
+ if (!context->MakeCurrent(surface)) {
LOG(ERROR) << "gfx::GLContext::MakeCurrent() failed";
return NULL;
}
@@ -81,7 +79,16 @@ namespace gpu_info_collector {
bool CollectGraphicsInfoGL(GPUInfo* gpu_info) {
DCHECK(gpu_info);
- scoped_ptr<gfx::GLContext> context(InitializeGLContext());
+ if (!gfx::GLSurface::InitializeOneOff()) {
+ LOG(ERROR) << "gfx::GLContext::InitializeOneOff() failed";
+ return false;
+ }
+
+ scoped_ptr<gfx::GLSurface> surface(InitializeGLSurface());
+ if (!surface.get())
+ return false;
+
+ scoped_ptr<gfx::GLContext> context(InitializeGLContext(surface.get()));
if (!context.get())
return false;