| 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 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 VideoFrameCapturerFake::~VideoFrameCapturerFake() { | 38 VideoFrameCapturerFake::~VideoFrameCapturerFake() { |
| 39 } | 39 } |
| 40 | 40 |
| 41 void VideoFrameCapturerFake::Start(const CursorShapeChangedCallback& callback) { | 41 void VideoFrameCapturerFake::Start(const CursorShapeChangedCallback& callback) { |
| 42 } | 42 } |
| 43 | 43 |
| 44 void VideoFrameCapturerFake::Stop() { | 44 void VideoFrameCapturerFake::Stop() { |
| 45 } | 45 } |
| 46 | 46 |
| 47 void VideoFrameCapturerFake::ScreenConfigurationChanged() { | |
| 48 size_ = SkISize::Make(kWidth, kHeight); | |
| 49 bytes_per_row_ = size_.width() * kBytesPerPixel; | |
| 50 pixel_format_ = media::VideoFrame::RGB32; | |
| 51 | |
| 52 // Create memory for the buffers. | |
| 53 int buffer_size = size_.height() * bytes_per_row_; | |
| 54 for (int i = 0; i < kNumBuffers; i++) { | |
| 55 buffers_[i].reset(new uint8[buffer_size]); | |
| 56 } | |
| 57 } | |
| 58 | |
| 59 media::VideoFrame::Format VideoFrameCapturerFake::pixel_format() const { | 47 media::VideoFrame::Format VideoFrameCapturerFake::pixel_format() const { |
| 60 return pixel_format_; | 48 return pixel_format_; |
| 61 } | 49 } |
| 62 | 50 |
| 63 void VideoFrameCapturerFake::ClearInvalidRegion() { | |
| 64 helper_.ClearInvalidRegion(); | |
| 65 } | |
| 66 | |
| 67 void VideoFrameCapturerFake::InvalidateRegion(const SkRegion& invalid_region) { | 51 void VideoFrameCapturerFake::InvalidateRegion(const SkRegion& invalid_region) { |
| 68 helper_.InvalidateRegion(invalid_region); | 52 helper_.InvalidateRegion(invalid_region); |
| 69 } | 53 } |
| 70 | 54 |
| 71 void VideoFrameCapturerFake::InvalidateScreen(const SkISize& size) { | |
| 72 helper_.InvalidateScreen(size); | |
| 73 } | |
| 74 | |
| 75 void VideoFrameCapturerFake::InvalidateFullScreen() { | |
| 76 helper_.InvalidateFullScreen(); | |
| 77 } | |
| 78 | |
| 79 void VideoFrameCapturerFake::CaptureInvalidRegion( | 55 void VideoFrameCapturerFake::CaptureInvalidRegion( |
| 80 const CaptureCompletedCallback& callback) { | 56 const CaptureCompletedCallback& callback) { |
| 81 GenerateImage(); | 57 GenerateImage(); |
| 82 InvalidateScreen(size_); | 58 helper_.InvalidateScreen(size_); |
| 83 | 59 |
| 84 SkRegion invalid_region; | 60 SkRegion invalid_region; |
| 85 helper_.SwapInvalidRegion(&invalid_region); | 61 helper_.SwapInvalidRegion(&invalid_region); |
| 86 | 62 |
| 87 DataPlanes planes; | 63 DataPlanes planes; |
| 88 planes.data[0] = buffers_[current_buffer_].get(); | 64 planes.data[0] = buffers_[current_buffer_].get(); |
| 89 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; | 65 current_buffer_ = (current_buffer_ + 1) % kNumBuffers; |
| 90 planes.strides[0] = bytes_per_row_; | 66 planes.strides[0] = bytes_per_row_; |
| 91 | 67 |
| 92 scoped_refptr<CaptureData> capture_data(new CaptureData(planes, | 68 scoped_refptr<CaptureData> capture_data(new CaptureData(planes, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 int b = 255 - (x * 255 / kBoxWidth); | 105 int b = 255 - (x * 255 / kBoxWidth); |
| 130 row[x * kBytesPerPixel] = r; | 106 row[x * kBytesPerPixel] = r; |
| 131 row[x * kBytesPerPixel+1] = g; | 107 row[x * kBytesPerPixel+1] = g; |
| 132 row[x * kBytesPerPixel+2] = b; | 108 row[x * kBytesPerPixel+2] = b; |
| 133 row[x * kBytesPerPixel+3] = 0xff; | 109 row[x * kBytesPerPixel+3] = 0xff; |
| 134 } | 110 } |
| 135 row += bytes_per_row_; | 111 row += bytes_per_row_; |
| 136 } | 112 } |
| 137 } | 113 } |
| 138 | 114 |
| 115 void VideoFrameCapturerFake::ScreenConfigurationChanged() { |
| 116 size_ = SkISize::Make(kWidth, kHeight); |
| 117 bytes_per_row_ = size_.width() * kBytesPerPixel; |
| 118 pixel_format_ = media::VideoFrame::RGB32; |
| 119 |
| 120 // Create memory for the buffers. |
| 121 int buffer_size = size_.height() * bytes_per_row_; |
| 122 for (int i = 0; i < kNumBuffers; i++) { |
| 123 buffers_[i].reset(new uint8[buffer_size]); |
| 124 } |
| 125 } |
| 126 |
| 139 } // namespace remoting | 127 } // namespace remoting |
| OLD | NEW |