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

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, 9 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 | « cc/resources/shared_bitmap.h ('k') | content/browser/compositor/image_transport_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « cc/resources/shared_bitmap.h ('k') | content/browser/compositor/image_transport_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698