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

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

Issue 701033005: content: Move type selection logic out of GpuMemoryBufferImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove blank line and add missing CONTENT_EXPORT Created 6 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
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 9a2ae220c3a56a2470743c6149722b52ec586a03..9adca18627d322ef838f6d7847f948b54dd11839 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
@@ -34,7 +34,7 @@ void GpuMemoryBufferImplSharedMemory::Create(gfx::GpuMemoryBufferId id,
const gfx::Size& size,
Format format,
const CreationCallback& callback) {
- DCHECK(IsLayoutSupported(size, format));
+ DCHECK(IsFormatSupported(format));
scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory());
if (!shared_memory->CreateAnonymous(size.GetArea() * BytesPerPixel(format))) {
@@ -54,10 +54,17 @@ void GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
Format format,
base::ProcessHandle child_process,
const AllocationCallback& callback) {
- DCHECK(IsLayoutSupported(size, format));
+ DCHECK(IsFormatSupported(format));
+ base::CheckedNumeric<int> buffer_size = size.width();
+ buffer_size *= size.height();
+ buffer_size *= BytesPerPixel(format);
+ if (!buffer_size.IsValid()) {
+ callback.Run(gfx::GpuMemoryBufferHandle());
+ return;
+ }
base::SharedMemory shared_memory;
- if (!shared_memory.CreateAnonymous(size.GetArea() * BytesPerPixel(format))) {
+ if (!shared_memory.CreateAnonymous(buffer_size.ValueOrDie())) {
callback.Run(gfx::GpuMemoryBufferHandle());
return;
}
@@ -75,7 +82,7 @@ GpuMemoryBufferImplSharedMemory::CreateFromHandle(
const gfx::Size& size,
Format format,
const DestructionCallback& callback) {
- DCHECK(IsLayoutSupported(size, format));
+ DCHECK(IsFormatSupported(format));
if (!base::SharedMemory::IsHandleValid(handle.handle))
return scoped_ptr<GpuMemoryBufferImpl>();
@@ -116,26 +123,6 @@ bool GpuMemoryBufferImplSharedMemory::IsUsageSupported(Usage usage) {
return false;
}
-// static
-bool GpuMemoryBufferImplSharedMemory::IsLayoutSupported(const gfx::Size& size,
- Format format) {
- if (!IsFormatSupported(format))
- return false;
-
- base::CheckedNumeric<int> buffer_size = size.width();
- buffer_size *= size.height();
- buffer_size *= BytesPerPixel(format);
- return buffer_size.IsValid();
-}
-
-// static
-bool GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
- const gfx::Size& size,
- Format format,
- Usage usage) {
- return IsLayoutSupported(size, format) && IsUsageSupported(usage);
-}
-
void* GpuMemoryBufferImplSharedMemory::Map() {
DCHECK(!mapped_);
if (!shared_memory_->Map(size_.GetArea() * BytesPerPixel(format_)))

Powered by Google App Engine
This is Rietveld 408576698