| Index: ui/gl/gl_image_ozone_native_pixmap.cc | 
| diff --git a/ui/gl/gl_image_ozone_native_pixmap.cc b/ui/gl/gl_image_ozone_native_pixmap.cc | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..5dcf5c40a3b041a1a9cb8c75cc43f4242433f9fc | 
| --- /dev/null | 
| +++ b/ui/gl/gl_image_ozone_native_pixmap.cc | 
| @@ -0,0 +1,126 @@ | 
| +// Copyright 2015 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#include "ui/gl/gl_image_ozone_native_pixmap.h" | 
| + | 
| +#include "ui/gl/gl_image_linux_dma_buffer.h" | 
| + | 
| +namespace gfx { | 
| + | 
| +// static | 
| +scoped_refptr<GLImageOzoneNativePixmap> GLImageOzoneNativePixmap::Create( | 
| +    scoped_refptr<ui::NativePixmap> pixmap, | 
| +    const Size& size, | 
| +    GpuMemoryBuffer::Format format, | 
| +    unsigned internalformat) { | 
| +  DCHECK(pixmap); | 
| +  scoped_refptr<GLImageOzoneNativePixmap> image( | 
| +      new GLImageOzoneNativePixmap(pixmap, size, format, internalformat)); | 
| +  if (!image->Initialize()) { | 
| +    return nullptr; | 
| +  } | 
| +  return image; | 
| +} | 
| + | 
| +GLImageOzoneNativePixmap::GLImageOzoneNativePixmap( | 
| +    scoped_refptr<ui::NativePixmap> pixmap, | 
| +    const Size& size, | 
| +    GpuMemoryBuffer::Format format, | 
| +    unsigned internalformat) | 
| +    : pixmap_(pixmap), | 
| +      size_(size), | 
| +      format_(format), | 
| +      internalformat_(internalformat) {} | 
| + | 
| +GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() {} | 
| + | 
| +bool GLImageOzoneNativePixmap::Initialize() { | 
| +  if (pixmap_->GetEGLClientBuffer()) { | 
| +    scoped_refptr<GLImageEGL> image = new GLImageEGL(size_); | 
| +    EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; | 
| +    if (!image->Initialize(EGL_NATIVE_PIXMAP_KHR, pixmap_->GetEGLClientBuffer(), | 
| +                           attrs)) { | 
| +      return false; | 
| +    } | 
| +    image_ = image; | 
| +    return true; | 
| +  } | 
| + | 
| +  if (pixmap_->GetDmaBufFd() >= 0) { | 
| +    scoped_refptr<GLImageLinuxDMABuffer> image = | 
| +        new GLImageLinuxDMABuffer(size_, internalformat_); | 
| +    base::FileDescriptor handle(pixmap_->GetDmaBufFd(), false); | 
| +    if (!image->Initialize(handle, format_, pixmap_->GetDmaBufPitch())) { | 
| +      return false; | 
| +    } | 
| +    image_ = image; | 
| +    return true; | 
| +  } | 
| + | 
| +  return true; | 
| +} | 
| + | 
| +void GLImageOzoneNativePixmap::Destroy(bool have_context) { | 
| +  if (image_) | 
| +    image_->Destroy(have_context); | 
| +  pixmap_ = nullptr; | 
| +} | 
| + | 
| +Size GLImageOzoneNativePixmap::GetSize() { | 
| +  return size_; | 
| +} | 
| + | 
| +unsigned GLImageOzoneNativePixmap::GetInternalFormat() { | 
| +  return internalformat_; | 
| +} | 
| + | 
| +bool GLImageOzoneNativePixmap::BindTexImage(unsigned target) { | 
| +  if (image_) | 
| +    return image_->BindTexImage(target); | 
| +  return true; | 
| +} | 
| + | 
| +void GLImageOzoneNativePixmap::ReleaseTexImage(unsigned target) { | 
| +  if (image_) | 
| +    image_->ReleaseTexImage(target); | 
| +} | 
| + | 
| +bool GLImageOzoneNativePixmap::CopyTexSubImage(unsigned target, | 
| +                                               const Point& offset, | 
| +                                               const Rect& rect) { | 
| +  if (image_) | 
| +    return image_->CopyTexSubImage(target, offset, rect); | 
| +  return false; | 
| +} | 
| +void GLImageOzoneNativePixmap::WillUseTexImage() { | 
| +  if (image_) | 
| +    image_->WillUseTexImage(); | 
| +} | 
| + | 
| +void GLImageOzoneNativePixmap::DidUseTexImage() { | 
| +  if (image_) | 
| +    image_->DidUseTexImage(); | 
| +} | 
| + | 
| +void GLImageOzoneNativePixmap::WillModifyTexImage() { | 
| +  if (image_) | 
| +    image_->WillModifyTexImage(); | 
| +} | 
| + | 
| +void GLImageOzoneNativePixmap::DidModifyTexImage() { | 
| +  if (image_) | 
| +    image_->DidModifyTexImage(); | 
| +} | 
| + | 
| +bool GLImageOzoneNativePixmap::ScheduleOverlayPlane(AcceleratedWidget widget, | 
| +                                                    int z_order, | 
| +                                                    OverlayTransform transform, | 
| +                                                    const Rect& bounds_rect, | 
| +                                                    const RectF& crop_rect) { | 
| +  return pixmap_ && | 
| +         pixmap_->ScheduleOverlayPlane(widget, z_order, transform, bounds_rect, | 
| +                                       crop_rect); | 
| +} | 
| + | 
| +}  // namespace gfx | 
|  |