| 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_BLINK_SKCANVAS_VIDEO_RENDERER_H_ | 5 #ifndef MEDIA_BLINK_SKCANVAS_VIDEO_RENDERER_H_ |
| 6 #define MEDIA_BLINK_SKCANVAS_VIDEO_RENDERER_H_ | 6 #define MEDIA_BLINK_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 "base/timer/timer.h" |
| 11 #include "media/base/media_export.h" | 11 #include "media/base/media_export.h" |
| 12 #include "media/base/video_rotation.h" | 12 #include "media/base/video_rotation.h" |
| 13 #include "media/filters/context_3d.h" | 13 #include "media/filters/context_3d.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | |
| 15 #include "third_party/skia/include/core/SkXfermode.h" | 14 #include "third_party/skia/include/core/SkXfermode.h" |
| 16 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 17 | 16 |
| 18 class SkCanvas; | 17 class SkCanvas; |
| 19 | 18 |
| 20 namespace media { | 19 namespace media { |
| 21 | 20 |
| 22 class VideoFrame; | 21 class VideoFrame; |
| 23 class VideoImageGenerator; | |
| 24 | 22 |
| 25 // Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV | 23 // Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV |
| 26 // conversion and caching of resulting RGB bitmaps. | 24 // conversion and caching of resulting RGB bitmaps. |
| 27 class MEDIA_EXPORT SkCanvasVideoRenderer { | 25 class MEDIA_EXPORT SkCanvasVideoRenderer { |
| 28 public: | 26 public: |
| 29 SkCanvasVideoRenderer(); | 27 SkCanvasVideoRenderer(); |
| 30 ~SkCanvasVideoRenderer(); | 28 ~SkCanvasVideoRenderer(); |
| 31 | 29 |
| 32 // Paints |video_frame| on |canvas|, scaling and rotating the result to fit | 30 // Paints |video_frame| on |canvas|, scaling and rotating the result to fit |
| 33 // dimensions specified by |dest_rect|. | 31 // dimensions specified by |dest_rect|. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 63 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. | 61 // The format of |video_frame| must be VideoFrame::NATIVE_TEXTURE. |
| 64 static void CopyVideoFrameTextureToGLTexture(gpu::gles2::GLES2Interface* gl, | 62 static void CopyVideoFrameTextureToGLTexture(gpu::gles2::GLES2Interface* gl, |
| 65 VideoFrame* video_frame, | 63 VideoFrame* video_frame, |
| 66 unsigned int texture, | 64 unsigned int texture, |
| 67 unsigned int internal_format, | 65 unsigned int internal_format, |
| 68 unsigned int type, | 66 unsigned int type, |
| 69 bool premultiply_alpha, | 67 bool premultiply_alpha, |
| 70 bool flip_y); | 68 bool flip_y); |
| 71 | 69 |
| 72 private: | 70 private: |
| 73 void ResetLastFrame(); | |
| 74 void ResetAcceleratedLastFrame(); | |
| 75 | |
| 76 // An RGB bitmap and corresponding timestamp of the previously converted | |
| 77 // video frame data by software color space conversion. | |
| 78 SkBitmap last_frame_; | |
| 79 base::TimeDelta last_frame_timestamp_; | |
| 80 // If |last_frame_| is not used for a while, it's deleted to save memory. | |
| 81 base::DelayTimer<SkCanvasVideoRenderer> frame_deleting_timer_; | |
| 82 | |
| 83 // This is a hardware accelerated copy of the frame generated by | |
| 84 // |accelerated_generator_|. | |
| 85 // It's used when |canvas| parameter in Paint() is Ganesh canvas. | |
| 86 // Note: all GrContext in SkCanvas instances are same. | |
| 87 SkBitmap accelerated_last_frame_; | |
| 88 VideoImageGenerator* accelerated_generator_; | |
| 89 base::TimeDelta accelerated_last_frame_timestamp_; | |
| 90 base::DelayTimer<SkCanvasVideoRenderer> accelerated_frame_deleting_timer_; | |
| 91 | |
| 92 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); | 71 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); |
| 93 }; | 72 }; |
| 94 | 73 |
| 95 } // namespace media | 74 } // namespace media |
| 96 | 75 |
| 97 #endif // MEDIA_BLINK_SKCANVAS_VIDEO_RENDERER_H_ | 76 #endif // MEDIA_BLINK_SKCANVAS_VIDEO_RENDERER_H_ |
| OLD | NEW |