summaryrefslogtreecommitdiffstats
path: root/webkit/media/skcanvas_video_renderer.h
blob: 0773297a20d0dd54e2d66bc3a66f9086d38d05bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef WEBKIT_MEDIA_SKCANVAS_VIDEO_RENDERER_H_
#define WEBKIT_MEDIA_SKCANVAS_VIDEO_RENDERER_H_

#include "base/time.h"
#include "ui/gfx/rect.h"
#include "third_party/skia/include/core/SkBitmap.h"

class SkCanvas;

namespace media {
class VideoFrame;
}

namespace webkit_media {

// Handles rendering of VideoFrames to SkCanvases, doing any necessary YUV
// conversion and caching of resulting RGB bitmaps.
class SkCanvasVideoRenderer {
 public:
  SkCanvasVideoRenderer();
  ~SkCanvasVideoRenderer();

  // Paints |video_frame| on |canvas|, scaling the result to fit dimensions
  // specified by |dest_rect|.
  //
  // Black will be painted on |canvas| if |video_frame| is null.
  void Paint(media::VideoFrame* video_frame,
             SkCanvas* canvas,
             const gfx::Rect& dest_rect);

 private:
  // An RGB bitmap and corresponding timestamp of the previously converted
  // video frame data.
  SkBitmap last_frame_;
  base::TimeDelta last_frame_timestamp_;

  DISALLOW_COPY_AND_ASSIGN(SkCanvasVideoRenderer);
};

}  // namespace webkit_media

#endif  // WEBKIT_MEDIA_SKCANVAS_VIDEO_RENDERER_H_