Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc

Issue 1134993003: ozone: Implement zero/one-copy texture for Ozone GBM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: not-leak USE_OZONE_GBM, GetSupportedGpuMemoryBufferConfigurations from ozone, return handle Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698