summaryrefslogtreecommitdiffstats
path: root/cc/resources
diff options
context:
space:
mode:
authorjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-30 07:02:27 +0000
committerjbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-30 07:02:27 +0000
commit34d6734d673656488fc07b0c015866707af696d9 (patch)
treea59062afcc93e61ccda37b9aa55cf4f2a2db2707 /cc/resources
parent1980f18478ce919b8ee445841470f40b092f6a2f (diff)
downloadchromium_src-34d6734d673656488fc07b0c015866707af696d9.zip
chromium_src-34d6734d673656488fc07b0c015866707af696d9.tar.gz
chromium_src-34d6734d673656488fc07b0c015866707af696d9.tar.bz2
Allow creating SharedBitmaps backed by new[]
Bitmaps allocated in the browser process may have to be shared between compositors (for surfaces) but not between processes, so they should be backed by new[] and use the SharedBitmap mechanism. BUG= Review URL: https://codereview.chromium.org/307973004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273743 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/resources')
-rw-r--r--cc/resources/shared_bitmap.cc13
-rw-r--r--cc/resources/shared_bitmap.h7
2 files changed, 18 insertions, 2 deletions
diff --git a/cc/resources/shared_bitmap.cc b/cc/resources/shared_bitmap.cc
index 6d2ff0a..31cf245 100644
--- a/cc/resources/shared_bitmap.cc
+++ b/cc/resources/shared_bitmap.cc
@@ -14,7 +14,18 @@ SharedBitmap::SharedBitmap(
base::SharedMemory* memory,
const SharedBitmapId& id,
const base::Callback<void(SharedBitmap* bitmap)>& free_callback)
- : memory_(memory), id_(id), free_callback_(free_callback) {}
+ : memory_(memory),
+ pixels_(static_cast<uint8*>(memory_->memory())),
+ id_(id),
+ free_callback_(free_callback) {
+}
+
+SharedBitmap::SharedBitmap(
+ uint8* pixels,
+ const SharedBitmapId& id,
+ const base::Callback<void(SharedBitmap* bitmap)>& free_callback)
+ : memory_(NULL), pixels_(pixels), id_(id), free_callback_(free_callback) {
+}
SharedBitmap::~SharedBitmap() { free_callback_.Run(this); }
diff --git a/cc/resources/shared_bitmap.h b/cc/resources/shared_bitmap.h
index 762547d..a90e47a 100644
--- a/cc/resources/shared_bitmap.h
+++ b/cc/resources/shared_bitmap.h
@@ -23,6 +23,10 @@ class CC_EXPORT SharedBitmap {
const SharedBitmapId& id,
const base::Callback<void(SharedBitmap* bitmap)>& free_callback);
+ SharedBitmap(uint8* pixels,
+ const SharedBitmapId& id,
+ const base::Callback<void(SharedBitmap* bitmap)>& free_callback);
+
~SharedBitmap();
bool operator<(const SharedBitmap& right) const {
@@ -33,7 +37,7 @@ class CC_EXPORT SharedBitmap {
return id_ < right.id_;
}
- uint8* pixels() { return static_cast<uint8*>(memory_->memory()); }
+ uint8* pixels() { return pixels_; }
base::SharedMemory* memory() { return memory_; }
@@ -54,6 +58,7 @@ class CC_EXPORT SharedBitmap {
private:
base::SharedMemory* memory_;
+ uint8* pixels_;
SharedBitmapId id_;
base::Callback<void(SharedBitmap* bitmap)> free_callback_;