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 "gpu/ipc/service/image_transport_surface.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/common/gpu/pass_through_image_transport_surface.h" | |
9 #include "gpu/ipc/common/gpu_surface_lookup.h" | 8 #include "gpu/ipc/common/gpu_surface_lookup.h" |
| 9 #include "gpu/ipc/service/pass_through_image_transport_surface.h" |
10 #include "ui/gl/gl_surface_egl.h" | 10 #include "ui/gl/gl_surface_egl.h" |
11 | 11 |
12 namespace content { | 12 namespace gpu { |
13 | 13 |
14 // static | 14 // static |
15 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface( | 15 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface( |
16 GpuChannelManager* manager, | 16 GpuChannelManager* manager, |
17 GpuCommandBufferStub* stub, | 17 GpuCommandBufferStub* stub, |
18 gpu::SurfaceHandle surface_handle, | 18 SurfaceHandle surface_handle, |
19 gfx::GLSurface::Format format) { | 19 gfx::GLSurface::Format format) { |
20 DCHECK(gpu::GpuSurfaceLookup::GetInstance()); | 20 DCHECK(GpuSurfaceLookup::GetInstance()); |
21 DCHECK_NE(surface_handle, gpu::kNullSurfaceHandle); | 21 DCHECK_NE(surface_handle, kNullSurfaceHandle); |
22 // On Android, the surface_handle is the id of the surface in the | 22 // On Android, the surface_handle is the id of the surface in the |
23 // GpuSurfaceTracker/gpu::GpuSurfaceLookup | 23 // GpuSurfaceTracker/GpuSurfaceLookup |
24 ANativeWindow* window = | 24 ANativeWindow* window = |
25 gpu::GpuSurfaceLookup::GetInstance()->AcquireNativeWidget(surface_handle); | 25 GpuSurfaceLookup::GetInstance()->AcquireNativeWidget(surface_handle); |
26 if (!window) { | 26 if (!window) { |
27 LOG(WARNING) << "Failed to acquire native widget."; | 27 LOG(WARNING) << "Failed to acquire native widget."; |
28 return nullptr; | 28 return nullptr; |
29 } | 29 } |
30 scoped_refptr<gfx::GLSurface> surface = | 30 scoped_refptr<gfx::GLSurface> surface = |
31 new gfx::NativeViewGLSurfaceEGL(window); | 31 new gfx::NativeViewGLSurfaceEGL(window); |
32 bool initialize_success = surface->Initialize(format); | 32 bool initialize_success = surface->Initialize(format); |
33 ANativeWindow_release(window); | 33 ANativeWindow_release(window); |
34 if (!initialize_success) | 34 if (!initialize_success) |
35 return scoped_refptr<gfx::GLSurface>(); | 35 return scoped_refptr<gfx::GLSurface>(); |
36 | 36 |
37 return scoped_refptr<gfx::GLSurface>( | 37 return scoped_refptr<gfx::GLSurface>( |
38 new PassThroughImageTransportSurface(manager, stub, surface.get())); | 38 new PassThroughImageTransportSurface(manager, stub, surface.get())); |
39 } | 39 } |
40 | 40 |
41 } // namespace content | 41 } // namespace gpu |
OLD | NEW |