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

Side by Side Diff: gpu/ipc/client/gpu_memory_buffer_impl_test_template.h

Issue 2526683002: gpu: Rename AllocateGpuMemoryBuffer to CreateGpuMemoryBuffer. (Closed)
Patch Set: . Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // This file defines tests that implementations of GpuMemoryBufferFactory should 5 // This file defines tests that implementations of GpuMemoryBufferFactory should
6 // pass in order to be conformant. 6 // pass in order to be conformant.
7 7
8 #ifndef GPU_IPC_CLIENT_GPU_MEMORY_BUFFER_IMPL_TEST_TEMPLATE_H_ 8 #ifndef GPU_IPC_CLIENT_GPU_MEMORY_BUFFER_IMPL_TEST_TEMPLATE_H_
9 #define GPU_IPC_CLIENT_GPU_MEMORY_BUFFER_IMPL_TEST_TEMPLATE_H_ 9 #define GPU_IPC_CLIENT_GPU_MEMORY_BUFFER_IMPL_TEST_TEMPLATE_H_
10 10
11 #include <stddef.h> 11 #include <stddef.h>
12 #include <string.h> 12 #include <string.h>
13 13
14 #include <memory> 14 #include <memory>
15 15
16 #include "base/bind.h" 16 #include "base/bind.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "ui/gfx/buffer_format_util.h" 18 #include "ui/gfx/buffer_format_util.h"
19 19
20 namespace gpu { 20 namespace gpu {
21 21
22 template <typename GpuMemoryBufferImplType> 22 template <typename GpuMemoryBufferImplType>
23 class GpuMemoryBufferImplTest : public testing::Test { 23 class GpuMemoryBufferImplTest : public testing::Test {
24 public: 24 public:
25 GpuMemoryBufferImpl::DestructionCallback AllocateGpuMemoryBuffer( 25 GpuMemoryBufferImpl::DestructionCallback CreateGpuMemoryBuffer(
26 const gfx::Size& size, 26 const gfx::Size& size,
27 gfx::BufferFormat format, 27 gfx::BufferFormat format,
28 gfx::BufferUsage usage, 28 gfx::BufferUsage usage,
29 gfx::GpuMemoryBufferHandle* handle, 29 gfx::GpuMemoryBufferHandle* handle,
30 bool* destroyed) { 30 bool* destroyed) {
31 return base::Bind(&GpuMemoryBufferImplTest::FreeGpuMemoryBuffer, 31 return base::Bind(&GpuMemoryBufferImplTest::FreeGpuMemoryBuffer,
32 base::Unretained(this), 32 base::Unretained(this),
33 GpuMemoryBufferImplType::AllocateForTesting( 33 GpuMemoryBufferImplType::AllocateForTesting(
34 size, format, usage, handle), 34 size, format, usage, handle),
35 base::Unretained(destroyed)); 35 base::Unretained(destroyed));
(...skipping 19 matching lines...) Expand all
55 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::SCANOUT, 55 gfx::BufferUsage::GPU_READ, gfx::BufferUsage::SCANOUT,
56 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, 56 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE,
57 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT}; 57 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT};
58 for (auto usage : usages) { 58 for (auto usage : usages) {
59 if (!TypeParam::IsConfigurationSupported(format, usage)) 59 if (!TypeParam::IsConfigurationSupported(format, usage))
60 continue; 60 continue;
61 61
62 bool destroyed = false; 62 bool destroyed = false;
63 gfx::GpuMemoryBufferHandle handle; 63 gfx::GpuMemoryBufferHandle handle;
64 GpuMemoryBufferImpl::DestructionCallback destroy_callback = 64 GpuMemoryBufferImpl::DestructionCallback destroy_callback =
65 TestFixture::AllocateGpuMemoryBuffer(kBufferSize, format, usage, 65 TestFixture::CreateGpuMemoryBuffer(kBufferSize, format, usage,
66 &handle, &destroyed); 66 &handle, &destroyed);
67 std::unique_ptr<TypeParam> buffer(TypeParam::CreateFromHandle( 67 std::unique_ptr<TypeParam> buffer(TypeParam::CreateFromHandle(
68 handle, kBufferSize, format, usage, destroy_callback)); 68 handle, kBufferSize, format, usage, destroy_callback));
69 ASSERT_TRUE(buffer); 69 ASSERT_TRUE(buffer);
70 EXPECT_EQ(buffer->GetFormat(), format); 70 EXPECT_EQ(buffer->GetFormat(), format);
71 71
72 // Check if destruction callback is executed when deleting the buffer. 72 // Check if destruction callback is executed when deleting the buffer.
73 buffer.reset(); 73 buffer.reset();
74 ASSERT_TRUE(destroyed); 74 ASSERT_TRUE(destroyed);
75 } 75 }
76 } 76 }
77 } 77 }
78 78
79 TYPED_TEST_P(GpuMemoryBufferImplTest, Map) { 79 TYPED_TEST_P(GpuMemoryBufferImplTest, Map) {
80 // Use a multiple of 4 for both dimensions to support compressed formats. 80 // Use a multiple of 4 for both dimensions to support compressed formats.
81 const gfx::Size kBufferSize(4, 4); 81 const gfx::Size kBufferSize(4, 4);
82 82
83 for (auto format : gfx::GetBufferFormatsForTesting()) { 83 for (auto format : gfx::GetBufferFormatsForTesting()) {
84 if (!TypeParam::IsConfigurationSupported( 84 if (!TypeParam::IsConfigurationSupported(
85 format, gfx::BufferUsage::GPU_READ_CPU_READ_WRITE)) { 85 format, gfx::BufferUsage::GPU_READ_CPU_READ_WRITE)) {
86 continue; 86 continue;
87 } 87 }
88 88
89 gfx::GpuMemoryBufferHandle handle; 89 gfx::GpuMemoryBufferHandle handle;
90 GpuMemoryBufferImpl::DestructionCallback destroy_callback = 90 GpuMemoryBufferImpl::DestructionCallback destroy_callback =
91 TestFixture::AllocateGpuMemoryBuffer( 91 TestFixture::CreateGpuMemoryBuffer(
92 kBufferSize, format, gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, 92 kBufferSize, format, gfx::BufferUsage::GPU_READ_CPU_READ_WRITE,
93 &handle, nullptr); 93 &handle, nullptr);
94 std::unique_ptr<TypeParam> buffer(TypeParam::CreateFromHandle( 94 std::unique_ptr<TypeParam> buffer(TypeParam::CreateFromHandle(
95 handle, kBufferSize, format, gfx::BufferUsage::GPU_READ_CPU_READ_WRITE, 95 handle, kBufferSize, format, gfx::BufferUsage::GPU_READ_CPU_READ_WRITE,
96 destroy_callback)); 96 destroy_callback));
97 ASSERT_TRUE(buffer); 97 ASSERT_TRUE(buffer);
98 98
99 const size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format); 99 const size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format);
100 100
101 // Map buffer into user space. 101 // Map buffer into user space.
(...skipping 29 matching lines...) Expand all
131 const gfx::Size kBufferSize(4, 4); 131 const gfx::Size kBufferSize(4, 4);
132 132
133 for (auto format : gfx::GetBufferFormatsForTesting()) { 133 for (auto format : gfx::GetBufferFormatsForTesting()) {
134 if (!TypeParam::IsConfigurationSupported( 134 if (!TypeParam::IsConfigurationSupported(
135 format, gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT)) { 135 format, gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT)) {
136 continue; 136 continue;
137 } 137 }
138 138
139 gfx::GpuMemoryBufferHandle handle; 139 gfx::GpuMemoryBufferHandle handle;
140 GpuMemoryBufferImpl::DestructionCallback destroy_callback = 140 GpuMemoryBufferImpl::DestructionCallback destroy_callback =
141 TestFixture::AllocateGpuMemoryBuffer( 141 TestFixture::CreateGpuMemoryBuffer(
142 kBufferSize, format, 142 kBufferSize, format,
143 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT, &handle, 143 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT, &handle,
144 nullptr); 144 nullptr);
145 std::unique_ptr<TypeParam> buffer(TypeParam::CreateFromHandle( 145 std::unique_ptr<TypeParam> buffer(TypeParam::CreateFromHandle(
146 handle, kBufferSize, format, 146 handle, kBufferSize, format,
147 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT, 147 gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT,
148 destroy_callback)); 148 destroy_callback));
149 ASSERT_TRUE(buffer); 149 ASSERT_TRUE(buffer);
150 150
151 // Map buffer into user space. 151 // Map buffer into user space.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // The GpuMemoryBufferImplTest test case verifies behavior that is expected 201 // The GpuMemoryBufferImplTest test case verifies behavior that is expected
202 // from a GpuMemoryBuffer implementation in order to be conformant. 202 // from a GpuMemoryBuffer implementation in order to be conformant.
203 REGISTER_TYPED_TEST_CASE_P(GpuMemoryBufferImplTest, 203 REGISTER_TYPED_TEST_CASE_P(GpuMemoryBufferImplTest,
204 CreateFromHandle, 204 CreateFromHandle,
205 Map, 205 Map,
206 PersistentMap); 206 PersistentMap);
207 207
208 } // namespace gpu 208 } // namespace gpu
209 209
210 #endif // GPU_IPC_CLIENT_GPU_MEMORY_BUFFER_IMPL_TEST_TEMPLATE_H_ 210 #endif // GPU_IPC_CLIENT_GPU_MEMORY_BUFFER_IMPL_TEST_TEMPLATE_H_
OLDNEW
« no previous file with comments | « gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.cc ('k') | gpu/ipc/common/gpu_surface_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698