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_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ | 5 #ifndef MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ |
6 #define MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ | 6 #define MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
| 16 #include "cc/paint/paint_canvas.h" |
16 #include "media/base/media_export.h" | 17 #include "media/base/media_export.h" |
17 #include "media/base/timestamp_constants.h" | 18 #include "media/base/timestamp_constants.h" |
18 #include "media/base/video_frame.h" | 19 #include "media/base/video_frame.h" |
19 #include "media/base/video_rotation.h" | 20 #include "media/base/video_rotation.h" |
20 #include "media/filters/context_3d.h" | 21 #include "media/filters/context_3d.h" |
21 #include "third_party/skia/include/core/SkImage.h" | 22 #include "third_party/skia/include/core/SkImage.h" |
22 #include "third_party/skia/include/core/SkRefCnt.h" | 23 #include "third_party/skia/include/core/SkRefCnt.h" |
23 | 24 |
24 class SkCanvas; | |
25 | 25 |
26 namespace gfx { | 26 namespace gfx { |
27 class RectF; | 27 class RectF; |
28 } | 28 } |
29 | 29 |
30 namespace media { | 30 namespace media { |
31 | 31 |
32 // Handles rendering of VideoFrames to SkCanvases. | 32 // TODO(enne): rename to PaintCanvasVideoRenderer |
| 33 // Handles rendering of VideoFrames to PaintCanvases. |
33 class MEDIA_EXPORT SkCanvasVideoRenderer { | 34 class MEDIA_EXPORT SkCanvasVideoRenderer { |
34 public: | 35 public: |
35 SkCanvasVideoRenderer(); | 36 SkCanvasVideoRenderer(); |
36 ~SkCanvasVideoRenderer(); | 37 ~SkCanvasVideoRenderer(); |
37 | 38 |
38 // Paints |video_frame| on |canvas|, scaling and rotating the result to fit | 39 // Paints |video_frame| on |canvas|, scaling and rotating the result to fit |
39 // dimensions specified by |dest_rect|. | 40 // dimensions specified by |dest_rect|. |
40 // If the format of |video_frame| is PIXEL_FORMAT_NATIVE_TEXTURE, |context_3d| | 41 // If the format of |video_frame| is PIXEL_FORMAT_NATIVE_TEXTURE, |context_3d| |
41 // must be provided. | 42 // must be provided. |
42 // | 43 // |
43 // Black will be painted on |canvas| if |video_frame| is null. | 44 // Black will be painted on |canvas| if |video_frame| is null. |
44 void Paint(const scoped_refptr<VideoFrame>& video_frame, | 45 void Paint(const scoped_refptr<VideoFrame>& video_frame, |
45 SkCanvas* canvas, | 46 cc::PaintCanvas* canvas, |
46 const gfx::RectF& dest_rect, | 47 const gfx::RectF& dest_rect, |
47 SkPaint& paint, | 48 SkPaint& paint, |
48 VideoRotation video_rotation, | 49 VideoRotation video_rotation, |
49 const Context3D& context_3d); | 50 const Context3D& context_3d); |
50 | 51 |
51 // Copy |video_frame| on |canvas|. | 52 // Copy |video_frame| on |canvas|. |
52 // If the format of |video_frame| is PIXEL_FORMAT_NATIVE_TEXTURE, |context_3d| | 53 // If the format of |video_frame| is PIXEL_FORMAT_NATIVE_TEXTURE, |context_3d| |
53 // must be provided. | 54 // must be provided. |
54 void Copy(const scoped_refptr<VideoFrame>& video_frame, | 55 void Copy(const scoped_refptr<VideoFrame>& video_frame, |
55 SkCanvas* canvas, | 56 cc::PaintCanvas* canvas, |
56 const Context3D& context_3d); | 57 const Context3D& context_3d); |
57 | 58 |
58 // Convert the contents of |video_frame| to raw RGB pixels. |rgb_pixels| | 59 // Convert the contents of |video_frame| to raw RGB pixels. |rgb_pixels| |
59 // should point into a buffer large enough to hold as many 32 bit RGBA pixels | 60 // should point into a buffer large enough to hold as many 32 bit RGBA pixels |
60 // as are in the visible_rect() area of the frame. | 61 // as are in the visible_rect() area of the frame. |
61 static void ConvertVideoFrameToRGBPixels(const media::VideoFrame* video_frame, | 62 static void ConvertVideoFrameToRGBPixels(const media::VideoFrame* video_frame, |
62 void* rgb_pixels, | 63 void* rgb_pixels, |
63 size_t row_bytes); | 64 size_t row_bytes); |
64 | 65 |
65 // Copy the contents of texture of |video_frame| to texture |texture|. | 66 // Copy the contents of texture of |video_frame| to texture |texture|. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 153 |
153 // Used for unit test. | 154 // Used for unit test. |
154 SkISize last_image_dimensions_for_testing_; | 155 SkISize last_image_dimensions_for_testing_; |
155 | 156 |
156 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); | 157 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); |
157 }; | 158 }; |
158 | 159 |
159 } // namespace media | 160 } // namespace media |
160 | 161 |
161 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ | 162 #endif // MEDIA_RENDERERS_SKCANVAS_VIDEO_RENDERER_H_ |
OLD | NEW |