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

Unified Diff: ui/gl/gl_image_shared_memory.cc

Issue 1431333002: Revert of Re-land: ui: Add custom stride support to GLImageMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « ui/gl/gl_image_shared_memory.h ('k') | ui/gl/gl_image_shared_memory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 21c72c11b2b5007fdc208a2ccc48f7f223376086..6ea5553229e825b7c509afc9fd33aa08e27bfc50 100644
--- a/ui/gl/gl_image_shared_memory.cc
+++ b/ui/gl/gl_image_shared_memory.cc
@@ -28,14 +28,9 @@
const base::SharedMemoryHandle& handle,
gfx::GenericSharedMemoryId shared_memory_id,
gfx::BufferFormat format,
- size_t offset,
- size_t stride) {
- if (NumberOfPlanesForBufferFormat(format) != 1)
- return false;
-
- base::CheckedNumeric<size_t> checked_size = stride;
- checked_size *= GetSize().height();
- if (!checked_size.IsValid())
+ size_t offset) {
+ size_t size_in_bytes;
+ if (!BufferSizeForBufferFormatChecked(GetSize(), format, &size_in_bytes))
return false;
if (!base::SharedMemory::IsHandleValid(handle))
@@ -57,21 +52,22 @@
size_t map_offset = base::SysInfo::VMAllocationGranularity() *
(offset / base::SysInfo::VMAllocationGranularity());
- checked_size += memory_offset;
- if (!checked_size.IsValid())
+ base::CheckedNumeric<size_t> checked_size_to_map_in_bytes = size_in_bytes;
+ checked_size_to_map_in_bytes += memory_offset;
+ if (!checked_size_to_map_in_bytes.IsValid())
return false;
scoped_ptr<base::SharedMemory> duped_shared_memory(
new base::SharedMemory(duped_shared_memory_handle, true));
if (!duped_shared_memory->MapAt(static_cast<off_t>(map_offset),
- checked_size.ValueOrDie())) {
+ checked_size_to_map_in_bytes.ValueOrDie())) {
DVLOG(0) << "Failed to map shared memory.";
return false;
}
if (!GLImageMemory::Initialize(
static_cast<uint8_t*>(duped_shared_memory->memory()) + memory_offset,
- format, stride)) {
+ format)) {
return false;
}
@@ -93,7 +89,7 @@
size_t size_in_bytes = 0;
if (shared_memory_)
- size_in_bytes = stride() * GetSize().height();
+ size_in_bytes = BufferSizeForBufferFormat(GetSize(), format());
// Dump under "/shared_memory", as the base class may also dump to
// "/texture_memory".
« no previous file with comments | « ui/gl/gl_image_shared_memory.h ('k') | ui/gl/gl_image_shared_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698