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 #include "ui/gfx/rect.h" | 7 #include "ui/gfx/rect.h" |
8 | 8 |
9 namespace remoting { | 9 namespace remoting { |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 int buffer_size = size_.height() * bytes_per_row_; | 47 int buffer_size = size_.height() * bytes_per_row_; |
48 for (int i = 0; i < kNumBuffers; i++) { | 48 for (int i = 0; i < kNumBuffers; i++) { |
49 buffers_[i].reset(new uint8[buffer_size]); | 49 buffers_[i].reset(new uint8[buffer_size]); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 media::VideoFrame::Format CapturerFake::pixel_format() const { | 53 media::VideoFrame::Format CapturerFake::pixel_format() const { |
54 return pixel_format_; | 54 return pixel_format_; |
55 } | 55 } |
56 | 56 |
57 void CapturerFake::ClearInvalidRects() { | 57 void CapturerFake::ClearInvalidRegion() { |
58 helper.ClearInvalidRects(); | 58 helper.ClearInvalidRegion(); |
59 } | 59 } |
60 | 60 |
61 void CapturerFake::InvalidateRects(const InvalidRects& inval_rects) { | 61 void CapturerFake::InvalidateRegion(const SkRegion& invalid_region) { |
62 helper.InvalidateRects(inval_rects); | 62 helper.InvalidateRegion(invalid_region); |
63 } | 63 } |
64 | 64 |
65 void CapturerFake::InvalidateScreen(const gfx::Size& size) { | 65 void CapturerFake::InvalidateScreen(const gfx::Size& size) { |
66 helper.InvalidateScreen(size); | 66 helper.InvalidateScreen(size); |
67 } | 67 } |
68 | 68 |
69 void CapturerFake::InvalidateFullScreen() { | 69 void CapturerFake::InvalidateFullScreen() { |
70 helper.InvalidateFullScreen(); | 70 helper.InvalidateFullScreen(); |
71 } | 71 } |
72 | 72 |
73 void CapturerFake::CaptureInvalidRects(CaptureCompletedCallback* callback) { | 73 void CapturerFake::CaptureInvalidRegion(CaptureCompletedCallback* callback) { |
74 scoped_ptr<CaptureCompletedCallback> callback_deleter(callback); | 74 scoped_ptr<CaptureCompletedCallback> callback_deleter(callback); |
75 | 75 |
76 GenerateImage(); | 76 GenerateImage(); |
77 InvalidateScreen(size_); | 77 InvalidateScreen(size_); |
78 | 78 |
79 InvalidRects inval_rects; | 79 SkRegion invalid_region; |
80 helper.SwapInvalidRects(inval_rects); | 80 helper.SwapInvalidRegion(&invalid_region); |
81 | 81 |
82 DataPlanes planes; | 82 DataPlanes planes; |
83 planes.data[0] = buffers_[current_buffer_].get(); | 83 planes.data[0] = buffers_[current_buffer_].get(); |
84 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; | 84 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; |
85 planes.strides[0] = bytes_per_row_; | 85 planes.strides[0] = bytes_per_row_; |
86 | 86 |
87 scoped_refptr<CaptureData> capture_data(new CaptureData(planes, | 87 scoped_refptr<CaptureData> capture_data(new CaptureData(planes, |
88 size_, | 88 size_, |
89 pixel_format_)); | 89 pixel_format_)); |
90 capture_data->mutable_dirty_rects() = inval_rects; | 90 capture_data->mutable_dirty_region() = invalid_region; |
91 | 91 |
92 helper.set_size_most_recent(capture_data->size()); | 92 helper.set_size_most_recent(capture_data->size()); |
93 | 93 |
94 callback->Run(capture_data); | 94 callback->Run(capture_data); |
95 } | 95 } |
96 | 96 |
97 const gfx::Size& CapturerFake::size_most_recent() const { | 97 const gfx::Size& CapturerFake::size_most_recent() const { |
98 return helper.size_most_recent(); | 98 return helper.size_most_recent(); |
99 } | 99 } |
100 | 100 |
(...skipping 24 matching lines...) Expand all Loading... |
125 row[x * kBytesPerPixel] = r; | 125 row[x * kBytesPerPixel] = r; |
126 row[x * kBytesPerPixel+1] = g; | 126 row[x * kBytesPerPixel+1] = g; |
127 row[x * kBytesPerPixel+2] = b; | 127 row[x * kBytesPerPixel+2] = b; |
128 row[x * kBytesPerPixel+3] = 0xff; | 128 row[x * kBytesPerPixel+3] = 0xff; |
129 } | 129 } |
130 row += bytes_per_row_; | 130 row += bytes_per_row_; |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 } // namespace remoting | 134 } // namespace remoting |
OLD | NEW |