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 <dwmapi.h> | 7 #include <dwmapi.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
14 #include "third_party/mesa/src/include/GL/osmesa.h" | |
15 #include "ui/gfx/frame_time.h" | 14 #include "ui/gfx/frame_time.h" |
16 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
17 #include "ui/gl/gl_bindings.h" | 16 #include "ui/gl/gl_bindings.h" |
18 #include "ui/gl/gl_implementation.h" | 17 #include "ui/gl/gl_implementation.h" |
19 #include "ui/gl/gl_surface_egl.h" | 18 #include "ui/gl/gl_surface_egl.h" |
20 #include "ui/gl/gl_surface_osmesa.h" | 19 #include "ui/gl/gl_surface_osmesa.h" |
21 #include "ui/gl/gl_surface_stub.h" | 20 #include "ui/gl/gl_surface_stub.h" |
22 #include "ui/gl/gl_surface_wgl.h" | 21 #include "ui/gl/gl_surface_wgl.h" |
23 | 22 |
24 // From ANGLE's egl/eglext.h. | 23 // From ANGLE's egl/eglext.h. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; | 104 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; |
106 return false; | 105 return false; |
107 } | 106 } |
108 break; | 107 break; |
109 } | 108 } |
110 return true; | 109 return true; |
111 } | 110 } |
112 | 111 |
113 NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa( | 112 NativeViewGLSurfaceOSMesa::NativeViewGLSurfaceOSMesa( |
114 gfx::AcceleratedWidget window) | 113 gfx::AcceleratedWidget window) |
115 : GLSurfaceOSMesa(OSMESA_RGBA, gfx::Size(1, 1)), | 114 : GLSurfaceOSMesa(OSMesaSurfaceFormatRGBA, gfx::Size(1, 1)), |
116 window_(window), | 115 window_(window), |
117 device_context_(NULL) { | 116 device_context_(NULL) { |
118 DCHECK(window); | 117 DCHECK(window); |
119 } | 118 } |
120 | 119 |
121 NativeViewGLSurfaceOSMesa::~NativeViewGLSurfaceOSMesa() { | 120 NativeViewGLSurfaceOSMesa::~NativeViewGLSurfaceOSMesa() { |
122 Destroy(); | 121 Destroy(); |
123 } | 122 } |
124 | 123 |
125 bool NativeViewGLSurfaceOSMesa::Initialize() { | 124 bool NativeViewGLSurfaceOSMesa::Initialize() { |
126 if (!GLSurfaceOSMesa::Initialize()) | 125 if (!GLSurfaceOSMesa::Initialize()) |
127 return false; | 126 return false; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 NOTREACHED(); | 257 NOTREACHED(); |
259 return NULL; | 258 return NULL; |
260 } | 259 } |
261 } | 260 } |
262 | 261 |
263 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( | 262 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( |
264 const gfx::Size& size) { | 263 const gfx::Size& size) { |
265 TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface"); | 264 TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface"); |
266 switch (GetGLImplementation()) { | 265 switch (GetGLImplementation()) { |
267 case kGLImplementationOSMesaGL: { | 266 case kGLImplementationOSMesaGL: { |
268 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA, | 267 scoped_refptr<GLSurface> surface( |
269 size)); | 268 new GLSurfaceOSMesa(OSMesaSurfaceFormatRGBA, size)); |
270 if (!surface->Initialize()) | 269 if (!surface->Initialize()) |
271 return NULL; | 270 return NULL; |
272 | 271 |
273 return surface; | 272 return surface; |
274 } | 273 } |
275 case kGLImplementationEGLGLES2: { | 274 case kGLImplementationEGLGLES2: { |
276 scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(size)); | 275 scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(size)); |
277 if (!surface->Initialize()) | 276 if (!surface->Initialize()) |
278 return NULL; | 277 return NULL; |
279 | 278 |
(...skipping 15 matching lines...) Expand all Loading... |
295 } | 294 } |
296 | 295 |
297 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { | 296 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { |
298 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableD3D11)) | 297 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableD3D11)) |
299 return EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE; | 298 return EGL_D3D11_ELSE_D3D9_DISPLAY_ANGLE; |
300 | 299 |
301 return EGL_DEFAULT_DISPLAY; | 300 return EGL_DEFAULT_DISPLAY; |
302 } | 301 } |
303 | 302 |
304 } // namespace gfx | 303 } // namespace gfx |
OLD | NEW |