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 "gpu/ipc/service/image_transport_surface.h" | 5 #include "gpu/ipc/service/image_transport_surface.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "gpu/ipc/service/image_transport_surface_overlay_mac.h" |
8 #include "gpu/ipc/service/pass_through_image_transport_surface.h" | 9 #include "gpu/ipc/service/pass_through_image_transport_surface.h" |
9 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
10 #include "ui/gl/gl_surface_osmesa.h" | 11 #include "ui/gl/gl_surface_osmesa.h" |
11 #include "ui/gl/gl_surface_stub.h" | 12 #include "ui/gl/gl_surface_stub.h" |
12 | 13 |
13 namespace gpu { | 14 namespace gpu { |
14 | 15 |
15 scoped_refptr<gl::GLSurface> ImageTransportSurfaceCreateNativeSurface( | |
16 GpuChannelManager* manager, | |
17 GpuCommandBufferStub* stub, | |
18 SurfaceHandle handle); | |
19 | |
20 namespace { | 16 namespace { |
21 | 17 |
22 // A subclass of GLSurfaceOSMesa that doesn't print an error message when | 18 // A subclass of GLSurfaceOSMesa that doesn't print an error message when |
23 // SwapBuffers() is called. | 19 // SwapBuffers() is called. |
24 class DRTSurfaceOSMesa : public gl::GLSurfaceOSMesa { | 20 class DRTSurfaceOSMesa : public gl::GLSurfaceOSMesa { |
25 public: | 21 public: |
26 // Size doesn't matter, the surface is resized to the right size later. | 22 // Size doesn't matter, the surface is resized to the right size later. |
27 DRTSurfaceOSMesa() | 23 DRTSurfaceOSMesa() |
28 : GLSurfaceOSMesa(gl::GLSurface::SURFACE_OSMESA_RGBA, gfx::Size(1, 1)) {} | 24 : GLSurfaceOSMesa(gl::GLSurface::SURFACE_OSMESA_RGBA, gfx::Size(1, 1)) {} |
29 | 25 |
(...skipping 18 matching lines...) Expand all Loading... |
48 GpuChannelManager* manager, | 44 GpuChannelManager* manager, |
49 GpuCommandBufferStub* stub, | 45 GpuCommandBufferStub* stub, |
50 SurfaceHandle surface_handle, | 46 SurfaceHandle surface_handle, |
51 gl::GLSurface::Format format) { | 47 gl::GLSurface::Format format) { |
52 DCHECK_NE(surface_handle, kNullSurfaceHandle); | 48 DCHECK_NE(surface_handle, kNullSurfaceHandle); |
53 | 49 |
54 switch (gl::GetGLImplementation()) { | 50 switch (gl::GetGLImplementation()) { |
55 case gl::kGLImplementationDesktopGL: | 51 case gl::kGLImplementationDesktopGL: |
56 case gl::kGLImplementationDesktopGLCoreProfile: | 52 case gl::kGLImplementationDesktopGLCoreProfile: |
57 case gl::kGLImplementationAppleGL: | 53 case gl::kGLImplementationAppleGL: |
58 return ImageTransportSurfaceCreateNativeSurface(manager, stub, | 54 return new ImageTransportSurfaceOverlayMac(stub); |
59 surface_handle); | |
60 case gl::kGLImplementationMockGL: | 55 case gl::kGLImplementationMockGL: |
61 return new gl::GLSurfaceStub; | 56 return new gl::GLSurfaceStub; |
62 default: | 57 default: |
63 // Content shell in DRT mode spins up a gpu process which needs an | 58 // Content shell in DRT mode spins up a gpu process which needs an |
64 // image transport surface, but that surface isn't used to read pixel | 59 // image transport surface, but that surface isn't used to read pixel |
65 // baselines. So this is mostly a dummy surface. | 60 // baselines. So this is mostly a dummy surface. |
66 if (!g_allow_os_mesa) { | 61 if (!g_allow_os_mesa) { |
67 NOTREACHED(); | 62 NOTREACHED(); |
68 return nullptr; | 63 return nullptr; |
69 } | 64 } |
70 scoped_refptr<gl::GLSurface> surface(new DRTSurfaceOSMesa()); | 65 scoped_refptr<gl::GLSurface> surface(new DRTSurfaceOSMesa()); |
71 if (!surface.get() || !surface->Initialize(format)) | 66 if (!surface.get() || !surface->Initialize(format)) |
72 return surface; | 67 return surface; |
73 return scoped_refptr<gl::GLSurface>( | 68 return scoped_refptr<gl::GLSurface>( |
74 new PassThroughImageTransportSurface(manager, stub, surface.get())); | 69 new PassThroughImageTransportSurface(manager, stub, surface.get())); |
75 } | 70 } |
76 } | 71 } |
77 | 72 |
78 // static | 73 // static |
79 void ImageTransportSurface::SetAllowOSMesaForTesting(bool allow) { | 74 void ImageTransportSurface::SetAllowOSMesaForTesting(bool allow) { |
80 g_allow_os_mesa = allow; | 75 g_allow_os_mesa = allow; |
81 } | 76 } |
82 | 77 |
83 } // namespace gpu | 78 } // namespace gpu |
OLD | NEW |