| 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> | 
|  | 8 | 
| 7 namespace remoting { | 9 namespace remoting { | 
| 8 | 10 | 
| 9 Capturer::Capturer() | 11 Capturer::Capturer() | 
| 10     : width_(0), | 12     : width_(0), | 
| 11       height_(0), | 13       height_(0), | 
| 12       pixel_format_(PixelFormatInvalid), | 14       pixel_format_(PixelFormatInvalid), | 
| 13       bytes_per_row_(0), | 15       bytes_per_row_(0), | 
| 14       current_buffer_(0) { | 16       current_buffer_(0) { | 
| 15 } | 17 } | 
| 16 | 18 | 
| 17 Capturer::~Capturer() { | 19 Capturer::~Capturer() { | 
| 18 } | 20 } | 
| 19 | 21 | 
|  | 22 void Capturer::ClearInvalidRects() { | 
|  | 23   AutoLock auto_inval_rects_lock(inval_rects_lock_); | 
|  | 24   inval_rects_.clear(); | 
|  | 25 } | 
|  | 26 | 
|  | 27 void Capturer::InvalidateRects(const InvalidRects& inval_rects) { | 
|  | 28   InvalidRects temp_rects; | 
|  | 29   std::set_union(inval_rects_.begin(), inval_rects_.end(), | 
|  | 30                  inval_rects.begin(), inval_rects.end(), | 
|  | 31                  std::inserter(temp_rects, temp_rects.begin())); | 
|  | 32   { | 
|  | 33     AutoLock auto_inval_rects_lock(inval_rects_lock_); | 
|  | 34     inval_rects_.swap(temp_rects); | 
|  | 35   } | 
|  | 36 } | 
|  | 37 | 
|  | 38 void Capturer::InvalidateFullScreen() { | 
|  | 39   AutoLock auto_inval_rects_lock(inval_rects_lock_); | 
|  | 40   inval_rects_.clear(); | 
|  | 41   inval_rects_.insert(gfx::Rect(0, 0, width_, height_)); | 
|  | 42 } | 
|  | 43 | 
| 20 void Capturer::CaptureInvalidRects(CaptureCompletedCallback* callback) { | 44 void Capturer::CaptureInvalidRects(CaptureCompletedCallback* callback) { | 
|  | 45   // Calculate which rects need to be captured. | 
|  | 46   CalculateInvalidRects(); | 
|  | 47 | 
| 21   // Braced to scope the lock. | 48   // Braced to scope the lock. | 
| 22   RectVector local_rects; | 49   InvalidRects local_rects; | 
| 23   { | 50   { | 
| 24     AutoLock auto_inval_rects_lock(inval_rects_lock_); | 51     AutoLock auto_inval_rects_lock(inval_rects_lock_); | 
| 25     local_rects = inval_rects_; | 52     local_rects = inval_rects_; | 
| 26     inval_rects_.clear(); | 53     inval_rects_.clear(); | 
| 27   } | 54   } | 
| 28 | 55 | 
| 29   CaptureRects(local_rects, callback); | 56   CaptureRects(local_rects, callback); | 
| 30 } | 57 } | 
| 31 | 58 | 
| 32 void Capturer::InvalidateRects(const RectVector& inval_rects) { |  | 
| 33   AutoLock auto_inval_rects_lock(inval_rects_lock_); |  | 
| 34   inval_rects_.insert(inval_rects_.end(), |  | 
| 35                       inval_rects.begin(), |  | 
| 36                       inval_rects.end()); |  | 
| 37 } |  | 
| 38 |  | 
| 39 void Capturer::InvalidateFullScreen() { |  | 
| 40   RectVector rects; |  | 
| 41   rects.push_back(gfx::Rect(0, 0, width_, height_)); |  | 
| 42 |  | 
| 43   InvalidateRects(rects); |  | 
| 44 } |  | 
| 45 |  | 
| 46 void Capturer::FinishCapture(scoped_refptr<CaptureData> data, | 59 void Capturer::FinishCapture(scoped_refptr<CaptureData> data, | 
| 47                              CaptureCompletedCallback* callback) { | 60                              CaptureCompletedCallback* callback) { | 
| 48   // Select the next buffer to be the current buffer. | 61   // Select the next buffer to be the current buffer. | 
| 49   current_buffer_ = (current_buffer_ + 1) % kNumBuffers; | 62   current_buffer_ = (current_buffer_ + 1) % kNumBuffers; | 
| 50 | 63 | 
| 51   callback->Run(data); | 64   callback->Run(data); | 
| 52   delete callback; | 65   delete callback; | 
| 53 } | 66 } | 
| 54 | 67 | 
| 55 }  // namespace remoting | 68 }  // namespace remoting | 
| OLD | NEW | 
|---|