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

Side by Side Diff: cc/test/test_shared_bitmap_manager.cc

Issue 609663003: cc: Remove use of PassAs() and constructor-casting with scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cc-passas: PassAs-presubmit-warning Created 6 years, 2 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
« no previous file with comments | « cc/test/render_pass_test_utils.cc ('k') | cc/test/test_web_graphics_context_3d.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/test/test_shared_bitmap_manager.h" 5 #include "cc/test/test_shared_bitmap_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 8
9 namespace cc { 9 namespace cc {
10 10
11 void FreeSharedBitmap(SharedBitmap* shared_bitmap) { 11 void FreeSharedBitmap(SharedBitmap* shared_bitmap) {
12 delete shared_bitmap->memory(); 12 delete shared_bitmap->memory();
13 } 13 }
14 14
15 void IgnoreSharedBitmap(SharedBitmap* shared_bitmap) {} 15 void IgnoreSharedBitmap(SharedBitmap* shared_bitmap) {}
16 16
17 TestSharedBitmapManager::TestSharedBitmapManager() {} 17 TestSharedBitmapManager::TestSharedBitmapManager() {}
18 18
19 TestSharedBitmapManager::~TestSharedBitmapManager() {} 19 TestSharedBitmapManager::~TestSharedBitmapManager() {}
20 20
21 scoped_ptr<SharedBitmap> TestSharedBitmapManager::AllocateSharedBitmap( 21 scoped_ptr<SharedBitmap> TestSharedBitmapManager::AllocateSharedBitmap(
22 const gfx::Size& size) { 22 const gfx::Size& size) {
23 base::AutoLock lock(lock_); 23 base::AutoLock lock(lock_);
24 scoped_ptr<base::SharedMemory> memory(new base::SharedMemory); 24 scoped_ptr<base::SharedMemory> memory(new base::SharedMemory);
25 memory->CreateAndMapAnonymous(size.GetArea() * 4); 25 memory->CreateAndMapAnonymous(size.GetArea() * 4);
26 SharedBitmapId id = SharedBitmap::GenerateId(); 26 SharedBitmapId id = SharedBitmap::GenerateId();
27 bitmap_map_[id] = memory.get(); 27 bitmap_map_[id] = memory.get();
28 return scoped_ptr<SharedBitmap>( 28 return make_scoped_ptr(
29 new SharedBitmap(memory.release(), id, base::Bind(&FreeSharedBitmap))); 29 new SharedBitmap(memory.release(), id, base::Bind(&FreeSharedBitmap)));
30 } 30 }
31 31
32 scoped_ptr<SharedBitmap> TestSharedBitmapManager::GetSharedBitmapFromId( 32 scoped_ptr<SharedBitmap> TestSharedBitmapManager::GetSharedBitmapFromId(
33 const gfx::Size&, 33 const gfx::Size&,
34 const SharedBitmapId& id) { 34 const SharedBitmapId& id) {
35 base::AutoLock lock(lock_); 35 base::AutoLock lock(lock_);
36 if (bitmap_map_.find(id) == bitmap_map_.end()) 36 if (bitmap_map_.find(id) == bitmap_map_.end())
37 return scoped_ptr<SharedBitmap>(); 37 return nullptr;
38 return scoped_ptr<SharedBitmap>( 38 return make_scoped_ptr(
39 new SharedBitmap(bitmap_map_[id], id, base::Bind(&IgnoreSharedBitmap))); 39 new SharedBitmap(bitmap_map_[id], id, base::Bind(&IgnoreSharedBitmap)));
40 } 40 }
41 41
42 scoped_ptr<SharedBitmap> TestSharedBitmapManager::GetBitmapForSharedMemory( 42 scoped_ptr<SharedBitmap> TestSharedBitmapManager::GetBitmapForSharedMemory(
43 base::SharedMemory* memory) { 43 base::SharedMemory* memory) {
44 base::AutoLock lock(lock_); 44 base::AutoLock lock(lock_);
45 SharedBitmapId id = SharedBitmap::GenerateId(); 45 SharedBitmapId id = SharedBitmap::GenerateId();
46 bitmap_map_[id] = memory; 46 bitmap_map_[id] = memory;
47 return scoped_ptr<SharedBitmap>( 47 return make_scoped_ptr(
48 new SharedBitmap(memory, id, base::Bind(&IgnoreSharedBitmap))); 48 new SharedBitmap(memory, id, base::Bind(&IgnoreSharedBitmap)));
49 } 49 }
50 50
51 } // namespace cc 51 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/render_pass_test_utils.cc ('k') | cc/test/test_web_graphics_context_3d.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698