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