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

Side by Side Diff: media/base/video_frame_unittest.cc

Issue 850993002: gpu video: optimize HW video to SW canvas and implement it for WebRTC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/base/video_frame.h" 5 #include "media/base/video_frame.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/memory/aligned_memory.h" 10 #include "base/memory/aligned_memory.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is 248 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is
249 // destroyed with the default release sync point. 249 // destroyed with the default release sync point.
250 TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) { 250 TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) {
251 uint32 called_sync_point = 1; 251 uint32 called_sync_point = 1;
252 252
253 { 253 {
254 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( 254 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture(
255 make_scoped_ptr( 255 make_scoped_ptr(
256 new gpu::MailboxHolder(gpu::Mailbox(), 5, 0 /* sync_point */)), 256 new gpu::MailboxHolder(gpu::Mailbox(), 5, 0 /* sync_point */)),
257 base::Bind(&TextureCallback, &called_sync_point), 257 base::Bind(&TextureCallback, &called_sync_point),
258 gfx::Size(10, 10), // coded_size 258 gfx::Size(10, 10), // coded_size
259 gfx::Rect(10, 10), // visible_rect 259 gfx::Rect(10, 10), // visible_rect
260 gfx::Size(10, 10), // natural_size 260 gfx::Size(10, 10), // natural_size
261 base::TimeDelta(), // timestamp 261 base::TimeDelta()); // timestamp
262 VideoFrame::ReadPixelsCB()); // read_pixels_cb
263 } 262 }
264 // Nobody set a sync point to |frame|, so |frame| set |called_sync_point| to 0 263 // Nobody set a sync point to |frame|, so |frame| set |called_sync_point| to 0
265 // as default value. 264 // as default value.
266 EXPECT_EQ(0u, called_sync_point); 265 EXPECT_EQ(0u, called_sync_point);
267 } 266 }
268 267
269 namespace { 268 namespace {
270 269
271 class SyncPointClientImpl : public VideoFrame::SyncPointClient { 270 class SyncPointClientImpl : public VideoFrame::SyncPointClient {
272 public: 271 public:
(...skipping 16 matching lines...) Expand all
289 mailbox.name[0] = 50; 288 mailbox.name[0] = 50;
290 uint32 sync_point = 7; 289 uint32 sync_point = 7;
291 uint32 target = 9; 290 uint32 target = 9;
292 uint32 release_sync_point = 111; 291 uint32 release_sync_point = 111;
293 uint32 called_sync_point = 0; 292 uint32 called_sync_point = 0;
294 293
295 { 294 {
296 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( 295 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture(
297 make_scoped_ptr(new gpu::MailboxHolder(mailbox, target, sync_point)), 296 make_scoped_ptr(new gpu::MailboxHolder(mailbox, target, sync_point)),
298 base::Bind(&TextureCallback, &called_sync_point), 297 base::Bind(&TextureCallback, &called_sync_point),
299 gfx::Size(10, 10), // coded_size 298 gfx::Size(10, 10), // coded_size
300 gfx::Rect(10, 10), // visible_rect 299 gfx::Rect(10, 10), // visible_rect
301 gfx::Size(10, 10), // natural_size 300 gfx::Size(10, 10), // natural_size
302 base::TimeDelta(), // timestamp 301 base::TimeDelta()); // timestamp
303 VideoFrame::ReadPixelsCB()); // read_pixels_cb
304 302
305 const gpu::MailboxHolder* mailbox_holder = frame->mailbox_holder(); 303 const gpu::MailboxHolder* mailbox_holder = frame->mailbox_holder();
306 304
307 EXPECT_EQ(mailbox.name[0], mailbox_holder->mailbox.name[0]); 305 EXPECT_EQ(mailbox.name[0], mailbox_holder->mailbox.name[0]);
308 EXPECT_EQ(target, mailbox_holder->texture_target); 306 EXPECT_EQ(target, mailbox_holder->texture_target);
309 EXPECT_EQ(sync_point, mailbox_holder->sync_point); 307 EXPECT_EQ(sync_point, mailbox_holder->sync_point);
310 308
311 SyncPointClientImpl client(release_sync_point); 309 SyncPointClientImpl client(release_sync_point);
312 frame->UpdateReleaseSyncPoint(&client); 310 frame->UpdateReleaseSyncPoint(&client);
313 EXPECT_EQ(sync_point, mailbox_holder->sync_point); 311 EXPECT_EQ(sync_point, mailbox_holder->sync_point);
314 } 312 }
315 EXPECT_EQ(release_sync_point, called_sync_point); 313 EXPECT_EQ(release_sync_point, called_sync_point);
316 } 314 }
317 315
318 TEST(VideoFrame, ZeroInitialized) { 316 TEST(VideoFrame, ZeroInitialized) {
319 const int kWidth = 64; 317 const int kWidth = 64;
320 const int kHeight = 48; 318 const int kHeight = 48;
321 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337); 319 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337);
322 320
323 gfx::Size size(kWidth, kHeight); 321 gfx::Size size(kWidth, kHeight);
324 scoped_refptr<media::VideoFrame> frame = VideoFrame::CreateFrame( 322 scoped_refptr<media::VideoFrame> frame = VideoFrame::CreateFrame(
325 media::VideoFrame::YV12, size, gfx::Rect(size), size, kTimestamp); 323 media::VideoFrame::YV12, size, gfx::Rect(size), size, kTimestamp);
326 324
327 for (size_t i = 0; i < VideoFrame::NumPlanes(frame->format()); ++i) 325 for (size_t i = 0; i < VideoFrame::NumPlanes(frame->format()); ++i)
328 EXPECT_EQ(0, frame->data(i)[0]); 326 EXPECT_EQ(0, frame->data(i)[0]);
329 } 327 }
330 328
331 } // namespace media 329 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698