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

Unified Diff: cc/resources/media/skcanvas_video_renderer.h

Issue 445013002: media: Optimize HW Video to 2D Canvas copy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix cc unittests Created 6 years, 4 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: cc/resources/media/skcanvas_video_renderer.h
diff --git a/cc/resources/media/skcanvas_video_renderer.h b/cc/resources/media/skcanvas_video_renderer.h
new file mode 100644
index 0000000000000000000000000000000000000000..96156d717313d7cafcf814f33d60d5402f8b6957
--- /dev/null
+++ b/cc/resources/media/skcanvas_video_renderer.h
@@ -0,0 +1,64 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_RESOURCES_MEDIA_SKCANVAS_VIDEO_RENDERER_H_
+#define CC_RESOURCES_MEDIA_SKCANVAS_VIDEO_RENDERER_H_
+
+#include "base/time/time.h"
+#include "cc/base/cc_export.h"
+#include "cc/output/context_provider.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/gfx/rect.h"
+
+class SkCanvas;
+
+namespace media {
+class VideoFrame;
+}
+
+namespace cc {
+
+// Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV
+// conversion and caching of resulting RGB bitmaps.
+class CC_EXPORT SkCanvasVideoRenderer {
+ public:
+ SkCanvasVideoRenderer();
+ ~SkCanvasVideoRenderer();
+
+ // Paints |video_frame| on |canvas|, scaling the result to fit dimensions
+ // specified by |dest_rect|.
+ //
+ // Black will be painted on |canvas| if |video_frame| is null.
+ void Paint(media::VideoFrame* video_frame,
+ SkCanvas* canvas,
+ const gfx::RectF& dest_rect,
+ uint8 alpha,
+ ContextProvider* context_provider);
+
+ static void CopyVideoFrameToTexture(gpu::gles2::GLES2Interface* gl,
+ media::VideoFrame* video_frame,
+ unsigned int texture,
+ unsigned int level,
+ unsigned int internal_format,
+ unsigned int type,
+ bool premultiply_alpha,
+ bool flip_y);
+
+ private:
+ void CleanUpTemporaryBuffers();
+
+ // An RGB bitmap and corresponding timestamp of the previously converted
+ // video frame data.
+ SkBitmap last_frame_;
+ base::TimeDelta last_frame_timestamp_;
+ // It's possible to be used by accelerated client and non-accelerated client.
+ SkBitmap accelerated_last_frame_;
+ base::TimeDelta accelerated_last_frame_timestamp_;
+
+ DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer);
+};
+
+} // namespace cc
+
+#endif // CC_RESOURCES_MEDIA_SKCANVAS_VIDEO_RENDERER_H_

Powered by Google App Engine
This is Rietveld 408576698