OLD | NEW |
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 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/memory/discardable_memory.h" | 7 #include "base/memory/discardable_memory.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "content/child/child_discardable_shared_memory_manager.h" | 10 #include "content/child/child_discardable_shared_memory_manager.h" |
11 #include "content/child/child_gpu_memory_buffer_manager.h" | 11 #include "content/child/child_gpu_memory_buffer_manager.h" |
12 #include "content/child/child_thread_impl.h" | 12 #include "content/child/child_thread_impl.h" |
13 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" | 13 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
14 #include "content/common/host_discardable_shared_memory_manager.h" | 14 #include "content/common/host_discardable_shared_memory_manager.h" |
15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
16 #include "content/public/test/content_browser_test.h" | 16 #include "content/public/test/content_browser_test.h" |
17 #include "content/public/test/content_browser_test_utils.h" | 17 #include "content/public/test/content_browser_test_utils.h" |
18 #include "content/shell/browser/shell.h" | 18 #include "content/shell/browser/shell.h" |
| 19 #include "ui/gfx/buffer_format_util.h" |
19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 namespace { | 23 namespace { |
23 | 24 |
24 class ChildThreadImplBrowserTest : public ContentBrowserTest { | 25 class ChildThreadImplBrowserTest : public ContentBrowserTest { |
25 public: | 26 public: |
26 ChildThreadImplBrowserTest() | 27 ChildThreadImplBrowserTest() |
27 : child_gpu_memory_buffer_manager_(nullptr), | 28 : child_gpu_memory_buffer_manager_(nullptr), |
28 child_discardable_shared_memory_manager_(nullptr) {} | 29 child_discardable_shared_memory_manager_(nullptr) {} |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 DISABLED_Map) { | 151 DISABLED_Map) { |
151 gfx::BufferFormat format = ::testing::get<1>(GetParam()); | 152 gfx::BufferFormat format = ::testing::get<1>(GetParam()); |
152 gfx::Size buffer_size(4, 4); | 153 gfx::Size buffer_size(4, 4); |
153 | 154 |
154 scoped_ptr<gfx::GpuMemoryBuffer> buffer = | 155 scoped_ptr<gfx::GpuMemoryBuffer> buffer = |
155 child_gpu_memory_buffer_manager()->AllocateGpuMemoryBuffer( | 156 child_gpu_memory_buffer_manager()->AllocateGpuMemoryBuffer( |
156 buffer_size, format, gfx::BufferUsage::MAP); | 157 buffer_size, format, gfx::BufferUsage::MAP); |
157 ASSERT_TRUE(buffer); | 158 ASSERT_TRUE(buffer); |
158 EXPECT_EQ(format, buffer->GetFormat()); | 159 EXPECT_EQ(format, buffer->GetFormat()); |
159 | 160 |
160 size_t num_planes = | 161 size_t num_planes = gfx::NumberOfPlanesForBufferFormat(format); |
161 GpuMemoryBufferImpl::NumberOfPlanesForGpuMemoryBufferFormat(format); | |
162 | 162 |
163 // Map buffer planes. | 163 // Map buffer planes. |
164 scoped_ptr<void* []> planes(new void* [num_planes]); | 164 scoped_ptr<void* []> planes(new void* [num_planes]); |
165 bool rv = buffer->Map(planes.get()); | 165 bool rv = buffer->Map(planes.get()); |
166 ASSERT_TRUE(rv); | 166 ASSERT_TRUE(rv); |
167 EXPECT_TRUE(buffer->IsMapped()); | 167 EXPECT_TRUE(buffer->IsMapped()); |
168 | 168 |
169 // Get strides. | 169 // Get strides. |
170 scoped_ptr<int[]> strides(new int[num_planes]); | 170 scoped_ptr<int[]> strides(new int[num_planes]); |
171 buffer->GetStride(strides.get()); | 171 buffer->GetStride(strides.get()); |
(...skipping 29 matching lines...) Expand all Loading... |
201 kEnableNativeBuffers), | 201 kEnableNativeBuffers), |
202 // These formats are guaranteed to work on all platforms. | 202 // These formats are guaranteed to work on all platforms. |
203 ::testing::Values(gfx::BufferFormat::R_8, | 203 ::testing::Values(gfx::BufferFormat::R_8, |
204 gfx::BufferFormat::RGBA_4444, | 204 gfx::BufferFormat::RGBA_4444, |
205 gfx::BufferFormat::RGBA_8888, | 205 gfx::BufferFormat::RGBA_8888, |
206 gfx::BufferFormat::BGRA_8888, | 206 gfx::BufferFormat::BGRA_8888, |
207 gfx::BufferFormat::YUV_420))); | 207 gfx::BufferFormat::YUV_420))); |
208 | 208 |
209 } // namespace | 209 } // namespace |
210 } // namespace content | 210 } // namespace content |
OLD | NEW |