1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/gl/gl_surface.h"
7 #include "base/debug/trace_event.h"
8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "third_party/mesa/src/include/GL/osmesa.h"
11 #include "ui/gl/gl_bindings.h"
12 #include "ui/gl/gl_implementation.h"
13 #include "ui/gl/gl_surface_cgl.h"
14 #include "ui/gl/gl_surface_osmesa.h"
15 #include "ui/gl/gl_surface_stub.h"
19 bool GLSurface::InitializeOneOffInternal() {
20 switch (GetGLImplementation()) {
21 case kGLImplementationDesktopGL
:
22 case kGLImplementationAppleGL
:
23 if (!GLSurfaceCGL::InitializeOneOff()) {
24 LOG(ERROR
) << "GLSurfaceCGL::InitializeOneOff failed.";
34 scoped_refptr
<GLSurface
> GLSurface::CreateViewGLSurface(
35 gfx::AcceleratedWidget window
) {
36 TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface");
37 switch (GetGLImplementation()) {
38 case kGLImplementationDesktopGL
:
39 case kGLImplementationAppleGL
: {
40 NOTIMPLEMENTED() << "No onscreen support on Mac.";
43 case kGLImplementationMockGL
:
44 return new GLSurfaceStub
;
51 scoped_refptr
<GLSurface
> GLSurface::CreateOffscreenGLSurface(
52 const gfx::Size
& size
) {
53 TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface");
54 switch (GetGLImplementation()) {
55 case kGLImplementationOSMesaGL
: {
56 scoped_refptr
<GLSurface
> surface(new GLSurfaceOSMesa(OSMESA_RGBA
,
58 if (!surface
->Initialize())
63 case kGLImplementationDesktopGL
:
64 case kGLImplementationAppleGL
: {
65 scoped_refptr
<GLSurface
> surface(new NoOpGLSurfaceCGL(size
));
66 if (!surface
->Initialize())
71 case kGLImplementationMockGL
:
72 return new GLSurfaceStub
;