Chromium Code Reviews| Index: content/common/gpu/image_transport_surface_android.cc |
| diff --git a/content/common/gpu/image_transport_surface_android.cc b/content/common/gpu/image_transport_surface_android.cc |
| index 36f58171bed0c14496633c59235a7499cfd03da0..bd815fc8b06bd36403350ec05d851c8f0b44a50f 100644 |
| --- a/content/common/gpu/image_transport_surface_android.cc |
| +++ b/content/common/gpu/image_transport_surface_android.cc |
| @@ -2,14 +2,45 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "base/logging.h" |
| #include "content/common/gpu/image_transport_surface.h" |
| +#include "base/logging.h" |
| +#include "content/common/gpu/texture_image_transport_surface.h" |
| +#include "ui/gl/gl_surface_egl.h" |
| + |
| +#include <android/native_window_jni.h> |
| + |
| +gfx::AcceleratedWidget GetNativeWidgetAndroid(int surface_id); |
| + |
| // static |
| scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface( |
| GpuChannelManager* manager, |
| GpuCommandBufferStub* stub, |
| const gfx::GLSurfaceHandle& handle) { |
| - NOTIMPLEMENTED(); |
| - return NULL; |
| + scoped_refptr<gfx::GLSurface> surface; |
| + if (!handle.handle && handle.transport) { |
| + DCHECK(handle.transport); |
|
apatrick_chromium
2012/07/24 18:34:16
DCHECK is redundant.
no sievers
2012/07/26 21:21:17
Done.
|
| + DCHECK(handle.parent_client_id); |
| + surface = new TextureImageTransportSurface(manager, stub, handle); |
| + } else if (handle.handle == gfx::kDummyPluginWindow && !handle.transport) { |
| + ANativeWindow* window = GetNativeWidgetAndroid(stub->surface_id()); |
| + DCHECK(window); |
| + surface = new gfx::NativeViewGLSurfaceEGL(false, window); |
| + if (!surface.get() || !surface->Initialize()) |
| + return NULL; |
| + |
| + // Release the extra ref now that we created an EGLSurface holding |
| + // a reference to the surface. |
| + ANativeWindow_release(window); |
| + |
| + surface = new PassThroughImageTransportSurface( |
| + manager, stub, surface.get(), handle.transport); |
| + } |
| + |
| + if (surface->Initialize()) |
| + return surface; |
| + else { |
| + LOG(ERROR) << "Failed to initialize ImageTransportSurface"; |
| + return NULL; |
| + } |
| } |