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