Implement nacl_irt_memory for non-sfi mode.
[chromium-blink-merge.git] / ui / gl / gl_surface_mac.cc
blobd6bf072fd5b3490e71d9e78aeef30a253d7dfa15
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"
16 #include "ui/gl/gl_surface_nsview.h"
18 namespace gfx {
20 bool GLSurface::InitializeOneOffInternal() {
21 switch (GetGLImplementation()) {
22 case kGLImplementationDesktopGL:
23 case kGLImplementationAppleGL:
24 if (!GLSurfaceCGL::InitializeOneOff()) {
25 LOG(ERROR) << "GLSurfaceCGL::InitializeOneOff failed.";
26 return false;
28 break;
29 default:
30 break;
32 return true;
35 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
36 gfx::AcceleratedWidget window) {
37 TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface");
38 switch (GetGLImplementation()) {
39 case kGLImplementationDesktopGL:
40 case kGLImplementationAppleGL: {
41 scoped_refptr<GLSurface> surface(new GLSurfaceNSView(window));
42 if (!surface->Initialize())
43 return NULL;
45 return surface;
47 case kGLImplementationMockGL:
48 return new GLSurfaceStub;
49 default:
50 NOTREACHED();
51 return NULL;
55 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
56 const gfx::Size& size) {
57 TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface");
58 switch (GetGLImplementation()) {
59 case kGLImplementationOSMesaGL: {
60 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA,
61 size));
62 if (!surface->Initialize())
63 return NULL;
65 return surface;
67 case kGLImplementationDesktopGL:
68 case kGLImplementationAppleGL: {
69 scoped_refptr<GLSurface> surface(new NoOpGLSurfaceCGL(size));
70 if (!surface->Initialize())
71 return NULL;
73 return surface;
75 case kGLImplementationMockGL:
76 return new GLSurfaceStub;
77 default:
78 NOTREACHED();
79 return NULL;
83 } // namespace gfx