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 b2bd575507f1be38f581ea09cd56120352e887fe..5572c1fa2a92ab8422d61ebe7d65efef2b0818ae 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 |
@@ -35,17 +35,7 @@ |
const gfx::Size& size, |
Format format) { |
scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory()); |
- |
- size_t stride_in_bytes = 0; |
- if (!StrideInBytes(size.width(), format, &stride_in_bytes)) |
- return scoped_ptr<GpuMemoryBufferImpl>(); |
- |
- base::CheckedNumeric<size_t> size_in_bytes = stride_in_bytes; |
- size_in_bytes *= size.height(); |
- if (!size_in_bytes.IsValid()) |
- return scoped_ptr<GpuMemoryBufferImpl>(); |
- |
- if (!shared_memory->CreateAnonymous(size_in_bytes.ValueOrDie())) |
+ if (!shared_memory->CreateAnonymous(size.GetArea() * BytesPerPixel(format))) |
return scoped_ptr<GpuMemoryBufferImpl>(); |
return make_scoped_ptr(new GpuMemoryBufferImplSharedMemory( |
@@ -59,12 +49,9 @@ |
const gfx::Size& size, |
Format format, |
base::ProcessHandle child_process) { |
- size_t stride_in_bytes = 0; |
- if (!StrideInBytes(size.width(), format, &stride_in_bytes)) |
- return gfx::GpuMemoryBufferHandle(); |
- |
- base::CheckedNumeric<int> buffer_size = stride_in_bytes; |
+ base::CheckedNumeric<int> buffer_size = size.width(); |
buffer_size *= size.height(); |
+ buffer_size *= BytesPerPixel(format); |
if (!buffer_size.IsValid()) |
return gfx::GpuMemoryBufferHandle(); |
@@ -114,17 +101,7 @@ |
void* GpuMemoryBufferImplSharedMemory::Map() { |
DCHECK(!mapped_); |
- |
- size_t stride_in_bytes = 0; |
- if (!StrideInBytes(size_.width(), format_, &stride_in_bytes)) |
- return NULL; |
- |
- base::CheckedNumeric<size_t> size_in_bytes = stride_in_bytes; |
- size_in_bytes *= size_.height(); |
- if (!size_in_bytes.IsValid()) |
- return NULL; |
- |
- if (!shared_memory_->Map(size_in_bytes.ValueOrDie())) |
+ if (!shared_memory_->Map(size_.GetArea() * BytesPerPixel(format_))) |
return NULL; |
mapped_ = true; |
return shared_memory_->memory(); |
@@ -137,9 +114,7 @@ |
} |
uint32 GpuMemoryBufferImplSharedMemory::GetStride() const { |
- size_t stride_in_bytes = 0; |
- DCHECK(StrideInBytes(size_.width(), format_, &stride_in_bytes)); |
- return stride_in_bytes; |
+ return size_.width() * BytesPerPixel(format_); |
} |
gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSharedMemory::GetHandle() const { |