Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Side by Side Diff: content/common/gpu/image_transport_surface_mac.cc

Issue 12315103: mac content shell drt: Hook up a dummy image transport (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: jochen Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ui/gfx/native_widget_types.h" 11 #include "ui/gfx/native_widget_types.h"
12 #include "ui/gl/gl_bindings.h" 12 #include "ui/gl/gl_bindings.h"
13 #include "ui/gl/gl_context.h" 13 #include "ui/gl/gl_context.h"
14 #include "ui/gl/gl_implementation.h" 14 #include "ui/gl/gl_implementation.h"
15 #include "ui/gl/gl_surface_cgl.h" 15 #include "ui/gl/gl_surface_cgl.h"
16 #include "ui/gl/gl_surface_osmesa.h"
16 #include "ui/surface/io_surface_support_mac.h" 17 #include "ui/surface/io_surface_support_mac.h"
17 18
18 namespace content { 19 namespace content {
19 namespace { 20 namespace {
20 21
21 // IOSurface dimensions will be rounded up to a multiple of this value in order 22 // 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. 23 // to reduce memory thrashing during resize. This must be a power of 2.
23 const uint32 kIOSurfaceDimensionRoundup = 64; 24 const uint32 kIOSurfaceDimensionRoundup = 64;
24 25
25 int RoundUpSurfaceDimension(int number) { 26 int RoundUpSurfaceDimension(int number) {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 UnrefIOSurface(); 404 UnrefIOSurface();
404 return; 405 return;
405 } 406 }
406 407
407 glFlush(); 408 glFlush();
408 409
409 glBindTexture(target, previous_texture_id); 410 glBindTexture(target, previous_texture_id);
410 // The FBO remains bound for this GL context. 411 // The FBO remains bound for this GL context.
411 } 412 }
412 413
414 // A subclass of GLSurfaceOSMesa that doesn't print an error message when
415 // SwapBuffers() is called.
416 class DRTSurfaceOSMesa : public gfx::GLSurfaceOSMesa {
417 public:
418 // Size doesn't matter, the surface is resized to the right size later.
419 DRTSurfaceOSMesa() : GLSurfaceOSMesa(GL_RGBA, gfx::Size(1, 1)) {}
420
421 // Implement a subset of GLSurface.
422 virtual bool SwapBuffers() OVERRIDE;
423
424 private:
425 virtual ~DRTSurfaceOSMesa() {}
426 DISALLOW_COPY_AND_ASSIGN(DRTSurfaceOSMesa);
427 };
428
429 bool DRTSurfaceOSMesa::SwapBuffers() {
430 return true;
431 }
432
433 bool g_allow_os_mesa = false;
434
413 } // namespace 435 } // namespace
414 436
415 // static 437 // static
416 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( 438 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface(
417 GpuChannelManager* manager, 439 GpuChannelManager* manager,
418 GpuCommandBufferStub* stub, 440 GpuCommandBufferStub* stub,
419 const gfx::GLSurfaceHandle& surface_handle) { 441 const gfx::GLSurfaceHandle& surface_handle) {
420 scoped_refptr<gfx::GLSurface> surface; 442 scoped_refptr<gfx::GLSurface> surface;
421 if (surface_handle.transport_type == gfx::TEXTURE_TRANSPORT) { 443 if (surface_handle.transport_type == gfx::TEXTURE_TRANSPORT) {
422 surface = new TextureImageTransportSurface(manager, stub, surface_handle); 444 surface = new TextureImageTransportSurface(manager, stub, surface_handle);
423 } else { 445 } else {
424 DCHECK(surface_handle.transport_type == gfx::NATIVE_TRANSPORT); 446 DCHECK(surface_handle.transport_type == gfx::NATIVE_TRANSPORT);
425 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); 447 IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize();
426 448
427 switch (gfx::GetGLImplementation()) { 449 switch (gfx::GetGLImplementation()) {
428 case gfx::kGLImplementationDesktopGL: 450 case gfx::kGLImplementationDesktopGL:
429 case gfx::kGLImplementationAppleGL: 451 case gfx::kGLImplementationAppleGL:
430 if (!io_surface_support) { 452 if (!io_surface_support) {
431 DLOG(WARNING) << "No IOSurface support"; 453 DLOG(WARNING) << "No IOSurface support";
432 return NULL; 454 return NULL;
433 } else { 455 } else {
434 surface = new IOSurfaceImageTransportSurface( 456 surface = new IOSurfaceImageTransportSurface(
435 manager, stub, surface_handle.handle); 457 manager, stub, surface_handle.handle);
436 } 458 }
437 break; 459 break;
438 default: 460 default:
439 NOTREACHED(); 461 // Content shell in DRT mode spins up a gpu process which needs an
440 return NULL; 462 // image transport surface, but that surface isn't used to read pixel
463 // baselines. So this is mostly a dummy surface.
464 if (g_allow_os_mesa) {
465 surface = new DRTSurfaceOSMesa();
466 } else {
467 NOTREACHED();
468 return NULL;
469 }
441 } 470 }
442 } 471 }
443 if (surface->Initialize()) 472 if (surface->Initialize())
444 return surface; 473 return surface;
445 else 474 else
446 return NULL; 475 return NULL;
447 } 476 }
448 477
478 // static
479 void ImageTransportSurface::SetAllowOSMesaForTesting(bool allow) {
480 g_allow_os_mesa = allow;
481 }
482
449 } // namespace content 483 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698