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