190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// found in the LICENSE file.
4c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
5c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "content/common/gpu/image_transport_surface.h"
6c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
7c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)namespace content {
8c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
9c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)// static
10c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)scoped_refptr<gfx::GLSurface> ImageTransportSurface::CreateNativeSurface(
11c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    GpuChannelManager* manager,
12c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    GpuCommandBufferStub* stub,
13c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    const gfx::GLSurfaceHandle& handle) {
14c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  DCHECK(handle.handle);
155c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  DCHECK(handle.transport_type == gfx::NATIVE_DIRECT);
16c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  scoped_refptr<gfx::GLSurface> surface =
177d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)      gfx::GLSurface::CreateViewGLSurface(handle.handle);
18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  if (!surface.get())
19c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)    return surface;
20c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  return scoped_refptr<gfx::GLSurface>(new PassThroughImageTransportSurface(
215c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu      manager, stub, surface.get()));
22c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}
23c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
24c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)}  // namespace content
25