OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/capturer/video_frame_capturer_fake.h" | 5 #include "remoting/capturer/video_frame_capturer_fake.h" |
6 | 6 |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "remoting/capturer/capture_data.h" | 8 #include "remoting/capturer/capture_data.h" |
9 | 9 |
10 namespace remoting { | 10 namespace remoting { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 buffers_[current_buffer_].get(), bytes_per_row_, size_)); | 63 buffers_[current_buffer_].get(), bytes_per_row_, size_)); |
64 capture_data->mutable_dirty_region() = invalid_region; | 64 capture_data->mutable_dirty_region() = invalid_region; |
65 | 65 |
66 helper_.set_size_most_recent(capture_data->size()); | 66 helper_.set_size_most_recent(capture_data->size()); |
67 | 67 |
68 capture_data->set_capture_time_ms( | 68 capture_data->set_capture_time_ms( |
69 (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); | 69 (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); |
70 delegate_->OnCaptureCompleted(capture_data); | 70 delegate_->OnCaptureCompleted(capture_data); |
71 } | 71 } |
72 | 72 |
73 const SkISize& VideoFrameCapturerFake::size_most_recent() const { | |
74 return helper_.size_most_recent(); | |
75 } | |
76 | |
77 void VideoFrameCapturerFake::GenerateImage() { | 73 void VideoFrameCapturerFake::GenerateImage() { |
78 memset(buffers_[current_buffer_].get(), 0xff, | 74 memset(buffers_[current_buffer_].get(), 0xff, |
79 size_.width() * size_.height() * CaptureData::kBytesPerPixel); | 75 size_.width() * size_.height() * CaptureData::kBytesPerPixel); |
80 | 76 |
81 uint8* row = buffers_[current_buffer_].get() + | 77 uint8* row = buffers_[current_buffer_].get() + |
82 (box_pos_y_ * size_.width() + box_pos_x_) * CaptureData::kBytesPerPixel; | 78 (box_pos_y_ * size_.width() + box_pos_x_) * CaptureData::kBytesPerPixel; |
83 | 79 |
84 box_pos_x_ += box_speed_x_; | 80 box_pos_x_ += box_speed_x_; |
85 if (box_pos_x_ + kBoxWidth >= size_.width() || box_pos_x_ == 0) | 81 if (box_pos_x_ + kBoxWidth >= size_.width() || box_pos_x_ == 0) |
86 box_speed_x_ = -box_speed_x_; | 82 box_speed_x_ = -box_speed_x_; |
(...skipping 25 matching lines...) Expand all Loading... |
112 bytes_per_row_ = size_.width() * CaptureData::kBytesPerPixel; | 108 bytes_per_row_ = size_.width() * CaptureData::kBytesPerPixel; |
113 | 109 |
114 // Create memory for the buffers. | 110 // Create memory for the buffers. |
115 int buffer_size = size_.height() * bytes_per_row_; | 111 int buffer_size = size_.height() * bytes_per_row_; |
116 for (int i = 0; i < kNumBuffers; i++) { | 112 for (int i = 0; i < kNumBuffers; i++) { |
117 buffers_[i].reset(new uint8[buffer_size]); | 113 buffers_[i].reset(new uint8[buffer_size]); |
118 } | 114 } |
119 } | 115 } |
120 | 116 |
121 } // namespace remoting | 117 } // namespace remoting |
OLD | NEW |