Chromium Code Reviews| 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..bdb160ca95c4dd78e40642297d84a8827564786e |
| --- /dev/null |
| +++ b/ui/gl/gl_image_ozone_native_pixmap.cc |
| @@ -0,0 +1,50 @@ |
| +// 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" |
| + |
| +namespace gfx { |
| + |
| +GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const Size& size, |
| + unsigned internalformat) |
| + : GLImageLinuxDMABuffer(size, internalformat) {} |
| + |
| +GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() {} |
|
reveman
2015/07/28 19:11:17
DCHECK(!pixmap_) in dtor
dshwang
2015/07/29 13:23:09
Done.
|
| + |
| +bool GLImageOzoneNativePixmap::Initialize( |
| + scoped_refptr<ui::NativePixmap> pixmap, |
| + GpuMemoryBuffer::Format format) { |
| + DCHECK(pixmap); |
|
reveman
2015/07/28 19:11:17
DCHECK(!pixmap_) instead
dshwang
2015/07/29 13:23:09
Take both. Done.
reveman
2015/07/29 14:16:41
Checking that the first param to a function is non
dshwang
2015/07/29 15:15:03
Done. relying on natural crash.
|
| + pixmap_ = pixmap; |
|
reveman
2015/07/28 19:11:17
pixmap_ should not be set if we return false
dshwang
2015/07/29 13:23:09
Done.
|
| + if (pixmap_->GetEGLClientBuffer()) { |
| + EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; |
| + return GLImageEGL::Initialize(EGL_NATIVE_PIXMAP_KHR, |
| + pixmap_->GetEGLClientBuffer(), attrs); |
| + } |
| + |
| + if (pixmap_->GetDmaBufFd() >= 0) { |
| + base::FileDescriptor handle(pixmap_->GetDmaBufFd(), false); |
| + return GLImageLinuxDMABuffer::Initialize(handle, format, |
| + pixmap_->GetDmaBufPitch()); |
| + } |
| + |
| + return true; |
| +} |
| + |
| +void GLImageOzoneNativePixmap::Destroy(bool have_context) { |
| + GLImageEGL::Destroy(have_context); |
| + pixmap_ = nullptr; |
| +} |
| + |
| +bool GLImageOzoneNativePixmap::ScheduleOverlayPlane(AcceleratedWidget widget, |
| + int z_order, |
| + OverlayTransform transform, |
| + const Rect& bounds_rect, |
| + const RectF& crop_rect) { |
| + return pixmap_ && |
|
reveman
2015/07/28 19:11:17
can we DCHECK(pixmap_) instead?
dshwang
2015/07/29 13:23:09
Yes, Done.
|
| + pixmap_->ScheduleOverlayPlane(widget, z_order, transform, bounds_rect, |
| + crop_rect); |
| +} |
| + |
| +} // namespace gfx |