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