| 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/memory/ref_counted.h" |
| 8 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 9 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
| 10 #include "media/base/video_rotation.h" | 11 #include "media/base/video_rotation.h" |
| 11 #include "third_party/skia/include/core/SkBitmap.h" | 12 #include "third_party/skia/include/core/SkBitmap.h" |
| 12 #include "third_party/skia/include/core/SkXfermode.h" | 13 #include "third_party/skia/include/core/SkXfermode.h" |
| 13 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 14 | 15 |
| 15 class SkCanvas; | 16 class SkCanvas; |
| 16 | 17 |
| 17 namespace media { | 18 namespace media { |
| 18 | 19 |
| 19 class VideoFrame; | 20 class VideoFrame; |
| 21 class VideoImageGenerator; |
| 20 | 22 |
| 21 // Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV | 23 // Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV |
| 22 // conversion and caching of resulting RGB bitmaps. | 24 // conversion and caching of resulting RGB bitmaps. |
| 23 class MEDIA_EXPORT SkCanvasVideoRenderer { | 25 class MEDIA_EXPORT SkCanvasVideoRenderer { |
| 24 public: | 26 public: |
| 25 SkCanvasVideoRenderer(); | 27 SkCanvasVideoRenderer(); |
| 26 ~SkCanvasVideoRenderer(); | 28 ~SkCanvasVideoRenderer(); |
| 27 | 29 |
| 28 // Paints |video_frame| on |canvas|, scaling the result to fit dimensions | 30 // Paints |video_frame| on |canvas|, scaling the result to fit dimensions |
| 29 // specified by |dest_rect|. | 31 // specified by |dest_rect|. |
| 30 // | 32 // |
| 31 // Black will be painted on |canvas| if |video_frame| is null. | 33 // Black will be painted on |canvas| if |video_frame| is null. |
| 32 void Paint(media::VideoFrame* video_frame, | 34 void Paint(const scoped_refptr<VideoFrame>& video_frame, |
| 33 SkCanvas* canvas, | 35 SkCanvas* canvas, |
| 34 const gfx::RectF& dest_rect, | 36 const gfx::RectF& dest_rect, |
| 35 uint8 alpha, | 37 uint8 alpha, |
| 36 SkXfermode::Mode mode, | 38 SkXfermode::Mode mode, |
| 37 VideoRotation video_rotation); | 39 VideoRotation video_rotation); |
| 38 | 40 |
| 39 // Copy |video_frame| on |canvas|. | 41 // Copy |video_frame| on |canvas|. |
| 40 void Copy(media::VideoFrame* video_frame, SkCanvas* canvas); | 42 void Copy(const scoped_refptr<VideoFrame>&, SkCanvas* canvas); |
| 41 | 43 |
| 42 private: | 44 private: |
| 45 VideoImageGenerator* generator_; |
| 46 |
| 43 // An RGB bitmap and corresponding timestamp of the previously converted | 47 // An RGB bitmap and corresponding timestamp of the previously converted |
| 44 // video frame data. | 48 // video frame data. |
| 45 SkBitmap last_frame_; | 49 SkBitmap last_frame_; |
| 46 base::TimeDelta last_frame_timestamp_; | 50 base::TimeDelta last_frame_timestamp_; |
| 47 | 51 |
| 48 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); | 52 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); |
| 49 }; | 53 }; |
| 50 | 54 |
| 51 } // namespace media | 55 } // namespace media |
| 52 | 56 |
| 53 #endif // MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_ | 57 #endif // MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_ |
| OLD | NEW |