| 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> |
| 8 |
| 7 #include "gpu/ipc/service/child_window_surface_win.h" | 9 #include "gpu/ipc/service/child_window_surface_win.h" |
| 8 #include "gpu/ipc/service/pass_through_image_transport_surface.h" | 10 #include "gpu/ipc/service/pass_through_image_transport_surface.h" |
| 9 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
| 10 #include "ui/gl/gl_bindings.h" | 12 #include "ui/gl/gl_bindings.h" |
| 11 #include "ui/gl/gl_implementation.h" | 13 #include "ui/gl/gl_implementation.h" |
| 12 #include "ui/gl/gl_surface_egl.h" | 14 #include "ui/gl/gl_surface_egl.h" |
| 13 #include "ui/gl/vsync_provider_win.h" | 15 #include "ui/gl/vsync_provider_win.h" |
| 14 | 16 |
| 15 namespace gpu { | 17 namespace gpu { |
| 16 | 18 |
| 17 // static | 19 // static |
| 18 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface( | 20 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface( |
| 19 GpuChannelManager* manager, | 21 GpuChannelManager* manager, |
| 20 GpuCommandBufferStub* stub, | 22 GpuCommandBufferStub* stub, |
| 21 SurfaceHandle surface_handle, | 23 SurfaceHandle surface_handle, |
| 22 gfx::GLSurface::Format format) { | 24 gfx::GLSurface::Format format) { |
| 23 DCHECK_NE(surface_handle, kNullSurfaceHandle); | 25 DCHECK_NE(surface_handle, kNullSurfaceHandle); |
| 24 | 26 |
| 25 scoped_refptr<gfx::GLSurface> surface; | 27 scoped_refptr<gfx::GLSurface> surface; |
| 26 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && | 28 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && |
| 27 gfx::GLSurfaceEGL::IsDirectCompositionSupported()) { | 29 gfx::GLSurfaceEGL::IsDirectCompositionSupported()) { |
| 28 scoped_refptr<ChildWindowSurfaceWin> egl_surface( | 30 scoped_refptr<ChildWindowSurfaceWin> egl_surface( |
| 29 new ChildWindowSurfaceWin(manager, surface_handle)); | 31 new ChildWindowSurfaceWin(manager, surface_handle)); |
| 30 surface = egl_surface; | 32 surface = egl_surface; |
| 31 | 33 |
| 32 // TODO(jbauman): Get frame statistics from DirectComposition | 34 // TODO(jbauman): Get frame statistics from DirectComposition |
| 33 scoped_ptr<gfx::VSyncProvider> vsync_provider( | 35 std::unique_ptr<gfx::VSyncProvider> vsync_provider( |
| 34 new gfx::VSyncProviderWin(surface_handle)); | 36 new gfx::VSyncProviderWin(surface_handle)); |
| 35 if (!egl_surface->Initialize(std::move(vsync_provider))) | 37 if (!egl_surface->Initialize(std::move(vsync_provider))) |
| 36 return nullptr; | 38 return nullptr; |
| 37 } else { | 39 } else { |
| 38 surface = gfx::GLSurface::CreateViewGLSurface(surface_handle); | 40 surface = gfx::GLSurface::CreateViewGLSurface(surface_handle); |
| 39 if (!surface) | 41 if (!surface) |
| 40 return nullptr; | 42 return nullptr; |
| 41 } | 43 } |
| 42 | 44 |
| 43 return scoped_refptr<gfx::GLSurface>(new PassThroughImageTransportSurface( | 45 return scoped_refptr<gfx::GLSurface>(new PassThroughImageTransportSurface( |
| 44 manager, stub, surface.get())); | 46 manager, stub, surface.get())); |
| 45 } | 47 } |
| 46 | 48 |
| 47 } // namespace gpu | 49 } // namespace gpu |
| OLD | NEW |