| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "content/common/gpu/gpu_channel.h" | 9 #include "content/common/gpu/gpu_channel.h" |
| 10 #include "content/common/gpu/gpu_channel_manager.h" | 10 #include "content/common/gpu/gpu_channel_manager.h" |
| 11 #include "content/common/gpu/gpu_command_buffer_stub.h" | 11 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 12 #include "content/common/gpu/gpu_surface_lookup.h" | 12 #include "content/common/gpu/gpu_surface_lookup.h" |
| 13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 14 #include "ui/gl/gl_surface_egl.h" | 14 #include "ui/gl/gl_surface_egl.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 // static | 18 // static |
| 19 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface( | 19 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface( |
| 20 GpuChannelManager* manager, | 20 GpuChannelManager* manager, |
| 21 GpuCommandBufferStub* stub, | 21 GpuCommandBufferStub* stub, |
| 22 const gfx::GLSurfaceHandle& handle) { | 22 const gfx::GLSurfaceHandle& handle) { |
| 23 DCHECK(GpuSurfaceLookup::GetInstance()); | 23 DCHECK(GpuSurfaceLookup::GetInstance()); |
| 24 DCHECK_EQ(handle.transport_type, gfx::NATIVE_DIRECT); | 24 DCHECK_EQ(handle.transport_type, gfx::NATIVE_DIRECT); |
| 25 ANativeWindow* window = | 25 ANativeWindow* window = |
| 26 GpuSurfaceLookup::GetInstance()->AcquireNativeWidget( | 26 GpuSurfaceLookup::GetInstance()->AcquireNativeWidget(handle.handle); |
| 27 stub->surface_id()); | |
| 28 CHECK(window) << "Failed to retrieve window handle."; | 27 CHECK(window) << "Failed to retrieve window handle."; |
| 29 scoped_refptr<gfx::GLSurface> surface = | 28 scoped_refptr<gfx::GLSurface> surface = |
| 30 new gfx::NativeViewGLSurfaceEGL(window); | 29 new gfx::NativeViewGLSurfaceEGL(window); |
| 31 bool initialize_success = surface->Initialize(); | 30 bool initialize_success = surface->Initialize(); |
| 32 if (window) | 31 if (window) |
| 33 ANativeWindow_release(window); | 32 ANativeWindow_release(window); |
| 34 if (!initialize_success) | 33 if (!initialize_success) |
| 35 return scoped_refptr<gfx::GLSurface>(); | 34 return scoped_refptr<gfx::GLSurface>(); |
| 36 | 35 |
| 37 return scoped_refptr<gfx::GLSurface>( | 36 return scoped_refptr<gfx::GLSurface>( |
| 38 new PassThroughImageTransportSurface(manager, stub, surface.get())); | 37 new PassThroughImageTransportSurface(manager, stub, surface.get())); |
| 39 } | 38 } |
| 40 | 39 |
| 41 } // namespace content | 40 } // namespace content |
| OLD | NEW |