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 "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 GrContext; |
15 class SkCanvas; | 16 class SkCanvas; |
16 | 17 |
| 18 namespace gpu { |
| 19 namespace gles2 { |
| 20 class GLES2Interface; |
| 21 } |
| 22 } |
| 23 |
17 namespace media { | 24 namespace media { |
18 | 25 |
19 class VideoFrame; | 26 class VideoFrame; |
20 | 27 |
21 // Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV | 28 // Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV |
22 // conversion and caching of resulting RGB bitmaps. | 29 // conversion and caching of resulting RGB bitmaps. |
23 class MEDIA_EXPORT SkCanvasVideoRenderer { | 30 class MEDIA_EXPORT SkCanvasVideoRenderer { |
24 public: | 31 public: |
25 SkCanvasVideoRenderer(); | 32 SkCanvasVideoRenderer(); |
26 ~SkCanvasVideoRenderer(); | 33 ~SkCanvasVideoRenderer(); |
27 | 34 |
| 35 struct Context3DProvider { |
| 36 gpu::gles2::GLES2Interface* gl; |
| 37 class GrContext* gr_context; |
| 38 }; |
28 // Paints |video_frame| on |canvas|, scaling the result to fit dimensions | 39 // Paints |video_frame| on |canvas|, scaling the result to fit dimensions |
29 // specified by |dest_rect|. | 40 // specified by |dest_rect|. |
30 // | 41 // |
31 // Black will be painted on |canvas| if |video_frame| is null. | 42 // Black will be painted on |canvas| if |video_frame| is null. |
32 void Paint(media::VideoFrame* video_frame, | 43 void Paint(media::VideoFrame* video_frame, |
33 SkCanvas* canvas, | 44 SkCanvas* canvas, |
34 const gfx::RectF& dest_rect, | 45 const gfx::RectF& dest_rect, |
35 uint8 alpha, | 46 uint8 alpha, |
36 SkXfermode::Mode mode, | 47 SkXfermode::Mode mode, |
37 VideoRotation video_rotation); | 48 VideoRotation video_rotation, |
| 49 Context3DProvider* context_provider); |
38 | 50 |
39 // Copy |video_frame| on |canvas|. | 51 // Copy |video_frame| on |canvas|. |
40 void Copy(media::VideoFrame* video_frame, SkCanvas* canvas); | 52 void Copy(media::VideoFrame* video_frame, SkCanvas* canvas); |
41 | 53 |
| 54 static void CopyVideoFrameToTexture(gpu::gles2::GLES2Interface* gl, |
| 55 media::VideoFrame* video_frame, |
| 56 unsigned int texture, |
| 57 unsigned int level, |
| 58 unsigned int internal_format, |
| 59 unsigned int type, |
| 60 bool premultiply_alpha, |
| 61 bool flip_y); |
| 62 |
42 private: | 63 private: |
| 64 void CleanUpTemporaryBuffers(); |
| 65 |
43 // An RGB bitmap and corresponding timestamp of the previously converted | 66 // An RGB bitmap and corresponding timestamp of the previously converted |
44 // video frame data. | 67 // video frame data. |
45 SkBitmap last_frame_; | 68 SkBitmap last_frame_; |
46 base::TimeDelta last_frame_timestamp_; | 69 base::TimeDelta last_frame_timestamp_; |
| 70 // It's possible to be used by accelerated client and non-accelerated client. |
| 71 SkBitmap accelerated_last_frame_; |
| 72 base::TimeDelta accelerated_last_frame_timestamp_; |
47 | 73 |
48 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); | 74 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); |
49 }; | 75 }; |
50 | 76 |
51 } // namespace media | 77 } // namespace media |
52 | 78 |
53 #endif // MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_ | 79 #endif // MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_ |
OLD | NEW |