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

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

Issue 806653006: Update GPU memory buffers to use StrideInBytes internally. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nit Created 5 years, 11 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/client/gpu_memory_buffer_impl.cc
diff --git a/content/common/gpu/client/gpu_memory_buffer_impl.cc b/content/common/gpu/client/gpu_memory_buffer_impl.cc
index d3c08bdb1a09b0d1256c297148cd190d2fae5690..4b05bbff2aa1c4ce67da55713b3d020a4a9d8f0a 100644
--- a/content/common/gpu/client/gpu_memory_buffer_impl.cc
+++ b/content/common/gpu/client/gpu_memory_buffer_impl.cc
@@ -5,6 +5,7 @@
#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
#include "base/logging.h"
+#include "base/numerics/safe_math.h"
#include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
#include "ui/gl/gl_bindings.h"
@@ -76,16 +77,24 @@ GpuMemoryBufferImpl* GpuMemoryBufferImpl::FromClientBuffer(
}
// static
-size_t GpuMemoryBufferImpl::BytesPerPixel(Format format) {
+bool GpuMemoryBufferImpl::StrideInBytes(size_t width,
+ Format format,
+ size_t* stride_in_bytes) {
+ base::CheckedNumeric<size_t> s = width;
switch (format) {
case RGBA_8888:
case RGBX_8888:
case BGRA_8888:
- return 4;
+ s *= 4;
+ if (!s.IsValid())
+ return false;
+
+ *stride_in_bytes = s.ValueOrDie();
+ return true;
}
NOTREACHED();
- return 0;
+ return false;
}
gfx::GpuMemoryBuffer::Format GpuMemoryBufferImpl::GetFormat() const {
« no previous file with comments | « content/common/gpu/client/gpu_memory_buffer_impl.h ('k') | content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698