OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CC_RESOURCES_MEDIA_SKCANVAS_VIDEO_RENDERER_H_ |
| 6 #define CC_RESOURCES_MEDIA_SKCANVAS_VIDEO_RENDERER_H_ |
| 7 |
| 8 #include "base/time/time.h" |
| 9 #include "cc/base/cc_export.h" |
| 10 #include "cc/output/context_provider.h" |
| 11 #include "third_party/skia/include/core/SkBitmap.h" |
| 12 #include "ui/gfx/rect.h" |
| 13 |
| 14 class SkCanvas; |
| 15 |
| 16 namespace media { |
| 17 class VideoFrame; |
| 18 } |
| 19 |
| 20 namespace cc { |
| 21 |
| 22 // Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV |
| 23 // conversion and caching of resulting RGB bitmaps. |
| 24 class CC_EXPORT SkCanvasVideoRenderer { |
| 25 public: |
| 26 SkCanvasVideoRenderer(); |
| 27 ~SkCanvasVideoRenderer(); |
| 28 |
| 29 // Paints |video_frame| on |canvas|, scaling the result to fit dimensions |
| 30 // specified by |dest_rect|. |
| 31 // |
| 32 // Black will be painted on |canvas| if |video_frame| is null. |
| 33 void Paint(media::VideoFrame* video_frame, |
| 34 SkCanvas* canvas, |
| 35 const gfx::RectF& dest_rect, |
| 36 uint8 alpha, |
| 37 ContextProvider* context_provider); |
| 38 |
| 39 static void CopyVideoFrameToTexture(gpu::gles2::GLES2Interface* gl, |
| 40 media::VideoFrame* video_frame, |
| 41 unsigned int texture, |
| 42 unsigned int level, |
| 43 unsigned int internal_format, |
| 44 unsigned int type, |
| 45 bool premultiply_alpha, |
| 46 bool flip_y); |
| 47 |
| 48 private: |
| 49 void CleanUpTemporaryBuffers(); |
| 50 |
| 51 // An RGB bitmap and corresponding timestamp of the previously converted |
| 52 // video frame data. |
| 53 SkBitmap last_frame_; |
| 54 base::TimeDelta last_frame_timestamp_; |
| 55 // It's possible to be used by accelerated client and non-accelerated client. |
| 56 SkBitmap accelerated_last_frame_; |
| 57 base::TimeDelta accelerated_last_frame_timestamp_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer); |
| 60 }; |
| 61 |
| 62 } // namespace cc |
| 63 |
| 64 #endif // CC_RESOURCES_MEDIA_SKCANVAS_VIDEO_RENDERER_H_ |
OLD | NEW |