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

Unified Diff: cc/test/test_shared_bitmap_manager.cc

Issue 202763002: Switch to use SharedBitmapManager all the time in cc_unittests (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/test/test_shared_bitmap_manager.h ('k') | cc/trees/damage_tracker_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/test/test_shared_bitmap_manager.cc
diff --git a/cc/test/test_shared_bitmap_manager.cc b/cc/test/test_shared_bitmap_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..29aa028adcbe58202881d8935c15feecde5bf2fd
--- /dev/null
+++ b/cc/test/test_shared_bitmap_manager.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/test/test_shared_bitmap_manager.h"
+
+#include "base/bind.h"
+
+namespace cc {
+
+void FreeSharedBitmap(SharedBitmap* shared_bitmap) {
+ delete shared_bitmap->memory();
+}
+
+void IgnoreSharedBitmap(SharedBitmap* shared_bitmap) {}
+
+TestSharedBitmapManager::TestSharedBitmapManager() {}
+
+TestSharedBitmapManager::~TestSharedBitmapManager() {}
+
+scoped_ptr<SharedBitmap> TestSharedBitmapManager::AllocateSharedBitmap(
+ const gfx::Size& size) {
+ base::AutoLock lock(lock_);
+ scoped_ptr<base::SharedMemory> memory(new base::SharedMemory);
+ memory->CreateAndMapAnonymous(size.GetArea() * 4);
+ SharedBitmapId id = SharedBitmap::GenerateId();
+ bitmap_map_[id] = memory.get();
+ return scoped_ptr<SharedBitmap>(
+ new SharedBitmap(memory.release(), id, base::Bind(&FreeSharedBitmap)));
+}
+
+scoped_ptr<SharedBitmap> TestSharedBitmapManager::GetSharedBitmapFromId(
+ const gfx::Size&,
+ const SharedBitmapId& id) {
+ base::AutoLock lock(lock_);
+ if (bitmap_map_.find(id) == bitmap_map_.end())
+ return scoped_ptr<SharedBitmap>();
+ return scoped_ptr<SharedBitmap>(
+ new SharedBitmap(bitmap_map_[id], id, base::Bind(&IgnoreSharedBitmap)));
+}
+
+scoped_ptr<SharedBitmap> TestSharedBitmapManager::GetBitmapForSharedMemory(
+ base::SharedMemory* memory) {
+ base::AutoLock lock(lock_);
+ SharedBitmapId id = SharedBitmap::GenerateId();
+ bitmap_map_[id] = memory;
+ return scoped_ptr<SharedBitmap>(
+ new SharedBitmap(memory, id, base::Bind(&IgnoreSharedBitmap)));
+}
+
+} // namespace cc
« no previous file with comments | « cc/test/test_shared_bitmap_manager.h ('k') | cc/trees/damage_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698