diff options
author | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-07 05:54:23 +0000 |
---|---|---|
committer | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-07 05:54:23 +0000 |
commit | 5de788d86f799edb83a1c3a320d3326a85434d1a (patch) | |
tree | 917d9766fe5bea9a2a4dca8dde350df3e356919c /media | |
parent | f9721f1c14c4b1904e56c4db3d381b61d1049831 (diff) | |
download | chromium_src-5de788d86f799edb83a1c3a320d3326a85434d1a.zip chromium_src-5de788d86f799edb83a1c3a320d3326a85434d1a.tar.gz chromium_src-5de788d86f799edb83a1c3a320d3326a85434d1a.tar.bz2 |
Adding a unit test to verify the IPC channel between the network and desktop processes.
Related changes:
- The fake screen capturer now uses shared buffers when they available.
- DesktopSessionAgent frees the client end handle of the network-to-desktop pipe once the connection has been established.
BUG=134694
Review URL: https://chromiumcodereview.appspot.com/12096071
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181221 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/video/capture/screen/screen_capturer_fake.cc | 28 | ||||
-rw-r--r-- | media/video/capture/screen/screen_capturer_fake.h | 8 |
2 files changed, 25 insertions, 11 deletions
diff --git a/media/video/capture/screen/screen_capturer_fake.cc b/media/video/capture/screen/screen_capturer_fake.cc index d069d54..5db2765 100644 --- a/media/video/capture/screen/screen_capturer_fake.cc +++ b/media/video/capture/screen/screen_capturer_fake.cc @@ -39,6 +39,18 @@ ScreenCapturerFake::~ScreenCapturerFake() { void ScreenCapturerFake::Start(Delegate* delegate) { delegate_ = delegate; + + // Create memory for the buffers. + int buffer_size = size_.height() * bytes_per_row_; + for (int i = 0; i < kNumBuffers; i++) { + shared_buffers_[i] = delegate_->CreateSharedBuffer(buffer_size); + if (shared_buffers_[i]) { + buffers_[i] = reinterpret_cast<uint8*>(shared_buffers_[i]->ptr()); + } else { + private_buffers_[i].reset(new uint8[buffer_size]); + buffers_[i] = private_buffers_[i].get(); + } + } } void ScreenCapturerFake::Stop() { @@ -60,10 +72,12 @@ void ScreenCapturerFake::CaptureFrame() { current_buffer_ = (current_buffer_ + 1) % kNumBuffers; scoped_refptr<ScreenCaptureData> capture_data(new ScreenCaptureData( - buffers_[current_buffer_].get(), bytes_per_row_, size_)); + buffers_[current_buffer_], bytes_per_row_, size_)); capture_data->mutable_dirty_region() = invalid_region; - helper_.set_size_most_recent(capture_data->size()); + helper_.set_size_most_recent(size_); + + capture_data->set_shared_buffer(shared_buffers_[current_buffer_]); capture_data->set_capture_time_ms( (base::Time::Now() - capture_start_time).InMillisecondsRoundedUp()); @@ -71,10 +85,10 @@ void ScreenCapturerFake::CaptureFrame() { } void ScreenCapturerFake::GenerateImage() { - memset(buffers_[current_buffer_].get(), 0xff, + memset(buffers_[current_buffer_], 0xff, size_.width() * size_.height() * ScreenCaptureData::kBytesPerPixel); - uint8* row = buffers_[current_buffer_].get() + + uint8* row = buffers_[current_buffer_] + (box_pos_y_ * size_.width() + box_pos_x_) * ScreenCaptureData::kBytesPerPixel; @@ -107,12 +121,6 @@ void ScreenCapturerFake::GenerateImage() { void ScreenCapturerFake::ScreenConfigurationChanged() { size_ = SkISize::Make(kWidth, kHeight); bytes_per_row_ = size_.width() * ScreenCaptureData::kBytesPerPixel; - - // Create memory for the buffers. - int buffer_size = size_.height() * bytes_per_row_; - for (int i = 0; i < kNumBuffers; i++) { - buffers_[i].reset(new uint8[buffer_size]); - } } } // namespace media diff --git a/media/video/capture/screen/screen_capturer_fake.h b/media/video/capture/screen/screen_capturer_fake.h index 11daad4..69f4dd1 100644 --- a/media/video/capture/screen/screen_capturer_fake.h +++ b/media/video/capture/screen/screen_capturer_fake.h @@ -50,11 +50,17 @@ class MEDIA_EXPORT ScreenCapturerFake : public ScreenCapturer { // We have two buffers for the screen images as required by Capturer. static const int kNumBuffers = 2; - scoped_array<uint8> buffers_[kNumBuffers]; + uint8* buffers_[kNumBuffers]; // The current buffer with valid data for reading. int current_buffer_; + // Used when |delegate_| implements CreateSharedBuffer(). + scoped_refptr<SharedBuffer> shared_buffers_[kNumBuffers]; + + // Used when |delegate_| does not implement CreateSharedBuffer(). + scoped_array<uint8> private_buffers_[kNumBuffers]; + DISALLOW_COPY_AND_ASSIGN(ScreenCapturerFake); }; |