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/memory/ref_counted.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "base/timer/timer.h" |
10 #include "media/base/media_export.h" | 11 #include "media/base/media_export.h" |
11 #include "media/base/video_rotation.h" | 12 #include "media/base/video_rotation.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
13 #include "third_party/skia/include/core/SkXfermode.h" | 14 #include "third_party/skia/include/core/SkXfermode.h" |
14 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
15 | 16 |
16 class SkCanvas; | 17 class SkCanvas; |
17 | 18 |
18 namespace media { | 19 namespace media { |
19 | 20 |
(...skipping 15 matching lines...) Expand all Loading... |
35 SkCanvas* canvas, | 36 SkCanvas* canvas, |
36 const gfx::RectF& dest_rect, | 37 const gfx::RectF& dest_rect, |
37 uint8 alpha, | 38 uint8 alpha, |
38 SkXfermode::Mode mode, | 39 SkXfermode::Mode mode, |
39 VideoRotation video_rotation); | 40 VideoRotation video_rotation); |
40 | 41 |
41 // Copy |video_frame| on |canvas|. | 42 // Copy |video_frame| on |canvas|. |
42 void Copy(const scoped_refptr<VideoFrame>&, SkCanvas* canvas); | 43 void Copy(const scoped_refptr<VideoFrame>&, SkCanvas* canvas); |
43 | 44 |
44 private: | 45 private: |
45 VideoImageGenerator* generator_; | 46 void ResetLastFrame(); |
| 47 void ResetAcceleratedLastFrame(); |
46 | 48 |
47 // An RGB bitmap and corresponding timestamp of the previously converted | 49 // An RGB bitmap and corresponding timestamp of the previously converted |
48 // video frame data. | 50 // video frame data by software color space conversion. |
49 SkBitmap last_frame_; | 51 SkBitmap last_frame_; |
50 base::TimeDelta last_frame_timestamp_; | 52 base::TimeDelta last_frame_timestamp_; |
| 53 // If |last_frame_| is not used for a while, it's deleted to save memory. |
| 54 base::DelayTimer<SkCanvasVideoRenderer> frame_deleting_timer_; |
| 55 |
| 56 // This is a hardware accelerated copy of the frame generated by |
| 57 // |accelerated_generator_|. |
| 58 // It's used when |canvas| parameter in Paint() is Ganesh canvas. |
| 59 // Note: all GrContext in SkCanvas instances are same. |
| 60 SkBitmap accelerated_last_frame_; |
| 61 VideoImageGenerator* accelerated_generator_; |
| 62 base::TimeDelta accelerated_last_frame_timestamp_; |
| 63 base::DelayTimer<SkCanvasVideoRenderer> accelerated_frame_deleting_timer_; |
51 | 64 |
52 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); | 65 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); |
53 }; | 66 }; |
54 | 67 |
55 } // namespace media | 68 } // namespace media |
56 | 69 |
57 #endif // MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_ | 70 #endif // MEDIA_FILTERS_SKCANVAS_VIDEO_RENDERER_H_ |
OLD | NEW |