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" |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } | 404 } |
405 | 405 |
406 bool WebMediaPlayerMS::copyVideoTextureToPlatformTexture( | 406 bool WebMediaPlayerMS::copyVideoTextureToPlatformTexture( |
407 blink::WebGraphicsContext3D* web_graphics_context, | 407 blink::WebGraphicsContext3D* web_graphics_context, |
408 unsigned int texture, | 408 unsigned int texture, |
409 unsigned int level, | 409 unsigned int level, |
410 unsigned int internal_format, | 410 unsigned int internal_format, |
411 unsigned int type, | 411 unsigned int type, |
412 bool premultiply_alpha, | 412 bool premultiply_alpha, |
413 bool flip_y) { | 413 bool flip_y) { |
| 414 return copyVideoTextureToPlatformTexture(web_graphics_context, texture, |
| 415 internal_format, type, |
| 416 premultiply_alpha, flip_y); |
| 417 } |
| 418 |
| 419 bool WebMediaPlayerMS::copyVideoTextureToPlatformTexture( |
| 420 blink::WebGraphicsContext3D* web_graphics_context, |
| 421 unsigned int texture, |
| 422 unsigned int internal_format, |
| 423 unsigned int type, |
| 424 bool premultiply_alpha, |
| 425 bool flip_y) { |
414 TRACE_EVENT0("media", "WebMediaPlayerMS:copyVideoTextureToPlatformTexture"); | 426 TRACE_EVENT0("media", "WebMediaPlayerMS:copyVideoTextureToPlatformTexture"); |
415 DCHECK(thread_checker_.CalledOnValidThread()); | 427 DCHECK(thread_checker_.CalledOnValidThread()); |
416 | 428 |
417 scoped_refptr<media::VideoFrame> video_frame; | 429 scoped_refptr<media::VideoFrame> video_frame; |
418 { | 430 { |
419 base::AutoLock auto_lock(current_frame_lock_); | 431 base::AutoLock auto_lock(current_frame_lock_); |
420 video_frame = current_frame_; | 432 video_frame = current_frame_; |
421 } | 433 } |
422 | 434 |
423 if (!video_frame.get() || | 435 if (!video_frame.get() || |
424 video_frame->format() != media::VideoFrame::NATIVE_TEXTURE) { | 436 video_frame->format() != media::VideoFrame::NATIVE_TEXTURE) { |
425 return false; | 437 return false; |
426 } | 438 } |
427 | 439 |
428 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to | 440 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to |
429 // GLES2Interface. | 441 // GLES2Interface. |
430 gpu::gles2::GLES2Interface* gl = | 442 gpu::gles2::GLES2Interface* gl = |
431 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) | 443 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) |
432 ->GetGLInterface(); | 444 ->GetGLInterface(); |
433 media::SkCanvasVideoRenderer::CopyVideoFrameTextureToGLTexture( | 445 media::SkCanvasVideoRenderer::CopyVideoFrameTextureToGLTexture( |
434 gl, video_frame.get(), texture, level, internal_format, type, | 446 gl, video_frame.get(), texture, internal_format, type, premultiply_alpha, |
435 premultiply_alpha, flip_y); | 447 flip_y); |
436 return true; | 448 return true; |
437 } | 449 } |
438 | 450 |
439 void WebMediaPlayerMS::SetVideoFrameProviderClient( | 451 void WebMediaPlayerMS::SetVideoFrameProviderClient( |
440 cc::VideoFrameProvider::Client* client) { | 452 cc::VideoFrameProvider::Client* client) { |
441 // This is called from both the main renderer thread and the compositor | 453 // This is called from both the main renderer thread and the compositor |
442 // thread (when the main thread is blocked). | 454 // thread (when the main thread is blocked). |
443 if (video_frame_provider_client_) | 455 if (video_frame_provider_client_) |
444 video_frame_provider_client_->StopUsingProvider(); | 456 video_frame_provider_client_->StopUsingProvider(); |
445 video_frame_provider_client_ = client; | 457 video_frame_provider_client_ = client; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 GetClient()->readyStateChanged(); | 548 GetClient()->readyStateChanged(); |
537 } | 549 } |
538 | 550 |
539 blink::WebMediaPlayerClient* WebMediaPlayerMS::GetClient() { | 551 blink::WebMediaPlayerClient* WebMediaPlayerMS::GetClient() { |
540 DCHECK(thread_checker_.CalledOnValidThread()); | 552 DCHECK(thread_checker_.CalledOnValidThread()); |
541 DCHECK(client_); | 553 DCHECK(client_); |
542 return client_; | 554 return client_; |
543 } | 555 } |
544 | 556 |
545 } // namespace content | 557 } // namespace content |
OLD | NEW |