OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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.h" | 5 #include "remoting/host/capturer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "remoting/base/tracer.h" | 9 #include "remoting/base/tracer.h" |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 int Capturer::height() const { | 31 int Capturer::height() const { |
32 return height_; | 32 return height_; |
33 } | 33 } |
34 | 34 |
35 // Return the pixel format of the screen. | 35 // Return the pixel format of the screen. |
36 media::VideoFrame::Format Capturer::pixel_format() const { | 36 media::VideoFrame::Format Capturer::pixel_format() const { |
37 return pixel_format_; | 37 return pixel_format_; |
38 } | 38 } |
39 | 39 |
40 void Capturer::ClearInvalidRects() { | 40 void Capturer::ClearInvalidRects() { |
41 AutoLock auto_inval_rects_lock(inval_rects_lock_); | 41 base::AutoLock auto_inval_rects_lock(inval_rects_lock_); |
42 inval_rects_.clear(); | 42 inval_rects_.clear(); |
43 } | 43 } |
44 | 44 |
45 void Capturer::InvalidateRects(const InvalidRects& inval_rects) { | 45 void Capturer::InvalidateRects(const InvalidRects& inval_rects) { |
46 InvalidRects temp_rects; | 46 InvalidRects temp_rects; |
47 std::set_union(inval_rects_.begin(), inval_rects_.end(), | 47 std::set_union(inval_rects_.begin(), inval_rects_.end(), |
48 inval_rects.begin(), inval_rects.end(), | 48 inval_rects.begin(), inval_rects.end(), |
49 std::inserter(temp_rects, temp_rects.begin())); | 49 std::inserter(temp_rects, temp_rects.begin())); |
50 { | 50 { |
51 AutoLock auto_inval_rects_lock(inval_rects_lock_); | 51 base::AutoLock auto_inval_rects_lock(inval_rects_lock_); |
52 inval_rects_.swap(temp_rects); | 52 inval_rects_.swap(temp_rects); |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 void Capturer::InvalidateFullScreen() { | 56 void Capturer::InvalidateFullScreen() { |
57 AutoLock auto_inval_rects_lock(inval_rects_lock_); | 57 base::AutoLock auto_inval_rects_lock(inval_rects_lock_); |
58 inval_rects_.clear(); | 58 inval_rects_.clear(); |
59 inval_rects_.insert(gfx::Rect(0, 0, width_, height_)); | 59 inval_rects_.insert(gfx::Rect(0, 0, width_, height_)); |
60 } | 60 } |
61 | 61 |
62 void Capturer::CaptureInvalidRects(CaptureCompletedCallback* callback) { | 62 void Capturer::CaptureInvalidRects(CaptureCompletedCallback* callback) { |
63 // Calculate which rects need to be captured. | 63 // Calculate which rects need to be captured. |
64 TraceContext::tracer()->PrintString("Started CalculateInvalidRects"); | 64 TraceContext::tracer()->PrintString("Started CalculateInvalidRects"); |
65 CalculateInvalidRects(); | 65 CalculateInvalidRects(); |
66 TraceContext::tracer()->PrintString("Done CalculateInvalidRects"); | 66 TraceContext::tracer()->PrintString("Done CalculateInvalidRects"); |
67 | 67 |
68 // Braced to scope the lock. | 68 // Braced to scope the lock. |
69 InvalidRects local_rects; | 69 InvalidRects local_rects; |
70 { | 70 { |
71 AutoLock auto_inval_rects_lock(inval_rects_lock_); | 71 base::AutoLock auto_inval_rects_lock(inval_rects_lock_); |
72 local_rects.swap(inval_rects_); | 72 local_rects.swap(inval_rects_); |
73 } | 73 } |
74 | 74 |
75 TraceContext::tracer()->PrintString("Start CaptureRects"); | 75 TraceContext::tracer()->PrintString("Start CaptureRects"); |
76 CaptureRects(local_rects, callback); | 76 CaptureRects(local_rects, callback); |
77 } | 77 } |
78 | 78 |
79 void Capturer::FinishCapture(scoped_refptr<CaptureData> data, | 79 void Capturer::FinishCapture(scoped_refptr<CaptureData> data, |
80 CaptureCompletedCallback* callback) { | 80 CaptureCompletedCallback* callback) { |
81 // Select the next buffer to be the current buffer. | 81 // Select the next buffer to be the current buffer. |
82 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; | 82 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; |
83 | 83 |
84 callback->Run(data); | 84 callback->Run(data); |
85 delete callback; | 85 delete callback; |
86 } | 86 } |
87 | 87 |
88 } // namespace remoting | 88 } // namespace remoting |
OLD | NEW |