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

Side by Side Diff: media/video/gpu_memory_buffer_video_frame_copier_unittest.cc

Issue 1874733002: media: split GpuMemoryBufferVideoFramePool into GpuMemoryBufferVideoFrameCopier/Pool Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add GpuMemoryBufferVideoFramePoolTest Created 4 years, 8 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 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/test/test_simple_task_runner.h" 8 #include "base/test/test_simple_task_runner.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "gpu/command_buffer/client/gles2_interface_stub.h" 10 #include "gpu/command_buffer/client/gles2_interface_stub.h"
11 #include "media/base/video_frame.h" 11 #include "media/base/video_frame.h"
12 #include "media/renderers/mock_gpu_video_accelerator_factories.h" 12 #include "media/renderers/mock_gpu_video_accelerator_factories.h"
13 #include "media/video/gpu_memory_buffer_video_frame_pool.h" 13 #include "media/video/gpu_memory_buffer_video_frame_copier.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 15
16 namespace media { 16 namespace media {
17 17
18 namespace { 18 namespace {
19 class TestGLES2Interface : public gpu::gles2::GLES2InterfaceStub { 19 class TestGLES2Interface : public gpu::gles2::GLES2InterfaceStub {
20 public: 20 public:
21 unsigned gen_textures = 0u; 21 unsigned gen_textures = 0u;
22 void GenTextures(GLsizei n, GLuint* textures) override { 22 void GenTextures(GLsizei n, GLuint* textures) override {
23 DCHECK_EQ(1, n); 23 DCHECK_EQ(1, n);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 60
61 private: 61 private:
62 uint64_t next_fence_sync_ = 1u; 62 uint64_t next_fence_sync_ = 1u;
63 uint64_t flushed_fence_sync_ = 0u; 63 uint64_t flushed_fence_sync_ = 0u;
64 unsigned mailbox_ = 0u; 64 unsigned mailbox_ = 0u;
65 }; 65 };
66 66
67 } // unnamed namespace 67 } // unnamed namespace
68 68
69 class GpuMemoryBufferVideoFramePoolTest : public ::testing::Test { 69 class GpuMemoryBufferVideoFrameCopierTest : public ::testing::Test {
70 public: 70 public:
71 GpuMemoryBufferVideoFramePoolTest() {} 71 GpuMemoryBufferVideoFrameCopierTest() {}
72 void SetUp() override { 72 void SetUp() override {
73 gles2_.reset(new TestGLES2Interface); 73 gles2_.reset(new TestGLES2Interface);
74 media_task_runner_ = make_scoped_refptr(new base::TestSimpleTaskRunner); 74 media_task_runner_ = make_scoped_refptr(new base::TestSimpleTaskRunner);
75 copy_task_runner_ = make_scoped_refptr(new base::TestSimpleTaskRunner); 75 copy_task_runner_ = make_scoped_refptr(new base::TestSimpleTaskRunner);
76 media_task_runner_handle_.reset( 76 media_task_runner_handle_.reset(
77 new base::ThreadTaskRunnerHandle(media_task_runner_)); 77 new base::ThreadTaskRunnerHandle(media_task_runner_));
78 mock_gpu_factories_.reset( 78 mock_gpu_factories_.reset(
79 new MockGpuVideoAcceleratorFactories(gles2_.get())); 79 new MockGpuVideoAcceleratorFactories(gles2_.get()));
80 gpu_memory_buffer_pool_.reset(new GpuMemoryBufferVideoFramePool( 80 gpu_memory_buffer_copier_.reset(new GpuMemoryBufferVideoFrameCopier(
81 media_task_runner_, copy_task_runner_.get(), 81 media_task_runner_, copy_task_runner_.get(),
82 mock_gpu_factories_.get())); 82 mock_gpu_factories_.get()));
83 } 83 }
84 84
85 void TearDown() override { 85 void TearDown() override {
86 gpu_memory_buffer_pool_.reset(); 86 gpu_memory_buffer_copier_.reset();
87 RunUntilIdle(); 87 RunUntilIdle();
88 mock_gpu_factories_.reset(); 88 mock_gpu_factories_.reset();
89 } 89 }
90 90
91 void RunUntilIdle() { 91 void RunUntilIdle() {
92 media_task_runner_->RunUntilIdle(); 92 media_task_runner_->RunUntilIdle();
93 copy_task_runner_->RunUntilIdle(); 93 copy_task_runner_->RunUntilIdle();
94 media_task_runner_->RunUntilIdle(); 94 media_task_runner_->RunUntilIdle();
95 } 95 }
96 96
(...skipping 19 matching lines...) Expand all
116 y_data, // y_data 116 y_data, // y_data
117 u_data, // u_data 117 u_data, // u_data
118 v_data, // v_data 118 v_data, // v_data
119 base::TimeDelta()); // timestamp 119 base::TimeDelta()); // timestamp
120 EXPECT_TRUE(video_frame); 120 EXPECT_TRUE(video_frame);
121 return video_frame; 121 return video_frame;
122 } 122 }
123 123
124 protected: 124 protected:
125 scoped_ptr<MockGpuVideoAcceleratorFactories> mock_gpu_factories_; 125 scoped_ptr<MockGpuVideoAcceleratorFactories> mock_gpu_factories_;
126 scoped_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool_; 126 scoped_ptr<GpuMemoryBufferVideoFrameCopier> gpu_memory_buffer_copier_;
127 scoped_refptr<base::TestSimpleTaskRunner> media_task_runner_; 127 scoped_refptr<base::TestSimpleTaskRunner> media_task_runner_;
128 scoped_refptr<base::TestSimpleTaskRunner> copy_task_runner_; 128 scoped_refptr<base::TestSimpleTaskRunner> copy_task_runner_;
129 // GpuMemoryBufferVideoFramePool uses BindToCurrentLoop(), which requires 129 // GpuMemoryBufferVideoFramePool uses BindToCurrentLoop(), which requires
130 // ThreadTaskRunnerHandle initialization. 130 // ThreadTaskRunnerHandle initialization.
131 scoped_ptr<base::ThreadTaskRunnerHandle> media_task_runner_handle_; 131 scoped_ptr<base::ThreadTaskRunnerHandle> media_task_runner_handle_;
132 scoped_ptr<TestGLES2Interface> gles2_; 132 scoped_ptr<TestGLES2Interface> gles2_;
133 }; 133 };
134 134
135 void MaybeCreateHardwareFrameCallback( 135 void MaybeCreateHardwareFrameCallback(
136 scoped_refptr<VideoFrame>* video_frame_output, 136 scoped_refptr<VideoFrame>* video_frame_output,
137 const scoped_refptr<VideoFrame>& video_frame) { 137 const scoped_refptr<VideoFrame>& video_frame) {
138 *video_frame_output = video_frame; 138 *video_frame_output = video_frame;
139 } 139 }
140 140
141 TEST_F(GpuMemoryBufferVideoFramePoolTest, VideoFrameOutputFormatUnknown) { 141 TEST_F(GpuMemoryBufferVideoFrameCopierTest, VideoFrameOutputFormatUnknown) {
142 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10); 142 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10);
143 mock_gpu_factories_->SetVideoFrameOutputFormat(PIXEL_FORMAT_UNKNOWN); 143 mock_gpu_factories_->SetVideoFrameOutputFormat(PIXEL_FORMAT_UNKNOWN);
144 scoped_refptr<VideoFrame> frame; 144 scoped_refptr<VideoFrame> frame;
145 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 145 gpu_memory_buffer_copier_->MaybeCreateHardwareFrame(
146 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame)); 146 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
147 RunUntilIdle(); 147 RunUntilIdle();
148 148
149 EXPECT_EQ(software_frame.get(), frame.get()); 149 EXPECT_EQ(software_frame.get(), frame.get());
150 } 150 }
151 151
152 TEST_F(GpuMemoryBufferVideoFramePoolTest, CreateOneHardwareFrame) { 152 TEST_F(GpuMemoryBufferVideoFrameCopierTest, CreateOneHardwareFrame) {
153 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10); 153 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10);
154 scoped_refptr<VideoFrame> frame; 154 scoped_refptr<VideoFrame> frame;
155 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 155 gpu_memory_buffer_copier_->MaybeCreateHardwareFrame(
156 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame)); 156 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
157 157
158 RunUntilIdle(); 158 RunUntilIdle();
159 159
160 EXPECT_NE(software_frame.get(), frame.get()); 160 EXPECT_NE(software_frame.get(), frame.get());
161 EXPECT_EQ(3u, gles2_->gen_textures); 161 EXPECT_EQ(3u, gles2_->gen_textures);
162 } 162 }
163 163
164 TEST_F(GpuMemoryBufferVideoFramePoolTest, ReuseFirstResource) { 164 TEST_F(GpuMemoryBufferVideoFrameCopierTest, ReuseFirstResource) {
165 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10); 165 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10);
166 scoped_refptr<VideoFrame> frame; 166 scoped_refptr<VideoFrame> frame;
167 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 167 gpu_memory_buffer_copier_->MaybeCreateHardwareFrame(
168 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame)); 168 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
169 RunUntilIdle(); 169 RunUntilIdle();
170 170
171 EXPECT_NE(software_frame.get(), frame.get()); 171 EXPECT_NE(software_frame.get(), frame.get());
172 gpu::Mailbox mailbox = frame->mailbox_holder(0).mailbox; 172 gpu::Mailbox mailbox = frame->mailbox_holder(0).mailbox;
173 const gpu::SyncToken sync_token = frame->mailbox_holder(0).sync_token; 173 const gpu::SyncToken sync_token = frame->mailbox_holder(0).sync_token;
174 EXPECT_EQ(3u, gles2_->gen_textures); 174 EXPECT_EQ(3u, gles2_->gen_textures);
175 175
176 scoped_refptr<VideoFrame> frame2; 176 scoped_refptr<VideoFrame> frame2;
177 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 177 gpu_memory_buffer_copier_->MaybeCreateHardwareFrame(
178 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame2)); 178 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame2));
179 RunUntilIdle(); 179 RunUntilIdle();
180 180
181 EXPECT_NE(software_frame.get(), frame2.get()); 181 EXPECT_NE(software_frame.get(), frame2.get());
182 EXPECT_NE(mailbox, frame2->mailbox_holder(0).mailbox); 182 EXPECT_NE(mailbox, frame2->mailbox_holder(0).mailbox);
183 EXPECT_EQ(6u, gles2_->gen_textures); 183 EXPECT_EQ(6u, gles2_->gen_textures);
184 184
185 frame = nullptr; 185 frame = nullptr;
186 frame2 = nullptr; 186 frame2 = nullptr;
187 RunUntilIdle(); 187 RunUntilIdle();
188 188
189 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 189 gpu_memory_buffer_copier_->MaybeCreateHardwareFrame(
190 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame)); 190 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
191 RunUntilIdle(); 191 RunUntilIdle();
192 192
193 EXPECT_NE(software_frame.get(), frame.get()); 193 EXPECT_NE(software_frame.get(), frame.get());
194 EXPECT_EQ(6u, gles2_->gen_textures); 194 EXPECT_EQ(6u, gles2_->gen_textures);
195 EXPECT_EQ(frame->mailbox_holder(0).mailbox, mailbox); 195 EXPECT_EQ(frame->mailbox_holder(0).mailbox, mailbox);
196 EXPECT_NE(frame->mailbox_holder(0).sync_token, sync_token); 196 EXPECT_NE(frame->mailbox_holder(0).sync_token, sync_token);
197 } 197 }
198 198
199 TEST_F(GpuMemoryBufferVideoFramePoolTest, DoNotReuseInUse) { 199 TEST_F(GpuMemoryBufferVideoFrameCopierTest, DoNotReuseInUse) {
200 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10); 200 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10);
201 scoped_refptr<VideoFrame> frame; 201 scoped_refptr<VideoFrame> frame;
202 scoped_refptr<VideoFrame> frame2; 202 scoped_refptr<VideoFrame> frame2;
203 203
204 // Allocate a frame. 204 // Allocate a frame.
205 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 205 gpu_memory_buffer_copier_->MaybeCreateHardwareFrame(
206 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame)); 206 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
207 RunUntilIdle(); 207 RunUntilIdle();
208 EXPECT_NE(software_frame.get(), frame.get()); 208 EXPECT_NE(software_frame.get(), frame.get());
209 gpu::Mailbox mailbox = frame->mailbox_holder(0).mailbox; 209 gpu::Mailbox mailbox = frame->mailbox_holder(0).mailbox;
210 const gpu::SyncToken sync_token = frame->mailbox_holder(0).sync_token; 210 const gpu::SyncToken sync_token = frame->mailbox_holder(0).sync_token;
211 EXPECT_EQ(3u, gles2_->gen_textures); 211 EXPECT_EQ(3u, gles2_->gen_textures);
212 212
213 // Allocate a second frame. 213 // Allocate a second frame.
214 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 214 gpu_memory_buffer_copier_->MaybeCreateHardwareFrame(
215 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame2)); 215 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame2));
216 RunUntilIdle(); 216 RunUntilIdle();
217 EXPECT_NE(software_frame.get(), frame2.get()); 217 EXPECT_NE(software_frame.get(), frame2.get());
218 EXPECT_NE(mailbox, frame2->mailbox_holder(0).mailbox); 218 EXPECT_NE(mailbox, frame2->mailbox_holder(0).mailbox);
219 EXPECT_EQ(6u, gles2_->gen_textures); 219 EXPECT_EQ(6u, gles2_->gen_textures);
220 220
221 // Allow the frames to be recycled. 221 // Allow the frames to be recycled.
222 frame = nullptr; 222 frame = nullptr;
223 frame2 = nullptr; 223 frame2 = nullptr;
224 RunUntilIdle(); 224 RunUntilIdle();
225 225
226 // Set all buffers to be in use, so the next hardware frame will require 226 // Set all buffers to be in use, so the next hardware frame will require
227 // a new allocation. 227 // a new allocation.
228 mock_gpu_factories_->SetGpuMemoryBuffersInUseByMacOSWindowServer(true); 228 mock_gpu_factories_->SetGpuMemoryBuffersInUseByMacOSWindowServer(true);
229 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 229 gpu_memory_buffer_copier_->MaybeCreateHardwareFrame(
230 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame)); 230 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
231 RunUntilIdle(); 231 RunUntilIdle();
232 EXPECT_NE(software_frame.get(), frame.get()); 232 EXPECT_NE(software_frame.get(), frame.get());
233 EXPECT_EQ(9u, gles2_->gen_textures); 233 EXPECT_EQ(9u, gles2_->gen_textures);
234 EXPECT_NE(frame->mailbox_holder(0).mailbox, mailbox); 234 EXPECT_NE(frame->mailbox_holder(0).mailbox, mailbox);
235 EXPECT_NE(frame->mailbox_holder(0).sync_token, sync_token); 235 EXPECT_NE(frame->mailbox_holder(0).sync_token, sync_token);
236 236
237 // Set the buffers no longer in use, so no new allocations will be made. 237 // Set the buffers no longer in use, so no new allocations will be made.
238 mock_gpu_factories_->SetGpuMemoryBuffersInUseByMacOSWindowServer(false); 238 mock_gpu_factories_->SetGpuMemoryBuffersInUseByMacOSWindowServer(false);
239 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 239 gpu_memory_buffer_copier_->MaybeCreateHardwareFrame(
240 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame2)); 240 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame2));
241 RunUntilIdle(); 241 RunUntilIdle();
242 EXPECT_NE(software_frame.get(), frame2.get()); 242 EXPECT_NE(software_frame.get(), frame2.get());
243 EXPECT_EQ(9u, gles2_->gen_textures); 243 EXPECT_EQ(9u, gles2_->gen_textures);
244 EXPECT_NE(frame->mailbox_holder(0).mailbox, mailbox); 244 EXPECT_NE(frame->mailbox_holder(0).mailbox, mailbox);
245 EXPECT_NE(frame->mailbox_holder(0).sync_token, sync_token); 245 EXPECT_NE(frame->mailbox_holder(0).sync_token, sync_token);
246 } 246 }
247 247
248 TEST_F(GpuMemoryBufferVideoFramePoolTest, DropResourceWhenSizeIsDifferent) { 248 TEST_F(GpuMemoryBufferVideoFrameCopierTest, DropResourceWhenSizeIsDifferent) {
249 scoped_refptr<VideoFrame> frame; 249 scoped_refptr<VideoFrame> frame;
250 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 250 gpu_memory_buffer_copier_->MaybeCreateHardwareFrame(
251 CreateTestYUVVideoFrame(10), 251 CreateTestYUVVideoFrame(10),
252 base::Bind(MaybeCreateHardwareFrameCallback, &frame)); 252 base::Bind(MaybeCreateHardwareFrameCallback, &frame));
253 RunUntilIdle(); 253 RunUntilIdle();
254 254
255 EXPECT_EQ(3u, gles2_->gen_textures); 255 EXPECT_EQ(3u, gles2_->gen_textures);
256 256
257 frame = nullptr; 257 frame = nullptr;
258 RunUntilIdle(); 258 RunUntilIdle();
259 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 259 gpu_memory_buffer_copier_->MaybeCreateHardwareFrame(
260 CreateTestYUVVideoFrame(4), 260 CreateTestYUVVideoFrame(4),
261 base::Bind(MaybeCreateHardwareFrameCallback, &frame)); 261 base::Bind(MaybeCreateHardwareFrameCallback, &frame));
262 RunUntilIdle(); 262 RunUntilIdle();
263 EXPECT_EQ(6u, gles2_->gen_textures); 263 EXPECT_EQ(6u, gles2_->gen_textures);
264 } 264 }
265 265
266 TEST_F(GpuMemoryBufferVideoFramePoolTest, CreateOneHardwareUYUVFrame) { 266 TEST_F(GpuMemoryBufferVideoFrameCopierTest, CreateOneHardwareUYUVFrame) {
267 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10); 267 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10);
268 scoped_refptr<VideoFrame> frame; 268 scoped_refptr<VideoFrame> frame;
269 mock_gpu_factories_->SetVideoFrameOutputFormat(PIXEL_FORMAT_UYVY); 269 mock_gpu_factories_->SetVideoFrameOutputFormat(PIXEL_FORMAT_UYVY);
270 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 270 gpu_memory_buffer_copier_->MaybeCreateHardwareFrame(
271 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame)); 271 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
272 272
273 RunUntilIdle(); 273 RunUntilIdle();
274 274
275 EXPECT_NE(software_frame.get(), frame.get()); 275 EXPECT_NE(software_frame.get(), frame.get());
276 EXPECT_EQ(1u, gles2_->gen_textures); 276 EXPECT_EQ(1u, gles2_->gen_textures);
277 EXPECT_TRUE(frame->metadata()->IsTrue( 277 EXPECT_TRUE(frame->metadata()->IsTrue(
278 media::VideoFrameMetadata::READ_LOCK_FENCES_ENABLED)); 278 media::VideoFrameMetadata::READ_LOCK_FENCES_ENABLED));
279 } 279 }
280 280
281 TEST_F(GpuMemoryBufferVideoFramePoolTest, CreateOneHardwareNV12Frame) { 281 TEST_F(GpuMemoryBufferVideoFrameCopierTest, CreateOneHardwareNV12Frame) {
282 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10); 282 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10);
283 scoped_refptr<VideoFrame> frame; 283 scoped_refptr<VideoFrame> frame;
284 mock_gpu_factories_->SetVideoFrameOutputFormat(PIXEL_FORMAT_NV12); 284 mock_gpu_factories_->SetVideoFrameOutputFormat(PIXEL_FORMAT_NV12);
285 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 285 gpu_memory_buffer_copier_->MaybeCreateHardwareFrame(
286 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame)); 286 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
287 287
288 RunUntilIdle(); 288 RunUntilIdle();
289 289
290 EXPECT_NE(software_frame.get(), frame.get()); 290 EXPECT_NE(software_frame.get(), frame.get());
291 EXPECT_EQ(1u, gles2_->gen_textures); 291 EXPECT_EQ(1u, gles2_->gen_textures);
292 EXPECT_TRUE(frame->metadata()->IsTrue( 292 EXPECT_TRUE(frame->metadata()->IsTrue(
293 media::VideoFrameMetadata::READ_LOCK_FENCES_ENABLED)); 293 media::VideoFrameMetadata::READ_LOCK_FENCES_ENABLED));
294 } 294 }
295 295
296 // AllocateGpuMemoryBuffer can return null (e.g: when the GPU process is down). 296 // AllocateGpuMemoryBuffer can return null (e.g: when the GPU process is down).
297 // This test checks that in that case we don't crash and still create the 297 // This test checks that in that case we don't crash and don't copy it to
298 // textures. 298 // VideoFrame backed native texture.
299 TEST_F(GpuMemoryBufferVideoFramePoolTest, AllocateGpuMemoryBufferFail) { 299 TEST_F(GpuMemoryBufferVideoFrameCopierTest, AllocateGpuMemoryBufferFail) {
300 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10); 300 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10);
301 scoped_refptr<VideoFrame> frame; 301 scoped_refptr<VideoFrame> frame;
302 mock_gpu_factories_->SetFailToAllocateGpuMemoryBufferForTesting(true); 302 mock_gpu_factories_->SetFailToAllocateGpuMemoryBufferForTesting(true);
303 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 303 gpu_memory_buffer_copier_->MaybeCreateHardwareFrame(
304 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame)); 304 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
305 305
306 RunUntilIdle(); 306 RunUntilIdle();
307 307
308 EXPECT_NE(software_frame.get(), frame.get()); 308 EXPECT_EQ(software_frame.get(), frame.get());
309 EXPECT_EQ(3u, gles2_->gen_textures); 309 EXPECT_EQ(0u, gles2_->gen_textures);
310 } 310 }
311 311
312 } // namespace media 312 } // namespace media
OLDNEW
« no previous file with comments | « media/video/gpu_memory_buffer_video_frame_copier.cc ('k') | media/video/gpu_memory_buffer_video_frame_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698