OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_HOST_CAPTURER_HELPER_H_ | 5 #ifndef REMOTING_HOST_CAPTURER_HELPER_H_ |
6 #define REMOTING_HOST_CAPTURER_HELPER_H_ | 6 #define REMOTING_HOST_CAPTURER_HELPER_H_ |
7 | 7 |
8 #include "base/synchronization/lock.h" | 8 #include "base/synchronization/lock.h" |
9 #include "third_party/skia/include/core/SkRegion.h" | 9 #include "remoting/base/types.h" |
10 #include "ui/gfx/size.h" | |
11 | 10 |
12 namespace remoting { | 11 namespace remoting { |
13 | 12 |
14 // CapturerHelper is intended to be used by an implementation of the Capturer | 13 // CapturerHelper is intended to be used by an implementation of the Capturer |
15 // interface. It maintains a thread-safe invalid region, and the size of the | 14 // interface. It maintains a thread-safe list of invalid rectangles, and the |
16 // most recently captured screen, on behalf of the Capturer that owns it. | 15 // size of the most recently captured screen, on behalf of the Capturer that |
| 16 // owns it. |
17 class CapturerHelper { | 17 class CapturerHelper { |
18 public: | 18 public: |
19 CapturerHelper(); | 19 CapturerHelper(); |
20 ~CapturerHelper(); | 20 ~CapturerHelper(); |
21 | 21 |
22 // Clear out the invalid region. | 22 // Clear out the list of invalid rects. |
23 void ClearInvalidRegion(); | 23 void ClearInvalidRects(); |
24 | 24 |
25 // Invalidate the specified region. | 25 // Invalidate the specified screen rects. |
26 void InvalidateRegion(const SkRegion& invalid_region); | 26 void InvalidateRects(const InvalidRects& inval_rects); |
27 | 27 |
28 // Invalidate the entire screen, of a given size. | 28 // Invalidate the entire screen, of a given size. |
29 void InvalidateScreen(const gfx::Size& size); | 29 void InvalidateScreen(const gfx::Size& size); |
30 | 30 |
31 // Invalidate the entire screen, using the size of the most recently | 31 // Invalidate the entire screen, using the size of the most recently |
32 // captured screen. | 32 // captured screen. |
33 void InvalidateFullScreen(); | 33 void InvalidateFullScreen(); |
34 | 34 |
35 // Whether the invalid region is a full screen of a given size. | 35 // Whether the invalid region is a full screen of a given size. |
36 bool IsCaptureFullScreen(const gfx::Size& size); | 36 bool IsCaptureFullScreen(const gfx::Size& size); |
37 | 37 |
38 // Swap the given region with the stored invalid region. | 38 // Swap the given set of rects with the stored invalid rects. |
39 void SwapInvalidRegion(SkRegion* invalid_region); | 39 // This should be used like this: |
| 40 // |
| 41 // InvalidRects inval_rects; |
| 42 // common.SwapInvalidRects(inval_rects); |
| 43 // |
| 44 // This passes the invalid rects to the caller, and removes them from this |
| 45 // object. The caller should then pass the raster data in those rects to the |
| 46 // client. |
| 47 void SwapInvalidRects(InvalidRects& inval_rects); |
40 | 48 |
41 // Access the size of the most recently captured screen. | 49 // Access the size of the most recently captured screen. |
42 const gfx::Size& size_most_recent() const; | 50 const gfx::Size& size_most_recent() const; |
43 void set_size_most_recent(const gfx::Size& size); | 51 void set_size_most_recent(const gfx::Size& size); |
44 | 52 |
45 private: | 53 private: |
46 // A region that has been manually invalidated (through InvalidateRegion). | 54 // Rects that have been manually invalidated (through InvalidateRect). |
47 // These will be returned as dirty_region in the capture data during the next | 55 // These will be returned as dirty_rects in the capture data during the next |
48 // capture. | 56 // capture. |
49 SkRegion invalid_region_; | 57 InvalidRects inval_rects_; |
50 | 58 |
51 // A lock protecting |invalid_region_| across threads. | 59 // A lock protecting |inval_rects_| across threads. |
52 base::Lock invalid_region_lock_; | 60 base::Lock inval_rects_lock_; |
53 | 61 |
54 // The size of the most recently captured screen. | 62 // The size of the most recently captured screen. |
55 gfx::Size size_most_recent_; | 63 gfx::Size size_most_recent_; |
56 | 64 |
57 DISALLOW_COPY_AND_ASSIGN(CapturerHelper); | 65 DISALLOW_COPY_AND_ASSIGN(CapturerHelper); |
58 }; | 66 }; |
59 | 67 |
60 } // namespace remoting | 68 } // namespace remoting |
61 | 69 |
62 #endif // REMOTING_HOST_CAPTURER_HELPER_H_ | 70 #endif // REMOTING_HOST_CAPTURER_HELPER_H_ |
OLD | NEW |