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

Side by Side Diff: media/filters/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: Rebase to ToT. Address nits 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 unified diff | Download patch
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/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "media/base/media_export.h" 10 #include "media/base/media_export.h"
11 #include "media/base/video_rotation.h" 11 #include "media/base/video_rotation.h"
12 #include "third_party/skia/include/core/SkBitmap.h" 12 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "third_party/skia/include/core/SkXfermode.h" 13 #include "third_party/skia/include/core/SkXfermode.h"
14 #include "ui/gfx/rect.h" 14 #include "ui/gfx/rect.h"
15 15
16 class GrContext;
16 class SkCanvas; 17 class SkCanvas;
17 18
19 namespace gpu {
20 namespace gles2 {
21 class GLES2Interface;
22 }
23 }
24
18 namespace media { 25 namespace media {
19 26
20 class VideoFrame; 27 class VideoFrame;
21 class VideoImageGenerator; 28 class VideoImageGenerator;
22 29
23 // Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV 30 // Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV
24 // conversion and caching of resulting RGB bitmaps. 31 // conversion and caching of resulting RGB bitmaps.
25 class MEDIA_EXPORT SkCanvasVideoRenderer { 32 class MEDIA_EXPORT SkCanvasVideoRenderer {
26 public: 33 public:
27 SkCanvasVideoRenderer(); 34 SkCanvasVideoRenderer();
28 ~SkCanvasVideoRenderer(); 35 ~SkCanvasVideoRenderer();
29 36
37 struct Context3DProvider {
scherkus (not reviewing) 2014/10/15 17:10:24 to be clear, we need this because we don't depend
38 gpu::gles2::GLES2Interface* gl;
39 class GrContext* gr_context;
40 };
30 // Paints |video_frame| on |canvas|, scaling and rotating the result to fit 41 // Paints |video_frame| on |canvas|, scaling and rotating the result to fit
31 // dimensions specified by |dest_rect|. 42 // dimensions specified by |dest_rect|.
32 // 43 //
33 // Black will be painted on |canvas| if |video_frame| is null. 44 // Black will be painted on |canvas| if |video_frame| is null.
34 void Paint(const scoped_refptr<VideoFrame>& video_frame, 45 void Paint(const scoped_refptr<VideoFrame>& video_frame,
35 SkCanvas* canvas, 46 SkCanvas* canvas,
36 const gfx::RectF& dest_rect, 47 const gfx::RectF& dest_rect,
37 uint8 alpha, 48 uint8 alpha,
38 SkXfermode::Mode mode, 49 SkXfermode::Mode mode,
39 VideoRotation video_rotation); 50 VideoRotation video_rotation,
51 Context3DProvider* context_provider);
40 52
41 // Copy |video_frame| on |canvas|. 53 // Copy |video_frame| on |canvas|.
42 void Copy(const scoped_refptr<VideoFrame>&, SkCanvas* canvas); 54 void Copy(const scoped_refptr<VideoFrame>&, SkCanvas* canvas);
43 55
56 static void CopyVideoFrameToTexture(gpu::gles2::GLES2Interface* gl,
57 media::VideoFrame* video_frame,
58 unsigned int texture,
59 unsigned int level,
60 unsigned int internal_format,
61 unsigned int type,
62 bool premultiply_alpha,
63 bool flip_y);
64
44 private: 65 private:
45 VideoImageGenerator* generator_; 66 void CleanUpTemporaryBuffers();
46 67
47 // An RGB bitmap and corresponding timestamp of the previously converted 68 // An RGB bitmap and corresponding timestamp of the previously converted
48 // video frame data. 69 // video frame data.
49 SkBitmap last_frame_; 70 SkBitmap last_frame_;
71 VideoImageGenerator* generator_;
50 base::TimeDelta last_frame_timestamp_; 72 base::TimeDelta last_frame_timestamp_;
51 73
74 // It's possible to be used by accelerated client and non-accelerated client.
75 SkBitmap accelerated_last_frame_;
76 base::TimeDelta accelerated_last_frame_timestamp_;
77
52 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); 78 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer);
53 }; 79 };
54 80
55 } // namespace media 81 } // namespace media
56 82
57 #endif // MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_ 83 #endif // MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698