Chromium Code Reviews| 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 "content/common/gpu/image_transport_surface.h" | 5 #include "content/common/gpu/image_transport_surface.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_cftyperef.h" | 7 #include "base/mac/scoped_cftyperef.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "content/common/gpu/gpu_messages.h" | 9 #include "content/common/gpu/gpu_messages.h" |
| 10 #include "content/common/gpu/texture_image_transport_surface.h" | 10 #include "content/common/gpu/texture_image_transport_surface.h" |
| 11 #include "content/shell/shell_switches.h" | |
|
jochen (gone - plz use gerrit)
2013/02/26 14:12:07
why do you need this?
Nico
2013/02/26 14:26:52
Removed.
| |
| 11 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
| 12 #include "ui/gl/gl_bindings.h" | 13 #include "ui/gl/gl_bindings.h" |
| 13 #include "ui/gl/gl_context.h" | 14 #include "ui/gl/gl_context.h" |
| 14 #include "ui/gl/gl_implementation.h" | 15 #include "ui/gl/gl_implementation.h" |
| 15 #include "ui/gl/gl_surface_cgl.h" | 16 #include "ui/gl/gl_surface_cgl.h" |
| 17 #include "ui/gl/gl_surface_osmesa.h" | |
| 16 #include "ui/surface/io_surface_support_mac.h" | 18 #include "ui/surface/io_surface_support_mac.h" |
| 17 | 19 |
| 18 namespace content { | 20 namespace content { |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 // IOSurface dimensions will be rounded up to a multiple of this value in order | 23 // IOSurface dimensions will be rounded up to a multiple of this value in order |
| 22 // to reduce memory thrashing during resize. This must be a power of 2. | 24 // to reduce memory thrashing during resize. This must be a power of 2. |
| 23 const uint32 kIOSurfaceDimensionRoundup = 64; | 25 const uint32 kIOSurfaceDimensionRoundup = 64; |
| 24 | 26 |
| 25 int RoundUpSurfaceDimension(int number) { | 27 int RoundUpSurfaceDimension(int number) { |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 UnrefIOSurface(); | 405 UnrefIOSurface(); |
| 404 return; | 406 return; |
| 405 } | 407 } |
| 406 | 408 |
| 407 glFlush(); | 409 glFlush(); |
| 408 | 410 |
| 409 glBindTexture(target, previous_texture_id); | 411 glBindTexture(target, previous_texture_id); |
| 410 // The FBO remains bound for this GL context. | 412 // The FBO remains bound for this GL context. |
| 411 } | 413 } |
| 412 | 414 |
| 415 // A subclass of GLSurfaceOSMesa that doesn't print an error message when | |
| 416 // SwapBuffers() is called. | |
| 417 class DRTSurfaceOSMesa : public gfx::GLSurfaceOSMesa { | |
| 418 public: | |
| 419 // Size doesn't matter, the surface is resized to the right size later. | |
| 420 explicit DRTSurfaceOSMesa() | |
|
jochen (gone - plz use gerrit)
2013/02/26 14:12:07
no explicit
Nico
2013/02/26 14:26:52
Done.
| |
| 421 : GLSurfaceOSMesa(GL_RGBA, gfx::Size(1, 1)) {} | |
| 422 | |
| 423 // Implement a subset of GLSurface. | |
| 424 virtual bool SwapBuffers() OVERRIDE; | |
| 425 | |
| 426 private: | |
| 427 ~DRTSurfaceOSMesa() {} | |
|
jochen (gone - plz use gerrit)
2013/02/26 14:12:07
virtual
Nico
2013/02/26 14:26:52
Done.
| |
| 428 DISALLOW_COPY_AND_ASSIGN(DRTSurfaceOSMesa); | |
| 429 }; | |
| 430 | |
| 431 bool DRTSurfaceOSMesa::SwapBuffers() { | |
| 432 return true; | |
| 433 } | |
| 434 | |
| 435 bool g_allow_os_mesa = false; | |
| 436 | |
| 413 } // namespace | 437 } // namespace |
| 414 | 438 |
| 415 // static | 439 // static |
| 416 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( | 440 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( |
| 417 GpuChannelManager* manager, | 441 GpuChannelManager* manager, |
| 418 GpuCommandBufferStub* stub, | 442 GpuCommandBufferStub* stub, |
| 419 const gfx::GLSurfaceHandle& surface_handle) { | 443 const gfx::GLSurfaceHandle& surface_handle) { |
| 420 scoped_refptr<gfx::GLSurface> surface; | 444 scoped_refptr<gfx::GLSurface> surface; |
| 421 if (surface_handle.transport_type == gfx::TEXTURE_TRANSPORT) { | 445 if (surface_handle.transport_type == gfx::TEXTURE_TRANSPORT) { |
| 422 surface = new TextureImageTransportSurface(manager, stub, surface_handle); | 446 surface = new TextureImageTransportSurface(manager, stub, surface_handle); |
| 423 } else { | 447 } else { |
| 424 DCHECK(surface_handle.transport_type == gfx::NATIVE_TRANSPORT); | 448 DCHECK(surface_handle.transport_type == gfx::NATIVE_TRANSPORT); |
| 425 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); | 449 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); |
| 426 | 450 |
| 427 switch (gfx::GetGLImplementation()) { | 451 switch (gfx::GetGLImplementation()) { |
| 428 case gfx::kGLImplementationDesktopGL: | 452 case gfx::kGLImplementationDesktopGL: |
| 429 case gfx::kGLImplementationAppleGL: | 453 case gfx::kGLImplementationAppleGL: |
| 430 if (!io_surface_support) { | 454 if (!io_surface_support) { |
| 431 DLOG(WARNING) << "No IOSurface support"; | 455 DLOG(WARNING) << "No IOSurface support"; |
| 432 return NULL; | 456 return NULL; |
| 433 } else { | 457 } else { |
| 434 surface = new IOSurfaceImageTransportSurface( | 458 surface = new IOSurfaceImageTransportSurface( |
| 435 manager, stub, surface_handle.handle); | 459 manager, stub, surface_handle.handle); |
| 436 } | 460 } |
| 437 break; | 461 break; |
| 438 default: | 462 default: |
| 439 NOTREACHED(); | 463 // Content shell in DRT mode spins up a gpu process which needs an |
| 440 return NULL; | 464 // image transport surface, but that surface isn't used to read pixel |
| 465 // baselines. So this is mostly a dummy surface. | |
| 466 if (g_allow_os_mesa) { | |
| 467 surface = new DRTSurfaceOSMesa(); | |
|
jochen (gone - plz use gerrit)
2013/02/26 14:12:07
does it matter that it prints the error message? C
Nico
2013/02/26 14:26:52
Sure it matters, random error log spew is confusin
| |
| 468 } else { | |
| 469 NOTREACHED(); | |
| 470 return NULL; | |
| 471 } | |
| 441 } | 472 } |
| 442 } | 473 } |
| 443 if (surface->Initialize()) | 474 if (surface->Initialize()) |
| 444 return surface; | 475 return surface; |
| 445 else | 476 else |
| 446 return NULL; | 477 return NULL; |
| 447 } | 478 } |
| 448 | 479 |
| 480 // static | |
| 481 void ImageTransportSurface::SetAllowOSMesa(bool allow) { | |
| 482 g_allow_os_mesa = allow; | |
| 483 } | |
| 484 | |
| 449 } // namespace content | 485 } // namespace content |
| OLD | NEW |