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

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

Issue 175223003: HW Video: Make media::VideoFrame handle the sync point of the compositor as well as webgl (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: build fix cast_unittests Created 6 years, 9 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 const gfx::Rect& visible_rect, 402 const gfx::Rect& visible_rect,
403 const gfx::Size& natural_size, 403 const gfx::Size& natural_size,
404 base::TimeDelta timestamp, 404 base::TimeDelta timestamp,
405 bool end_of_stream) 405 bool end_of_stream)
406 : format_(format), 406 : format_(format),
407 coded_size_(coded_size), 407 coded_size_(coded_size),
408 visible_rect_(visible_rect), 408 visible_rect_(visible_rect),
409 natural_size_(natural_size), 409 natural_size_(natural_size),
410 shared_memory_handle_(base::SharedMemory::NULLHandle()), 410 shared_memory_handle_(base::SharedMemory::NULLHandle()),
411 timestamp_(timestamp), 411 timestamp_(timestamp),
412 release_sync_point_(0),
412 end_of_stream_(end_of_stream) { 413 end_of_stream_(end_of_stream) {
413 memset(&strides_, 0, sizeof(strides_)); 414 memset(&strides_, 0, sizeof(strides_));
414 memset(&data_, 0, sizeof(data_)); 415 memset(&data_, 0, sizeof(data_));
415 } 416 }
416 417
417 VideoFrame::~VideoFrame() { 418 VideoFrame::~VideoFrame() {
418 if (!mailbox_holder_release_cb_.is_null()) { 419 if (!mailbox_holder_release_cb_.is_null()) {
420 {
421 base::AutoLock locker(release_sync_point_lock_);
422 if (release_sync_point_)
423 mailbox_holder_->sync_point = release_sync_point_;
424 }
419 base::ResetAndReturn(&mailbox_holder_release_cb_) 425 base::ResetAndReturn(&mailbox_holder_release_cb_)
420 .Run(mailbox_holder_.Pass()); 426 .Run(mailbox_holder_.Pass());
421 } 427 }
422 if (!no_longer_needed_cb_.is_null()) 428 if (!no_longer_needed_cb_.is_null())
423 base::ResetAndReturn(&no_longer_needed_cb_).Run(); 429 base::ResetAndReturn(&no_longer_needed_cb_).Run();
424 } 430 }
425 431
426 bool VideoFrame::IsValidPlane(size_t plane) const { 432 bool VideoFrame::IsValidPlane(size_t plane) const {
427 return (plane < NumPlanes(format_)); 433 return (plane < NumPlanes(format_));
428 } 434 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 497
492 gpu::MailboxHolder* VideoFrame::mailbox_holder() const { 498 gpu::MailboxHolder* VideoFrame::mailbox_holder() const {
493 DCHECK_EQ(format_, NATIVE_TEXTURE); 499 DCHECK_EQ(format_, NATIVE_TEXTURE);
494 return mailbox_holder_.get(); 500 return mailbox_holder_.get();
495 } 501 }
496 502
497 base::SharedMemoryHandle VideoFrame::shared_memory_handle() const { 503 base::SharedMemoryHandle VideoFrame::shared_memory_handle() const {
498 return shared_memory_handle_; 504 return shared_memory_handle_;
499 } 505 }
500 506
507 void VideoFrame::SetReleaseSyncPoint(uint32 sync_point) {
508 DCHECK_EQ(format_, NATIVE_TEXTURE);
509 base::AutoLock locker(release_sync_point_lock_);
510 release_sync_point_ = sync_point;
511 }
512
501 void VideoFrame::HashFrameForTesting(base::MD5Context* context) { 513 void VideoFrame::HashFrameForTesting(base::MD5Context* context) {
502 for (int plane = 0; plane < kMaxPlanes; ++plane) { 514 for (int plane = 0; plane < kMaxPlanes; ++plane) {
503 if (!IsValidPlane(plane)) 515 if (!IsValidPlane(plane))
504 break; 516 break;
505 for (int row = 0; row < rows(plane); ++row) { 517 for (int row = 0; row < rows(plane); ++row) {
506 base::MD5Update(context, base::StringPiece( 518 base::MD5Update(context, base::StringPiece(
507 reinterpret_cast<char*>(data(plane) + stride(plane) * row), 519 reinterpret_cast<char*>(data(plane) + stride(plane) * row),
508 row_bytes(plane))); 520 row_bytes(plane)));
509 } 521 }
510 } 522 }
511 } 523 }
512 524
513 } // namespace media 525 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698