OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "remoting/host/capturer_fake_ascii.h" | |
6 | |
7 namespace remoting { | |
8 | |
9 static const int kWidth = 32; | |
10 static const int kHeight = 20; | |
11 static const int kBytesPerPixel = 1; | |
12 | |
13 CapturerFakeAscii::CapturerFakeAscii() | |
14 : current_buffer_(0), | |
15 pixel_format_(media::VideoFrame::ASCII) { | |
16 } | |
17 | |
18 CapturerFakeAscii::~CapturerFakeAscii() { | |
19 } | |
20 | |
21 void CapturerFakeAscii::ScreenConfigurationChanged() { | |
22 width_ = kWidth; | |
23 height_ = kHeight; | |
24 bytes_per_row_ = width_ * kBytesPerPixel; | |
25 pixel_format_ = media::VideoFrame::ASCII; | |
26 | |
27 // Create memory for the buffers. | |
28 int buffer_size = height_ * bytes_per_row_; | |
29 for (int i = 0; i < kNumBuffers; i++) { | |
30 buffers_[i].reset(new uint8[buffer_size]); | |
31 } | |
32 } | |
33 | |
34 media::VideoFrame::Format CapturerFakeAscii::pixel_format() const { | |
35 return pixel_format_; | |
36 } | |
37 | |
38 void CapturerFakeAscii::ClearInvalidRegion() { | |
39 helper_.ClearInvalidRegion(); | |
40 } | |
41 | |
42 void CapturerFakeAscii::InvalidateRegion(const SkRegion& invalid_region) { | |
43 helper_.InvalidateRegion(invalid_region); | |
44 } | |
45 | |
46 void CapturerFakeAscii::InvalidateScreen(const SkISize& size) { | |
47 helper_.InvalidateScreen(size); | |
48 } | |
49 | |
50 void CapturerFakeAscii::InvalidateFullScreen() { | |
51 helper_.InvalidateFullScreen(); | |
52 } | |
53 | |
54 void CapturerFakeAscii::CaptureInvalidRegion( | |
55 const CaptureCompletedCallback& callback) { | |
56 GenerateImage(); | |
57 DataPlanes planes; | |
58 planes.data[0] = buffers_[current_buffer_].get(); | |
59 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; | |
60 planes.strides[0] = bytes_per_row_; | |
61 scoped_refptr<CaptureData> capture_data(new CaptureData( | |
62 planes, SkISize::Make(width_, height_), pixel_format_)); | |
63 | |
64 helper_.set_size_most_recent(capture_data->size()); | |
65 | |
66 callback.Run(capture_data); | |
67 } | |
68 | |
69 const SkISize& CapturerFakeAscii::size_most_recent() const { | |
70 return helper_.size_most_recent(); | |
71 } | |
72 | |
73 void CapturerFakeAscii::GenerateImage() { | |
74 for (int y = 0; y < height_; ++y) { | |
75 uint8* row = buffers_[current_buffer_].get() + bytes_per_row_ * y; | |
76 for (int x = 0; x < bytes_per_row_; ++x) { | |
77 if (y == 0 || x == 0 || x == (width_ - 1) || y == (height_ - 1)) { | |
78 row[x] = '*'; | |
79 } else { | |
80 row[x] = ' '; | |
81 } | |
82 } | |
83 } | |
84 } | |
85 | |
86 } // namespace remoting | |
OLD | NEW |