image_transport_surface_linux.cc revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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
3// found in the LICENSE file.
4
5#include "content/common/gpu/image_transport_surface.h"
6
7#include "content/common/gpu/texture_image_transport_surface.h"
8
9namespace content {
10
11// static
12scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateSurface(
13    GpuChannelManager* manager,
14    GpuCommandBufferStub* stub,
15    const gfx::GLSurfaceHandle& handle) {
16  scoped_refptr<gfx::GLSurface> surface;
17  if (handle.transport_type == gfx::TEXTURE_TRANSPORT) {
18    DCHECK(!handle.handle);
19    surface = new TextureImageTransportSurface(manager, stub, handle);
20  } else {
21    DCHECK(handle.handle);
22    DCHECK(handle.transport_type == gfx::NATIVE_DIRECT ||
23           handle.transport_type == gfx::NATIVE_TRANSPORT);
24    surface = gfx::GLSurface::CreateViewGLSurface(false, handle.handle);
25    if (!surface.get())
26      return NULL;
27    surface = new PassThroughImageTransportSurface(manager,
28                                                   stub,
29                                                   surface.get(),
30                                                   handle.is_transport());
31  }
32
33  if (surface->Initialize())
34    return surface;
35  else
36    return NULL;
37}
38
39}  // namespace content
40