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