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

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

Issue 1533773002: Delete CC. (Closed) Base URL: git@github.com:domokit/mojo.git@cl-2e
Patch Set: rebase Created 5 years 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/test_shared_bitmap_manager.h ('k') | cc/test/test_task_graph_runner.h » ('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 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/memory/shared_memory.h"
8
9 namespace cc {
10
11 namespace {
12 class OwnedSharedBitmap : public SharedBitmap {
13 public:
14 OwnedSharedBitmap(scoped_ptr<base::SharedMemory> shared_memory,
15 const SharedBitmapId& id)
16 : SharedBitmap(static_cast<uint8*>(shared_memory->memory()), id),
17 shared_memory_(shared_memory.Pass()) {}
18
19 ~OwnedSharedBitmap() override {}
20
21 private:
22 scoped_ptr<base::SharedMemory> shared_memory_;
23 };
24
25 } // namespace
26
27 TestSharedBitmapManager::TestSharedBitmapManager() {}
28
29 TestSharedBitmapManager::~TestSharedBitmapManager() {}
30
31 scoped_ptr<SharedBitmap> TestSharedBitmapManager::AllocateSharedBitmap(
32 const gfx::Size& size) {
33 base::AutoLock lock(lock_);
34 scoped_ptr<base::SharedMemory> memory(new base::SharedMemory);
35 memory->CreateAndMapAnonymous(size.GetArea() * 4);
36 SharedBitmapId id = SharedBitmap::GenerateId();
37 bitmap_map_[id] = memory.get();
38 return make_scoped_ptr(new OwnedSharedBitmap(memory.Pass(), id));
39 }
40
41 scoped_ptr<SharedBitmap> TestSharedBitmapManager::GetSharedBitmapFromId(
42 const gfx::Size&,
43 const SharedBitmapId& id) {
44 base::AutoLock lock(lock_);
45 if (bitmap_map_.find(id) == bitmap_map_.end())
46 return nullptr;
47 uint8* pixels = static_cast<uint8*>(bitmap_map_[id]->memory());
48 return make_scoped_ptr(new SharedBitmap(pixels, id));
49 }
50
51 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_shared_bitmap_manager.h ('k') | cc/test/test_task_graph_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698