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

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: Use StrideInBytes 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..78e5c710b8c1c8fcc0a52422c40098bddbacbddd 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,8 @@ 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(
+ StrideInBytes(size.width(), format) * size.height()))
return scoped_ptr<GpuMemoryBufferImpl>();
return make_scoped_ptr(new GpuMemoryBufferImplSharedMemory(
@@ -49,9 +50,8 @@ GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
const gfx::Size& size,
Format format,
base::ProcessHandle child_process) {
- base::CheckedNumeric<int> buffer_size = size.width();
+ base::CheckedNumeric<int> buffer_size = StrideInBytes(size.width(), format);
reveman 2014/12/18 18:49:56 Can a malicious renderer make this overflow? ie. w
christiank 2015/01/12 10:35:22 Should be fixed now that StrideInBytes uses Checke
buffer_size *= size.height();
- buffer_size *= BytesPerPixel(format);
if (!buffer_size.IsValid())
return gfx::GpuMemoryBufferHandle();
@@ -101,7 +101,8 @@ bool GpuMemoryBufferImplSharedMemory::IsFormatSupported(Format format) {
void* GpuMemoryBufferImplSharedMemory::Map() {
DCHECK(!mapped_);
- if (!shared_memory_->Map(size_.GetArea() * BytesPerPixel(format_)))
+ if (!shared_memory_->Map(
+ StrideInBytes(size_.width(), format_) * size_.height()))
return NULL;
mapped_ = true;
return shared_memory_->memory();
@@ -114,7 +115,7 @@ void GpuMemoryBufferImplSharedMemory::Unmap() {
}
uint32 GpuMemoryBufferImplSharedMemory::GetStride() const {
- return size_.width() * BytesPerPixel(format_);
+ return StrideInBytes(size_.width(), format_);
}
gfx::GpuMemoryBufferHandle GpuMemoryBufferImplSharedMemory::GetHandle() const {

Powered by Google App Engine
This is Rietveld 408576698