| 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 18 matching lines...) Expand all Loading... |
| 29 #include "content/renderer/media/webaudiosourceprovider_impl.h" | 29 #include "content/renderer/media/webaudiosourceprovider_impl.h" |
| 30 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" | 30 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" |
| 31 #include "content/renderer/media/webinbandtexttrack_impl.h" | 31 #include "content/renderer/media/webinbandtexttrack_impl.h" |
| 32 #include "content/renderer/media/webmediaplayer_delegate.h" | 32 #include "content/renderer/media/webmediaplayer_delegate.h" |
| 33 #include "content/renderer/media/webmediaplayer_params.h" | 33 #include "content/renderer/media/webmediaplayer_params.h" |
| 34 #include "content/renderer/media/webmediaplayer_util.h" | 34 #include "content/renderer/media/webmediaplayer_util.h" |
| 35 #include "content/renderer/media/webmediasource_impl.h" | 35 #include "content/renderer/media/webmediasource_impl.h" |
| 36 #include "content/renderer/pepper/pepper_webplugin_impl.h" | 36 #include "content/renderer/pepper/pepper_webplugin_impl.h" |
| 37 #include "content/renderer/render_thread_impl.h" | 37 #include "content/renderer/render_thread_impl.h" |
| 38 #include "gpu/GLES2/gl2extchromium.h" | 38 #include "gpu/GLES2/gl2extchromium.h" |
| 39 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 39 #include "media/audio/null_audio_sink.h" | 40 #include "media/audio/null_audio_sink.h" |
| 40 #include "media/base/bind_to_current_loop.h" | 41 #include "media/base/bind_to_current_loop.h" |
| 41 #include "media/base/filter_collection.h" | 42 #include "media/base/filter_collection.h" |
| 42 #include "media/base/limits.h" | 43 #include "media/base/limits.h" |
| 43 #include "media/base/media_log.h" | 44 #include "media/base/media_log.h" |
| 44 #include "media/base/media_switches.h" | 45 #include "media/base/media_switches.h" |
| 45 #include "media/base/pipeline.h" | 46 #include "media/base/pipeline.h" |
| 46 #include "media/base/text_renderer.h" | 47 #include "media/base/text_renderer.h" |
| 47 #include "media/base/video_frame.h" | 48 #include "media/base/video_frame.h" |
| 48 #include "media/filters/audio_renderer_impl.h" | 49 #include "media/filters/audio_renderer_impl.h" |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 bool flip_y) { | 599 bool flip_y) { |
| 599 scoped_refptr<media::VideoFrame> video_frame = | 600 scoped_refptr<media::VideoFrame> video_frame = |
| 600 painter_.GetCurrentFrame(false); | 601 painter_.GetCurrentFrame(false); |
| 601 | 602 |
| 602 TRACE_EVENT0("media", "WebMediaPlayerImpl:copyVideoTextureToPlatformTexture"); | 603 TRACE_EVENT0("media", "WebMediaPlayerImpl:copyVideoTextureToPlatformTexture"); |
| 603 | 604 |
| 604 if (!video_frame) | 605 if (!video_frame) |
| 605 return false; | 606 return false; |
| 606 if (video_frame->format() != media::VideoFrame::NATIVE_TEXTURE) | 607 if (video_frame->format() != media::VideoFrame::NATIVE_TEXTURE) |
| 607 return false; | 608 return false; |
| 608 if (video_frame->texture_target() != GL_TEXTURE_2D) | 609 |
| 610 gpu::MailboxHolder* mailbox_holder = video_frame->mailbox_holder(); |
| 611 if (mailbox_holder->texture_target != GL_TEXTURE_2D) |
| 609 return false; | 612 return false; |
| 610 | 613 |
| 611 // Since this method changes which texture is bound to the TEXTURE_2D target, | 614 // Since this method changes which texture is bound to the TEXTURE_2D target, |
| 612 // ideally it would restore the currently-bound texture before returning. | 615 // ideally it would restore the currently-bound texture before returning. |
| 613 // The cost of getIntegerv is sufficiently high, however, that we want to | 616 // The cost of getIntegerv is sufficiently high, however, that we want to |
| 614 // avoid it in user builds. As a result assume (below) that |texture| is | 617 // avoid it in user builds. As a result assume (below) that |texture| is |
| 615 // bound when this method is called, and only verify this fact when | 618 // bound when this method is called, and only verify this fact when |
| 616 // DCHECK_IS_ON. | 619 // DCHECK_IS_ON. |
| 617 if (DCHECK_IS_ON()) { | 620 if (DCHECK_IS_ON()) { |
| 618 GLint bound_texture = 0; | 621 GLint bound_texture = 0; |
| 619 web_graphics_context->getIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); | 622 web_graphics_context->getIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); |
| 620 DCHECK_EQ(static_cast<GLuint>(bound_texture), texture); | 623 DCHECK_EQ(static_cast<GLuint>(bound_texture), texture); |
| 621 } | 624 } |
| 622 | 625 |
| 623 media::VideoFrame::MailboxHolder* mailbox_holder = | |
| 624 video_frame->texture_mailbox(); | |
| 625 | |
| 626 uint32 source_texture = web_graphics_context->createTexture(); | 626 uint32 source_texture = web_graphics_context->createTexture(); |
| 627 | 627 |
| 628 web_graphics_context->waitSyncPoint(mailbox_holder->sync_point()); | 628 web_graphics_context->waitSyncPoint(mailbox_holder->sync_point); |
| 629 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture); | 629 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture); |
| 630 web_graphics_context->consumeTextureCHROMIUM(GL_TEXTURE_2D, | 630 web_graphics_context->consumeTextureCHROMIUM(GL_TEXTURE_2D, |
| 631 mailbox_holder->mailbox().name); | 631 mailbox_holder->mailbox.name); |
| 632 | 632 |
| 633 // The video is stored in a unmultiplied format, so premultiply | 633 // The video is stored in a unmultiplied format, so premultiply |
| 634 // if necessary. | 634 // if necessary. |
| 635 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 635 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
| 636 premultiply_alpha); | 636 premultiply_alpha); |
| 637 // Application itself needs to take care of setting the right flip_y | 637 // Application itself needs to take care of setting the right flip_y |
| 638 // value down to get the expected result. | 638 // value down to get the expected result. |
| 639 // flip_y==true means to reverse the video orientation while | 639 // flip_y==true means to reverse the video orientation while |
| 640 // flip_y==false means to keep the intrinsic orientation. | 640 // flip_y==false means to keep the intrinsic orientation. |
| 641 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); | 641 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 | 1308 |
| 1309 if (web_cdm_) { | 1309 if (web_cdm_) { |
| 1310 decryptor_ready_cb.Run(web_cdm_->GetDecryptor()); | 1310 decryptor_ready_cb.Run(web_cdm_->GetDecryptor()); |
| 1311 return; | 1311 return; |
| 1312 } | 1312 } |
| 1313 | 1313 |
| 1314 decryptor_ready_cb_ = decryptor_ready_cb; | 1314 decryptor_ready_cb_ = decryptor_ready_cb; |
| 1315 } | 1315 } |
| 1316 | 1316 |
| 1317 } // namespace content | 1317 } // namespace content |
| OLD | NEW |