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

Unified Diff: media/filters/skcanvas_video_renderer.cc

Issue 619343003: Optimize to copy from rotated video to canvas. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/skcanvas_video_renderer.cc
diff --git a/media/filters/skcanvas_video_renderer.cc b/media/filters/skcanvas_video_renderer.cc
index 9bdd393e56c31c368b926de08be9e4e42a993382..d3b7876096bad8ad9da24c8438ca283da3779e4e 100644
--- a/media/filters/skcanvas_video_renderer.cc
+++ b/media/filters/skcanvas_video_renderer.cc
@@ -328,41 +328,39 @@ void SkCanvasVideoRenderer::Paint(const scoped_refptr<VideoFrame>& video_frame,
NOTREACHED();
}
- // TODO(rileya): Perform this rotation on the canvas, rather than allocating
- // a new bitmap and copying.
- switch (video_rotation) {
- case VIDEO_ROTATION_0:
- break;
- case VIDEO_ROTATION_90:
- last_frame_ = SkBitmapOperations::Rotate(
- last_frame_, SkBitmapOperations::ROTATION_90_CW);
- break;
- case VIDEO_ROTATION_180:
- last_frame_ = SkBitmapOperations::Rotate(
- last_frame_, SkBitmapOperations::ROTATION_180_CW);
- break;
- case VIDEO_ROTATION_270:
- last_frame_ = SkBitmapOperations::Rotate(
- last_frame_, SkBitmapOperations::ROTATION_270_CW);
- break;
- }
-
- // We copied the frame into a new bitmap and threw out the old one, so we
- // no longer have a |generator_| around. This should be removed when the
- // above TODO is addressed.
- if (video_rotation != VIDEO_ROTATION_0)
- generator_ = NULL;
-
last_frame_timestamp_ = video_frame->timestamp();
} else if (generator_) {
generator_->set_frame(video_frame);
}
paint.setXfermodeMode(mode);
-
- // Paint using |last_frame_|.
paint.setFilterLevel(SkPaint::kLow_FilterLevel);
- canvas->drawBitmapRect(last_frame_, NULL, dest, &paint);
+
+ SkScalar angle = SkFloatToScalar(0.0f);
+ switch (video_rotation) {
+ case VIDEO_ROTATION_0:
+ break;
+ case VIDEO_ROTATION_90:
+ angle = SkFloatToScalar(90.0f);
+ break;
+ case VIDEO_ROTATION_180:
+ angle = SkFloatToScalar(180.0f);
+ break;
+ case VIDEO_ROTATION_270:
+ angle = SkFloatToScalar(270.0f);
+ break;
+ }
+ if (video_rotation != VIDEO_ROTATION_0) {
+ canvas->save();
+ canvas->translate(SkFloatToScalar(dest_rect.width() * 0.5f),
+ SkFloatToScalar(dest_rect.height() * 0.5f));
+ canvas->rotate(angle);
+ canvas->translate(-SkFloatToScalar(dest_rect.width() * 0.5f),
+ -SkFloatToScalar(dest_rect.height() * 0.5f));
+ }
+ canvas->drawBitmap(last_frame_, 0, 0, &paint);
+ if (video_rotation != VIDEO_ROTATION_0)
+ canvas->restore();
dshwang 2014/10/02 19:17:30 This code is almost copy&paste from https://code.g
canvas->flush();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698