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

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

Issue 1414793018: Revert of Converted video frame and image callbacks to use new sync tokens. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/base/video_frame.cc ('k') | media/renderers/skcanvas_video_renderer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 } 262 }
263 263
264 static void TextureCallback(gpu::SyncToken* called_sync_token, 264 static void TextureCallback(gpu::SyncToken* called_sync_token,
265 const gpu::SyncToken& release_sync_token) { 265 const gpu::SyncToken& release_sync_token) {
266 *called_sync_token = release_sync_token; 266 *called_sync_token = release_sync_token;
267 } 267 }
268 268
269 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is 269 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is
270 // destroyed with the default release sync point. 270 // destroyed with the default release sync point.
271 TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) { 271 TEST(VideoFrame, TextureNoLongerNeededCallbackIsCalled) {
272 gpu::SyncToken called_sync_token(gpu::CommandBufferNamespace::GPU_IO, 1, 1); 272 gpu::SyncToken called_sync_token(1);
273 273
274 { 274 {
275 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture( 275 scoped_refptr<VideoFrame> frame = VideoFrame::WrapNativeTexture(
276 PIXEL_FORMAT_ARGB, 276 PIXEL_FORMAT_ARGB,
277 gpu::MailboxHolder(gpu::Mailbox::Generate(), gpu::SyncToken(), 5), 277 gpu::MailboxHolder(gpu::Mailbox::Generate(), gpu::SyncToken(), 5),
278 base::Bind(&TextureCallback, &called_sync_token), 278 base::Bind(&TextureCallback, &called_sync_token),
279 gfx::Size(10, 10), // coded_size 279 gfx::Size(10, 10), // coded_size
280 gfx::Rect(10, 10), // visible_rect 280 gfx::Rect(10, 10), // visible_rect
281 gfx::Size(10, 10), // natural_size 281 gfx::Size(10, 10), // natural_size
282 base::TimeDelta()); // timestamp 282 base::TimeDelta()); // timestamp
283 EXPECT_EQ(PIXEL_FORMAT_ARGB, frame->format()); 283 EXPECT_EQ(PIXEL_FORMAT_ARGB, frame->format());
284 EXPECT_EQ(VideoFrame::STORAGE_OPAQUE, frame->storage_type()); 284 EXPECT_EQ(VideoFrame::STORAGE_OPAQUE, frame->storage_type());
285 EXPECT_TRUE(frame->HasTextures()); 285 EXPECT_TRUE(frame->HasTextures());
286 } 286 }
287 // Nobody set a sync point to |frame|, so |frame| set |called_sync_token| 287 // Nobody set a sync point to |frame|, so |frame| set |called_sync_token|
288 // cleared to default value. 288 // cleared to default value.
289 EXPECT_FALSE(called_sync_token.HasData()); 289 EXPECT_FALSE(called_sync_token.HasData());
290 } 290 }
291 291
292 namespace { 292 namespace {
293 293
294 class SyncTokenClientImpl : public VideoFrame::SyncTokenClient { 294 class SyncTokenClientImpl : public VideoFrame::SyncTokenClient {
295 public: 295 public:
296 explicit SyncTokenClientImpl(const gpu::SyncToken& sync_token) 296 explicit SyncTokenClientImpl(const gpu::SyncToken& sync_token)
297 : sync_token_(sync_token) {} 297 : sync_token_(sync_token) {}
298 ~SyncTokenClientImpl() override {} 298 ~SyncTokenClientImpl() override {}
299 void GenerateSyncToken(gpu::SyncToken* sync_token) override { 299 uint32 InsertSyncPoint() override {
300 *sync_token = sync_token_; 300 return static_cast<uint32>(sync_token_.release_count());
301 } 301 }
302 void WaitSyncToken(const gpu::SyncToken& sync_token) override {} 302 void WaitSyncToken(const gpu::SyncToken& sync_token) override {}
303 303
304 private: 304 private:
305 gpu::SyncToken sync_token_; 305 gpu::SyncToken sync_token_;
306 }; 306 };
307 307
308 } // namespace 308 } // namespace
309 309
310 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is 310 // Verify the gpu::MailboxHolder::ReleaseCallback is called when VideoFrame is
311 // destroyed with the release sync point, which was updated by clients. 311 // destroyed with the release sync point, which was updated by clients.
312 // (i.e. the compositor, webgl). 312 // (i.e. the compositor, webgl).
313 TEST(VideoFrame, 313 TEST(VideoFrame,
314 TexturesNoLongerNeededCallbackAfterTakingAndReleasingMailboxes) { 314 TexturesNoLongerNeededCallbackAfterTakingAndReleasingMailboxes) {
315 const int kPlanesNum = 3; 315 const int kPlanesNum = 3;
316 const gpu::CommandBufferNamespace kNamespace =
317 gpu::CommandBufferNamespace::GPU_IO;
318 const uint64_t kCommandBufferId = 0x123;
319 gpu::Mailbox mailbox[kPlanesNum]; 316 gpu::Mailbox mailbox[kPlanesNum];
320 for (int i = 0; i < kPlanesNum; ++i) { 317 for (int i = 0; i < kPlanesNum; ++i) {
321 mailbox[i].name[0] = 50 + 1; 318 mailbox[i].name[0] = 50 + 1;
322 } 319 }
323 320
324 gpu::SyncToken sync_token(kNamespace, kCommandBufferId, 7); 321 gpu::SyncToken sync_token(7);
325 sync_token.SetVerifyFlush();
326 uint32 target = 9; 322 uint32 target = 9;
327 gpu::SyncToken release_sync_token(kNamespace, kCommandBufferId, 111); 323 gpu::SyncToken release_sync_token(111);
328 release_sync_token.SetVerifyFlush();
329
330 gpu::SyncToken called_sync_token; 324 gpu::SyncToken called_sync_token;
331 { 325 {
332 scoped_refptr<VideoFrame> frame = VideoFrame::WrapYUV420NativeTextures( 326 scoped_refptr<VideoFrame> frame = VideoFrame::WrapYUV420NativeTextures(
333 gpu::MailboxHolder(mailbox[VideoFrame::kYPlane], sync_token, target), 327 gpu::MailboxHolder(mailbox[VideoFrame::kYPlane], sync_token, target),
334 gpu::MailboxHolder(mailbox[VideoFrame::kUPlane], sync_token, target), 328 gpu::MailboxHolder(mailbox[VideoFrame::kUPlane], sync_token, target),
335 gpu::MailboxHolder(mailbox[VideoFrame::kVPlane], sync_token, target), 329 gpu::MailboxHolder(mailbox[VideoFrame::kVPlane], sync_token, target),
336 base::Bind(&TextureCallback, &called_sync_token), 330 base::Bind(&TextureCallback, &called_sync_token),
337 gfx::Size(10, 10), // coded_size 331 gfx::Size(10, 10), // coded_size
338 gfx::Rect(10, 10), // visible_rect 332 gfx::Rect(10, 10), // visible_rect
339 gfx::Size(10, 10), // natural_size 333 gfx::Size(10, 10), // natural_size
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 476
483 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) { 477 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) {
484 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i); 478 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i);
485 int value = -1; 479 int value = -1;
486 EXPECT_TRUE(result.GetInteger(key, &value)); 480 EXPECT_TRUE(result.GetInteger(key, &value));
487 EXPECT_EQ(i, value); 481 EXPECT_EQ(i, value);
488 } 482 }
489 } 483 }
490 484
491 } // namespace media 485 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.cc ('k') | media/renderers/skcanvas_video_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698