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

Unified Diff: ui/gl/gl_image_shared_memory.cc

Issue 634083002: gpu: Compositor management of GpuMemoryBuffer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cc-pre-chromium-image-refactor
Patch Set: mac build fix Created 6 years, 2 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: ui/gl/gl_image_shared_memory.cc
diff --git a/ui/gl/gl_image_shared_memory.cc b/ui/gl/gl_image_shared_memory.cc
index 7c615f8efabc9f191267995c96b1a55092799d04..4aa255b03df7edb15b46936eba3af6bf5df3da3a 100644
--- a/ui/gl/gl_image_shared_memory.cc
+++ b/ui/gl/gl_image_shared_memory.cc
@@ -18,10 +18,8 @@ GLImageSharedMemory::~GLImageSharedMemory() {
DCHECK(!shared_memory_);
}
-bool GLImageSharedMemory::Initialize(const gfx::GpuMemoryBufferHandle& handle) {
- if (!HasValidFormat())
- return false;
-
+bool GLImageSharedMemory::Initialize(const gfx::GpuMemoryBufferHandle& handle,
+ gfx::GpuMemoryBuffer::Format format) {
if (!base::SharedMemory::IsHandleValid(handle.handle))
return false;
@@ -37,16 +35,18 @@ bool GLImageSharedMemory::Initialize(const gfx::GpuMemoryBufferHandle& handle) {
scoped_ptr<base::SharedMemory> duped_shared_memory(
new base::SharedMemory(duped_shared_memory_handle, true));
-
- if (!duped_shared_memory->Map(Bytes())) {
+ if (!duped_shared_memory->Map(GetSize().GetArea() * BytesPerPixel(format))) {
piman 2014/10/09 21:33:02 We should avoid GetSize().GetArea() * BytesPerPixe
reveman 2014/10/10 02:20:16 Done.
DVLOG(0) << "Failed to map shared memory.";
return false;
}
+ if (!GLImageMemory::Initialize(
+ static_cast<unsigned char*>(duped_shared_memory->memory()), format)) {
+ return false;
+ }
+
DCHECK(!shared_memory_);
shared_memory_ = duped_shared_memory.Pass();
- GLImageMemory::Initialize(
- static_cast<unsigned char*>(shared_memory_->memory()));
return true;
}

Powered by Google App Engine
This is Rietveld 408576698