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/logging.h" | 7 #include "base/logging.h" |
8 #include "content/common/gpu/gpu_surface_lookup.h" | 8 #include "content/common/gpu/gpu_surface_lookup.h" |
9 #include "content/common/gpu/texture_image_transport_surface.h" | 9 #include "content/common/gpu/texture_image_transport_surface.h" |
10 #include "ui/gl/gl_surface_egl.h" | 10 #include "ui/gl/gl_surface_egl.h" |
11 | 11 |
12 // static | 12 // static |
13 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( | 13 scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( |
14 GpuChannelManager* manager, | 14 GpuChannelManager* manager, |
15 GpuCommandBufferStub* stub, | 15 GpuCommandBufferStub* stub, |
16 const gfx::GLSurfaceHandle& handle) { | 16 const gfx::GLSurfaceHandle& handle) { |
17 scoped_refptr<gfx::GLSurface> surface; | 17 scoped_refptr<gfx::GLSurface> surface; |
18 if (!handle.handle && handle.transport) { | 18 if (!handle.handle && handle.transport) { |
19 DCHECK(handle.parent_client_id); | |
20 surface = new TextureImageTransportSurface(manager, stub, handle); | 19 surface = new TextureImageTransportSurface(manager, stub, handle); |
21 } else if (handle.handle == gfx::kDummyPluginWindow && !handle.transport) { | 20 } else if (handle.handle == gfx::kDummyPluginWindow && !handle.transport) { |
22 DCHECK(GpuSurfaceLookup::GetInstance()); | 21 DCHECK(GpuSurfaceLookup::GetInstance()); |
23 ANativeWindow* window = GpuSurfaceLookup::GetInstance()->GetNativeWidget( | 22 ANativeWindow* window = GpuSurfaceLookup::GetInstance()->GetNativeWidget( |
24 stub->surface_id()); | 23 stub->surface_id()); |
25 DCHECK(window); | 24 DCHECK(window); |
26 surface = new gfx::NativeViewGLSurfaceEGL(false, window); | 25 surface = new gfx::NativeViewGLSurfaceEGL(false, window); |
27 if (!surface.get() || !surface->Initialize()) | 26 if (!surface.get() || !surface->Initialize()) |
28 return NULL; | 27 return NULL; |
29 | 28 |
30 surface = new PassThroughImageTransportSurface( | 29 surface = new PassThroughImageTransportSurface( |
31 manager, stub, surface.get(), handle.transport); | 30 manager, stub, surface.get(), handle.transport); |
32 } else { | 31 } else { |
33 NOTIMPLEMENTED(); | 32 NOTIMPLEMENTED(); |
34 return NULL; | 33 return NULL; |
35 } | 34 } |
36 | 35 |
37 if (surface->Initialize()) | 36 if (surface->Initialize()) |
38 return surface; | 37 return surface; |
39 else { | 38 else { |
40 LOG(ERROR) << "Failed to initialize ImageTransportSurface"; | 39 LOG(ERROR) << "Failed to initialize ImageTransportSurface"; |
41 return NULL; | 40 return NULL; |
42 } | 41 } |
43 } | 42 } |
OLD | NEW |