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 #include "remoting/host/capturer_helper.h" | 5 #include "remoting/host/capturer_helper.h" |
6 | 6 |
7 #include <algorithm> | |
8 #include <iterator> | |
9 | |
10 namespace remoting { | 7 namespace remoting { |
11 | 8 |
12 CapturerHelper::CapturerHelper() : size_most_recent_(0, 0) { | 9 CapturerHelper::CapturerHelper() : size_most_recent_(0, 0) { |
13 } | 10 } |
14 | 11 |
15 CapturerHelper::~CapturerHelper() { | 12 CapturerHelper::~CapturerHelper() { |
16 } | 13 } |
17 | 14 |
18 void CapturerHelper::ClearInvalidRects() { | 15 void CapturerHelper::ClearInvalidRegion() { |
19 base::AutoLock auto_inval_rects_lock(inval_rects_lock_); | 16 base::AutoLock auto_inval_region_lock(inval_region_lock_); |
20 inval_rects_.clear(); | 17 inval_region_.setEmpty(); |
21 } | 18 } |
22 | 19 |
23 void CapturerHelper::InvalidateRects(const InvalidRects& inval_rects) { | 20 void CapturerHelper::InvalidateRegion(const SkRegion& inval_region) { |
24 base::AutoLock auto_inval_rects_lock(inval_rects_lock_); | 21 base::AutoLock auto_inval_region_lock(inval_region_lock_); |
25 InvalidRects temp_rects; | 22 inval_region_.op(inval_region, SkRegion::kUnion_Op); |
26 std::set_union(inval_rects_.begin(), inval_rects_.end(), | |
27 inval_rects.begin(), inval_rects.end(), | |
28 std::inserter(temp_rects, temp_rects.begin())); | |
29 inval_rects_.swap(temp_rects); | |
30 } | 23 } |
31 | 24 |
32 void CapturerHelper::InvalidateScreen(const gfx::Size& size) { | 25 void CapturerHelper::InvalidateScreen(const gfx::Size& size) { |
33 base::AutoLock auto_inval_rects_lock(inval_rects_lock_); | 26 base::AutoLock auto_inval_region_lock(inval_region_lock_); |
34 inval_rects_.clear(); | 27 inval_region_.setRect(SkIRect::MakeWH(size.width(), size.height())); |
Wez
2011/08/08 20:49:34
nit: Technically this should be a union operation.
dmac
2011/08/10 20:30:36
Done.
| |
35 inval_rects_.insert(gfx::Rect(0, 0, size.width(), size.height())); | |
36 } | 28 } |
37 | 29 |
38 void CapturerHelper::InvalidateFullScreen() { | 30 void CapturerHelper::InvalidateFullScreen() { |
39 if (size_most_recent_ != gfx::Size(0, 0)) | 31 if (size_most_recent_ != gfx::Size(0, 0)) |
40 InvalidateScreen(size_most_recent_); | 32 InvalidateScreen(size_most_recent_); |
41 } | 33 } |
42 | 34 |
43 bool CapturerHelper::IsCaptureFullScreen(const gfx::Size& size) { | 35 bool CapturerHelper::IsCaptureFullScreen(const gfx::Size& size) { |
44 base::AutoLock auto_inval_rects_lock(inval_rects_lock_); | 36 base::AutoLock auto_inval_region_lock(inval_region_lock_); |
45 return inval_rects_.size() == 1u && | 37 const SkIRect& bounds = inval_region_.getBounds(); |
46 inval_rects_.begin()->x() == 0 && inval_rects_.begin()->y() == 0 && | 38 return bounds.fLeft == 0 && bounds.fTop == 0 && |
47 inval_rects_.begin()->width() == size.width() && | 39 bounds.width() == size.width() && bounds.height() == size.height(); |
Wez
2011/08/08 20:49:34
This will return true if the capture consists of t
Wez
2011/08/08 20:49:34
See above.
dmac
2011/08/10 20:30:36
Added bug and comment.
| |
48 inval_rects_.begin()->height() == size.height(); | |
49 } | 40 } |
50 | 41 |
51 void CapturerHelper::SwapInvalidRects(InvalidRects& inval_rects) { | 42 void CapturerHelper::SwapInvalidRegion(SkRegion& inval_region) { |
52 base::AutoLock auto_inval_rects_lock(inval_rects_lock_); | 43 base::AutoLock auto_inval_region_lock(inval_region_lock_); |
53 inval_rects.swap(inval_rects_); | 44 inval_region.swap(inval_region_); |
54 } | 45 } |
55 | 46 |
56 const gfx::Size& CapturerHelper::size_most_recent() const { | 47 const gfx::Size& CapturerHelper::size_most_recent() const { |
57 return size_most_recent_; | 48 return size_most_recent_; |
58 } | 49 } |
59 | 50 |
60 void CapturerHelper::set_size_most_recent(const gfx::Size& size) { | 51 void CapturerHelper::set_size_most_recent(const gfx::Size& size) { |
61 size_most_recent_ = size; | 52 size_most_recent_ = size; |
62 } | 53 } |
63 | 54 |
64 } // namespace remoting | 55 } // namespace remoting |
OLD | NEW |