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

Unified Diff: cc/resources/shared_bitmap.cc

Issue 148243013: Add shared bitmap managers for browser and renderer processes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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: cc/resources/shared_bitmap.cc
diff --git a/cc/resources/shared_bitmap.cc b/cc/resources/shared_bitmap.cc
index 3a6fc3589e3a8471b9a4d10e75278c76bfbe0a41..3caab4050d13d26e630c52af16cdf86013a9e516 100644
--- a/cc/resources/shared_bitmap.cc
+++ b/cc/resources/shared_bitmap.cc
@@ -4,6 +4,8 @@
#include "cc/resources/shared_bitmap.h"
+#include "base/rand_util.h"
+
namespace cc {
SharedBitmap::SharedBitmap(
@@ -14,4 +16,28 @@ SharedBitmap::SharedBitmap(
SharedBitmap::~SharedBitmap() { free_callback_.Run(this); }
+// static
+bool SharedBitmap::GetSizeInBytes(const gfx::Size& size,
+ size_t* size_in_bytes) {
+ static const size_t kMaxSize = static_cast<size_t>(INT_MAX);
+ const size_t stride = 4 * size.width();
+ if (size.width() <= 0 || size.height() <= 0 ||
+ static_cast<size_t>(size.width()) > (kMaxSize / 4) ||
+ static_cast<size_t>(size.height()) > (kMaxSize / stride)) {
+ return false;
+ }
+
+ *size_in_bytes = size.GetArea() * 4;
jschuh 2014/03/08 00:58:11 I think the base::CheckedNumeric template would ma
+
+ return true;
+}
+
+// static
+SharedBitmapId SharedBitmap::GenerateId() {
+ SharedBitmapId id;
+ // Needs cryptographically-secure random numbers.
+ base::RandBytes(id.name, sizeof(id.name));
+ return id;
+}
+
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698