video_layer_impl.h revision 868fa2fe829687343ffae624259930155e16dbd8
1// Copyright 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_LAYERS_VIDEO_LAYER_IMPL_H_
6#define CC_LAYERS_VIDEO_LAYER_IMPL_H_
7
8#include <vector>
9
10#include "cc/base/cc_export.h"
11#include "cc/layers/layer_impl.h"
12#include "cc/resources/video_resource_updater.h"
13
14namespace media {
15class VideoFrame;
16}
17
18namespace cc {
19class VideoFrameProvider;
20class VideoFrameProviderClientImpl;
21
22class CC_EXPORT VideoLayerImpl : public LayerImpl {
23 public:
24  static scoped_ptr<VideoLayerImpl> Create(LayerTreeImpl* tree_impl,
25                                           int id,
26                                           VideoFrameProvider* provider);
27  virtual ~VideoLayerImpl();
28
29  // LayerImpl implementation.
30  virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
31      OVERRIDE;
32  virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
33  virtual bool WillDraw(DrawMode draw_mode,
34                        ResourceProvider* resource_provider) OVERRIDE;
35  virtual void AppendQuads(QuadSink* quad_sink,
36                           AppendQuadsData* append_quads_data) OVERRIDE;
37  virtual void DidDraw(ResourceProvider* resource_provider) OVERRIDE;
38  virtual void DidBecomeActive() OVERRIDE;
39  virtual void DidLoseOutputSurface() OVERRIDE;
40
41  void SetNeedsRedraw();
42
43  void SetProviderClientImpl(
44      scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl);
45
46 private:
47  VideoLayerImpl(LayerTreeImpl* tree_impl, int id);
48
49  virtual const char* LayerTypeAsString() const OVERRIDE;
50
51  scoped_refptr<VideoFrameProviderClientImpl> provider_client_impl_;
52
53  scoped_refptr<media::VideoFrame> frame_;
54
55  scoped_ptr<VideoResourceUpdater> updater_;
56  VideoFrameExternalResources::ResourceType frame_resource_type_;
57  std::vector<ResourceProvider::ResourceId> frame_resources_;
58
59  // TODO(danakj): Remove this when hardware frames come through a mailbox.
60  unsigned hardware_resource_;
61  TextureMailbox::ReleaseCallback hardware_release_callback_;
62
63  // TODO(danakj): Remove these, hide software path inside ResourceProvider and
64  // ExternalResource (aka TextureMailbox) classes.
65  std::vector<unsigned> software_resources_;
66  TextureMailbox::ReleaseCallback software_release_callback_;
67
68  DISALLOW_COPY_AND_ASSIGN(VideoLayerImpl);
69};
70
71}  // namespace cc
72
73#endif  // CC_LAYERS_VIDEO_LAYER_IMPL_H_
74