OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gl/gl_surface.h" | 5 #include "ui/gl/gl_surface.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "third_party/mesa/src/include/GL/osmesa.h" | 10 #include "third_party/mesa/src/include/GL/osmesa.h" |
11 #include "ui/gl/gl_bindings.h" | 11 #include "ui/gl/gl_bindings.h" |
12 #include "ui/gl/gl_implementation.h" | 12 #include "ui/gl/gl_implementation.h" |
13 #include "ui/gl/gl_surface_cgl.h" | 13 #include "ui/gl/gl_surface_cgl.h" |
14 #include "ui/gl/gl_surface_osmesa.h" | 14 #include "ui/gl/gl_surface_osmesa.h" |
15 #include "ui/gl/gl_surface_stub.h" | 15 #include "ui/gl/gl_surface_stub.h" |
16 | |
17 #if defined(USE_AURA) | |
18 #include "ui/gl/gl_surface_nsview.h" | 16 #include "ui/gl/gl_surface_nsview.h" |
19 #endif | |
20 | 17 |
21 namespace gfx { | 18 namespace gfx { |
22 | 19 |
23 bool GLSurface::InitializeOneOffInternal() { | 20 bool GLSurface::InitializeOneOffInternal() { |
24 switch (GetGLImplementation()) { | 21 switch (GetGLImplementation()) { |
25 case kGLImplementationDesktopGL: | 22 case kGLImplementationDesktopGL: |
26 case kGLImplementationAppleGL: | 23 case kGLImplementationAppleGL: |
27 if (!GLSurfaceCGL::InitializeOneOff()) { | 24 if (!GLSurfaceCGL::InitializeOneOff()) { |
28 LOG(ERROR) << "GLSurfaceCGL::InitializeOneOff failed."; | 25 LOG(ERROR) << "GLSurfaceCGL::InitializeOneOff failed."; |
29 return false; | 26 return false; |
30 } | 27 } |
31 break; | 28 break; |
32 default: | 29 default: |
33 break; | 30 break; |
34 } | 31 } |
35 return true; | 32 return true; |
36 } | 33 } |
37 | 34 |
38 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( | 35 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( |
39 gfx::AcceleratedWidget window) { | 36 gfx::AcceleratedWidget window) { |
40 TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface"); | 37 TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface"); |
41 #if defined(USE_AURA) | |
42 switch (GetGLImplementation()) { | 38 switch (GetGLImplementation()) { |
43 case kGLImplementationDesktopGL: | 39 case kGLImplementationDesktopGL: |
44 case kGLImplementationAppleGL: { | 40 case kGLImplementationAppleGL: { |
45 scoped_refptr<GLSurface> surface(new GLSurfaceNSView(window)); | 41 scoped_refptr<GLSurface> surface(new GLSurfaceNSView(window)); |
46 if (!surface->Initialize()) | 42 if (!surface->Initialize()) |
47 return NULL; | 43 return NULL; |
48 | 44 |
49 return surface; | 45 return surface; |
50 } | 46 } |
51 case kGLImplementationMockGL: | 47 case kGLImplementationMockGL: |
52 return new GLSurfaceStub; | 48 return new GLSurfaceStub; |
53 default: | 49 default: |
54 NOTREACHED(); | 50 NOTREACHED(); |
55 return NULL; | 51 return NULL; |
56 } | 52 } |
57 #else | |
58 return CreateOffscreenGLSurface(gfx::Size(1, 1)); | |
59 #endif | |
60 } | 53 } |
61 | 54 |
62 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( | 55 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( |
63 const gfx::Size& size) { | 56 const gfx::Size& size) { |
64 TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface"); | 57 TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface"); |
65 switch (GetGLImplementation()) { | 58 switch (GetGLImplementation()) { |
66 case kGLImplementationOSMesaGL: { | 59 case kGLImplementationOSMesaGL: { |
67 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA, | 60 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA, |
68 size)); | 61 size)); |
69 if (!surface->Initialize()) | 62 if (!surface->Initialize()) |
(...skipping 11 matching lines...) Expand all Loading... |
81 } | 74 } |
82 case kGLImplementationMockGL: | 75 case kGLImplementationMockGL: |
83 return new GLSurfaceStub; | 76 return new GLSurfaceStub; |
84 default: | 77 default: |
85 NOTREACHED(); | 78 NOTREACHED(); |
86 return NULL; | 79 return NULL; |
87 } | 80 } |
88 } | 81 } |
89 | 82 |
90 } // namespace gfx | 83 } // namespace gfx |
OLD | NEW |