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

Unified Diff: components/mus/gles2/mojo_gpu_memory_buffer.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
« no previous file with comments | « components/mus/gles2/mojo_gpu_memory_buffer.h ('k') | content/browser/compositor/buffer_queue_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/gles2/mojo_gpu_memory_buffer.cc
diff --git a/components/mus/gles2/mojo_gpu_memory_buffer.cc b/components/mus/gles2/mojo_gpu_memory_buffer.cc
index b3538a14819f7e3f58bf983309c4b3e3a358e49a..a5e0a6c7a28539e9349e58afbc2963dc0cae6220 100644
--- a/components/mus/gles2/mojo_gpu_memory_buffer.cc
+++ b/components/mus/gles2/mojo_gpu_memory_buffer.cc
@@ -43,23 +43,21 @@ const unsigned char* MojoGpuMemoryBufferImpl::GetMemory() const {
return static_cast<const unsigned char*>(shared_memory_->memory());
}
-bool MojoGpuMemoryBufferImpl::Map(void** data) {
+bool MojoGpuMemoryBufferImpl::Map() {
DCHECK(!mapped_);
if (!shared_memory_->Map(gfx::BufferSizeForBufferFormat(size_, format_)))
return false;
mapped_ = true;
- size_t offset = 0;
- int num_planes =
- static_cast<int>(gfx::NumberOfPlanesForBufferFormat(format_));
- for (int i = 0; i < num_planes; ++i) {
- data[i] = reinterpret_cast<uint8*>(shared_memory_->memory()) + offset;
- offset +=
- gfx::RowSizeForBufferFormat(size_.width(), format_, i) *
- (size_.height() / gfx::SubsamplingFactorForBufferFormat(format_, i));
- }
return true;
}
+void* MojoGpuMemoryBufferImpl::memory(size_t plane) {
+ DCHECK(mapped_);
+ DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
+ return reinterpret_cast<uint8*>(shared_memory_->memory()) +
+ gfx::BufferOffsetForBufferFormat(size_, format_, plane);
+}
+
void MojoGpuMemoryBufferImpl::Unmap() {
DCHECK(mapped_);
shared_memory_->Unmap();
@@ -74,12 +72,10 @@ gfx::BufferFormat MojoGpuMemoryBufferImpl::GetFormat() const {
return format_;
}
-void MojoGpuMemoryBufferImpl::GetStride(int* stride) const {
- int num_planes =
- static_cast<int>(gfx::NumberOfPlanesForBufferFormat(format_));
- for (int i = 0; i < num_planes; ++i)
- stride[i] = base::checked_cast<int>(
- gfx::RowSizeForBufferFormat(size_.width(), format_, i));
+int MojoGpuMemoryBufferImpl::stride(size_t plane) const {
+ DCHECK_LT(plane, gfx::NumberOfPlanesForBufferFormat(format_));
+ return base::checked_cast<int>(gfx::RowSizeForBufferFormat(
+ size_.width(), format_, static_cast<int>(plane)));
}
gfx::GpuMemoryBufferId MojoGpuMemoryBufferImpl::GetId() const {
« no previous file with comments | « components/mus/gles2/mojo_gpu_memory_buffer.h ('k') | content/browser/compositor/buffer_queue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698