Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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 "ui/gl/gl_image_ozone_native_pixmap.h" | |
| 6 | |
| 7 namespace gfx { | |
| 8 | |
| 9 GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const Size& size, | |
| 10 unsigned internalformat) | |
| 11 : GLImageLinuxDMABuffer(size, internalformat) {} | |
| 12 | |
| 13 GLImageOzoneNativePixmap::~GLImageOzoneNativePixmap() {} | |
|
reveman
2015/07/28 19:11:17
DCHECK(!pixmap_) in dtor
dshwang
2015/07/29 13:23:09
Done.
| |
| 14 | |
| 15 bool GLImageOzoneNativePixmap::Initialize( | |
| 16 scoped_refptr<ui::NativePixmap> pixmap, | |
| 17 GpuMemoryBuffer::Format format) { | |
| 18 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.
| |
| 19 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.
| |
| 20 if (pixmap_->GetEGLClientBuffer()) { | |
| 21 EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; | |
| 22 return GLImageEGL::Initialize(EGL_NATIVE_PIXMAP_KHR, | |
| 23 pixmap_->GetEGLClientBuffer(), attrs); | |
| 24 } | |
| 25 | |
| 26 if (pixmap_->GetDmaBufFd() >= 0) { | |
| 27 base::FileDescriptor handle(pixmap_->GetDmaBufFd(), false); | |
| 28 return GLImageLinuxDMABuffer::Initialize(handle, format, | |
| 29 pixmap_->GetDmaBufPitch()); | |
| 30 } | |
| 31 | |
| 32 return true; | |
| 33 } | |
| 34 | |
| 35 void GLImageOzoneNativePixmap::Destroy(bool have_context) { | |
| 36 GLImageEGL::Destroy(have_context); | |
| 37 pixmap_ = nullptr; | |
| 38 } | |
| 39 | |
| 40 bool GLImageOzoneNativePixmap::ScheduleOverlayPlane(AcceleratedWidget widget, | |
| 41 int z_order, | |
| 42 OverlayTransform transform, | |
| 43 const Rect& bounds_rect, | |
| 44 const RectF& crop_rect) { | |
| 45 return pixmap_ && | |
|
reveman
2015/07/28 19:11:17
can we DCHECK(pixmap_) instead?
dshwang
2015/07/29 13:23:09
Yes, Done.
| |
| 46 pixmap_->ScheduleOverlayPlane(widget, z_order, transform, bounds_rect, | |
| 47 crop_rect); | |
| 48 } | |
| 49 | |
| 50 } // namespace gfx | |
| OLD | NEW |