| OLD | NEW |
| 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" | |
| 11 | 10 |
| 12 namespace content { | 11 namespace content { |
| 13 namespace { | 12 namespace { |
| 14 | 13 |
| 15 const int kClientId = 1; | 14 const int kClientId = 1; |
| 16 | 15 |
| 17 class GpuMemoryBufferImplTest | 16 class GpuMemoryBufferImplTest |
| 18 : public testing::TestWithParam<gfx::GpuMemoryBufferType> { | 17 : public testing::TestWithParam<gfx::GpuMemoryBufferType> { |
| 19 public: | 18 public: |
| 20 GpuMemoryBufferImplTest() : buffer_count_(0), factory_(nullptr) {} | 19 GpuMemoryBufferImplTest() : buffer_count_(0), factory_(nullptr) {} |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 GpuMemoryBufferImpl::CreateFromHandle( | 85 GpuMemoryBufferImpl::CreateFromHandle( |
| 87 CreateGpuMemoryBuffer(kBufferId, buffer_size, configuration.format, | 86 CreateGpuMemoryBuffer(kBufferId, buffer_size, configuration.format, |
| 88 configuration.usage), | 87 configuration.usage), |
| 89 buffer_size, configuration.format, configuration.usage, | 88 buffer_size, configuration.format, configuration.usage, |
| 90 base::Bind(&GpuMemoryBufferImplTest::DestroyGpuMemoryBuffer, | 89 base::Bind(&GpuMemoryBufferImplTest::DestroyGpuMemoryBuffer, |
| 91 base::Unretained(this), kBufferId))); | 90 base::Unretained(this), kBufferId))); |
| 92 ASSERT_TRUE(buffer); | 91 ASSERT_TRUE(buffer); |
| 93 EXPECT_FALSE(buffer->IsMapped()); | 92 EXPECT_FALSE(buffer->IsMapped()); |
| 94 | 93 |
| 95 size_t num_planes = | 94 size_t num_planes = |
| 96 gfx::NumberOfPlanesForBufferFormat(configuration.format); | 95 GpuMemoryBufferImpl::NumberOfPlanesForGpuMemoryBufferFormat( |
| 96 configuration.format); |
| 97 | 97 |
| 98 // Map buffer into user space. | 98 // Map buffer into user space. |
| 99 scoped_ptr<void*[]> mapped_buffers(new void*[num_planes]); | 99 scoped_ptr<void*[]> mapped_buffers(new void*[num_planes]); |
| 100 bool rv = buffer->Map(mapped_buffers.get()); | 100 bool rv = buffer->Map(mapped_buffers.get()); |
| 101 ASSERT_TRUE(rv); | 101 ASSERT_TRUE(rv); |
| 102 EXPECT_TRUE(buffer->IsMapped()); | 102 EXPECT_TRUE(buffer->IsMapped()); |
| 103 | 103 |
| 104 // Get strides. | 104 // Get strides. |
| 105 scoped_ptr<int[]> strides(new int[num_planes]); | 105 scoped_ptr<int[]> strides(new int[num_planes]); |
| 106 buffer->GetStride(strides.get()); | 106 buffer->GetStride(strides.get()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 GpuMemoryBufferImpl::CreateFromHandle( | 148 GpuMemoryBufferImpl::CreateFromHandle( |
| 149 CreateGpuMemoryBuffer(kBufferId, buffer_size, configuration.format, | 149 CreateGpuMemoryBuffer(kBufferId, buffer_size, configuration.format, |
| 150 configuration.usage), | 150 configuration.usage), |
| 151 buffer_size, configuration.format, configuration.usage, | 151 buffer_size, configuration.format, configuration.usage, |
| 152 base::Bind(&GpuMemoryBufferImplTest::DestroyGpuMemoryBuffer, | 152 base::Bind(&GpuMemoryBufferImplTest::DestroyGpuMemoryBuffer, |
| 153 base::Unretained(this), kBufferId))); | 153 base::Unretained(this), kBufferId))); |
| 154 ASSERT_TRUE(buffer); | 154 ASSERT_TRUE(buffer); |
| 155 EXPECT_FALSE(buffer->IsMapped()); | 155 EXPECT_FALSE(buffer->IsMapped()); |
| 156 | 156 |
| 157 size_t num_planes = | 157 size_t num_planes = |
| 158 gfx::NumberOfPlanesForBufferFormat(configuration.format); | 158 GpuMemoryBufferImpl::NumberOfPlanesForGpuMemoryBufferFormat( |
| 159 configuration.format); |
| 159 | 160 |
| 160 // Map buffer into user space. | 161 // Map buffer into user space. |
| 161 scoped_ptr<void* []> mapped_buffers(new void* [num_planes]); | 162 scoped_ptr<void* []> mapped_buffers(new void* [num_planes]); |
| 162 bool rv = buffer->Map(mapped_buffers.get()); | 163 bool rv = buffer->Map(mapped_buffers.get()); |
| 163 ASSERT_TRUE(rv); | 164 ASSERT_TRUE(rv); |
| 164 EXPECT_TRUE(buffer->IsMapped()); | 165 EXPECT_TRUE(buffer->IsMapped()); |
| 165 | 166 |
| 166 // Get strides. | 167 // Get strides. |
| 167 scoped_ptr<int[]> strides(new int[num_planes]); | 168 scoped_ptr<int[]> strides(new int[num_planes]); |
| 168 buffer->GetStride(strides.get()); | 169 buffer->GetStride(strides.get()); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 return supported_types; | 232 return supported_types; |
| 232 } | 233 } |
| 233 | 234 |
| 234 INSTANTIATE_TEST_CASE_P( | 235 INSTANTIATE_TEST_CASE_P( |
| 235 GpuMemoryBufferImplTests, | 236 GpuMemoryBufferImplTests, |
| 236 GpuMemoryBufferImplTest, | 237 GpuMemoryBufferImplTest, |
| 237 ::testing::ValuesIn(GetSupportedGpuMemoryBufferTypes())); | 238 ::testing::ValuesIn(GetSupportedGpuMemoryBufferTypes())); |
| 238 | 239 |
| 239 } // namespace | 240 } // namespace |
| 240 } // namespace content | 241 } // namespace content |
| OLD | NEW |