| 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 15 matching lines...) Expand all Loading... |
| 26 #include "content/renderer/media/texttrack_impl.h" | 26 #include "content/renderer/media/texttrack_impl.h" |
| 27 #include "content/renderer/media/webaudiosourceprovider_impl.h" | 27 #include "content/renderer/media/webaudiosourceprovider_impl.h" |
| 28 #include "content/renderer/media/webinbandtexttrack_impl.h" | 28 #include "content/renderer/media/webinbandtexttrack_impl.h" |
| 29 #include "content/renderer/media/webmediaplayer_delegate.h" | 29 #include "content/renderer/media/webmediaplayer_delegate.h" |
| 30 #include "content/renderer/media/webmediaplayer_params.h" | 30 #include "content/renderer/media/webmediaplayer_params.h" |
| 31 #include "content/renderer/media/webmediaplayer_util.h" | 31 #include "content/renderer/media/webmediaplayer_util.h" |
| 32 #include "content/renderer/media/webmediasource_impl.h" | 32 #include "content/renderer/media/webmediasource_impl.h" |
| 33 #include "content/renderer/pepper/pepper_webplugin_impl.h" | 33 #include "content/renderer/pepper/pepper_webplugin_impl.h" |
| 34 #include "content/renderer/render_thread_impl.h" | 34 #include "content/renderer/render_thread_impl.h" |
| 35 #include "gpu/GLES2/gl2extchromium.h" | 35 #include "gpu/GLES2/gl2extchromium.h" |
| 36 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 36 #include "media/audio/null_audio_sink.h" | 37 #include "media/audio/null_audio_sink.h" |
| 37 #include "media/base/bind_to_loop.h" | 38 #include "media/base/bind_to_loop.h" |
| 38 #include "media/base/filter_collection.h" | 39 #include "media/base/filter_collection.h" |
| 39 #include "media/base/limits.h" | 40 #include "media/base/limits.h" |
| 40 #include "media/base/media_log.h" | 41 #include "media/base/media_log.h" |
| 41 #include "media/base/media_switches.h" | 42 #include "media/base/media_switches.h" |
| 42 #include "media/base/pipeline.h" | 43 #include "media/base/pipeline.h" |
| 43 #include "media/base/text_renderer.h" | 44 #include "media/base/text_renderer.h" |
| 44 #include "media/base/video_frame.h" | 45 #include "media/base/video_frame.h" |
| 45 #include "media/filters/audio_renderer_impl.h" | 46 #include "media/filters/audio_renderer_impl.h" |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 base::AutoLock auto_lock(lock_); | 628 base::AutoLock auto_lock(lock_); |
| 628 video_frame = current_frame_; | 629 video_frame = current_frame_; |
| 629 } | 630 } |
| 630 | 631 |
| 631 TRACE_EVENT0("media", "WebMediaPlayerImpl:copyVideoTextureToPlatformTexture"); | 632 TRACE_EVENT0("media", "WebMediaPlayerImpl:copyVideoTextureToPlatformTexture"); |
| 632 | 633 |
| 633 if (!video_frame) | 634 if (!video_frame) |
| 634 return false; | 635 return false; |
| 635 if (video_frame->format() != media::VideoFrame::NATIVE_TEXTURE) | 636 if (video_frame->format() != media::VideoFrame::NATIVE_TEXTURE) |
| 636 return false; | 637 return false; |
| 637 if (video_frame->texture_target() != GL_TEXTURE_2D) | 638 |
| 639 gpu::MailboxHolder* mailbox_holder = video_frame->mailbox_holder(); |
| 640 if (mailbox_holder->texture_target != GL_TEXTURE_2D) |
| 638 return false; | 641 return false; |
| 639 | 642 |
| 640 // Since this method changes which texture is bound to the TEXTURE_2D target, | 643 // Since this method changes which texture is bound to the TEXTURE_2D target, |
| 641 // ideally it would restore the currently-bound texture before returning. | 644 // ideally it would restore the currently-bound texture before returning. |
| 642 // The cost of getIntegerv is sufficiently high, however, that we want to | 645 // The cost of getIntegerv is sufficiently high, however, that we want to |
| 643 // avoid it in user builds. As a result assume (below) that |texture| is | 646 // avoid it in user builds. As a result assume (below) that |texture| is |
| 644 // bound when this method is called, and only verify this fact when | 647 // bound when this method is called, and only verify this fact when |
| 645 // DCHECK_IS_ON. | 648 // DCHECK_IS_ON. |
| 646 if (DCHECK_IS_ON()) { | 649 if (DCHECK_IS_ON()) { |
| 647 GLint bound_texture = 0; | 650 GLint bound_texture = 0; |
| 648 web_graphics_context->getIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); | 651 web_graphics_context->getIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); |
| 649 DCHECK_EQ(static_cast<GLuint>(bound_texture), texture); | 652 DCHECK_EQ(static_cast<GLuint>(bound_texture), texture); |
| 650 } | 653 } |
| 651 | 654 |
| 652 media::VideoFrame::MailboxHolder* mailbox_holder = | |
| 653 video_frame->texture_mailbox(); | |
| 654 | |
| 655 uint32 source_texture = web_graphics_context->createTexture(); | 655 uint32 source_texture = web_graphics_context->createTexture(); |
| 656 | 656 |
| 657 web_graphics_context->waitSyncPoint(mailbox_holder->sync_point()); | 657 web_graphics_context->waitSyncPoint(mailbox_holder->sync_point); |
| 658 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture); | 658 web_graphics_context->bindTexture(GL_TEXTURE_2D, source_texture); |
| 659 web_graphics_context->consumeTextureCHROMIUM(GL_TEXTURE_2D, | 659 web_graphics_context->consumeTextureCHROMIUM(GL_TEXTURE_2D, |
| 660 mailbox_holder->mailbox().name); | 660 mailbox_holder->mailbox.name); |
| 661 | 661 |
| 662 // The video is stored in a unmultiplied format, so premultiply | 662 // The video is stored in a unmultiplied format, so premultiply |
| 663 // if necessary. | 663 // if necessary. |
| 664 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | 664 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, |
| 665 premultiply_alpha); | 665 premultiply_alpha); |
| 666 // Application itself needs to take care of setting the right flip_y | 666 // Application itself needs to take care of setting the right flip_y |
| 667 // value down to get the expected result. | 667 // value down to get the expected result. |
| 668 // flip_y==true means to reverse the video orientation while | 668 // flip_y==true means to reverse the video orientation while |
| 669 // flip_y==false means to keep the intrinsic orientation. | 669 // flip_y==false means to keep the intrinsic orientation. |
| 670 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); | 670 web_graphics_context->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 // The |current_frame_| wasn't painted, it is being replaced, and we haven't | 1302 // The |current_frame_| wasn't painted, it is being replaced, and we haven't |
| 1303 // even gotten the chance to request a repaint for it yet. Mark it as dropped. | 1303 // even gotten the chance to request a repaint for it yet. Mark it as dropped. |
| 1304 TRACE_EVENT0("media", "WebMediaPlayerImpl:frameDropped"); | 1304 TRACE_EVENT0("media", "WebMediaPlayerImpl:frameDropped"); |
| 1305 DVLOG(1) << "Frame dropped before being painted: " | 1305 DVLOG(1) << "Frame dropped before being painted: " |
| 1306 << current_frame_->GetTimestamp().InSecondsF(); | 1306 << current_frame_->GetTimestamp().InSecondsF(); |
| 1307 if (frames_dropped_before_paint_ < kuint32max) | 1307 if (frames_dropped_before_paint_ < kuint32max) |
| 1308 frames_dropped_before_paint_++; | 1308 frames_dropped_before_paint_++; |
| 1309 } | 1309 } |
| 1310 | 1310 |
| 1311 } // namespace content | 1311 } // namespace content |
| OLD | NEW |