summaryrefslogtreecommitdiffstats
path: root/content/gpu/gpu_info_collector.cc
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-12 22:54:29 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-12 22:54:29 +0000
commitffae402c58ea5e0787208ccdcd60b0f021b7ebd2 (patch)
tree0fdcbd1873b6a76b47d3074976a8e9f07b9d68ed /content/gpu/gpu_info_collector.cc
parent8d9591d65ffcd08c5f69f5bb231f9c08a1f7042a (diff)
downloadchromium_src-ffae402c58ea5e0787208ccdcd60b0f021b7ebd2.zip
chromium_src-ffae402c58ea5e0787208ccdcd60b0f021b7ebd2.tar.gz
chromium_src-ffae402c58ea5e0787208ccdcd60b0f021b7ebd2.tar.bz2
Reland 85013 - Split GLContext::Create*GLContext into GLSurface::Create*GLSurface plus a
surface type independent GLContext::CreateGLContext TEST=try, including layout tests BUG=none Review URL: http://codereview.chromium.org/7013037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85207 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/gpu/gpu_info_collector.cc')
-rw-r--r--content/gpu/gpu_info_collector.cc39
1 files changed, 19 insertions, 20 deletions
diff --git a/content/gpu/gpu_info_collector.cc b/content/gpu/gpu_info_collector.cc
index 6b37c27..07a5f1c 100644
--- a/content/gpu/gpu_info_collector.cc
+++ b/content/gpu/gpu_info_collector.cc
@@ -7,44 +7,45 @@
#include <string>
#include <vector>
+#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<gfx::GLSurface> surface(gfx::GLSurface::CreateOffscreenGLSurface(
+ gfx::Size(1, 1)));
+ if (!surface.get()) {
+ LOG(ERROR) << "gfx::GLContext::CreateOffscreenGLSurface failed";
return NULL;
}
+
+ scoped_ptr<gfx::GLContext> 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;
-}
-// This destroy and delete the GL context.
-void FinalizeGLContext(gfx::GLContext** context) {
- DCHECK(context);
- if (*context) {
- (*context)->Destroy();
- delete *context;
- *context = NULL;
- }
+ return context.release();
}
std::string GetGLString(unsigned int pname) {
@@ -80,8 +81,8 @@ namespace gpu_info_collector {
bool CollectGraphicsInfoGL(GPUInfo* gpu_info) {
DCHECK(gpu_info);
- gfx::GLContext* context = InitializeGLContext();
- if (context == NULL)
+ scoped_ptr<gfx::GLContext> context(InitializeGLContext());
+ if (!context.get())
return false;
gpu_info->gl_renderer = GetGLString(GL_RENDERER);
@@ -93,8 +94,6 @@ bool CollectGraphicsInfoGL(GPUInfo* gpu_info) {
bool validVideoCardInfo = CollectVideoCardInfo(gpu_info);
bool validDriverInfo = CollectDriverInfoGL(gpu_info);
- FinalizeGLContext(&context);
-
return (validGLVersionInfo && validVideoCardInfo && validDriverInfo);
}