| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 | 7 |
| 8 #include "components/viz/display_compositor/host_shared_bitmap_manager.h" | 8 #include "components/viz/display_compositor/host_shared_bitmap_manager.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 client.ChildAllocatedSharedBitmap(size_in_bytes, bitmap2->handle(), id); | 126 client.ChildAllocatedSharedBitmap(size_in_bytes, bitmap2->handle(), id); |
| 127 | 127 |
| 128 std::unique_ptr<cc::SharedBitmap> shared_bitmap; | 128 std::unique_ptr<cc::SharedBitmap> shared_bitmap; |
| 129 shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id); | 129 shared_bitmap = manager_->GetSharedBitmapFromId(bitmap_size, id); |
| 130 ASSERT_TRUE(shared_bitmap.get() != NULL); | 130 ASSERT_TRUE(shared_bitmap.get() != NULL); |
| 131 EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes), | 131 EXPECT_EQ(memcmp(shared_bitmap->pixels(), bitmap->memory(), size_in_bytes), |
| 132 0); | 132 0); |
| 133 client.DidDeleteSharedBitmap(id); | 133 client.DidDeleteSharedBitmap(id); |
| 134 } | 134 } |
| 135 | 135 |
| 136 TEST_F(HostSharedBitmapManagerTest, SharedMemoryHandle) { |
| 137 gfx::Size bitmap_size(1, 1); |
| 138 size_t size_in_bytes; |
| 139 EXPECT_TRUE(cc::SharedBitmap::SizeInBytes(bitmap_size, &size_in_bytes)); |
| 140 std::unique_ptr<base::SharedMemory> bitmap(new base::SharedMemory()); |
| 141 auto shared_memory_guid = bitmap->handle().GetGUID(); |
| 142 bitmap->CreateAndMapAnonymous(size_in_bytes); |
| 143 memset(bitmap->memory(), 0xff, size_in_bytes); |
| 144 cc::SharedBitmapId id = cc::SharedBitmap::GenerateId(); |
| 145 |
| 146 HostSharedBitmapManagerClient client(manager_.get()); |
| 147 base::SharedMemoryHandle handle = bitmap->handle().Duplicate(); |
| 148 client.ChildAllocatedSharedBitmap(size_in_bytes, handle, id); |
| 149 |
| 150 std::unique_ptr<cc::SharedBitmap> shared_bitmap; |
| 151 shared_bitmap = manager_->GetSharedBitmapFromId(gfx::Size(1, 1), id); |
| 152 EXPECT_EQ(shared_bitmap->GetSharedMemoryHandle().GetGUID(), |
| 153 shared_memory_guid); |
| 154 |
| 155 client.DidDeleteSharedBitmap(id); |
| 156 } |
| 157 |
| 136 } // namespace | 158 } // namespace |
| 137 } // namespace viz | 159 } // namespace viz |
| OLD | NEW |