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

Unified Diff: content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc

Issue 1412223009: Reland: GpuMemoryBuffer interface change: Map(**) to Map() and memory(plane); stride(plane) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Win X64 compile fix Created 5 years, 2 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: content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc
diff --git a/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc b/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc
index 02437ffec15a3b53d48e1b95f237aa907ded084e..f12abf6cd9beab121ce28690d4252147cafedef0 100644
--- a/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc
+++ b/content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc
@@ -190,29 +190,27 @@ base::Closure GpuMemoryBufferImplSharedMemory::AllocateForTesting(
return base::Bind(&Noop);
}
-bool GpuMemoryBufferImplSharedMemory::Map(void** data) {
+bool GpuMemoryBufferImplSharedMemory::Map() {
DCHECK(!mapped_);
- size_t offset = 0;
- size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format_);
- for (size_t i = 0; i < num_planes; ++i) {
- data[i] = reinterpret_cast<uint8*>(shared_memory_->memory()) + offset;
- size_t row_size = gfx::RowSizeForBufferFormat(size_.width(), format_, i);
- size_t factor = gfx::SubsamplingFactorForBufferFormat(format_, i);
- offset += row_size * (size_.height() / factor);
- }
mapped_ = true;
return true;
}
+void* GpuMemoryBufferImplSharedMemory::memory(size_t plane) {
+ DCHECK(mapped_);
+ DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
+ return reinterpret_cast<uint8_t*>(shared_memory_->memory()) +
+ gfx::BufferOffsetForBufferFormat(size_, format_, plane);
+}
+
void GpuMemoryBufferImplSharedMemory::Unmap() {
DCHECK(mapped_);
mapped_ = false;
}
-void GpuMemoryBufferImplSharedMemory::GetStride(int* stride) const {
- size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format_);
- for (size_t i = 0; i < num_planes; ++i)
- stride[i] = gfx::RowSizeForBufferFormat(size_.width(), format_, i);
+int GpuMemoryBufferImplSharedMemory::stride(size_t plane) const {
+ DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
+ return gfx::RowSizeForBufferFormat(size_.width(), format_, plane);
}
gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSharedMemory::GetHandle() const {

Powered by Google App Engine
This is Rietveld 408576698