OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_fbo_mac.h" | 5 #include "content/common/gpu/image_transport_surface_fbo_mac.h" |
6 | 6 |
7 #include "content/common/gpu/gpu_messages.h" | 7 #include "content/common/gpu/gpu_messages.h" |
8 #include "content/common/gpu/image_transport_surface_iosurface_mac.h" | |
9 #include "content/common/gpu/image_transport_surface_calayer_mac.h" | |
10 #include "ui/gfx/native_widget_types.h" | 8 #include "ui/gfx/native_widget_types.h" |
11 #include "ui/gl/gl_context.h" | 9 #include "ui/gl/gl_context.h" |
12 #include "ui/gl/gl_implementation.h" | 10 #include "ui/gl/gl_implementation.h" |
13 #include "ui/gl/gl_surface_osmesa.h" | 11 #include "ui/gl/gl_surface_osmesa.h" |
14 | 12 |
15 namespace content { | 13 namespace content { |
16 namespace { | 14 namespace { |
17 | 15 |
18 // A subclass of GLSurfaceOSMesa that doesn't print an error message when | 16 // A subclass of GLSurfaceOSMesa that doesn't print an error message when |
19 // SwapBuffers() is called. | 17 // SwapBuffers() is called. |
(...skipping 22 matching lines...) Expand all Loading... |
42 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface( | 40 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface( |
43 GpuChannelManager* manager, | 41 GpuChannelManager* manager, |
44 GpuCommandBufferStub* stub, | 42 GpuCommandBufferStub* stub, |
45 const gfx::GLSurfaceHandle& surface_handle) { | 43 const gfx::GLSurfaceHandle& surface_handle) { |
46 DCHECK(surface_handle.transport_type == gfx::NATIVE_DIRECT || | 44 DCHECK(surface_handle.transport_type == gfx::NATIVE_DIRECT || |
47 surface_handle.transport_type == gfx::NATIVE_TRANSPORT); | 45 surface_handle.transport_type == gfx::NATIVE_TRANSPORT); |
48 | 46 |
49 switch (gfx::GetGLImplementation()) { | 47 switch (gfx::GetGLImplementation()) { |
50 case gfx::kGLImplementationDesktopGL: | 48 case gfx::kGLImplementationDesktopGL: |
51 case gfx::kGLImplementationAppleGL: | 49 case gfx::kGLImplementationAppleGL: |
52 // TODO(ccameron): If the remote layer API is supported on this system, | |
53 // use a CALayerStorageProvider instead of an IOSurfaceStorageProvider. | |
54 return scoped_refptr<gfx::GLSurface>(new ImageTransportSurfaceFBO( | 50 return scoped_refptr<gfx::GLSurface>(new ImageTransportSurfaceFBO( |
55 new IOSurfaceStorageProvider, manager, stub, surface_handle.handle)); | 51 manager, stub, surface_handle.handle)); |
56 default: | 52 default: |
57 // Content shell in DRT mode spins up a gpu process which needs an | 53 // Content shell in DRT mode spins up a gpu process which needs an |
58 // image transport surface, but that surface isn't used to read pixel | 54 // image transport surface, but that surface isn't used to read pixel |
59 // baselines. So this is mostly a dummy surface. | 55 // baselines. So this is mostly a dummy surface. |
60 if (!g_allow_os_mesa) { | 56 if (!g_allow_os_mesa) { |
61 NOTREACHED(); | 57 NOTREACHED(); |
62 return scoped_refptr<gfx::GLSurface>(); | 58 return scoped_refptr<gfx::GLSurface>(); |
63 } | 59 } |
64 scoped_refptr<gfx::GLSurface> surface(new DRTSurfaceOSMesa()); | 60 scoped_refptr<gfx::GLSurface> surface(new DRTSurfaceOSMesa()); |
65 if (!surface.get() || !surface->Initialize()) | 61 if (!surface.get() || !surface->Initialize()) |
66 return surface; | 62 return surface; |
67 return scoped_refptr<gfx::GLSurface>(new PassThroughImageTransportSurface( | 63 return scoped_refptr<gfx::GLSurface>(new PassThroughImageTransportSurface( |
68 manager, stub, surface.get())); | 64 manager, stub, surface.get())); |
69 } | 65 } |
70 } | 66 } |
71 | 67 |
72 // static | 68 // static |
73 void ImageTransportSurface::SetAllowOSMesaForTesting(bool allow) { | 69 void ImageTransportSurface::SetAllowOSMesaForTesting(bool allow) { |
74 g_allow_os_mesa = allow; | 70 g_allow_os_mesa = allow; |
75 } | 71 } |
76 | 72 |
77 } // namespace content | 73 } // namespace content |
OLD | NEW |