| 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 #include "ui/gfx/rect.h" | |
| 8 | |
| 9 namespace remoting { | 7 namespace remoting { |
| 10 | 8 |
| 11 static const int kWidth = 32; | 9 static const int kWidth = 32; |
| 12 static const int kHeight = 20; | 10 static const int kHeight = 20; |
| 13 static const int kBytesPerPixel = 1; | 11 static const int kBytesPerPixel = 1; |
| 14 | 12 |
| 15 CapturerFakeAscii::CapturerFakeAscii() | 13 CapturerFakeAscii::CapturerFakeAscii() |
| 16 : current_buffer_(0), | 14 : current_buffer_(0), |
| 17 pixel_format_(media::VideoFrame::ASCII) { | 15 pixel_format_(media::VideoFrame::ASCII) { |
| 18 } | 16 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 38 } | 36 } |
| 39 | 37 |
| 40 void CapturerFakeAscii::ClearInvalidRegion() { | 38 void CapturerFakeAscii::ClearInvalidRegion() { |
| 41 helper_.ClearInvalidRegion(); | 39 helper_.ClearInvalidRegion(); |
| 42 } | 40 } |
| 43 | 41 |
| 44 void CapturerFakeAscii::InvalidateRegion(const SkRegion& invalid_region) { | 42 void CapturerFakeAscii::InvalidateRegion(const SkRegion& invalid_region) { |
| 45 helper_.InvalidateRegion(invalid_region); | 43 helper_.InvalidateRegion(invalid_region); |
| 46 } | 44 } |
| 47 | 45 |
| 48 void CapturerFakeAscii::InvalidateScreen(const gfx::Size& size) { | 46 void CapturerFakeAscii::InvalidateScreen(const SkISize& size) { |
| 49 helper_.InvalidateScreen(size); | 47 helper_.InvalidateScreen(size); |
| 50 } | 48 } |
| 51 | 49 |
| 52 void CapturerFakeAscii::InvalidateFullScreen() { | 50 void CapturerFakeAscii::InvalidateFullScreen() { |
| 53 helper_.InvalidateFullScreen(); | 51 helper_.InvalidateFullScreen(); |
| 54 } | 52 } |
| 55 | 53 |
| 56 void CapturerFakeAscii::CaptureInvalidRegion( | 54 void CapturerFakeAscii::CaptureInvalidRegion( |
| 57 CaptureCompletedCallback* callback) { | 55 CaptureCompletedCallback* callback) { |
| 58 scoped_ptr<CaptureCompletedCallback> callback_deleter(callback); | 56 scoped_ptr<CaptureCompletedCallback> callback_deleter(callback); |
| 59 | 57 |
| 60 GenerateImage(); | 58 GenerateImage(); |
| 61 DataPlanes planes; | 59 DataPlanes planes; |
| 62 planes.data[0] = buffers_[current_buffer_].get(); | 60 planes.data[0] = buffers_[current_buffer_].get(); |
| 63 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; | 61 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; |
| 64 planes.strides[0] = bytes_per_row_; | 62 planes.strides[0] = bytes_per_row_; |
| 65 scoped_refptr<CaptureData> capture_data(new CaptureData( | 63 scoped_refptr<CaptureData> capture_data(new CaptureData( |
| 66 planes, gfx::Size(width_, height_), pixel_format_)); | 64 planes, SkISize::Make(width_, height_), pixel_format_)); |
| 67 | 65 |
| 68 helper_.set_size_most_recent(capture_data->size()); | 66 helper_.set_size_most_recent(capture_data->size()); |
| 69 | 67 |
| 70 callback->Run(capture_data); | 68 callback->Run(capture_data); |
| 71 } | 69 } |
| 72 | 70 |
| 73 const gfx::Size& CapturerFakeAscii::size_most_recent() const { | 71 const SkISize& CapturerFakeAscii::size_most_recent() const { |
| 74 return helper_.size_most_recent(); | 72 return helper_.size_most_recent(); |
| 75 } | 73 } |
| 76 | 74 |
| 77 void CapturerFakeAscii::GenerateImage() { | 75 void CapturerFakeAscii::GenerateImage() { |
| 78 for (int y = 0; y < height_; ++y) { | 76 for (int y = 0; y < height_; ++y) { |
| 79 uint8* row = buffers_[current_buffer_].get() + bytes_per_row_ * y; | 77 uint8* row = buffers_[current_buffer_].get() + bytes_per_row_ * y; |
| 80 for (int x = 0; x < bytes_per_row_; ++x) { | 78 for (int x = 0; x < bytes_per_row_; ++x) { |
| 81 if (y == 0 || x == 0 || x == (width_ - 1) || y == (height_ - 1)) { | 79 if (y == 0 || x == 0 || x == (width_ - 1) || y == (height_ - 1)) { |
| 82 row[x] = '*'; | 80 row[x] = '*'; |
| 83 } else { | 81 } else { |
| 84 row[x] = ' '; | 82 row[x] = ' '; |
| 85 } | 83 } |
| 86 } | 84 } |
| 87 } | 85 } |
| 88 } | 86 } |
| 89 | 87 |
| 90 } // namespace remoting | 88 } // namespace remoting |
| OLD | NEW |