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

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

Issue 1403283007: Re-land: ui: Add custom stride support to GLImageMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more missing static_casts Created 5 years, 1 month 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 | « content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h ('k') | content/common/gpu/gpu_channel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9a36a3b7d611951a517a426383586848e6181be4..8b840739d4cdceda70bd77219ce241781ccbcf09 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
@@ -23,10 +23,12 @@ GpuMemoryBufferImplSharedMemory::GpuMemoryBufferImplSharedMemory(
gfx::BufferFormat format,
const DestructionCallback& callback,
scoped_ptr<base::SharedMemory> shared_memory,
- size_t offset)
+ size_t offset,
+ int stride)
: GpuMemoryBufferImpl(id, size, format, callback),
shared_memory_(shared_memory.Pass()),
- offset_(offset) {
+ offset_(offset),
+ stride_(stride) {
DCHECK(IsSizeValidForFormat(size, format));
}
@@ -48,7 +50,8 @@ GpuMemoryBufferImplSharedMemory::Create(gfx::GpuMemoryBufferId id,
return nullptr;
return make_scoped_ptr(new GpuMemoryBufferImplSharedMemory(
- id, size, format, callback, shared_memory.Pass(), 0));
+ id, size, format, callback, shared_memory.Pass(), 0,
+ gfx::RowSizeForBufferFormat(size.width(), format, 0)));
}
// static
@@ -70,6 +73,8 @@ GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
handle.type = gfx::SHARED_MEMORY_BUFFER;
handle.id = id;
handle.offset = 0;
+ handle.stride = static_cast<int32_t>(
+ gfx::RowSizeForBufferFormat(size.width(), format, 0));
shared_memory.GiveToProcess(child_process, &handle.handle);
return handle;
}
@@ -88,7 +93,7 @@ GpuMemoryBufferImplSharedMemory::CreateFromHandle(
return make_scoped_ptr(new GpuMemoryBufferImplSharedMemory(
handle.id, size, format, callback,
make_scoped_ptr(new base::SharedMemory(handle.handle, false)),
- handle.offset));
+ handle.offset, handle.stride));
}
// static
@@ -162,6 +167,8 @@ base::Closure GpuMemoryBufferImplSharedMemory::AllocateForTesting(
DCHECK(rv);
handle->type = gfx::SHARED_MEMORY_BUFFER;
handle->offset = 0;
+ handle->stride = static_cast<int32_t>(
+ gfx::RowSizeForBufferFormat(size.width(), format, 0));
handle->handle = base::SharedMemory::DuplicateHandle(shared_memory.handle());
return base::Bind(&Noop);
}
@@ -172,6 +179,8 @@ bool GpuMemoryBufferImplSharedMemory::Map() {
// Map the buffer first time Map() is called then keep it mapped for the
// lifetime of the buffer. This avoids mapping the buffer unless necessary.
if (!shared_memory_->memory()) {
+ DCHECK_EQ(static_cast<size_t>(stride_),
+ gfx::RowSizeForBufferFormat(size_.width(), format_, 0));
size_t buffer_size = gfx::BufferSizeForBufferFormat(size_, format_);
// Note: offset_ != 0 is not common use-case. To keep it simple we
// map offset + buffer_size here but this can be avoided using MapAt().
@@ -205,6 +214,7 @@ gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSharedMemory::GetHandle() const {
handle.type = gfx::SHARED_MEMORY_BUFFER;
handle.id = id_;
handle.offset = offset_;
+ handle.stride = stride_;
handle.handle = shared_memory_->handle();
return handle;
}
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h ('k') | content/common/gpu/gpu_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698