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<gl::GLSurface> ImageTransportSurface::CreateNativeSurface( | 16 scoped_refptr<gl::GLSurface> ImageTransportSurface::CreateNativeSurface( |
17 base::WeakPtr<ImageTransportSurfaceDelegate> delegate, | 17 base::WeakPtr<ImageTransportSurfaceDelegate> delegate, |
18 SurfaceHandle surface_handle, | 18 SurfaceHandle surface_handle, |
19 gl::GLSurface::Format format) { | 19 gl::GLSurfaceFormat format) { |
20 if (gl::GetGLImplementation() == gl::kGLImplementationMockGL) | 20 if (gl::GetGLImplementation() == gl::kGLImplementationMockGL) |
21 return new gl::GLSurfaceStub; | 21 return new gl::GLSurfaceStub; |
22 DCHECK(GpuSurfaceLookup::GetInstance()); | 22 DCHECK(GpuSurfaceLookup::GetInstance()); |
23 DCHECK_NE(surface_handle, kNullSurfaceHandle); | 23 DCHECK_NE(surface_handle, kNullSurfaceHandle); |
24 // On Android, the surface_handle is the id of the surface in the | 24 // On Android, the surface_handle is the id of the surface in the |
25 // GpuSurfaceTracker/GpuSurfaceLookup | 25 // GpuSurfaceTracker/GpuSurfaceLookup |
26 ANativeWindow* window = | 26 ANativeWindow* window = |
27 GpuSurfaceLookup::GetInstance()->AcquireNativeWidget(surface_handle); | 27 GpuSurfaceLookup::GetInstance()->AcquireNativeWidget(surface_handle); |
28 if (!window) { | 28 if (!window) { |
29 LOG(WARNING) << "Failed to acquire native widget."; | 29 LOG(WARNING) << "Failed to acquire native widget."; |
30 return nullptr; | 30 return nullptr; |
31 } | 31 } |
32 scoped_refptr<gl::GLSurface> surface = new gl::NativeViewGLSurfaceEGL(window); | 32 scoped_refptr<gl::GLSurface> surface = new gl::NativeViewGLSurfaceEGL(window); |
33 bool initialize_success = surface->Initialize(format); | 33 bool initialize_success = surface->Initialize(format); |
34 ANativeWindow_release(window); | 34 ANativeWindow_release(window); |
35 if (!initialize_success) | 35 if (!initialize_success) |
36 return scoped_refptr<gl::GLSurface>(); | 36 return scoped_refptr<gl::GLSurface>(); |
37 | 37 |
38 return scoped_refptr<gl::GLSurface>( | 38 return scoped_refptr<gl::GLSurface>( |
39 new PassThroughImageTransportSurface(delegate, surface.get())); | 39 new PassThroughImageTransportSurface(delegate, surface.get())); |
40 } | 40 } |
41 | 41 |
42 } // namespace gpu | 42 } // namespace gpu |
OLD | NEW |