summaryrefslogtreecommitdiffstats
path: root/remoting/client/frame_consumer.h
blob: ab6f16e4960a17a56c2d8a3ad25ef57e8f06d58f (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// 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 REMOTING_CLIENT_FRAME_CONSUMER_H_
#define REMOTING_CLIENT_FRAME_CONSUMER_H_

#include "base/basictypes.h"

namespace webrtc {
class DesktopFrame;
class DesktopRect;
class DesktopRegion;
class DesktopSize;
class DesktopVector;
}  // namespace webrtc

namespace remoting {

class FrameConsumer {
 public:

  // List of supported pixel formats needed by various platforms.
  enum PixelFormat {
    FORMAT_BGRA,  // Used by the Pepper plugin.
    FORMAT_RGBA,  // Used for Android's Bitmap class.
  };

  // Paints the contents of |buffer| into the area of the view identified
  // by |clip_area|. |view_size| specifies the full-frame dimensions to which
  // the |buffer|/|clip_area| portion was scaled. Implementations may be
  // optimized to only paint pixels within the intersection of |region| and
  // |clip_area|. If |shape| is non-NULL then it specifies the complete shape
  // of the frame, otherwise the frame is un-shaped.
  //
  // N.B. |clip_area|, |region| and |shape| should be provided in output view
  // coordinates.
  virtual void ApplyBuffer(const webrtc::DesktopSize& view_size,
                           const webrtc::DesktopRect& clip_area,
                           webrtc::DesktopFrame* buffer,
                           const webrtc::DesktopRegion& region,
                           const webrtc::DesktopRegion* shape) = 0;

  // Accepts a buffer that couldn't be used for drawing for any reason (shutdown
  // is in progress, the view area has changed, etc.). The accepted buffer can
  // be freed or reused for another drawing operation.
  virtual void ReturnBuffer(webrtc::DesktopFrame* buffer) = 0;

  // Set the dimension of the entire host screen.
  virtual void SetSourceSize(const webrtc::DesktopSize& source_size,
                             const webrtc::DesktopVector& dpi) = 0;

  // Returns the preferred pixel encoding for the platform.
  virtual PixelFormat GetPixelFormat() = 0;

 protected:
  FrameConsumer() {}
  virtual ~FrameConsumer() {}

 private:
  DISALLOW_COPY_AND_ASSIGN(FrameConsumer);
};

}  // namespace remoting

#endif  // REMOTING_CLIENT_FRAME_CONSUMER_H_