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

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

Issue 1062853002: Add gfx::GpuMemoryBuffer::YUV_420 and GpuMemoryBufferImplSharedMemory support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 790fcab9f8ae4bfcda1daba8d4b1638a446cdb03..992decd875d5e06e2637e8a17f9c8ae995d1a8ae 100644
--- a/content/common/gpu/gpu_memory_buffer_factory_shared_memory.cc
+++ b/content/common/gpu/gpu_memory_buffer_factory_shared_memory.cc
@@ -7,7 +7,7 @@
#include <vector>
#include "base/logging.h"
-#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
+#include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
#include "ui/gl/gl_image.h"
#include "ui/gl/gl_image_shared_memory.h"
@@ -24,7 +24,8 @@ void GpuMemoryBufferFactorySharedMemory::
std::vector<Configuration>* configurations) {
const Configuration supported_configurations[] = {
{ gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::MAP },
- { gfx::GpuMemoryBuffer::BGRA_8888, gfx::GpuMemoryBuffer::MAP }
+ { gfx::GpuMemoryBuffer::BGRA_8888, gfx::GpuMemoryBuffer::MAP },
+ { gfx::GpuMemoryBuffer::YUV_420, gfx::GpuMemoryBuffer::MAP }
};
configurations->assign(
supported_configurations,
@@ -39,19 +40,13 @@ GpuMemoryBufferFactorySharedMemory::CreateGpuMemoryBuffer(
gfx::GpuMemoryBuffer::Usage usage,
int client_id,
gfx::PluginWindowHandle surface_handle) {
- base::SharedMemory shared_memory;
-
- size_t stride_in_bytes = 0;
- if (!GpuMemoryBufferImpl::StrideInBytes(
- size.width(), format, &stride_in_bytes))
+ size_t buffer_size = 0u;
+ if (!GpuMemoryBufferImplSharedMemory::BufferSizeInBytes(size, format,
+ &buffer_size))
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()))
+ base::SharedMemory shared_memory;
+ if (!shared_memory.CreateAnonymous(buffer_size))
return gfx::GpuMemoryBufferHandle();
gfx::GpuMemoryBufferHandle handle;

Powered by Google App Engine
This is Rietveld 408576698