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

Unified Diff: ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc

Issue 1050923003: zero-copy: Clarify to allocate/destroy GpuMemoryBuffer on any thread and use it on the main thread o (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc
diff --git a/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc b/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc
index 38667e51e180f2d306fc50ec87e8994da9d88e1f..b265c9176c9679f6176306c4898e57dd1b1065e5 100644
--- a/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc
+++ b/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc
@@ -138,6 +138,7 @@ bool GpuMemoryBufferFactoryOzoneNativeBuffer::CreateGpuMemoryBuffer(
gfx::GpuMemoryBuffer::Usage usage,
int client_id,
gfx::PluginWindowHandle surface_handle) {
+ DCHECK(thread_checker_.CalledOnValidThread());
scoped_refptr<NativePixmap> pixmap =
SurfaceFactoryOzone::GetInstance()->CreateNativePixmap(
surface_handle, size, GetOzoneFormatFor(format),
@@ -147,7 +148,6 @@ bool GpuMemoryBufferFactoryOzoneNativeBuffer::CreateGpuMemoryBuffer(
<< size.height() << " format " << format << ", usage " << usage;
return false;
}
- base::AutoLock lock(native_pixmap_map_lock_);
native_pixmap_map_[GetIndex(id, client_id)] = pixmap;
return true;
}
@@ -155,7 +155,7 @@ bool GpuMemoryBufferFactoryOzoneNativeBuffer::CreateGpuMemoryBuffer(
void GpuMemoryBufferFactoryOzoneNativeBuffer::DestroyGpuMemoryBuffer(
gfx::GpuMemoryBufferId id,
int client_id) {
- base::AutoLock lock(native_pixmap_map_lock_);
+ DCHECK(thread_checker_.CalledOnValidThread());
native_pixmap_map_.erase(GetIndex(id, client_id));
}
@@ -166,16 +166,13 @@ GpuMemoryBufferFactoryOzoneNativeBuffer::CreateImageForGpuMemoryBuffer(
gfx::GpuMemoryBuffer::Format format,
unsigned internalformat,
int client_id) {
- NativePixmap* pixmap = nullptr;
- {
- base::AutoLock lock(native_pixmap_map_lock_);
- BufferToPixmapMap::iterator it =
- native_pixmap_map_.find(GetIndex(id, client_id));
- if (it == native_pixmap_map_.end()) {
- return scoped_refptr<gfx::GLImage>();
- }
- pixmap = it->second.get();
+ DCHECK(thread_checker_.CalledOnValidThread());
+ BufferToPixmapMap::iterator it =
+ native_pixmap_map_.find(GetIndex(id, client_id));
+ if (it == native_pixmap_map_.end()) {
+ return scoped_refptr<gfx::GLImage>();
}
+ NativePixmap* pixmap = it->second.get();
return CreateImageForPixmap(pixmap, size, format, internalformat);
}

Powered by Google App Engine
This is Rietveld 408576698