| 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" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 75 } |
| 76 break; | 76 break; |
| 77 } | 77 } |
| 78 | 78 |
| 79 initialized = true; | 79 initialized = true; |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa( | 83 NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa( |
| 84 gfx::PluginWindowHandle window) | 84 gfx::PluginWindowHandle window) |
| 85 : GLSurfaceOSMesa(gfx::Size()), | 85 : GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size()), |
| 86 window_(window), | 86 window_(window), |
| 87 device_context_(NULL) { | 87 device_context_(NULL) { |
| 88 DCHECK(window); | 88 DCHECK(window); |
| 89 } | 89 } |
| 90 | 90 |
| 91 NativeViewGLSurfaceOSMesa::~NativeViewGLSurfaceOSMesa() { | 91 NativeViewGLSurfaceOSMesa::~NativeViewGLSurfaceOSMesa() { |
| 92 Destroy(); | 92 Destroy(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 bool NativeViewGLSurfaceOSMesa::Initialize() { | 95 bool NativeViewGLSurfaceOSMesa::Initialize() { |
| 96 if (!GLSurfaceOSMesa::Initialize()) | 96 if (!GLSurfaceOSMesa::Initialize()) |
| 97 return false; | 97 return false; |
| 98 | 98 |
| 99 device_context_ = GetDC(window_); | 99 device_context_ = GetDC(window_); |
| 100 UpdateSize(); | 100 UpdateSize(); |
| 101 return true; | 101 return true; |
| 102 } | 102 } |
| 103 | 103 |
| 104 void NativeViewGLSurfaceOSMesa::Destroy() { | 104 void NativeViewGLSurfaceOSMesa::Destroy() { |
| 105 if (window_ && device_context_) | 105 if (window_ && device_context_) |
| 106 ReleaseDC(window_, device_context_); | 106 ReleaseDC(window_, device_context_); |
| 107 | 107 |
| 108 window_ = NULL; | |
| 109 device_context_ = NULL; | 108 device_context_ = NULL; |
| 110 | 109 |
| 111 GLSurfaceOSMesa::Destroy(); | 110 GLSurfaceOSMesa::Destroy(); |
| 112 } | 111 } |
| 113 | 112 |
| 114 bool NativeViewGLSurfaceOSMesa::IsOffscreen() { | 113 bool NativeViewGLSurfaceOSMesa::IsOffscreen() { |
| 115 return false; | 114 return false; |
| 116 } | 115 } |
| 117 | 116 |
| 118 bool NativeViewGLSurfaceOSMesa::SwapBuffers() { | 117 bool NativeViewGLSurfaceOSMesa::SwapBuffers() { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 return new GLSurfaceStub; | 197 return new GLSurfaceStub; |
| 199 default: | 198 default: |
| 200 NOTREACHED(); | 199 NOTREACHED(); |
| 201 return NULL; | 200 return NULL; |
| 202 } | 201 } |
| 203 } | 202 } |
| 204 | 203 |
| 205 GLSurface* GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) { | 204 GLSurface* GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) { |
| 206 switch (GetGLImplementation()) { | 205 switch (GetGLImplementation()) { |
| 207 case kGLImplementationOSMesaGL: { | 206 case kGLImplementationOSMesaGL: { |
| 208 scoped_ptr<GLSurfaceOSMesa> surface(new GLSurfaceOSMesa(size)); | 207 scoped_ptr<GLSurfaceOSMesa> surface(new GLSurfaceOSMesa(OSMESA_RGBA, |
| 208 size)); |
| 209 if (!surface->Initialize()) | 209 if (!surface->Initialize()) |
| 210 return NULL; | 210 return NULL; |
| 211 | 211 |
| 212 return surface.release(); | 212 return surface.release(); |
| 213 } | 213 } |
| 214 case kGLImplementationEGLGLES2: { | 214 case kGLImplementationEGLGLES2: { |
| 215 scoped_ptr<PbufferGLSurfaceEGL> surface(new PbufferGLSurfaceEGL(size)); | 215 scoped_ptr<PbufferGLSurfaceEGL> surface(new PbufferGLSurfaceEGL(size)); |
| 216 if (!surface->Initialize()) | 216 if (!surface->Initialize()) |
| 217 return NULL; | 217 return NULL; |
| 218 | 218 |
| 219 return surface.release(); | 219 return surface.release(); |
| 220 } | 220 } |
| 221 case kGLImplementationDesktopGL: { | 221 case kGLImplementationDesktopGL: { |
| 222 scoped_ptr<PbufferGLSurfaceWGL> surface(new PbufferGLSurfaceWGL(size)); | 222 scoped_ptr<PbufferGLSurfaceWGL> surface(new PbufferGLSurfaceWGL(size)); |
| 223 if (!surface->Initialize()) | 223 if (!surface->Initialize()) |
| 224 return NULL; | 224 return NULL; |
| 225 | 225 |
| 226 return surface.release(); | 226 return surface.release(); |
| 227 } | 227 } |
| 228 case kGLImplementationMockGL: | 228 case kGLImplementationMockGL: |
| 229 return new GLSurfaceStub; | 229 return new GLSurfaceStub; |
| 230 default: | 230 default: |
| 231 NOTREACHED(); | 231 NOTREACHED(); |
| 232 return NULL; | 232 return NULL; |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace gfx | 236 } // namespace gfx |
| OLD | NEW |