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/metrics/histogram_macros.h" | |
10 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
11 #include "gpu/ipc/service/child_window_surface_win.h" | |
12 #include "gpu/ipc/service/direct_composition_surface_win.h" | 10 #include "gpu/ipc/service/direct_composition_surface_win.h" |
13 #include "gpu/ipc/service/gpu_vsync_provider_win.h" | 11 #include "gpu/ipc/service/gpu_vsync_provider_win.h" |
14 #include "gpu/ipc/service/pass_through_image_transport_surface.h" | 12 #include "gpu/ipc/service/pass_through_image_transport_surface.h" |
15 #include "gpu/ipc/service/switches.h" | 13 #include "gpu/ipc/service/switches.h" |
16 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
17 #include "ui/gl/gl_bindings.h" | 15 #include "ui/gl/gl_bindings.h" |
18 #include "ui/gl/gl_implementation.h" | 16 #include "ui/gl/gl_implementation.h" |
19 #include "ui/gl/gl_surface_egl.h" | 17 #include "ui/gl/gl_surface_egl.h" |
20 #include "ui/gl/gl_switches.h" | 18 #include "ui/gl/gl_switches.h" |
21 #include "ui/gl/init/gl_factory.h" | 19 #include "ui/gl/init/gl_factory.h" |
(...skipping 23 matching lines...) Expand all Loading... |
45 kMultiWindowSwapIntervalDefault; | 43 kMultiWindowSwapIntervalDefault; |
46 if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2) { | 44 if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2) { |
47 std::unique_ptr<gfx::VSyncProvider> vsync_provider; | 45 std::unique_ptr<gfx::VSyncProvider> vsync_provider; |
48 | 46 |
49 if (IsGpuVSyncSignalSupported()) | 47 if (IsGpuVSyncSignalSupported()) |
50 vsync_provider.reset(new GpuVSyncProviderWin(delegate, surface_handle)); | 48 vsync_provider.reset(new GpuVSyncProviderWin(delegate, surface_handle)); |
51 else | 49 else |
52 vsync_provider.reset(new gl::VSyncProviderWin(surface_handle)); | 50 vsync_provider.reset(new gl::VSyncProviderWin(surface_handle)); |
53 | 51 |
54 if (gl::GLSurfaceEGL::IsDirectCompositionSupported()) { | 52 if (gl::GLSurfaceEGL::IsDirectCompositionSupported()) { |
55 bool overlays_supported = | 53 scoped_refptr<DirectCompositionSurfaceWin> egl_surface = |
56 DirectCompositionSurfaceWin::AreOverlaysSupported(); | 54 make_scoped_refptr(new DirectCompositionSurfaceWin( |
57 UMA_HISTOGRAM_BOOLEAN("GPU.DirectComposition.OverlaysSupported", | 55 std::move(vsync_provider), delegate, surface_handle)); |
58 overlays_supported); | 56 if (!egl_surface->Initialize()) |
59 if (overlays_supported) { | 57 return nullptr; |
60 scoped_refptr<DirectCompositionSurfaceWin> egl_surface = | 58 surface = egl_surface; |
61 make_scoped_refptr(new DirectCompositionSurfaceWin( | |
62 std::move(vsync_provider), delegate, surface_handle)); | |
63 if (!egl_surface->Initialize()) | |
64 return nullptr; | |
65 surface = egl_surface; | |
66 } else { | |
67 scoped_refptr<ChildWindowSurfaceWin> egl_surface = | |
68 make_scoped_refptr(new ChildWindowSurfaceWin( | |
69 std::move(vsync_provider), delegate, surface_handle)); | |
70 if (!egl_surface->Initialize()) | |
71 return nullptr; | |
72 surface = egl_surface; | |
73 } | |
74 } else { | 59 } else { |
75 surface = gl::init::CreateNativeViewGLSurfaceEGL( | 60 surface = gl::init::CreateNativeViewGLSurfaceEGL( |
76 surface_handle, std::move(vsync_provider)); | 61 surface_handle, std::move(vsync_provider)); |
77 // This is unnecessary with DirectComposition because that doesn't block | 62 // This is unnecessary with DirectComposition because that doesn't block |
78 // swaps, but instead blocks the first draw into a surface during the next | 63 // swaps, but instead blocks the first draw into a surface during the next |
79 // frame. | 64 // frame. |
80 multi_window_swap_interval = kMultiWindowSwapIntervalForceZero; | 65 multi_window_swap_interval = kMultiWindowSwapIntervalForceZero; |
81 if (!surface) | 66 if (!surface) |
82 return nullptr; | 67 return nullptr; |
83 } | 68 } |
84 } else { | 69 } else { |
85 surface = gl::init::CreateViewGLSurface(surface_handle); | 70 surface = gl::init::CreateViewGLSurface(surface_handle); |
86 if (!surface) | 71 if (!surface) |
87 return nullptr; | 72 return nullptr; |
88 } | 73 } |
89 | 74 |
90 return scoped_refptr<gl::GLSurface>(new PassThroughImageTransportSurface( | 75 return scoped_refptr<gl::GLSurface>(new PassThroughImageTransportSurface( |
91 delegate, surface.get(), multi_window_swap_interval)); | 76 delegate, surface.get(), multi_window_swap_interval)); |
92 } | 77 } |
93 | 78 |
94 } // namespace gpu | 79 } // namespace gpu |
OLD | NEW |