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