| 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 "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 x, y); | 259 x, y); |
| 260 | 260 |
| 261 return true; | 261 return true; |
| 262 } | 262 } |
| 263 | 263 |
| 264 NativeViewGLSurfaceOSMesa::~NativeViewGLSurfaceOSMesa() { | 264 NativeViewGLSurfaceOSMesa::~NativeViewGLSurfaceOSMesa() { |
| 265 Destroy(); | 265 Destroy(); |
| 266 } | 266 } |
| 267 | 267 |
| 268 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( | 268 scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( |
| 269 bool software, | |
| 270 gfx::AcceleratedWidget window) { | 269 gfx::AcceleratedWidget window) { |
| 271 TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface"); | 270 TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface"); |
| 272 if (software) | |
| 273 return NULL; | |
| 274 | |
| 275 switch (GetGLImplementation()) { | 271 switch (GetGLImplementation()) { |
| 276 case kGLImplementationOSMesaGL: { | 272 case kGLImplementationOSMesaGL: { |
| 277 scoped_refptr<GLSurface> surface( | 273 scoped_refptr<GLSurface> surface( |
| 278 new NativeViewGLSurfaceOSMesa(window)); | 274 new NativeViewGLSurfaceOSMesa(window)); |
| 279 if (!surface->Initialize()) | 275 if (!surface->Initialize()) |
| 280 return NULL; | 276 return NULL; |
| 281 | 277 |
| 282 return surface; | 278 return surface; |
| 283 } | 279 } |
| 284 case kGLImplementationDesktopGL: { | 280 case kGLImplementationDesktopGL: { |
| 285 scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceGLX( | 281 scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceGLX(window)); |
| 286 window)); | |
| 287 if (!surface->Initialize()) | 282 if (!surface->Initialize()) |
| 288 return NULL; | 283 return NULL; |
| 289 | 284 |
| 290 return surface; | 285 return surface; |
| 291 } | 286 } |
| 292 case kGLImplementationEGLGLES2: { | 287 case kGLImplementationEGLGLES2: { |
| 293 scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceEGL( | 288 scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceEGL(window)); |
| 294 false, window)); | |
| 295 if (!surface->Initialize()) | 289 if (!surface->Initialize()) |
| 296 return NULL; | 290 return NULL; |
| 297 | 291 |
| 298 return surface; | 292 return surface; |
| 299 } | 293 } |
| 300 case kGLImplementationMockGL: | 294 case kGLImplementationMockGL: |
| 301 return new GLSurfaceStub; | 295 return new GLSurfaceStub; |
| 302 default: | 296 default: |
| 303 NOTREACHED(); | 297 NOTREACHED(); |
| 304 return NULL; | 298 return NULL; |
| 305 } | 299 } |
| 306 } | 300 } |
| 307 | 301 |
| 308 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( | 302 scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( |
| 309 bool software, | |
| 310 const gfx::Size& size) { | 303 const gfx::Size& size) { |
| 311 TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface"); | 304 TRACE_EVENT0("gpu", "GLSurface::CreateOffscreenGLSurface"); |
| 312 if (software) | |
| 313 return NULL; | |
| 314 | |
| 315 switch (GetGLImplementation()) { | 305 switch (GetGLImplementation()) { |
| 316 case kGLImplementationOSMesaGL: { | 306 case kGLImplementationOSMesaGL: { |
| 317 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA, | 307 scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA, |
| 318 size)); | 308 size)); |
| 319 if (!surface->Initialize()) | 309 if (!surface->Initialize()) |
| 320 return NULL; | 310 return NULL; |
| 321 | 311 |
| 322 return surface; | 312 return surface; |
| 323 } | 313 } |
| 324 case kGLImplementationDesktopGL: { | 314 case kGLImplementationDesktopGL: { |
| 325 scoped_refptr<GLSurface> surface(new PbufferGLSurfaceGLX(size)); | 315 scoped_refptr<GLSurface> surface(new PbufferGLSurfaceGLX(size)); |
| 326 if (!surface->Initialize()) | 316 if (!surface->Initialize()) |
| 327 return NULL; | 317 return NULL; |
| 328 | 318 |
| 329 return surface; | 319 return surface; |
| 330 } | 320 } |
| 331 case kGLImplementationEGLGLES2: { | 321 case kGLImplementationEGLGLES2: { |
| 332 scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(false, size)); | 322 scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(size)); |
| 333 if (!surface->Initialize()) | 323 if (!surface->Initialize()) |
| 334 return NULL; | 324 return NULL; |
| 335 | 325 |
| 336 return surface; | 326 return surface; |
| 337 } | 327 } |
| 338 case kGLImplementationMockGL: | 328 case kGLImplementationMockGL: |
| 339 return new GLSurfaceStub; | 329 return new GLSurfaceStub; |
| 340 default: | 330 default: |
| 341 NOTREACHED(); | 331 NOTREACHED(); |
| 342 return NULL; | 332 return NULL; |
| 343 } | 333 } |
| 344 } | 334 } |
| 345 | 335 |
| 346 } // namespace gfx | 336 } // namespace gfx |
| OLD | NEW |