| 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_ms.h" | 5 #include "content/renderer/media/webmediaplayer_ms.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "cc/blink/web_layer_impl.h" | 13 #include "cc/blink/web_layer_impl.h" |
| 14 #include "cc/layers/video_layer.h" | 14 #include "cc/layers/video_layer.h" |
| 15 #include "content/public/renderer/render_view.h" | 15 #include "content/public/renderer/render_view.h" |
| 16 #include "content/renderer/media/media_stream_audio_renderer.h" | 16 #include "content/renderer/media/media_stream_audio_renderer.h" |
| 17 #include "content/renderer/media/media_stream_renderer_factory.h" | 17 #include "content/renderer/media/media_stream_renderer_factory.h" |
| 18 #include "content/renderer/media/video_frame_provider.h" | 18 #include "content/renderer/media/video_frame_provider.h" |
| 19 #include "content/renderer/render_frame_impl.h" | 19 #include "content/renderer/render_frame_impl.h" |
| 20 #include "content/renderer/render_thread_impl.h" |
| 20 #include "media/base/media_log.h" | 21 #include "media/base/media_log.h" |
| 21 #include "media/base/video_frame.h" | 22 #include "media/base/video_frame.h" |
| 22 #include "media/base/video_rotation.h" | 23 #include "media/base/video_rotation.h" |
| 23 #include "media/base/video_util.h" | 24 #include "media/base/video_util.h" |
| 24 #include "media/blink/webmediaplayer_delegate.h" | 25 #include "media/blink/webmediaplayer_delegate.h" |
| 25 #include "media/blink/webmediaplayer_util.h" | 26 #include "media/blink/webmediaplayer_util.h" |
| 26 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" | 27 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" |
| 27 #include "third_party/WebKit/public/platform/WebRect.h" | 28 #include "third_party/WebKit/public/platform/WebRect.h" |
| 28 #include "third_party/WebKit/public/platform/WebSize.h" | 29 #include "third_party/WebKit/public/platform/WebSize.h" |
| 29 #include "third_party/WebKit/public/platform/WebURL.h" | 30 #include "third_party/WebKit/public/platform/WebURL.h" |
| 30 #include "third_party/WebKit/public/web/WebFrame.h" | 31 #include "third_party/WebKit/public/web/WebFrame.h" |
| 31 #include "third_party/WebKit/public/web/WebView.h" | 32 #include "third_party/WebKit/public/web/WebView.h" |
| 32 #include "third_party/skia/include/core/SkBitmap.h" | 33 #include "third_party/skia/include/core/SkBitmap.h" |
| 34 #include "webkit/common/gpu/context_provider_web_context.h" |
| 33 | 35 |
| 34 using blink::WebCanvas; | 36 using blink::WebCanvas; |
| 35 using blink::WebMediaPlayer; | 37 using blink::WebMediaPlayer; |
| 36 using blink::WebRect; | 38 using blink::WebRect; |
| 37 using blink::WebSize; | 39 using blink::WebSize; |
| 38 | 40 |
| 39 namespace { | 41 namespace { |
| 40 | 42 |
| 41 // This function copies a YV12 or NATIVE_TEXTURE to a new YV12 | 43 // This function copies a YV12 or NATIVE_TEXTURE to a new YV12 |
| 42 // media::VideoFrame. | 44 // media::VideoFrame. |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 return true; | 321 return true; |
| 320 } | 322 } |
| 321 | 323 |
| 322 void WebMediaPlayerMS::paint(blink::WebCanvas* canvas, | 324 void WebMediaPlayerMS::paint(blink::WebCanvas* canvas, |
| 323 const blink::WebRect& rect, | 325 const blink::WebRect& rect, |
| 324 unsigned char alpha, | 326 unsigned char alpha, |
| 325 SkXfermode::Mode mode) { | 327 SkXfermode::Mode mode) { |
| 326 DVLOG(3) << "WebMediaPlayerMS::paint"; | 328 DVLOG(3) << "WebMediaPlayerMS::paint"; |
| 327 DCHECK(thread_checker_.CalledOnValidThread()); | 329 DCHECK(thread_checker_.CalledOnValidThread()); |
| 328 | 330 |
| 331 media::Context3D context_3d; |
| 332 if (current_frame_.get() && |
| 333 current_frame_->format() == media::VideoFrame::NATIVE_TEXTURE) { |
| 334 cc::ContextProvider* provider = |
| 335 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); |
| 336 // GPU Process crashed. |
| 337 if (!provider) |
| 338 return; |
| 339 context_3d = media::Context3D(provider->ContextGL(), provider->GrContext()); |
| 340 DCHECK(context_3d.gl); |
| 341 } |
| 329 gfx::RectF dest_rect(rect.x, rect.y, rect.width, rect.height); | 342 gfx::RectF dest_rect(rect.x, rect.y, rect.width, rect.height); |
| 330 video_renderer_.Paint(current_frame_, canvas, dest_rect, alpha, mode, | 343 video_renderer_.Paint(current_frame_, canvas, dest_rect, alpha, mode, |
| 331 media::VIDEO_ROTATION_0, media::Context3D()); | 344 media::VIDEO_ROTATION_0, context_3d); |
| 332 | 345 |
| 333 { | 346 { |
| 334 base::AutoLock auto_lock(current_frame_lock_); | 347 base::AutoLock auto_lock(current_frame_lock_); |
| 335 if (current_frame_.get()) | 348 if (current_frame_.get()) |
| 336 current_frame_used_ = true; | 349 current_frame_used_ = true; |
| 337 } | 350 } |
| 338 } | 351 } |
| 339 | 352 |
| 340 bool WebMediaPlayerMS::hasSingleSecurityOrigin() const { | 353 bool WebMediaPlayerMS::hasSingleSecurityOrigin() const { |
| 341 DCHECK(thread_checker_.CalledOnValidThread()); | 354 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 GetClient()->readyStateChanged(); | 488 GetClient()->readyStateChanged(); |
| 476 } | 489 } |
| 477 | 490 |
| 478 blink::WebMediaPlayerClient* WebMediaPlayerMS::GetClient() { | 491 blink::WebMediaPlayerClient* WebMediaPlayerMS::GetClient() { |
| 479 DCHECK(thread_checker_.CalledOnValidThread()); | 492 DCHECK(thread_checker_.CalledOnValidThread()); |
| 480 DCHECK(client_); | 493 DCHECK(client_); |
| 481 return client_; | 494 return client_; |
| 482 } | 495 } |
| 483 | 496 |
| 484 } // namespace content | 497 } // namespace content |
| OLD | NEW |