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 |
22 // static | 24 // static |
23 scoped_refptr<gl::GLSurface> ImageTransportSurface::CreateNativeSurface( | 25 scoped_refptr<gl::GLSurface> ImageTransportSurface::CreateNativeSurface( |
24 base::WeakPtr<ImageTransportSurfaceDelegate> delegate, | 26 base::WeakPtr<ImageTransportSurfaceDelegate> delegate, |
25 SurfaceHandle surface_handle, | 27 SurfaceHandle surface_handle, |
26 gl::GLSurfaceFormat format) { | 28 gl::GLSurfaceFormat format) { |
27 DCHECK_NE(surface_handle, kNullSurfaceHandle); | 29 DCHECK_NE(surface_handle, kNullSurfaceHandle); |
28 | 30 |
29 scoped_refptr<gl::GLSurface> surface; | 31 scoped_refptr<gl::GLSurface> surface; |
30 if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2 && | 32 if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2 && |
31 gl::GLSurfaceEGL::IsDirectCompositionSupported()) { | 33 gl::GLSurfaceEGL::IsDirectCompositionSupported()) { |
32 // TODO(stanisc): http://crbug.com/659844: | 34 std::unique_ptr<gfx::VSyncProvider> vsync_provider; |
33 // Force DWM based gl::VSyncProviderWin provider to avoid video playback | 35 |
34 // smoothness issues. Once that issue is fixed, passing a nullptr | 36 if (base::FeatureList::IsEnabled(features::kD3DVsync)) |
35 // vsync_provider would result in assigning a default VSyncProvider inside | 37 vsync_provider.reset(new GpuVSyncProviderWin(delegate, surface_handle)); |
stanisc
2017/02/02 22:01:23
This doesn't work for CreateViewGLSurface case bel
| |
36 // the Initialize call. | 38 else |
37 std::unique_ptr<gfx::VSyncProvider> vsync_provider( | 39 vsync_provider.reset(new gl::VSyncProviderWin(surface_handle)); |
38 new gl::VSyncProviderWin(surface_handle)); | 40 |
39 if (base::FeatureList::IsEnabled(switches::kDirectCompositionOverlays)) { | 41 if (base::FeatureList::IsEnabled(switches::kDirectCompositionOverlays)) { |
40 scoped_refptr<DirectCompositionSurfaceWin> egl_surface = | 42 scoped_refptr<DirectCompositionSurfaceWin> egl_surface = |
41 make_scoped_refptr( | 43 make_scoped_refptr( |
42 new DirectCompositionSurfaceWin(delegate, surface_handle)); | 44 new DirectCompositionSurfaceWin(delegate, surface_handle)); |
43 if (!egl_surface->Initialize(std::move(vsync_provider))) | 45 if (!egl_surface->Initialize(std::move(vsync_provider))) |
44 return nullptr; | 46 return nullptr; |
45 surface = egl_surface; | 47 surface = egl_surface; |
46 } else { | 48 } else { |
47 scoped_refptr<ChildWindowSurfaceWin> egl_surface = make_scoped_refptr( | 49 scoped_refptr<ChildWindowSurfaceWin> egl_surface = make_scoped_refptr( |
48 new ChildWindowSurfaceWin(delegate, surface_handle)); | 50 new ChildWindowSurfaceWin(delegate, surface_handle)); |
49 if (!egl_surface->Initialize(std::move(vsync_provider))) | 51 if (!egl_surface->Initialize(std::move(vsync_provider))) |
50 return nullptr; | 52 return nullptr; |
51 surface = egl_surface; | 53 surface = egl_surface; |
52 } | 54 } |
53 } else { | 55 } else { |
54 surface = gl::init::CreateViewGLSurface(surface_handle); | 56 surface = gl::init::CreateViewGLSurface(surface_handle); |
55 if (!surface) | 57 if (!surface) |
56 return nullptr; | 58 return nullptr; |
57 } | 59 } |
58 | 60 |
59 return scoped_refptr<gl::GLSurface>( | 61 return scoped_refptr<gl::GLSurface>( |
60 new PassThroughImageTransportSurface(delegate, surface.get())); | 62 new PassThroughImageTransportSurface(delegate, surface.get())); |
61 } | 63 } |
62 | 64 |
63 } // namespace gpu | 65 } // namespace gpu |
OLD | NEW |