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

Unified Diff: content/common/gpu/client/gpu_memory_buffer_impl_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: Created 6 years 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 5572c1fa2a92ab8422d61ebe7d65efef2b0818ae..0c217e8ea01202fe89615e11196fbd1f97a0d803 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,7 +35,7 @@ scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImplSharedMemory::Create(
const gfx::Size& size,
Format format) {
scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory());
- if (!shared_memory->CreateAnonymous(size.GetArea() * BytesPerPixel(format)))
+ if (!shared_memory->CreateAnonymous(PixelsToBytes(size.GetArea(), format)))
return scoped_ptr<GpuMemoryBufferImpl>();
return make_scoped_ptr(new GpuMemoryBufferImplSharedMemory(
@@ -50,8 +50,7 @@ GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
Format format,
base::ProcessHandle child_process) {
base::CheckedNumeric<int> buffer_size = size.width();
- buffer_size *= size.height();
- buffer_size *= BytesPerPixel(format);
+ buffer_size *= PixelsToBytes(size.height(), format);
if (!buffer_size.IsValid())
return gfx::GpuMemoryBufferHandle();
@@ -101,7 +100,7 @@ bool GpuMemoryBufferImplSharedMemory::IsFormatSupported(Format format) {
void* GpuMemoryBufferImplSharedMemory::Map() {
DCHECK(!mapped_);
- if (!shared_memory_->Map(size_.GetArea() * BytesPerPixel(format_)))
+ if (!shared_memory_->Map(PixelsToBytes(size_.GetArea(), format_)))
return NULL;
mapped_ = true;
return shared_memory_->memory();
@@ -114,7 +113,7 @@ void GpuMemoryBufferImplSharedMemory::Unmap() {
}
uint32 GpuMemoryBufferImplSharedMemory::GetStride() const {
- return size_.width() * BytesPerPixel(format_);
+ return PixelsToBytes(size_.width(), format_);
}
gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSharedMemory::GetHandle() const {

Powered by Google App Engine
This is Rietveld 408576698