From 8d78aa3cd5d34bb154aa7a832e0be8a6d7397af6 Mon Sep 17 00:00:00 2001 From: "dongseong.hwang" Date: Wed, 14 Jan 2015 05:42:09 -0800 Subject: [PATCH] WebRTC: One WebRTC Video can have both SW and HW VideoFrame. SkCanvasVideoRenderer assumes that the VideoFrames belonging to one WebRTC video are always either software VideoFrame or hardware VideoFrame. However, it's not true. VideoFrame can be changed each frame. TEST=content_browsertests WebRtcBrowserTest.CallAndVerify* on Nexus5 BUG=448014 Review URL: https://codereview.chromium.org/848683003 Cr-Commit-Position: refs/heads/master@{#311468} --- media/filters/skcanvas_video_renderer.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/media/filters/skcanvas_video_renderer.cc b/media/filters/skcanvas_video_renderer.cc index da1c4de8febd..465d1f0a628c 100644 --- a/media/filters/skcanvas_video_renderer.cc +++ b/media/filters/skcanvas_video_renderer.cc @@ -429,10 +429,14 @@ void SkCanvasVideoRenderer::Paint(const scoped_refptr& video_frame, if (accelerated_last_frame_.isNull() || video_frame->timestamp() != accelerated_last_frame_timestamp_) { if (video_frame->format() == VideoFrame::NATIVE_TEXTURE) { + // Draw HW Video on HW Canvas. DCHECK(context_3d.gl); DCHECK(context_3d.gr_context); - // Draw HW Video on HW Canvas. - DCHECK(!accelerated_generator_); + if (accelerated_generator_) { + // Reset SkBitmap used in SWVideo-to-HWCanvas path. + accelerated_last_frame_.reset(); + accelerated_generator_ = nullptr; + } if (!CopyVideoFrameTextureToSkBitmapTexture( video_frame.get(), &accelerated_last_frame_, context_3d)) { NOTREACHED(); @@ -440,6 +444,10 @@ void SkCanvasVideoRenderer::Paint(const scoped_refptr& video_frame, } } else { // Draw SW Video on HW Canvas. + if (!accelerated_generator_ && !accelerated_last_frame_.isNull()) { + // Reset SkBitmap used in HWVideo-to-HWCanvas path. + accelerated_last_frame_.reset(); + } accelerated_generator_ = new VideoImageGenerator(video_frame); // Note: This takes ownership of |accelerated_generator_|. -- 2.11.4.GIT