Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: media/filters/skcanvas_video_renderer.cc

Issue 850993002: gpu video: optimize HW video to SW canvas and implement it for WebRTC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/filters/skcanvas_video_renderer.cc
diff --git a/media/filters/skcanvas_video_renderer.cc b/media/filters/skcanvas_video_renderer.cc
index 465d1f0a628cc7b11490b71be7dfabf2cea56863..bec2a38a2cb68ede0ac23ef8d65ee7e0a82e088f 100644
--- a/media/filters/skcanvas_video_renderer.cc
+++ b/media/filters/skcanvas_video_renderer.cc
@@ -203,17 +203,9 @@ void ConvertVideoFrameToRGBPixels(
#endif
break;
- case media::VideoFrame::NATIVE_TEXTURE: {
- SkBitmap tmp;
- tmp.installPixels(
- SkImageInfo::MakeN32Premul(video_frame->visible_rect().width(),
- video_frame->visible_rect().height()),
- rgb_pixels,
- row_bytes);
- video_frame->ReadPixelsFromNativeTexture(tmp);
dshwang 2015/01/14 20:32:13 Remove this complicated ReadPixel callback impleme
+ case media::VideoFrame::NATIVE_TEXTURE:
+ NOTREACHED();
break;
- }
-
case media::VideoFrame::ARGB:
default:
NOTREACHED();
@@ -276,6 +268,7 @@ bool CopyVideoFrameTextureToSkBitmapTexture(VideoFrame* video_frame,
SkCanvasVideoRenderer::CopyVideoFrameTextureToGLTexture(
context_3d.gl, video_frame, texture_id, 0, GL_RGBA, GL_UNSIGNED_BYTE,
true, false);
+ bitmap->notifyPixelsChanged();
return true;
}
@@ -425,24 +418,38 @@ void SkCanvasVideoRenderer::Paint(const scoped_refptr<VideoFrame>& video_frame,
}
SkBitmap* target_frame = nullptr;
- if (canvas->getGrContext()) {
+
+ if (video_frame->format() == VideoFrame::NATIVE_TEXTURE) {
+ // Draw HW Video on both SW and HW Canvas.
+ // In SW Canvas case, rely on skia drawing Ganesh SkBitmap on SW SkCanvas.
dshwang 2015/01/14 20:32:13 As comment mentions, drawing ganesh SkBitmap on Sw
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);
- 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();
- return;
- }
- } else {
+ DCHECK(context_3d.gl);
+ DCHECK(context_3d.gr_context);
+ 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();
+ return;
+ }
+ DCHECK(video_frame->visible_rect().width() ==
+ accelerated_last_frame_.width() &&
+ video_frame->visible_rect().height() ==
+ accelerated_last_frame_.height());
+
+ accelerated_last_frame_timestamp_ = video_frame->timestamp();
+ }
+ target_frame = &accelerated_last_frame_;
+ accelerated_frame_deleting_timer_.Reset();
+ } else if (canvas->getGrContext()) {
+ DCHECK(video_frame->format() != VideoFrame::NATIVE_TEXTURE);
+ if (accelerated_last_frame_.isNull() ||
+ video_frame->timestamp() != accelerated_last_frame_timestamp_) {
+ {
// Draw SW Video on HW Canvas.
if (!accelerated_generator_ && !accelerated_last_frame_.isNull()) {
// Reset SkBitmap used in HWVideo-to-HWCanvas path.
@@ -469,7 +476,8 @@ void SkCanvasVideoRenderer::Paint(const scoped_refptr<VideoFrame>& video_frame,
target_frame = &accelerated_last_frame_;
accelerated_frame_deleting_timer_.Reset();
} else {
- // Draw both SW and HW Video on SW Canvas.
+ // Draw SW Video on SW Canvas.
+ DCHECK(video_frame->format() != VideoFrame::NATIVE_TEXTURE);
if (last_frame_.isNull() ||
video_frame->timestamp() != last_frame_timestamp_) {
// Check if |bitmap| needs to be (re)allocated.
@@ -542,9 +550,10 @@ void SkCanvasVideoRenderer::Paint(const scoped_refptr<VideoFrame>& video_frame,
}
void SkCanvasVideoRenderer::Copy(const scoped_refptr<VideoFrame>& video_frame,
- SkCanvas* canvas) {
+ SkCanvas* canvas,
+ const Context3D& context_3d) {
Paint(video_frame, canvas, video_frame->visible_rect(), 0xff,
- SkXfermode::kSrc_Mode, media::VIDEO_ROTATION_0, Context3D());
+ SkXfermode::kSrc_Mode, media::VIDEO_ROTATION_0, context_3d);
}
// static

Powered by Google App Engine
This is Rietveld 408576698