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 MEDIA_VIDEO_CAPTURE_SCREEN_CAPTURE_DATA_H_ | |
6 #define MEDIA_VIDEO_CAPTURE_SCREEN_CAPTURE_DATA_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "media/base/media_export.h" | |
13 #include "media/video/capture/screen/shared_buffer.h" | |
14 #include "third_party/skia/include/core/SkRegion.h" | |
15 | |
16 namespace media { | |
17 | |
18 class SharedBuffer; | |
19 | |
20 // Stores the data and information of a capture to pass off to the | |
21 // encoding thread. | |
22 class MEDIA_EXPORT ScreenCaptureData | |
23 : public base::RefCountedThreadSafe<ScreenCaptureData> { | |
24 public: | |
25 // 32 bit RGB is 4 bytes per pixel. | |
26 static const int kBytesPerPixel = 4; | |
27 | |
28 ScreenCaptureData(uint8* data, int stride, const SkISize& size); | |
29 | |
30 // Data buffer. | |
31 uint8* data() const { return data_; } | |
32 | |
33 // Distance in bytes between neighboring lines in the data buffer. | |
34 int stride() const { return stride_; } | |
35 | |
36 // Gets the dirty region from the previous capture. | |
37 const SkRegion& dirty_region() const { return dirty_region_; } | |
38 | |
39 // Returns the size of the image captured. | |
40 SkISize size() const { return size_; } | |
41 | |
42 SkRegion& mutable_dirty_region() { return dirty_region_; } | |
43 | |
44 // Returns the time spent on capturing. | |
45 int capture_time_ms() const { return capture_time_ms_; } | |
46 | |
47 // Sets the time spent on capturing. | |
48 void set_capture_time_ms(int capture_time_ms) { | |
49 capture_time_ms_ = capture_time_ms; | |
50 } | |
51 | |
52 int64 client_sequence_number() const { return client_sequence_number_; } | |
53 | |
54 void set_client_sequence_number(int64 client_sequence_number) { | |
55 client_sequence_number_ = client_sequence_number; | |
56 } | |
57 | |
58 SkIPoint dpi() const { return dpi_; } | |
59 | |
60 void set_dpi(const SkIPoint& dpi) { dpi_ = dpi; } | |
61 | |
62 // Returns the shared memory buffer pointed to by |data|. | |
63 scoped_refptr<SharedBuffer> shared_buffer() const { return shared_buffer_; } | |
64 | |
65 // Sets the shared memory buffer pointed to by |data|. | |
66 void set_shared_buffer(scoped_refptr<SharedBuffer> shared_buffer) { | |
67 shared_buffer_ = shared_buffer; | |
68 } | |
69 | |
70 private: | |
71 friend class base::RefCountedThreadSafe<ScreenCaptureData>; | |
72 virtual ~ScreenCaptureData(); | |
73 | |
74 uint8* data_; | |
75 int stride_; | |
76 SkRegion dirty_region_; | |
77 SkISize size_; | |
78 | |
79 // Time spent in capture. Unit is in milliseconds. | |
80 int capture_time_ms_; | |
81 | |
82 // Sequence number supplied by client for performance tracking. | |
83 int64 client_sequence_number_; | |
84 | |
85 // DPI for this frame. | |
86 SkIPoint dpi_; | |
87 | |
88 scoped_refptr<SharedBuffer> shared_buffer_; | |
89 }; | |
90 | |
91 } // namespace media | |
92 | |
93 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_CAPTURE_DATA_H_ | |
OLD | NEW |