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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/test/test_shared_bitmap_manager.h"
6
7 #include "base/bind.h"
8
9 namespace cc {
10
11 void FreeSharedBitmap(SharedBitmap* shared_bitmap) {
12 delete shared_bitmap->memory();
13 }
14
15 void IgnoreSharedBitmap(SharedBitmap* shared_bitmap) {}
16
17 TestSharedBitmapManager::TestSharedBitmapManager() {}
18
19 TestSharedBitmapManager::~TestSharedBitmapManager() {}
20
21 scoped_ptr<SharedBitmap> TestSharedBitmapManager::AllocateSharedBitmap(
22 const gfx::Size& size) {
23 base::AutoLock lock(lock_);
24 scoped_ptr<base::SharedMemory> memory(new base::SharedMemory);
25 memory->CreateAndMapAnonymous(size.GetArea() * 4);
26 SharedBitmapId id = SharedBitmap::GenerateId();
27 bitmap_map_[id] = memory.get();
28 return scoped_ptr<SharedBitmap>(
29 new SharedBitmap(memory.release(), id, base::Bind(&FreeSharedBitmap)));
30 }
31
32 scoped_ptr<SharedBitmap> TestSharedBitmapManager::GetSharedBitmapFromId(
33 const gfx::Size&,
34 const SharedBitmapId& id) {
35 base::AutoLock lock(lock_);
36 if (bitmap_map_.find(id) == bitmap_map_.end())
37 return scoped_ptr<SharedBitmap>();
38 return scoped_ptr<SharedBitmap>(
39 new SharedBitmap(bitmap_map_[id], id, base::Bind(&IgnoreSharedBitmap)));
40 }
41
42 scoped_ptr<SharedBitmap> TestSharedBitmapManager::GetBitmapForSharedMemory(
43 base::SharedMemory* memory) {
44 base::AutoLock lock(lock_);
45 SharedBitmapId id = SharedBitmap::GenerateId();
46 bitmap_map_[id] = memory;
47 return scoped_ptr<SharedBitmap>(
48 new SharedBitmap(memory, id, base::Bind(&IgnoreSharedBitmap)));
49 }
50
51 } // namespace cc
OLDNEW
« 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