| Index: cc/resources/shared_bitmap.cc
|
| diff --git a/cc/resources/shared_bitmap.cc b/cc/resources/shared_bitmap.cc
|
| index 3a6fc3589e3a8471b9a4d10e75278c76bfbe0a41..3b94d451dff1bcd9b25e8d83948e1f4f279e946d 100644
|
| --- a/cc/resources/shared_bitmap.cc
|
| +++ b/cc/resources/shared_bitmap.cc
|
| @@ -4,6 +4,9 @@
|
|
|
| #include "cc/resources/shared_bitmap.h"
|
|
|
| +#include "base/numerics/safe_math.h"
|
| +#include "base/rand_util.h"
|
| +
|
| namespace cc {
|
|
|
| SharedBitmap::SharedBitmap(
|
| @@ -14,4 +17,26 @@ SharedBitmap::SharedBitmap(
|
|
|
| SharedBitmap::~SharedBitmap() { free_callback_.Run(this); }
|
|
|
| +// static
|
| +bool SharedBitmap::GetSizeInBytes(const gfx::Size& size,
|
| + size_t* size_in_bytes) {
|
| + if (size.width() <= 0 || size.height() <= 0)
|
| + return false;
|
| + base::CheckedNumeric<int> s = size.width();
|
| + s *= size.height();
|
| + s *= 4;
|
| + if (!s.IsValid())
|
| + return false;
|
| + *size_in_bytes = s.ValueOrDie();
|
| + return true;
|
| +}
|
| +
|
| +// static
|
| +SharedBitmapId SharedBitmap::GenerateId() {
|
| + SharedBitmapId id;
|
| + // Needs cryptographically-secure random numbers.
|
| + base::RandBytes(id.name, sizeof(id.name));
|
| + return id;
|
| +}
|
| +
|
| } // namespace cc
|
|
|