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_EQ(pixmap_->GetBufferUsage(), NativePixmap::SCANOUT); | |
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 } // namespace | 127 } // namespace |
127 | 128 |
128 GpuMemoryBufferFactoryOzoneNativeBuffer:: | 129 GpuMemoryBufferFactoryOzoneNativeBuffer:: |
129 GpuMemoryBufferFactoryOzoneNativeBuffer() { | 130 GpuMemoryBufferFactoryOzoneNativeBuffer() { |
130 } | 131 } |
131 | 132 |
132 GpuMemoryBufferFactoryOzoneNativeBuffer:: | 133 GpuMemoryBufferFactoryOzoneNativeBuffer:: |
133 ~GpuMemoryBufferFactoryOzoneNativeBuffer() { | 134 ~GpuMemoryBufferFactoryOzoneNativeBuffer() { |
134 } | 135 } |
135 | 136 |
136 bool GpuMemoryBufferFactoryOzoneNativeBuffer::CreateGpuMemoryBuffer( | 137 gfx::GpuMemoryBufferHandle |
138 GpuMemoryBufferFactoryOzoneNativeBuffer::CreateGpuMemoryBuffer( | |
137 gfx::GpuMemoryBufferId id, | 139 gfx::GpuMemoryBufferId id, |
138 const gfx::Size& size, | 140 const gfx::Size& size, |
139 gfx::GpuMemoryBuffer::Format format, | 141 gfx::GpuMemoryBuffer::Format format, |
140 gfx::GpuMemoryBuffer::Usage usage, | 142 gfx::GpuMemoryBuffer::Usage usage, |
141 int client_id, | 143 int client_id, |
142 gfx::PluginWindowHandle surface_handle) { | 144 gfx::PluginWindowHandle surface_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)); |
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 gfx::GpuMemoryBufferHandle(); |
151 } | 153 } |
154 | |
155 gfx::GpuMemoryBufferHandle handle = | |
156 SurfaceFactoryOzone::GetInstance()->ExportGpuMemoryBufferHandle( | |
vignatti (out of this project)
2015/05/14 19:20:04
Am I wrong or the concept here is the opposite? GP
dshwang
2015/06/25 10:59:56
GPU process create gbm bo and *exporting* the dma_
| |
157 surface_handle, pixmap); | |
158 if (handle.type == gfx::EMPTY_BUFFER) | |
159 return gfx::GpuMemoryBufferHandle(); | |
160 handle.id = id; | |
161 | |
152 base::AutoLock lock(native_pixmap_map_lock_); | 162 base::AutoLock lock(native_pixmap_map_lock_); |
153 native_pixmap_map_[GetIndex(id, client_id)] = pixmap; | 163 native_pixmap_map_[GetIndex(id, client_id)] = pixmap; |
154 return true; | 164 return handle; |
155 } | 165 } |
156 | 166 |
157 void GpuMemoryBufferFactoryOzoneNativeBuffer::DestroyGpuMemoryBuffer( | 167 void GpuMemoryBufferFactoryOzoneNativeBuffer::DestroyGpuMemoryBuffer( |
158 gfx::GpuMemoryBufferId id, | 168 gfx::GpuMemoryBufferId id, |
159 int client_id) { | 169 int client_id) { |
160 base::AutoLock lock(native_pixmap_map_lock_); | 170 base::AutoLock lock(native_pixmap_map_lock_); |
161 native_pixmap_map_.erase(GetIndex(id, client_id)); | 171 native_pixmap_map_.erase(GetIndex(id, client_id)); |
162 } | 172 } |
163 | 173 |
164 scoped_refptr<gfx::GLImage> | 174 scoped_refptr<gfx::GLImage> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 new GLImageOzoneNativePixmapDmaBuf(size, internalformat); | 210 new GLImageOzoneNativePixmapDmaBuf(size, internalformat); |
201 if (!image->Initialize(pixmap.get(), format)) { | 211 if (!image->Initialize(pixmap.get(), format)) { |
202 return scoped_refptr<gfx::GLImage>(); | 212 return scoped_refptr<gfx::GLImage>(); |
203 } | 213 } |
204 return image; | 214 return image; |
205 } | 215 } |
206 return scoped_refptr<gfx::GLImage>(); | 216 return scoped_refptr<gfx::GLImage>(); |
207 } | 217 } |
208 | 218 |
209 } // namespace ui | 219 } // namespace ui |
OLD | NEW |