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

Side by Side Diff: media/filters/skcanvas_video_renderer.h

Issue 512733003: Do YUV conversion on the GPU when copying video frames into a GPU-accelerated canvas. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « media/DEPS ('k') | media/filters/skcanvas_video_renderer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_ 5 #ifndef MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_
6 #define MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_ 6 #define MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_
7 7
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "media/base/media_export.h" 9 #include "media/base/media_export.h"
10 #include "media/base/video_rotation.h" 10 #include "media/base/video_rotation.h"
11 #include "third_party/skia/include/core/SkBitmap.h" 11 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "third_party/skia/include/core/SkXfermode.h" 12 #include "third_party/skia/include/core/SkXfermode.h"
13 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
14 14
15 class SkCanvas; 15 class SkCanvas;
16 class GrContext;
16 17
17 namespace media { 18 namespace media {
18 19
19 class VideoFrame; 20 class VideoFrame;
20 21
21 // Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV 22 // Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV
22 // conversion and caching of resulting RGB bitmaps. 23 // conversion and caching of resulting RGB bitmaps.
23 class MEDIA_EXPORT SkCanvasVideoRenderer { 24 class MEDIA_EXPORT SkCanvasVideoRenderer {
24 public: 25 public:
25 SkCanvasVideoRenderer(); 26 SkCanvasVideoRenderer();
26 ~SkCanvasVideoRenderer(); 27 ~SkCanvasVideoRenderer();
27 28
28 // Paints |video_frame| on |canvas|, scaling the result to fit dimensions 29 // Paints |video_frame| on |canvas|, scaling the result to fit dimensions
29 // specified by |dest_rect|. 30 // specified by |dest_rect|.
30 // 31 //
31 // Black will be painted on |canvas| if |video_frame| is null. 32 // Black will be painted on |canvas| if |video_frame| is null.
32 void Paint(media::VideoFrame* video_frame, 33 void Paint(media::VideoFrame* video_frame,
33 SkCanvas* canvas, 34 SkCanvas* canvas,
34 const gfx::RectF& dest_rect, 35 const gfx::RectF& dest_rect,
35 uint8 alpha, 36 uint8 alpha,
36 SkXfermode::Mode mode, 37 SkXfermode::Mode mode,
37 VideoRotation video_rotation); 38 VideoRotation video_rotation);
38 39
39 // Copy |video_frame| on |canvas|. 40 // Copy |video_frame| on |canvas|.
40 void Copy(media::VideoFrame* video_frame, SkCanvas* canvas); 41 void Copy(media::VideoFrame* video_frame, SkCanvas* canvas);
41 42
42 private: 43 private:
44 // Special paint routine that uses a hardware-accelerated canvas to do YUV
45 // conversion.
46 bool HardwarePaint(media::VideoFrame* video_frame,
47 GrContext* gr,
48 const SkRect& dest_rect,
49 SkXfermode::Mode mode,
50 VideoRotation video_rotation);
51
43 // An RGB bitmap and corresponding timestamp of the previously converted 52 // An RGB bitmap and corresponding timestamp of the previously converted
44 // video frame data. 53 // video frame data.
45 SkBitmap last_frame_; 54 SkBitmap last_frame_;
46 base::TimeDelta last_frame_timestamp_; 55 base::TimeDelta last_frame_timestamp_;
47 56
57 // These never actually allocate pixels, but wrap our yuv planes so that we
58 // can use them for hardware yuv conversion.
59 SkBitmap yuv_planes_[3];
60
61 // We store a separate timestamp for |yuv_planes_|'s contents, as they can get
62 // cached separately on the GPU.
63 base::TimeDelta yuv_planes_timestamp_;
64
48 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); 65 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer);
49 }; 66 };
50 67
51 } // namespace media 68 } // namespace media
52 69
53 #endif // MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_ 70 #endif // MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_
OLDNEW
« no previous file with comments | « media/DEPS ('k') | media/filters/skcanvas_video_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698