| 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 "content/common/gpu/image_transport_surface.h" | 5 #include "content/common/gpu/image_transport_surface.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/win/windows_version.h" | 12 #include "base/win/windows_version.h" |
| 13 #include "content/common/gpu/child_window_surface_win.h" |
| 13 #include "content/common/gpu/gpu_messages.h" | 14 #include "content/common/gpu/gpu_messages.h" |
| 14 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
| 15 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
| 16 #include "ui/gl/gl_bindings.h" | 17 #include "ui/gl/gl_bindings.h" |
| 17 #include "ui/gl/gl_context.h" | 18 #include "ui/gl/gl_context.h" |
| 18 #include "ui/gl/gl_implementation.h" | 19 #include "ui/gl/gl_implementation.h" |
| 19 #include "ui/gl/gl_surface_egl.h" | 20 #include "ui/gl/gl_surface_egl.h" |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 | 23 |
| 23 // static | 24 // static |
| 24 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface( | 25 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface( |
| 25 GpuChannelManager* manager, | 26 GpuChannelManager* manager, |
| 26 GpuCommandBufferStub* stub, | 27 GpuCommandBufferStub* stub, |
| 27 const gfx::GLSurfaceHandle& handle) { | 28 const gfx::GLSurfaceHandle& handle) { |
| 28 DCHECK(handle.handle); | 29 DCHECK(handle.handle); |
| 29 DCHECK_EQ(handle.transport_type, gfx::NATIVE_DIRECT); | 30 DCHECK_EQ(handle.transport_type, gfx::NATIVE_DIRECT); |
| 30 scoped_refptr<gfx::GLSurface> surface = | 31 |
| 31 gfx::GLSurface::CreateViewGLSurface(handle.handle); | 32 scoped_refptr<gfx::GLSurface> surface; |
| 32 if (!surface.get()) | 33 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 && |
| 33 return surface; | 34 gfx::GLSurfaceEGL::IsDirectCompositionSupported()) { |
| 35 surface = new ChildWindowSurfaceWin(manager, handle.handle); |
| 36 if (!surface->Initialize()) |
| 37 return nullptr; |
| 38 } else { |
| 39 surface = gfx::GLSurface::CreateViewGLSurface(handle.handle); |
| 40 } |
| 41 |
| 34 return scoped_refptr<gfx::GLSurface>(new PassThroughImageTransportSurface( | 42 return scoped_refptr<gfx::GLSurface>(new PassThroughImageTransportSurface( |
| 35 manager, stub, surface.get())); | 43 manager, stub, surface.get())); |
| 36 } | 44 } |
| 37 | 45 |
| 38 } // namespace content | 46 } // namespace content |
| OLD | NEW |