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

Side by Side Diff: content/common/gpu/client/gpu_memory_buffer_impl_unittest.cc

Issue 1280513002: Add GenericSharedMemoryId and use w/ GpuMemoryBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@trackpools
Patch Set: remove "tracing" from name Created 5 years, 4 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
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 "content/common/gpu/client/gpu_memory_buffer_impl.h" 5 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/common/gpu/gpu_memory_buffer_factory.h" 8 #include "content/common/gpu/gpu_memory_buffer_factory.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/gfx/buffer_format_util.h" 10 #include "ui/gfx/buffer_format_util.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 std::vector<GpuMemoryBufferFactory::Configuration> supported_configurations_; 45 std::vector<GpuMemoryBufferFactory::Configuration> supported_configurations_;
46 int buffer_count_; 46 int buffer_count_;
47 47
48 private: 48 private:
49 scoped_ptr<GpuMemoryBufferFactory> factory_; 49 scoped_ptr<GpuMemoryBufferFactory> factory_;
50 }; 50 };
51 51
52 TEST_P(GpuMemoryBufferImplTest, CreateFromHandle) { 52 TEST_P(GpuMemoryBufferImplTest, CreateFromHandle) {
53 const int kBufferId = 1; 53 const gfx::GpuMemoryBufferId kBufferId(1);
54 54
55 gfx::Size buffer_size(8, 8); 55 gfx::Size buffer_size(8, 8);
56 56
57 for (auto configuration : supported_configurations_) { 57 for (auto configuration : supported_configurations_) {
58 scoped_ptr<GpuMemoryBufferImpl> buffer( 58 scoped_ptr<GpuMemoryBufferImpl> buffer(
59 GpuMemoryBufferImpl::CreateFromHandle( 59 GpuMemoryBufferImpl::CreateFromHandle(
60 CreateGpuMemoryBuffer(kBufferId, buffer_size, configuration.format, 60 CreateGpuMemoryBuffer(kBufferId, buffer_size, configuration.format,
61 configuration.usage), 61 configuration.usage),
62 buffer_size, configuration.format, configuration.usage, 62 buffer_size, configuration.format, configuration.usage,
63 base::Bind(&GpuMemoryBufferImplTest::DestroyGpuMemoryBuffer, 63 base::Bind(&GpuMemoryBufferImplTest::DestroyGpuMemoryBuffer,
64 base::Unretained(this), kBufferId))); 64 base::Unretained(this), kBufferId)));
65 EXPECT_EQ(1, buffer_count_); 65 EXPECT_EQ(1, buffer_count_);
66 ASSERT_TRUE(buffer); 66 ASSERT_TRUE(buffer);
67 EXPECT_EQ(buffer->GetFormat(), configuration.format); 67 EXPECT_EQ(buffer->GetFormat(), configuration.format);
68 68
69 // Check if destruction callback is executed when deleting the buffer. 69 // Check if destruction callback is executed when deleting the buffer.
70 buffer.reset(); 70 buffer.reset();
71 EXPECT_EQ(0, buffer_count_); 71 EXPECT_EQ(0, buffer_count_);
72 } 72 }
73 } 73 }
74 74
75 TEST_P(GpuMemoryBufferImplTest, Map) { 75 TEST_P(GpuMemoryBufferImplTest, Map) {
76 const int kBufferId = 1; 76 const gfx::GpuMemoryBufferId kBufferId(1);
77 77
78 // Use a multiple of 4 for both dimensions to support compressed formats. 78 // Use a multiple of 4 for both dimensions to support compressed formats.
79 gfx::Size buffer_size(4, 4); 79 gfx::Size buffer_size(4, 4);
80 80
81 for (auto configuration : supported_configurations_) { 81 for (auto configuration : supported_configurations_) {
82 if (configuration.usage != gfx::BufferUsage::MAP) 82 if (configuration.usage != gfx::BufferUsage::MAP)
83 continue; 83 continue;
84 84
85 scoped_ptr<GpuMemoryBufferImpl> buffer( 85 scoped_ptr<GpuMemoryBufferImpl> buffer(
86 GpuMemoryBufferImpl::CreateFromHandle( 86 GpuMemoryBufferImpl::CreateFromHandle(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 0); 128 0);
129 } 129 }
130 } 130 }
131 131
132 buffer->Unmap(); 132 buffer->Unmap();
133 EXPECT_FALSE(buffer->IsMapped()); 133 EXPECT_FALSE(buffer->IsMapped());
134 } 134 }
135 } 135 }
136 136
137 TEST_P(GpuMemoryBufferImplTest, PersistentMap) { 137 TEST_P(GpuMemoryBufferImplTest, PersistentMap) {
138 const int kBufferId = 1; 138 const gfx::GpuMemoryBufferId kBufferId(1);
139 139
140 // Use a multiple of 4 for both dimensions to support compressed formats. 140 // Use a multiple of 4 for both dimensions to support compressed formats.
141 gfx::Size buffer_size(4, 4); 141 gfx::Size buffer_size(4, 4);
142 142
143 for (auto configuration : supported_configurations_) { 143 for (auto configuration : supported_configurations_) {
144 if (configuration.usage != gfx::BufferUsage::PERSISTENT_MAP) 144 if (configuration.usage != gfx::BufferUsage::PERSISTENT_MAP)
145 continue; 145 continue;
146 146
147 scoped_ptr<GpuMemoryBufferImpl> buffer( 147 scoped_ptr<GpuMemoryBufferImpl> buffer(
148 GpuMemoryBufferImpl::CreateFromHandle( 148 GpuMemoryBufferImpl::CreateFromHandle(
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 return supported_types; 231 return supported_types;
232 } 232 }
233 233
234 INSTANTIATE_TEST_CASE_P( 234 INSTANTIATE_TEST_CASE_P(
235 GpuMemoryBufferImplTests, 235 GpuMemoryBufferImplTests,
236 GpuMemoryBufferImplTest, 236 GpuMemoryBufferImplTest,
237 ::testing::ValuesIn(GetSupportedGpuMemoryBufferTypes())); 237 ::testing::ValuesIn(GetSupportedGpuMemoryBufferTypes()));
238 238
239 } // namespace 239 } // namespace
240 } // namespace content 240 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698