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

Unified Diff: ui/gl/gl_image_shared_memory.cc

Issue 1415723006: ui: Add RGBX_8888 buffer format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix gles but no conversion needed case Created 5 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
« no previous file with comments | « ui/gl/gl_image_ref_counted_memory_unittest.cc ('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 6ca7905e2388458fb2cfe2805c09042c65ae3719..4fd61d5372952cd2602a2d4092941264dfa51561 100644
--- a/ui/gl/gl_image_shared_memory.cc
+++ b/ui/gl/gl_image_shared_memory.cc
@@ -11,27 +11,9 @@
#include "base/trace_event/memory_allocator_dump.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/process_memory_dump.h"
+#include "ui/gfx/buffer_format_util.h"
namespace gfx {
-namespace {
-
-// Returns true if the size is valid and false otherwise.
-bool SizeInBytes(const Size& size, BufferFormat format, size_t* size_in_bytes) {
- if (size.IsEmpty())
- return false;
-
- size_t stride_in_bytes = 0;
- if (!GLImageMemory::StrideInBytes(size.width(), format, &stride_in_bytes))
- return false;
- base::CheckedNumeric<size_t> s = stride_in_bytes;
- s *= size.height();
- if (!s.IsValid())
- return false;
- *size_in_bytes = s.ValueOrDie();
- return true;
-}
-
-} // namespace
GLImageSharedMemory::GLImageSharedMemory(const Size& size,
unsigned internalformat)
@@ -45,7 +27,7 @@ bool GLImageSharedMemory::Initialize(const base::SharedMemoryHandle& handle,
GenericSharedMemoryId shared_memory_id,
BufferFormat format) {
size_t size_in_bytes;
- if (!SizeInBytes(GetSize(), format, &size_in_bytes))
+ if (!BufferSizeForBufferFormatChecked(GetSize(), format, &size_in_bytes))
return false;
if (!base::SharedMemory::IsHandleValid(handle))
@@ -90,10 +72,8 @@ void GLImageSharedMemory::OnMemoryDump(
const std::string& dump_name) {
size_t size_in_bytes = 0;
- if (shared_memory_) {
- bool result = SizeInBytes(GetSize(), format(), &size_in_bytes);
- DCHECK(result);
- }
+ if (shared_memory_)
+ 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_ref_counted_memory_unittest.cc ('k') | ui/gl/gl_image_shared_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698