Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: remoting/host/capturer_helper.cc

Issue 7491070: Switch over to using SkRegions to calculate dirty areas. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleaned up comments Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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(invalid_region_lock_);
20 inval_rects_.clear(); 17 invalid_region_.setEmpty();
21 } 18 }
22 19
23 void CapturerHelper::InvalidateRects(const InvalidRects& inval_rects) { 20 void CapturerHelper::InvalidateRegion(const SkRegion& invalid_region) {
24 base::AutoLock auto_inval_rects_lock(inval_rects_lock_); 21 base::AutoLock auto_invalid_region_lock(invalid_region_lock_);
25 InvalidRects temp_rects; 22 invalid_region_.op(invalid_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_invalid_region_lock(invalid_region_lock_);
34 inval_rects_.clear(); 27 invalid_region_.op(SkIRect::MakeWH(size.width(), size.height()),
35 inval_rects_.insert(gfx::Rect(0, 0, size.width(), size.height())); 28 SkRegion::kUnion_Op);
36 } 29 }
37 30
38 void CapturerHelper::InvalidateFullScreen() { 31 void CapturerHelper::InvalidateFullScreen() {
39 if (size_most_recent_ != gfx::Size(0, 0)) 32 if (size_most_recent_ != gfx::Size(0, 0))
40 InvalidateScreen(size_most_recent_); 33 InvalidateScreen(size_most_recent_);
41 } 34 }
42 35
36 // TODO: Is this actually required? If we decide it is there is a bug here where
37 // This will return true if the capture consists of two small rectangles at
38 // opposite corners of the desktop. Need to check that there is exactly one
39 // rectangle in the region.
40 // http://crbug.com/92346
Wez 2011/08/10 22:05:43 The bug is introduced by this CL, though. Can be
Lambros 2011/08/10 22:17:10 Drive-by: If you want to test whether |invalid_reg
43 bool CapturerHelper::IsCaptureFullScreen(const gfx::Size& size) { 41 bool CapturerHelper::IsCaptureFullScreen(const gfx::Size& size) {
44 base::AutoLock auto_inval_rects_lock(inval_rects_lock_); 42 base::AutoLock auto_invalid_region_lock(invalid_region_lock_);
45 return inval_rects_.size() == 1u && 43 const SkIRect& bounds = invalid_region_.getBounds();
46 inval_rects_.begin()->x() == 0 && inval_rects_.begin()->y() == 0 && 44 return bounds.fLeft == 0 && bounds.fTop == 0 &&
47 inval_rects_.begin()->width() == size.width() && 45 bounds.width() == size.width() && bounds.height() == size.height();
48 inval_rects_.begin()->height() == size.height();
49 } 46 }
50 47
51 void CapturerHelper::SwapInvalidRects(InvalidRects& inval_rects) { 48 void CapturerHelper::SwapInvalidRegion(SkRegion* invalid_region) {
52 base::AutoLock auto_inval_rects_lock(inval_rects_lock_); 49 base::AutoLock auto_invalid_region_lock(invalid_region_lock_);
53 inval_rects.swap(inval_rects_); 50 invalid_region->swap(invalid_region_);
54 } 51 }
55 52
56 const gfx::Size& CapturerHelper::size_most_recent() const { 53 const gfx::Size& CapturerHelper::size_most_recent() const {
57 return size_most_recent_; 54 return size_most_recent_;
58 } 55 }
59 56
60 void CapturerHelper::set_size_most_recent(const gfx::Size& size) { 57 void CapturerHelper::set_size_most_recent(const gfx::Size& size) {
61 size_most_recent_ = size; 58 size_most_recent_ = size;
62 } 59 }
63 60
64 } // namespace remoting 61 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698