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

Unified Diff: content/common/gpu/gpu_memory_buffer_factory_shared_memory.cc

Issue 806653006: Update GPU memory buffers to use StrideInBytes internally. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nit Created 5 years, 11 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/gpu_memory_buffer_factory_shared_memory.cc
diff --git a/content/common/gpu/gpu_memory_buffer_factory_shared_memory.cc b/content/common/gpu/gpu_memory_buffer_factory_shared_memory.cc
index 9a4bdcf538cab2132266fe8de6202c1f1e7be133..b10fd00dfbc98f756bbb68ba087dd49dc8d1f0fa 100644
--- a/content/common/gpu/gpu_memory_buffer_factory_shared_memory.cc
+++ b/content/common/gpu/gpu_memory_buffer_factory_shared_memory.cc
@@ -38,8 +38,18 @@ GpuMemoryBufferFactorySharedMemory::CreateGpuMemoryBuffer(
int client_id,
gfx::PluginWindowHandle surface_handle) {
base::SharedMemory shared_memory;
- if (!shared_memory.CreateAnonymous(
- size.GetArea() * GpuMemoryBufferImpl::BytesPerPixel(format)))
+
+ size_t stride_in_bytes = 0;
+ if (!GpuMemoryBufferImpl::StrideInBytes(
+ size.width(), format, &stride_in_bytes))
+ return gfx::GpuMemoryBufferHandle();
+
+ base::CheckedNumeric<size_t> size_in_bytes = stride_in_bytes;
+ size_in_bytes *= size.height();
+ if (!size_in_bytes.IsValid())
+ return gfx::GpuMemoryBufferHandle();
+
+ if (!shared_memory.CreateAnonymous(size_in_bytes.ValueOrDie()))
return gfx::GpuMemoryBufferHandle();
gfx::GpuMemoryBufferHandle handle;
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl_unittest.cc ('k') | gpu/command_buffer/tests/gl_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698