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_ascii.h" | 5 #include "remoting/host/capturer_fake_ascii.h" |
6 | 6 |
7 namespace remoting { | 7 namespace remoting { |
8 | 8 |
9 static const int kWidth = 32; | 9 static const int kWidth = 32; |
10 static const int kHeight = 20; | 10 static const int kHeight = 20; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 void CapturerFakeAscii::InvalidateScreen(const SkISize& size) { | 46 void CapturerFakeAscii::InvalidateScreen(const SkISize& size) { |
47 helper_.InvalidateScreen(size); | 47 helper_.InvalidateScreen(size); |
48 } | 48 } |
49 | 49 |
50 void CapturerFakeAscii::InvalidateFullScreen() { | 50 void CapturerFakeAscii::InvalidateFullScreen() { |
51 helper_.InvalidateFullScreen(); | 51 helper_.InvalidateFullScreen(); |
52 } | 52 } |
53 | 53 |
54 void CapturerFakeAscii::CaptureInvalidRegion( | 54 void CapturerFakeAscii::CaptureInvalidRegion( |
55 CaptureCompletedCallback* callback) { | 55 const CaptureCompletedCallback& callback) { |
56 scoped_ptr<CaptureCompletedCallback> callback_deleter(callback); | |
57 | |
58 GenerateImage(); | 56 GenerateImage(); |
59 DataPlanes planes; | 57 DataPlanes planes; |
60 planes.data[0] = buffers_[current_buffer_].get(); | 58 planes.data[0] = buffers_[current_buffer_].get(); |
61 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; | 59 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; |
62 planes.strides[0] = bytes_per_row_; | 60 planes.strides[0] = bytes_per_row_; |
63 scoped_refptr<CaptureData> capture_data(new CaptureData( | 61 scoped_refptr<CaptureData> capture_data(new CaptureData( |
64 planes, SkISize::Make(width_, height_), pixel_format_)); | 62 planes, SkISize::Make(width_, height_), pixel_format_)); |
65 | 63 |
66 helper_.set_size_most_recent(capture_data->size()); | 64 helper_.set_size_most_recent(capture_data->size()); |
67 | 65 |
68 callback->Run(capture_data); | 66 callback.Run(capture_data); |
69 } | 67 } |
70 | 68 |
71 const SkISize& CapturerFakeAscii::size_most_recent() const { | 69 const SkISize& CapturerFakeAscii::size_most_recent() const { |
72 return helper_.size_most_recent(); | 70 return helper_.size_most_recent(); |
73 } | 71 } |
74 | 72 |
75 void CapturerFakeAscii::GenerateImage() { | 73 void CapturerFakeAscii::GenerateImage() { |
76 for (int y = 0; y < height_; ++y) { | 74 for (int y = 0; y < height_; ++y) { |
77 uint8* row = buffers_[current_buffer_].get() + bytes_per_row_ * y; | 75 uint8* row = buffers_[current_buffer_].get() + bytes_per_row_ * y; |
78 for (int x = 0; x < bytes_per_row_; ++x) { | 76 for (int x = 0; x < bytes_per_row_; ++x) { |
79 if (y == 0 || x == 0 || x == (width_ - 1) || y == (height_ - 1)) { | 77 if (y == 0 || x == 0 || x == (width_ - 1) || y == (height_ - 1)) { |
80 row[x] = '*'; | 78 row[x] = '*'; |
81 } else { | 79 } else { |
82 row[x] = ' '; | 80 row[x] = ' '; |
83 } | 81 } |
84 } | 82 } |
85 } | 83 } |
86 } | 84 } |
87 | 85 |
88 } // namespace remoting | 86 } // namespace remoting |
OLD | NEW |