| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gfx/gl/gl_surface.h" | 5 #include "ui/gfx/gl/gl_surface.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "third_party/mesa/MesaLib/include/GL/osmesa.h" | 9 #include "third_party/mesa/MesaLib/include/GL/osmesa.h" |
| 10 #include "ui/gfx/gl/gl_bindings.h" | 10 #include "ui/gfx/gl/gl_bindings.h" |
| 11 #include "ui/gfx/gl/gl_implementation.h" | 11 #include "ui/gfx/gl/gl_implementation.h" |
| 12 #include "ui/gfx/gl/gl_surface_cgl.h" | 12 #include "ui/gfx/gl/gl_surface_cgl.h" |
| 13 #include "ui/gfx/gl/gl_surface_osmesa.h" | 13 #include "ui/gfx/gl/gl_surface_osmesa.h" |
| 14 #include "ui/gfx/gl/gl_surface_stub.h" | 14 #include "ui/gfx/gl/gl_surface_stub.h" |
| 15 | 15 |
| 16 #if defined(USE_WEBKIT_COMPOSITOR) |
| 17 #include "ui/gfx/gl/gl_surface_nsview.h" |
| 18 #endif |
| 19 |
| 16 namespace gfx { | 20 namespace gfx { |
| 17 | 21 |
| 18 bool GLSurface::InitializeOneOffInternal() { | 22 bool GLSurface::InitializeOneOffInternal() { |
| 19 switch (GetGLImplementation()) { | 23 switch (GetGLImplementation()) { |
| 20 case kGLImplementationDesktopGL: | 24 case kGLImplementationDesktopGL: |
| 21 if (!GLSurfaceCGL::InitializeOneOff()) { | 25 if (!GLSurfaceCGL::InitializeOneOff()) { |
| 22 LOG(ERROR) << "GLSurfaceCGL::InitializeOneOff failed."; | 26 LOG(ERROR) << "GLSurfaceCGL::InitializeOneOff failed."; |
| 23 return false; | 27 return false; |
| 24 } | 28 } |
| 25 break; | 29 break; |
| 26 default: | 30 default: |
| 27 break; | 31 break; |
| 28 } | 32 } |
| 29 return true; | 33 return true; |
| 30 } | 34 } |
| 31 | 35 |
| 32 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( | 36 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( |
| 33 bool software, | 37 bool software, |
| 34 gfx::PluginWindowHandle window) { | 38 gfx::PluginWindowHandle window) { |
| 35 return CreateOffscreenGLSurface(software, gfx::Size(1, 1)); | 39 #if defined(USE_WEBKIT_COMPOSITOR) |
| 40 if (software) |
| 41 return NULL; |
| 42 |
| 43 switch (GetGLImplementation()) { |
| 44 case kGLImplementationDesktopGL: { |
| 45 scoped_refptr<GLSurface> surface(new GLSurfaceNSView(window)); |
| 46 if (!surface->Initialize()) |
| 47 return NULL; |
| 48 |
| 49 return surface; |
| 50 } |
| 51 case kGLImplementationMockGL: |
| 52 return new GLSurfaceStub; |
| 53 default: |
| 54 NOTREACHED(); |
| 55 return NULL; |
| 56 } |
| 57 #else |
| 58 return CreateOffscreenGLSurface(software, gfx::Size(1,1)); |
| 59 #endif |
| 36 } | 60 } |
| 37 | 61 |
| 38 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( | 62 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( |
| 39 bool software, | 63 bool software, |
| 40 const gfx::Size& size) { | 64 const gfx::Size& size) { |
| 41 if (software) | 65 if (software) |
| 42 return NULL; | 66 return NULL; |
| 43 | 67 |
| 44 switch (GetGLImplementation()) { | 68 switch (GetGLImplementation()) { |
| 45 case kGLImplementationOSMesaGL: { | 69 case kGLImplementationOSMesaGL: { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 59 } | 83 } |
| 60 case kGLImplementationMockGL: | 84 case kGLImplementationMockGL: |
| 61 return new GLSurfaceStub; | 85 return new GLSurfaceStub; |
| 62 default: | 86 default: |
| 63 NOTREACHED(); | 87 NOTREACHED(); |
| 64 return NULL; | 88 return NULL; |
| 65 } | 89 } |
| 66 } | 90 } |
| 67 | 91 |
| 68 } // namespace gfx | 92 } // namespace gfx |
| OLD | NEW |