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_fake.h" | 5 #include "remoting/host/capturer_fake.h" |
6 | 6 |
7 namespace remoting { | 7 namespace remoting { |
8 | 8 |
9 // CapturerFake generates a white picture of size kWidth x kHeight with a | 9 // CapturerFake generates a white picture of size kWidth x kHeight with a |
10 // rectangle of size kBoxWidth x kBoxHeight. The rectangle moves kSpeed pixels | 10 // rectangle of size kBoxWidth x kBoxHeight. The rectangle moves kSpeed pixels |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 | 62 |
63 void CapturerFake::InvalidateScreen(const SkISize& size) { | 63 void CapturerFake::InvalidateScreen(const SkISize& size) { |
64 helper.InvalidateScreen(size); | 64 helper.InvalidateScreen(size); |
65 } | 65 } |
66 | 66 |
67 void CapturerFake::InvalidateFullScreen() { | 67 void CapturerFake::InvalidateFullScreen() { |
68 helper.InvalidateFullScreen(); | 68 helper.InvalidateFullScreen(); |
69 } | 69 } |
70 | 70 |
71 void CapturerFake::CaptureInvalidRegion(CaptureCompletedCallback* callback) { | 71 void CapturerFake::CaptureInvalidRegion( |
72 scoped_ptr<CaptureCompletedCallback> callback_deleter(callback); | 72 const CaptureCompletedCallback& callback) { |
73 | |
74 GenerateImage(); | 73 GenerateImage(); |
75 InvalidateScreen(size_); | 74 InvalidateScreen(size_); |
76 | 75 |
77 SkRegion invalid_region; | 76 SkRegion invalid_region; |
78 helper.SwapInvalidRegion(&invalid_region); | 77 helper.SwapInvalidRegion(&invalid_region); |
79 | 78 |
80 DataPlanes planes; | 79 DataPlanes planes; |
81 planes.data[0] = buffers_[current_buffer_].get(); | 80 planes.data[0] = buffers_[current_buffer_].get(); |
82 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; | 81 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; |
83 planes.strides[0] = bytes_per_row_; | 82 planes.strides[0] = bytes_per_row_; |
84 | 83 |
85 scoped_refptr<CaptureData> capture_data(new CaptureData(planes, | 84 scoped_refptr<CaptureData> capture_data(new CaptureData(planes, |
86 size_, | 85 size_, |
87 pixel_format_)); | 86 pixel_format_)); |
88 capture_data->mutable_dirty_region() = invalid_region; | 87 capture_data->mutable_dirty_region() = invalid_region; |
89 | 88 |
90 helper.set_size_most_recent(capture_data->size()); | 89 helper.set_size_most_recent(capture_data->size()); |
91 | 90 |
92 callback->Run(capture_data); | 91 callback.Run(capture_data); |
93 } | 92 } |
94 | 93 |
95 const SkISize& CapturerFake::size_most_recent() const { | 94 const SkISize& CapturerFake::size_most_recent() const { |
96 return helper.size_most_recent(); | 95 return helper.size_most_recent(); |
97 } | 96 } |
98 | 97 |
99 void CapturerFake::GenerateImage() { | 98 void CapturerFake::GenerateImage() { |
100 memset(buffers_[current_buffer_].get(), 0xff, | 99 memset(buffers_[current_buffer_].get(), 0xff, |
101 size_.width() * size_.height() * kBytesPerPixel); | 100 size_.width() * size_.height() * kBytesPerPixel); |
102 | 101 |
(...skipping 20 matching lines...) Expand all Loading... |
123 row[x * kBytesPerPixel] = r; | 122 row[x * kBytesPerPixel] = r; |
124 row[x * kBytesPerPixel+1] = g; | 123 row[x * kBytesPerPixel+1] = g; |
125 row[x * kBytesPerPixel+2] = b; | 124 row[x * kBytesPerPixel+2] = b; |
126 row[x * kBytesPerPixel+3] = 0xff; | 125 row[x * kBytesPerPixel+3] = 0xff; |
127 } | 126 } |
128 row += bytes_per_row_; | 127 row += bytes_per_row_; |
129 } | 128 } |
130 } | 129 } |
131 | 130 |
132 } // namespace remoting | 131 } // namespace remoting |
OLD | NEW |