OLD | NEW |
---|---|
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 "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
11 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
12 | 12 |
13 class GrContext; | |
13 class SkCanvas; | 14 class SkCanvas; |
14 | 15 |
16 namespace gpu { | |
17 namespace gles2 { | |
18 class GLES2Interface; | |
19 } | |
20 } | |
21 | |
15 namespace media { | 22 namespace media { |
16 | 23 |
17 class VideoFrame; | 24 class VideoFrame; |
18 | 25 |
19 // Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV | 26 // Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV |
20 // conversion and caching of resulting RGB bitmaps. | 27 // conversion and caching of resulting RGB bitmaps. |
21 class MEDIA_EXPORT SkCanvasVideoRenderer { | 28 class MEDIA_EXPORT SkCanvasVideoRenderer { |
22 public: | 29 public: |
23 SkCanvasVideoRenderer(); | 30 SkCanvasVideoRenderer(); |
24 ~SkCanvasVideoRenderer(); | 31 ~SkCanvasVideoRenderer(); |
25 | 32 |
33 struct ContextProvider { | |
danakj
2014/08/07 14:07:31
Please use a different name for this, it's a bit c
dshwang
2014/08/07 15:10:43
Done. Now it's Context3DProvider.
btw I intended t
danakj
2014/08/07 15:14:34
Oh I had no idea that existed too.. heh.
| |
34 gpu::gles2::GLES2Interface* gl; | |
35 class GrContext* gr_context; | |
36 }; | |
26 // Paints |video_frame| on |canvas|, scaling the result to fit dimensions | 37 // Paints |video_frame| on |canvas|, scaling the result to fit dimensions |
27 // specified by |dest_rect|. | 38 // specified by |dest_rect|. |
28 // | 39 // |
29 // Black will be painted on |canvas| if |video_frame| is null. | 40 // Black will be painted on |canvas| if |video_frame| is null. |
30 void Paint(media::VideoFrame* video_frame, | 41 void Paint(media::VideoFrame* video_frame, |
31 SkCanvas* canvas, | 42 SkCanvas* canvas, |
32 const gfx::RectF& dest_rect, | 43 const gfx::RectF& dest_rect, |
33 uint8 alpha); | 44 uint8 alpha, |
45 ContextProvider* context_provider); | |
46 | |
47 static void CopyVideoFrameToTexture(gpu::gles2::GLES2Interface* gl, | |
48 media::VideoFrame* video_frame, | |
49 unsigned int texture, | |
50 unsigned int level, | |
51 unsigned int internal_format, | |
52 unsigned int type, | |
53 bool premultiply_alpha, | |
54 bool flip_y); | |
34 | 55 |
35 private: | 56 private: |
57 void CleanUpTemporaryBuffers(); | |
58 | |
36 // An RGB bitmap and corresponding timestamp of the previously converted | 59 // An RGB bitmap and corresponding timestamp of the previously converted |
37 // video frame data. | 60 // video frame data. |
38 SkBitmap last_frame_; | 61 SkBitmap last_frame_; |
39 base::TimeDelta last_frame_timestamp_; | 62 base::TimeDelta last_frame_timestamp_; |
63 // It's possible to be used by accelerated client and non-accelerated client. | |
64 SkBitmap accelerated_last_frame_; | |
65 base::TimeDelta accelerated_last_frame_timestamp_; | |
40 | 66 |
41 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); | 67 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); |
42 }; | 68 }; |
43 | 69 |
44 } // namespace media | 70 } // namespace media |
45 | 71 |
46 #endif // MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_ | 72 #endif // MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_ |
OLD | NEW |