OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/media/webmediaplayer_impl.h" | 5 #include "content/renderer/media/webmediaplayer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
529 // video frames are still rendered to a canvas. | 529 // video frames are still rendered to a canvas. |
530 UMA_HISTOGRAM_BOOLEAN( | 530 UMA_HISTOGRAM_BOOLEAN( |
531 "Media.AcceleratedCompositingActive", | 531 "Media.AcceleratedCompositingActive", |
532 frame_->view()->isAcceleratedCompositingActive()); | 532 frame_->view()->isAcceleratedCompositingActive()); |
533 } | 533 } |
534 | 534 |
535 | 535 |
536 TRACE_EVENT0("media", "WebMediaPlayerImpl:paint"); | 536 TRACE_EVENT0("media", "WebMediaPlayerImpl:paint"); |
537 scoped_refptr<media::VideoFrame> video_frame = painter_.GetCurrentFrame(true); | 537 scoped_refptr<media::VideoFrame> video_frame = painter_.GetCurrentFrame(true); |
538 gfx::Rect gfx_rect(rect); | 538 gfx::Rect gfx_rect(rect); |
539 skcanvas_video_renderer_.Paint(video_frame.get(), canvas, gfx_rect, alpha); | 539 skcanvas_video_renderer_.Paint(video_frame.get(), canvas, gfx_rect, alpha); |
danakj
2014/02/28 17:49:30
Should someone be waiting on the video frame's syn
dshwang
2014/02/28 18:01:48
we don't need to wait for the sync point. It's why
danakj
2014/02/28 18:41:19
All GL is actually run on the gpu process so I'm n
| |
540 if (video_frame && | |
541 video_frame->format() == media::VideoFrame::NATIVE_TEXTURE) { | |
542 DCHECK(gpu_factories_); | |
543 video_frame->SetReleaseSyncPoint(gpu_factories_->InsertSyncPoint()); | |
544 } | |
540 } | 545 } |
541 | 546 |
542 bool WebMediaPlayerImpl::hasSingleSecurityOrigin() const { | 547 bool WebMediaPlayerImpl::hasSingleSecurityOrigin() const { |
543 if (data_source_) | 548 if (data_source_) |
544 return data_source_->HasSingleOrigin(); | 549 return data_source_->HasSingleOrigin(); |
545 return true; | 550 return true; |
546 } | 551 } |
547 | 552 |
548 bool WebMediaPlayerImpl::didPassCORSAccessCheck() const { | 553 bool WebMediaPlayerImpl::didPassCORSAccessCheck() const { |
549 if (data_source_) | 554 if (data_source_) |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
644 // bound when this method is called, and only verify this fact when | 649 // bound when this method is called, and only verify this fact when |
645 // DCHECK_IS_ON. | 650 // DCHECK_IS_ON. |
646 if (DCHECK_IS_ON()) { | 651 if (DCHECK_IS_ON()) { |
647 GLint bound_texture = 0; | 652 GLint bound_texture = 0; |
648 web_graphics_context->getIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); | 653 web_graphics_context->getIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); |
649 DCHECK_EQ(static_cast<GLuint>(bound_texture), texture); | 654 DCHECK_EQ(static_cast<GLuint>(bound_texture), texture); |
650 } | 655 } |
651 | 656 |
652 uint32 source_texture = web_graphics_context->createTexture(); | 657 uint32 source_texture = web_graphics_context->createTexture(); |
653 | 658 |
654 web_graphics_context->waitSyncPoint(mailbox_holder->sync_point); | |
danakj
2014/02/28 17:49:30
Why is this gone? This sync point ensures the mail
| |
655 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture); | 659 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture); |
656 web_graphics_context->consumeTextureCHROMIUM(GL_TEXTURE_2D, | 660 web_graphics_context->consumeTextureCHROMIUM(GL_TEXTURE_2D, |
657 mailbox_holder->mailbox.name); | 661 mailbox_holder->mailbox.name); |
658 | 662 |
659 // The video is stored in a unmultiplied format, so premultiply | 663 // The video is stored in a unmultiplied format, so premultiply |
660 // if necessary. | 664 // if necessary. |
661 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 665 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
662 premultiply_alpha); | 666 premultiply_alpha); |
663 // Application itself needs to take care of setting the right flip_y | 667 // Application itself needs to take care of setting the right flip_y |
664 // value down to get the expected result. | 668 // value down to get the expected result. |
(...skipping 11 matching lines...) Expand all Loading... | |
676 false); | 680 false); |
677 | 681 |
678 // Restore the state for TEXTURE_2D binding point as mentioned above. | 682 // Restore the state for TEXTURE_2D binding point as mentioned above. |
679 web_graphics_context->bindTexture(GL_TEXTURE_2D, texture); | 683 web_graphics_context->bindTexture(GL_TEXTURE_2D, texture); |
680 | 684 |
681 web_graphics_context->deleteTexture(source_texture); | 685 web_graphics_context->deleteTexture(source_texture); |
682 | 686 |
683 // The flush() operation is not necessary here. It is kept since the | 687 // The flush() operation is not necessary here. It is kept since the |
684 // performance will be better when it is added than not. | 688 // performance will be better when it is added than not. |
685 web_graphics_context->flush(); | 689 web_graphics_context->flush(); |
690 // WebGL doesn't need to wait for the sync point of |video_frame| like | |
691 // paint(...) because |video_frame| is updated by the gpu process. | |
692 // However, it's necessary to insert a sync point because gpu video decoder | |
693 // in the render process must make sure executing all pending commands of | |
694 // WebGL before notifying reusable mailboxes to the gpu process. | |
695 video_frame->SetReleaseSyncPoint(web_graphics_context->insertSyncPoint()); | |
danakj
2014/02/28 17:49:30
While this solves the problem of two threads writi
dshwang
2014/02/28 18:01:48
you're right. GpuVideoDecoder will wait for only o
danakj
2014/02/28 18:41:19
That will work if and only if the person doing the
| |
686 return true; | 696 return true; |
687 } | 697 } |
688 | 698 |
689 // Helper functions to report media EME related stats to UMA. They follow the | 699 // Helper functions to report media EME related stats to UMA. They follow the |
690 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and | 700 // convention of more commonly used macros UMA_HISTOGRAM_ENUMERATION and |
691 // UMA_HISTOGRAM_COUNTS. The reason that we cannot use those macros directly is | 701 // UMA_HISTOGRAM_COUNTS. The reason that we cannot use those macros directly is |
692 // that UMA_* macros require the names to be constant throughout the process' | 702 // that UMA_* macros require the names to be constant throughout the process' |
693 // lifetime. | 703 // lifetime. |
694 static void EmeUMAHistogramEnumeration(const std::string& key_system, | 704 static void EmeUMAHistogramEnumeration(const std::string& key_system, |
695 const std::string& method, | 705 const std::string& method, |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1316 | 1326 |
1317 if (web_cdm_) { | 1327 if (web_cdm_) { |
1318 decryptor_ready_cb.Run(web_cdm_->GetDecryptor()); | 1328 decryptor_ready_cb.Run(web_cdm_->GetDecryptor()); |
1319 return; | 1329 return; |
1320 } | 1330 } |
1321 | 1331 |
1322 decryptor_ready_cb_ = decryptor_ready_cb; | 1332 decryptor_ready_cb_ = decryptor_ready_cb; |
1323 } | 1333 } |
1324 | 1334 |
1325 } // namespace content | 1335 } // namespace content |
OLD | NEW |