Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.h" | 5 #include "ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/gl/gl_image_egl.h" | 8 #include "ui/gl/gl_image_egl.h" |
| 9 #include "ui/gl/gl_image_linux_dma_buffer.h" | 9 #include "ui/gl/gl_image_linux_dma_buffer.h" |
| 10 #include "ui/ozone/public/native_pixmap.h" | 10 #include "ui/ozone/public/native_pixmap.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 return false; | 65 return false; |
| 66 pixmap_ = pixmap; | 66 pixmap_ = pixmap; |
| 67 return true; | 67 return true; |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 70 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
| 71 int z_order, | 71 int z_order, |
| 72 gfx::OverlayTransform transform, | 72 gfx::OverlayTransform transform, |
| 73 const gfx::Rect& bounds_rect, | 73 const gfx::Rect& bounds_rect, |
| 74 const gfx::RectF& crop_rect) override { | 74 const gfx::RectF& crop_rect) override { |
| 75 DCHECK(pixmap_->GetBufferUsage() == NativePixmap::SCANOUT); | |
|
reveman
2015/05/11 16:40:57
nit: use DCHECK_EQ
dshwang
2015/05/14 12:25:47
Done.
| |
| 75 return SurfaceFactoryOzone::GetInstance()->ScheduleOverlayPlane( | 76 return SurfaceFactoryOzone::GetInstance()->ScheduleOverlayPlane( |
| 76 widget, z_order, transform, pixmap_, bounds_rect, crop_rect); | 77 widget, z_order, transform, pixmap_, bounds_rect, crop_rect); |
| 77 } | 78 } |
| 78 | 79 |
| 79 protected: | 80 protected: |
| 80 ~GLImageOzoneNativePixmapDmaBuf() override {} | 81 ~GLImageOzoneNativePixmapDmaBuf() override {} |
| 81 | 82 |
| 82 private: | 83 private: |
| 83 scoped_refptr<NativePixmap> pixmap_; | 84 scoped_refptr<NativePixmap> pixmap_; |
| 84 }; | 85 }; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 GpuMemoryBufferFactoryOzoneNativeBuffer:: | 133 GpuMemoryBufferFactoryOzoneNativeBuffer:: |
| 133 ~GpuMemoryBufferFactoryOzoneNativeBuffer() { | 134 ~GpuMemoryBufferFactoryOzoneNativeBuffer() { |
| 134 } | 135 } |
| 135 | 136 |
| 136 bool GpuMemoryBufferFactoryOzoneNativeBuffer::CreateGpuMemoryBuffer( | 137 bool GpuMemoryBufferFactoryOzoneNativeBuffer::CreateGpuMemoryBuffer( |
| 137 gfx::GpuMemoryBufferId id, | 138 gfx::GpuMemoryBufferId id, |
| 138 const gfx::Size& size, | 139 const gfx::Size& size, |
| 139 gfx::GpuMemoryBuffer::Format format, | 140 gfx::GpuMemoryBuffer::Format format, |
| 140 gfx::GpuMemoryBuffer::Usage usage, | 141 gfx::GpuMemoryBuffer::Usage usage, |
| 141 int client_id, | 142 int client_id, |
| 142 gfx::PluginWindowHandle surface_handle) { | 143 gfx::PluginWindowHandle surface_handle, |
| 144 gfx::GpuMemoryBufferHandle* new_handle) { | |
| 143 scoped_refptr<NativePixmap> pixmap = | 145 scoped_refptr<NativePixmap> pixmap = |
| 144 SurfaceFactoryOzone::GetInstance()->CreateNativePixmap( | 146 SurfaceFactoryOzone::GetInstance()->CreateNativePixmap( |
| 145 surface_handle, size, GetOzoneFormatFor(format), | 147 surface_handle, size, GetOzoneFormatFor(format), |
| 146 GetOzoneUsageFor(usage)); | 148 GetOzoneUsageFor(usage), new_handle); |
| 147 if (!pixmap.get()) { | 149 if (!pixmap.get()) { |
| 148 LOG(ERROR) << "Failed to create pixmap " << size.width() << "x" | 150 LOG(ERROR) << "Failed to create pixmap " << size.width() << "x" |
| 149 << size.height() << " format " << format << ", usage " << usage; | 151 << size.height() << " format " << format << ", usage " << usage; |
| 150 return false; | 152 return false; |
| 151 } | 153 } |
| 152 base::AutoLock lock(native_pixmap_map_lock_); | 154 base::AutoLock lock(native_pixmap_map_lock_); |
| 153 native_pixmap_map_[GetIndex(id, client_id)] = pixmap; | 155 native_pixmap_map_[GetIndex(id, client_id)] = pixmap; |
| 154 return true; | 156 return true; |
| 155 } | 157 } |
| 156 | 158 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 new GLImageOzoneNativePixmapDmaBuf(size, internalformat); | 202 new GLImageOzoneNativePixmapDmaBuf(size, internalformat); |
| 201 if (!image->Initialize(pixmap.get(), format)) { | 203 if (!image->Initialize(pixmap.get(), format)) { |
| 202 return scoped_refptr<gfx::GLImage>(); | 204 return scoped_refptr<gfx::GLImage>(); |
| 203 } | 205 } |
| 204 return image; | 206 return image; |
| 205 } | 207 } |
| 206 return scoped_refptr<gfx::GLImage>(); | 208 return scoped_refptr<gfx::GLImage>(); |
| 207 } | 209 } |
| 208 | 210 |
| 209 } // namespace ui | 211 } // namespace ui |
| OLD | NEW |