| 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 {
|
|
|