OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 REMOTING_BASE_CAPTURE_DATA_H_ | 5 #ifndef REMOTING_BASE_CAPTURE_DATA_H_ |
6 #define REMOTING_BASE_CAPTURE_DATA_H_ | 6 #define REMOTING_BASE_CAPTURE_DATA_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "gfx/rect.h" | |
13 #include "remoting/base/protocol/chromotocol.pb.h" | 12 #include "remoting/base/protocol/chromotocol.pb.h" |
| 13 #include "remoting/base/types.h" |
14 | 14 |
15 namespace remoting { | 15 namespace remoting { |
16 | 16 |
17 typedef std::vector<gfx::Rect> RectVector; | |
18 | |
19 struct DataPlanes { | 17 struct DataPlanes { |
20 static const int kPlaneCount = 3; | 18 static const int kPlaneCount = 3; |
21 uint8* data[kPlaneCount]; | 19 uint8* data[kPlaneCount]; |
22 int strides[kPlaneCount]; | 20 int strides[kPlaneCount]; |
23 | 21 |
24 DataPlanes() { | 22 DataPlanes() { |
25 for (int i = 0; i < kPlaneCount; ++i) { | 23 for (int i = 0; i < kPlaneCount; ++i) { |
26 data[i] = NULL; | 24 data[i] = NULL; |
27 strides[i] = 0; | 25 strides[i] = 0; |
28 } | 26 } |
29 } | 27 } |
30 }; | 28 }; |
31 | 29 |
32 // Stores the data and information of a capture to pass off to the | 30 // Stores the data and information of a capture to pass off to the |
33 // encoding thread. | 31 // encoding thread. |
34 class CaptureData : public base::RefCountedThreadSafe<CaptureData> { | 32 class CaptureData : public base::RefCountedThreadSafe<CaptureData> { |
35 public: | 33 public: |
36 CaptureData(const DataPlanes &data_planes, | 34 CaptureData(const DataPlanes &data_planes, |
37 int width, | 35 int width, |
38 int height, | 36 int height, |
39 PixelFormat format) : | 37 PixelFormat format) : |
40 data_planes_(data_planes), dirty_rects_(), | 38 data_planes_(data_planes), dirty_rects_(), |
41 width_(width), height_(height), pixel_format_(format) { } | 39 width_(width), height_(height), pixel_format_(format) { } |
42 | 40 |
43 // Get the data_planes data of the last capture. | 41 // Get the data_planes data of the last capture. |
44 const DataPlanes& data_planes() const { return data_planes_; } | 42 const DataPlanes& data_planes() const { return data_planes_; } |
45 | 43 |
46 // Get the list of updated rectangles in the last capture. The result is | 44 // Get the list of updated rectangles in the last capture. The result is |
47 // written into |rects|. | 45 // written into |rects|. |
48 const RectVector& dirty_rects() const { return dirty_rects_; } | 46 const InvalidRects& dirty_rects() const { return dirty_rects_; } |
49 | 47 |
50 // Get the width of the image captured. | 48 // Get the width of the image captured. |
51 int width() const { return width_; } | 49 int width() const { return width_; } |
52 | 50 |
53 // Get the height of the image captured. | 51 // Get the height of the image captured. |
54 int height() const { return height_; } | 52 int height() const { return height_; } |
55 | 53 |
56 // Get the pixel format of the image captured. | 54 // Get the pixel format of the image captured. |
57 PixelFormat pixel_format() const { return pixel_format_; } | 55 PixelFormat pixel_format() const { return pixel_format_; } |
58 | 56 |
59 // Mutating methods. | 57 // Mutating methods. |
60 RectVector& mutable_dirty_rects() { return dirty_rects_; } | 58 InvalidRects& mutable_dirty_rects() { return dirty_rects_; } |
61 | 59 |
62 private: | 60 private: |
63 const DataPlanes data_planes_; | 61 const DataPlanes data_planes_; |
64 RectVector dirty_rects_; | 62 InvalidRects dirty_rects_; |
65 int width_; | 63 int width_; |
66 int height_; | 64 int height_; |
67 PixelFormat pixel_format_; | 65 PixelFormat pixel_format_; |
68 | 66 |
69 friend class base::RefCountedThreadSafe<CaptureData>; | 67 friend class base::RefCountedThreadSafe<CaptureData>; |
70 ~CaptureData() {} | 68 ~CaptureData() {} |
71 }; | 69 }; |
72 | 70 |
73 } // namespace remoting | 71 } // namespace remoting |
74 | 72 |
75 #endif // REMOTING_BASE_CAPTURE_DATA_H_ | 73 #endif // REMOTING_BASE_CAPTURE_DATA_H_ |
OLD | NEW |