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

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

Issue 2000323004: cc: Remove InUseByMacOSWindowServer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@video2
Patch Set: Created 4 years, 7 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
« no previous file with comments | « media/video/gpu_memory_buffer_video_frame_pool.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <memory> 6 #include <memory>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/test/test_simple_task_runner.h" 9 #include "base/test/test_simple_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 190 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame(
191 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame)); 191 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
192 RunUntilIdle(); 192 RunUntilIdle();
193 193
194 EXPECT_NE(software_frame.get(), frame.get()); 194 EXPECT_NE(software_frame.get(), frame.get());
195 EXPECT_EQ(6u, gles2_->gen_textures); 195 EXPECT_EQ(6u, gles2_->gen_textures);
196 EXPECT_EQ(frame->mailbox_holder(0).mailbox, mailbox); 196 EXPECT_EQ(frame->mailbox_holder(0).mailbox, mailbox);
197 EXPECT_NE(frame->mailbox_holder(0).sync_token, sync_token); 197 EXPECT_NE(frame->mailbox_holder(0).sync_token, sync_token);
198 } 198 }
199 199
200 TEST_F(GpuMemoryBufferVideoFramePoolTest, DoNotReuseInUse) {
201 scoped_refptr<VideoFrame> software_frame = CreateTestYUVVideoFrame(10);
202 scoped_refptr<VideoFrame> frame;
203 scoped_refptr<VideoFrame> frame2;
204
205 // Allocate a frame.
206 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame(
207 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
208 RunUntilIdle();
209 EXPECT_NE(software_frame.get(), frame.get());
210 gpu::Mailbox mailbox = frame->mailbox_holder(0).mailbox;
211 const gpu::SyncToken sync_token = frame->mailbox_holder(0).sync_token;
212 EXPECT_EQ(3u, gles2_->gen_textures);
213
214 // Allocate a second frame.
215 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame(
216 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame2));
217 RunUntilIdle();
218 EXPECT_NE(software_frame.get(), frame2.get());
219 EXPECT_NE(mailbox, frame2->mailbox_holder(0).mailbox);
220 EXPECT_EQ(6u, gles2_->gen_textures);
221
222 // Allow the frames to be recycled.
223 frame = nullptr;
224 frame2 = nullptr;
225 RunUntilIdle();
226
227 // Set all buffers to be in use, so the next hardware frame will require
228 // a new allocation.
229 mock_gpu_factories_->SetGpuMemoryBuffersInUseByMacOSWindowServer(true);
230 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame(
231 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
232 RunUntilIdle();
233 EXPECT_NE(software_frame.get(), frame.get());
234 EXPECT_EQ(9u, gles2_->gen_textures);
235 EXPECT_NE(frame->mailbox_holder(0).mailbox, mailbox);
236 EXPECT_NE(frame->mailbox_holder(0).sync_token, sync_token);
237
238 // Set the buffers no longer in use, so no new allocations will be made.
239 mock_gpu_factories_->SetGpuMemoryBuffersInUseByMacOSWindowServer(false);
240 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame(
241 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame2));
242 RunUntilIdle();
243 EXPECT_NE(software_frame.get(), frame2.get());
244 EXPECT_EQ(9u, gles2_->gen_textures);
245 EXPECT_NE(frame->mailbox_holder(0).mailbox, mailbox);
246 EXPECT_NE(frame->mailbox_holder(0).sync_token, sync_token);
247 }
248
249 TEST_F(GpuMemoryBufferVideoFramePoolTest, DropResourceWhenSizeIsDifferent) { 200 TEST_F(GpuMemoryBufferVideoFramePoolTest, DropResourceWhenSizeIsDifferent) {
250 scoped_refptr<VideoFrame> frame; 201 scoped_refptr<VideoFrame> frame;
251 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 202 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame(
252 CreateTestYUVVideoFrame(10), 203 CreateTestYUVVideoFrame(10),
253 base::Bind(MaybeCreateHardwareFrameCallback, &frame)); 204 base::Bind(MaybeCreateHardwareFrameCallback, &frame));
254 RunUntilIdle(); 205 RunUntilIdle();
255 206
256 EXPECT_EQ(3u, gles2_->gen_textures); 207 EXPECT_EQ(3u, gles2_->gen_textures);
257 208
258 frame = nullptr; 209 frame = nullptr;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame( 255 gpu_memory_buffer_pool_->MaybeCreateHardwareFrame(
305 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame)); 256 software_frame, base::Bind(MaybeCreateHardwareFrameCallback, &frame));
306 257
307 RunUntilIdle(); 258 RunUntilIdle();
308 259
309 EXPECT_NE(software_frame.get(), frame.get()); 260 EXPECT_NE(software_frame.get(), frame.get());
310 EXPECT_EQ(3u, gles2_->gen_textures); 261 EXPECT_EQ(3u, gles2_->gen_textures);
311 } 262 }
312 263
313 } // namespace media 264 } // namespace media
OLDNEW
« no previous file with comments | « media/video/gpu_memory_buffer_video_frame_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698