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