| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 // GPU Process crashed. | 475 // GPU Process crashed. |
| 476 if (!provider) | 476 if (!provider) |
| 477 return false; | 477 return false; |
| 478 context_3d = media::Context3D(provider->ContextGL(), provider->GrContext()); | 478 context_3d = media::Context3D(provider->ContextGL(), provider->GrContext()); |
| 479 DCHECK(context_3d.gl); | 479 DCHECK(context_3d.gl); |
| 480 return video_renderer_.CopyVideoFrameTexturesToGLTexture( | 480 return video_renderer_.CopyVideoFrameTexturesToGLTexture( |
| 481 context_3d, gl, video_frame.get(), texture, internal_format, type, | 481 context_3d, gl, video_frame.get(), texture, internal_format, type, |
| 482 premultiply_alpha, flip_y); | 482 premultiply_alpha, flip_y); |
| 483 } | 483 } |
| 484 | 484 |
| 485 bool WebMediaPlayerMS::texImageImpl(TexImageFunctionID functionID, |
| 486 unsigned target, |
| 487 gpu::gles2::GLES2Interface* gl, |
| 488 int level, |
| 489 int internalformat, |
| 490 unsigned format, |
| 491 unsigned type, |
| 492 int xoffset, |
| 493 int yoffset, |
| 494 int zoffset, |
| 495 bool flip_y, |
| 496 bool premultiply_alpha) { |
| 497 TRACE_EVENT0("media", "WebMediaPlayerMS:texImageImpl"); |
| 498 DCHECK(thread_checker_.CalledOnValidThread()); |
| 499 |
| 500 const scoped_refptr<media::VideoFrame> video_frame = |
| 501 compositor_->GetCurrentFrameWithoutUpdatingStatistics(); |
| 502 if (!video_frame || !video_frame->IsMappable() || |
| 503 video_frame->HasTextures() || |
| 504 media::VideoFrame::NumPlanes(video_frame->format()) != 1) { |
| 505 return false; |
| 506 } |
| 507 |
| 508 if (functionID == TexImage2D) { |
| 509 return media::SkCanvasVideoRenderer::TexImage2D( |
| 510 target, gl, video_frame.get(), level, internalformat, format, type, |
| 511 flip_y, premultiply_alpha); |
| 512 } else if (functionID == TexSubImage2D) { |
| 513 return media::SkCanvasVideoRenderer::TexSubImage2D( |
| 514 target, gl, video_frame.get(), level, format, type, xoffset, yoffset, |
| 515 flip_y, premultiply_alpha); |
| 516 } |
| 517 return false; |
| 518 } |
| 519 |
| 485 void WebMediaPlayerMS::OnFrameAvailable( | 520 void WebMediaPlayerMS::OnFrameAvailable( |
| 486 const scoped_refptr<media::VideoFrame>& frame) { | 521 const scoped_refptr<media::VideoFrame>& frame) { |
| 487 DVLOG(3) << __func__; | 522 DVLOG(3) << __func__; |
| 488 DCHECK(thread_checker_.CalledOnValidThread()); | 523 DCHECK(thread_checker_.CalledOnValidThread()); |
| 489 | 524 |
| 490 if (render_frame_suspended_) | 525 if (render_frame_suspended_) |
| 491 return; | 526 return; |
| 492 | 527 |
| 493 base::TimeTicks render_time; | 528 base::TimeTicks render_time; |
| 494 if (frame->metadata()->GetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME, | 529 if (frame->metadata()->GetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 void WebMediaPlayerMS::ResetCanvasCache() { | 596 void WebMediaPlayerMS::ResetCanvasCache() { |
| 562 DCHECK(thread_checker_.CalledOnValidThread()); | 597 DCHECK(thread_checker_.CalledOnValidThread()); |
| 563 video_renderer_.ResetCache(); | 598 video_renderer_.ResetCache(); |
| 564 } | 599 } |
| 565 | 600 |
| 566 void WebMediaPlayerMS::TriggerResize() { | 601 void WebMediaPlayerMS::TriggerResize() { |
| 567 get_client()->sizeChanged(); | 602 get_client()->sizeChanged(); |
| 568 } | 603 } |
| 569 | 604 |
| 570 } // namespace content | 605 } // namespace content |
| OLD | NEW |