| 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 "remoting/base/types.h" | 9 #include "third_party/skia/include/core/SkRegion.h" |
| 10 #include "ui/gfx/size.h" |
| 10 | 11 |
| 11 namespace remoting { | 12 namespace remoting { |
| 12 | 13 |
| 13 // CapturerHelper is intended to be used by an implementation of the Capturer | 14 // CapturerHelper is intended to be used by an implementation of the Capturer |
| 14 // interface. It maintains a thread-safe list of invalid rectangles, and the | 15 // interface. It maintains a thread-safe invalid region, and the size of the |
| 15 // size of the most recently captured screen, on behalf of the Capturer that | 16 // most recently captured screen, on behalf of the Capturer that owns it. |
| 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 list of invalid rects. | 22 // Clear out the invalid region. |
| 23 void ClearInvalidRects(); | 23 void ClearInvalidRegion(); |
| 24 | 24 |
| 25 // Invalidate the specified screen rects. | 25 // Invalidate the specified region. |
| 26 void InvalidateRects(const InvalidRects& inval_rects); | 26 void InvalidateRegion(const SkRegion& invalid_region); |
| 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 // Swap the given region with the stored invalid region. |
| 36 bool IsCaptureFullScreen(const gfx::Size& size); | 36 void SwapInvalidRegion(SkRegion* invalid_region); |
| 37 | |
| 38 // Swap the given set of rects with the stored invalid rects. | |
| 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); | |
| 48 | 37 |
| 49 // Access the size of the most recently captured screen. | 38 // Access the size of the most recently captured screen. |
| 50 const gfx::Size& size_most_recent() const; | 39 const gfx::Size& size_most_recent() const; |
| 51 void set_size_most_recent(const gfx::Size& size); | 40 void set_size_most_recent(const gfx::Size& size); |
| 52 | 41 |
| 53 private: | 42 private: |
| 54 // Rects that have been manually invalidated (through InvalidateRect). | 43 // A region that has been manually invalidated (through InvalidateRegion). |
| 55 // These will be returned as dirty_rects in the capture data during the next | 44 // These will be returned as dirty_region in the capture data during the next |
| 56 // capture. | 45 // capture. |
| 57 InvalidRects inval_rects_; | 46 SkRegion invalid_region_; |
| 58 | 47 |
| 59 // A lock protecting |inval_rects_| across threads. | 48 // A lock protecting |invalid_region_| across threads. |
| 60 base::Lock inval_rects_lock_; | 49 base::Lock invalid_region_lock_; |
| 61 | 50 |
| 62 // The size of the most recently captured screen. | 51 // The size of the most recently captured screen. |
| 63 gfx::Size size_most_recent_; | 52 gfx::Size size_most_recent_; |
| 64 | 53 |
| 65 DISALLOW_COPY_AND_ASSIGN(CapturerHelper); | 54 DISALLOW_COPY_AND_ASSIGN(CapturerHelper); |
| 66 }; | 55 }; |
| 67 | 56 |
| 68 } // namespace remoting | 57 } // namespace remoting |
| 69 | 58 |
| 70 #endif // REMOTING_HOST_CAPTURER_HELPER_H_ | 59 #endif // REMOTING_HOST_CAPTURER_HELPER_H_ |
| OLD | NEW |