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