From 92c2bc5ac0f605a14dfa88649e7c5a844eb0922b Mon Sep 17 00:00:00 2001 From: "apatrick@chromium.org" Date: Wed, 11 May 2011 19:22:37 +0000 Subject: Split GLContext::Create*GLContext into GLSurface::Create*GLSurface plus a surface type independent GLContext::CreateGLContext. TEST=webgl on windows and mac, trybots BUG=none Review URL: http://codereview.chromium.org/6997003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85013 0039d316-1c4b-4281-b951-d872f2087c98 --- content/gpu/gpu_info_collector.cc | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'content/gpu/gpu_info_collector.cc') diff --git a/content/gpu/gpu_info_collector.cc b/content/gpu/gpu_info_collector.cc index 6b37c27..d3492fd 100644 --- a/content/gpu/gpu_info_collector.cc +++ b/content/gpu/gpu_info_collector.cc @@ -7,34 +7,45 @@ #include #include +#include "base/memory/scoped_ptr.h" #include "base/logging.h" #include "base/string_number_conversions.h" #include "base/string_piece.h" #include "base/string_split.h" #include "ui/gfx/gl/gl_bindings.h" #include "ui/gfx/gl/gl_context.h" +#include "ui/gfx/gl/gl_surface.h" namespace { // This creates an offscreen GL context for gl queries. Returned GLContext // should be deleted in FinalizeGLContext. gfx::GLContext* InitializeGLContext() { - if (!gfx::GLContext::InitializeOneOff()) { + if (!gfx::GLSurface::InitializeOneOff()) { LOG(ERROR) << "gfx::GLContext::InitializeOneOff() failed"; return NULL; } - gfx::GLContext* context = gfx::GLContext::CreateOffscreenGLContext(NULL); - if (context == NULL) { - LOG(ERROR) << "gfx::GLContext::CreateOffscreenGLContext(NULL) failed"; + scoped_ptr surface(gfx::GLSurface::CreateOffscreenGLSurface( + gfx::Size(1, 1))); + if (!surface.get()) { + LOG(ERROR) << "gfx::GLContext::CreateOffscreenGLSurface failed"; return NULL; } + + scoped_ptr context(gfx::GLContext::CreateGLContext( + surface.release(), + NULL)); + if (!context.get()) { + LOG(ERROR) << "gfx::GLContext::CreateGLContext failed"; + return NULL; + } + if (!context->MakeCurrent()) { LOG(ERROR) << "gfx::GLContext::MakeCurrent() failed"; - context->Destroy(); - delete context; return NULL; } - return context; + + return context.release(); } // This destroy and delete the GL context. @@ -80,8 +91,8 @@ namespace gpu_info_collector { bool CollectGraphicsInfoGL(GPUInfo* gpu_info) { DCHECK(gpu_info); - gfx::GLContext* context = InitializeGLContext(); - if (context == NULL) + scoped_ptr context(InitializeGLContext()); + if (!context.get()) return false; gpu_info->gl_renderer = GetGLString(GL_RENDERER); @@ -93,8 +104,6 @@ bool CollectGraphicsInfoGL(GPUInfo* gpu_info) { bool validVideoCardInfo = CollectVideoCardInfo(gpu_info); bool validDriverInfo = CollectDriverInfoGL(gpu_info); - FinalizeGLContext(&context); - return (validGLVersionInfo && validVideoCardInfo && validDriverInfo); } -- cgit v1.1