| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/video_frame_capturer_fake.h" | 5 #include "remoting/host/video_frame_capturer_fake.h" |
| 6 | 6 |
| 7 #include "remoting/base/capture_data.h" | 7 #include "remoting/base/capture_data.h" |
| 8 | 8 |
| 9 namespace remoting { | 9 namespace remoting { |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 box_speed_x_(kSpeed), | 32 box_speed_x_(kSpeed), |
| 33 box_speed_y_(kSpeed), | 33 box_speed_y_(kSpeed), |
| 34 current_buffer_(0), | 34 current_buffer_(0), |
| 35 pixel_format_(media::VideoFrame::RGB32) { | 35 pixel_format_(media::VideoFrame::RGB32) { |
| 36 ScreenConfigurationChanged(); | 36 ScreenConfigurationChanged(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 VideoFrameCapturerFake::~VideoFrameCapturerFake() { | 39 VideoFrameCapturerFake::~VideoFrameCapturerFake() { |
| 40 } | 40 } |
| 41 | 41 |
| 42 void VideoFrameCapturerFake::Start(const CursorShapeChangedCallback& callback) { | 42 void VideoFrameCapturerFake::Start(Delegate* delegate) { |
| 43 delegate_ = delegate; |
| 43 } | 44 } |
| 44 | 45 |
| 45 void VideoFrameCapturerFake::Stop() { | 46 void VideoFrameCapturerFake::Stop() { |
| 46 } | 47 } |
| 47 | 48 |
| 48 media::VideoFrame::Format VideoFrameCapturerFake::pixel_format() const { | 49 media::VideoFrame::Format VideoFrameCapturerFake::pixel_format() const { |
| 49 return pixel_format_; | 50 return pixel_format_; |
| 50 } | 51 } |
| 51 | 52 |
| 52 void VideoFrameCapturerFake::InvalidateRegion(const SkRegion& invalid_region) { | 53 void VideoFrameCapturerFake::InvalidateRegion(const SkRegion& invalid_region) { |
| 53 helper_.InvalidateRegion(invalid_region); | 54 helper_.InvalidateRegion(invalid_region); |
| 54 } | 55 } |
| 55 | 56 |
| 56 void VideoFrameCapturerFake::CaptureInvalidRegion( | 57 void VideoFrameCapturerFake::CaptureInvalidRegion() { |
| 57 const CaptureCompletedCallback& callback) { | |
| 58 GenerateImage(); | 58 GenerateImage(); |
| 59 helper_.InvalidateScreen(size_); | 59 helper_.InvalidateScreen(size_); |
| 60 | 60 |
| 61 SkRegion invalid_region; | 61 SkRegion invalid_region; |
| 62 helper_.SwapInvalidRegion(&invalid_region); | 62 helper_.SwapInvalidRegion(&invalid_region); |
| 63 | 63 |
| 64 DataPlanes planes; | 64 DataPlanes planes; |
| 65 planes.data[0] = buffers_[current_buffer_].get(); | 65 planes.data[0] = buffers_[current_buffer_].get(); |
| 66 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; | 66 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; |
| 67 planes.strides[0] = bytes_per_row_; | 67 planes.strides[0] = bytes_per_row_; |
| 68 | 68 |
| 69 scoped_refptr<CaptureData> capture_data(new CaptureData(planes, | 69 scoped_refptr<CaptureData> capture_data(new CaptureData(planes, |
| 70 size_, | 70 size_, |
| 71 pixel_format_)); | 71 pixel_format_)); |
| 72 capture_data->mutable_dirty_region() = invalid_region; | 72 capture_data->mutable_dirty_region() = invalid_region; |
| 73 | 73 |
| 74 helper_.set_size_most_recent(capture_data->size()); | 74 helper_.set_size_most_recent(capture_data->size()); |
| 75 | 75 |
| 76 callback.Run(capture_data); | 76 delegate_->OnCaptureCompleted(capture_data); |
| 77 } | 77 } |
| 78 | 78 |
| 79 const SkISize& VideoFrameCapturerFake::size_most_recent() const { | 79 const SkISize& VideoFrameCapturerFake::size_most_recent() const { |
| 80 return helper_.size_most_recent(); | 80 return helper_.size_most_recent(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void VideoFrameCapturerFake::GenerateImage() { | 83 void VideoFrameCapturerFake::GenerateImage() { |
| 84 memset(buffers_[current_buffer_].get(), 0xff, | 84 memset(buffers_[current_buffer_].get(), 0xff, |
| 85 size_.width() * size_.height() * kBytesPerPixel); | 85 size_.width() * size_.height() * kBytesPerPixel); |
| 86 | 86 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 pixel_format_ = media::VideoFrame::RGB32; | 119 pixel_format_ = media::VideoFrame::RGB32; |
| 120 | 120 |
| 121 // Create memory for the buffers. | 121 // Create memory for the buffers. |
| 122 int buffer_size = size_.height() * bytes_per_row_; | 122 int buffer_size = size_.height() * bytes_per_row_; |
| 123 for (int i = 0; i < kNumBuffers; i++) { | 123 for (int i = 0; i < kNumBuffers; i++) { |
| 124 buffers_[i].reset(new uint8[buffer_size]); | 124 buffers_[i].reset(new uint8[buffer_size]); |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace remoting | 128 } // namespace remoting |
| OLD | NEW |