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 "gpu/ipc/service/image_transport_surface.h" | 5 #include "gpu/ipc/service/image_transport_surface.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "gpu/ipc/service/child_window_surface_win.h" | 9 #include "gpu/ipc/service/child_window_surface_win.h" |
10 #include "gpu/ipc/service/direct_composition_surface_win.h" | 10 #include "gpu/ipc/service/direct_composition_surface_win.h" |
| 11 #include "gpu/ipc/service/gpu_vsync_provider_win.h" |
11 #include "gpu/ipc/service/pass_through_image_transport_surface.h" | 12 #include "gpu/ipc/service/pass_through_image_transport_surface.h" |
12 #include "gpu/ipc/service/switches.h" | 13 #include "gpu/ipc/service/switches.h" |
13 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
14 #include "ui/gl/gl_bindings.h" | 15 #include "ui/gl/gl_bindings.h" |
15 #include "ui/gl/gl_implementation.h" | 16 #include "ui/gl/gl_implementation.h" |
16 #include "ui/gl/gl_surface_egl.h" | 17 #include "ui/gl/gl_surface_egl.h" |
| 18 #include "ui/gl/gl_switches.h" |
17 #include "ui/gl/init/gl_factory.h" | 19 #include "ui/gl/init/gl_factory.h" |
18 #include "ui/gl/vsync_provider_win.h" | 20 #include "ui/gl/vsync_provider_win.h" |
19 | 21 |
20 namespace gpu { | 22 namespace gpu { |
21 | 23 |
| 24 namespace { |
| 25 bool IsGpuVSyncSignalSupported() { |
| 26 // TODO(stanisc): http://crbug.com/467617 Limit to Windows 8+ for now because |
| 27 // of locking issue caused by waiting for VSync on Win7. |
| 28 return base::win::GetVersion() >= base::win::VERSION_WIN8 && |
| 29 base::FeatureList::IsEnabled(features::kD3DVsync); |
| 30 } |
| 31 |
| 32 } // namespace |
| 33 |
22 // static | 34 // static |
23 scoped_refptr<gl::GLSurface> ImageTransportSurface::CreateNativeSurface( | 35 scoped_refptr<gl::GLSurface> ImageTransportSurface::CreateNativeSurface( |
24 base::WeakPtr<ImageTransportSurfaceDelegate> delegate, | 36 base::WeakPtr<ImageTransportSurfaceDelegate> delegate, |
25 SurfaceHandle surface_handle, | 37 SurfaceHandle surface_handle, |
26 gl::GLSurfaceFormat format) { | 38 gl::GLSurfaceFormat format) { |
27 DCHECK_NE(surface_handle, kNullSurfaceHandle); | 39 DCHECK_NE(surface_handle, kNullSurfaceHandle); |
28 | 40 |
29 scoped_refptr<gl::GLSurface> surface; | 41 scoped_refptr<gl::GLSurface> surface; |
30 if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2 && | 42 if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2 && |
31 gl::GLSurfaceEGL::IsDirectCompositionSupported()) { | 43 gl::GLSurfaceEGL::IsDirectCompositionSupported()) { |
32 // TODO(stanisc): http://crbug.com/659844: | 44 std::unique_ptr<gfx::VSyncProvider> vsync_provider; |
33 // Force DWM based gl::VSyncProviderWin provider to avoid video playback | 45 |
34 // smoothness issues. Once that issue is fixed, passing a nullptr | 46 if (IsGpuVSyncSignalSupported()) |
35 // vsync_provider would result in assigning a default VSyncProvider inside | 47 vsync_provider.reset(new GpuVSyncProviderWin(delegate, surface_handle)); |
36 // the Initialize call. | 48 else |
37 std::unique_ptr<gfx::VSyncProvider> vsync_provider( | 49 vsync_provider.reset(new gl::VSyncProviderWin(surface_handle)); |
38 new gl::VSyncProviderWin(surface_handle)); | 50 |
39 if (base::FeatureList::IsEnabled(switches::kDirectCompositionOverlays)) { | 51 if (base::FeatureList::IsEnabled(switches::kDirectCompositionOverlays)) { |
40 scoped_refptr<DirectCompositionSurfaceWin> egl_surface = | 52 scoped_refptr<DirectCompositionSurfaceWin> egl_surface = |
41 make_scoped_refptr( | 53 make_scoped_refptr( |
42 new DirectCompositionSurfaceWin(delegate, surface_handle)); | 54 new DirectCompositionSurfaceWin(delegate, surface_handle)); |
43 if (!egl_surface->Initialize(std::move(vsync_provider))) | 55 if (!egl_surface->Initialize(std::move(vsync_provider))) |
44 return nullptr; | 56 return nullptr; |
45 surface = egl_surface; | 57 surface = egl_surface; |
46 } else { | 58 } else { |
47 scoped_refptr<ChildWindowSurfaceWin> egl_surface = make_scoped_refptr( | 59 scoped_refptr<ChildWindowSurfaceWin> egl_surface = make_scoped_refptr( |
48 new ChildWindowSurfaceWin(delegate, surface_handle)); | 60 new ChildWindowSurfaceWin(delegate, surface_handle)); |
49 if (!egl_surface->Initialize(std::move(vsync_provider))) | 61 if (!egl_surface->Initialize(std::move(vsync_provider))) |
50 return nullptr; | 62 return nullptr; |
51 surface = egl_surface; | 63 surface = egl_surface; |
52 } | 64 } |
53 } else { | 65 } else { |
54 surface = gl::init::CreateViewGLSurface(surface_handle); | 66 surface = gl::init::CreateViewGLSurface(surface_handle); |
55 if (!surface) | 67 if (!surface) |
56 return nullptr; | 68 return nullptr; |
57 } | 69 } |
58 | 70 |
59 return scoped_refptr<gl::GLSurface>( | 71 return scoped_refptr<gl::GLSurface>( |
60 new PassThroughImageTransportSurface(delegate, surface.get())); | 72 new PassThroughImageTransportSurface(delegate, surface.get())); |
61 } | 73 } |
62 | 74 |
63 } // namespace gpu | 75 } // namespace gpu |
OLD | NEW |