| 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/client/frame_consumer_proxy.h" | 5 #include "remoting/client/frame_consumer_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 10 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| 11 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | |
| 12 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | |
| 13 | 11 |
| 14 namespace remoting { | 12 namespace remoting { |
| 15 | 13 |
| 16 FrameConsumerProxy::FrameConsumerProxy( | 14 FrameConsumerProxy::FrameConsumerProxy( |
| 17 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 15 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
| 18 : task_runner_(task_runner) { | 16 : task_runner_(task_runner) { |
| 19 } | 17 } |
| 20 | 18 |
| 21 void FrameConsumerProxy::ApplyBuffer(const webrtc::DesktopSize& view_size, | 19 void FrameConsumerProxy::ApplyBuffer(const SkISize& view_size, |
| 22 const webrtc::DesktopRect& clip_area, | 20 const SkIRect& clip_area, |
| 23 webrtc::DesktopFrame* buffer, | 21 webrtc::DesktopFrame* buffer, |
| 24 const webrtc::DesktopRegion& region) { | 22 const SkRegion& region) { |
| 25 if (!task_runner_->BelongsToCurrentThread()) { | 23 if (!task_runner_->BelongsToCurrentThread()) { |
| 26 task_runner_->PostTask(FROM_HERE, base::Bind( | 24 task_runner_->PostTask(FROM_HERE, base::Bind( |
| 27 &FrameConsumerProxy::ApplyBuffer, this, | 25 &FrameConsumerProxy::ApplyBuffer, this, |
| 28 view_size, clip_area, buffer, region)); | 26 view_size, clip_area, buffer, region)); |
| 29 return; | 27 return; |
| 30 } | 28 } |
| 31 | 29 |
| 32 if (frame_consumer_.get()) | 30 if (frame_consumer_.get()) |
| 33 frame_consumer_->ApplyBuffer(view_size, clip_area, buffer, region); | 31 frame_consumer_->ApplyBuffer(view_size, clip_area, buffer, region); |
| 34 } | 32 } |
| 35 | 33 |
| 36 void FrameConsumerProxy::ReturnBuffer(webrtc::DesktopFrame* buffer) { | 34 void FrameConsumerProxy::ReturnBuffer(webrtc::DesktopFrame* buffer) { |
| 37 if (!task_runner_->BelongsToCurrentThread()) { | 35 if (!task_runner_->BelongsToCurrentThread()) { |
| 38 task_runner_->PostTask(FROM_HERE, base::Bind( | 36 task_runner_->PostTask(FROM_HERE, base::Bind( |
| 39 &FrameConsumerProxy::ReturnBuffer, this, buffer)); | 37 &FrameConsumerProxy::ReturnBuffer, this, buffer)); |
| 40 return; | 38 return; |
| 41 } | 39 } |
| 42 | 40 |
| 43 if (frame_consumer_.get()) | 41 if (frame_consumer_.get()) |
| 44 frame_consumer_->ReturnBuffer(buffer); | 42 frame_consumer_->ReturnBuffer(buffer); |
| 45 } | 43 } |
| 46 | 44 |
| 47 void FrameConsumerProxy::SetSourceSize( | 45 void FrameConsumerProxy::SetSourceSize(const SkISize& source_size, |
| 48 const webrtc::DesktopSize& source_size, | 46 const SkIPoint& source_dpi) { |
| 49 const webrtc::DesktopVector& source_dpi) { | |
| 50 if (!task_runner_->BelongsToCurrentThread()) { | 47 if (!task_runner_->BelongsToCurrentThread()) { |
| 51 task_runner_->PostTask(FROM_HERE, base::Bind( | 48 task_runner_->PostTask(FROM_HERE, base::Bind( |
| 52 &FrameConsumerProxy::SetSourceSize, this, source_size, source_dpi)); | 49 &FrameConsumerProxy::SetSourceSize, this, source_size, source_dpi)); |
| 53 return; | 50 return; |
| 54 } | 51 } |
| 55 | 52 |
| 56 if (frame_consumer_.get()) | 53 if (frame_consumer_.get()) |
| 57 frame_consumer_->SetSourceSize(source_size, source_dpi); | 54 frame_consumer_->SetSourceSize(source_size, source_dpi); |
| 58 } | 55 } |
| 59 | 56 |
| 60 void FrameConsumerProxy::Attach( | 57 void FrameConsumerProxy::Attach( |
| 61 const base::WeakPtr<FrameConsumer>& frame_consumer) { | 58 const base::WeakPtr<FrameConsumer>& frame_consumer) { |
| 62 DCHECK(task_runner_->BelongsToCurrentThread()); | 59 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 63 DCHECK(frame_consumer_.get() == NULL); | 60 DCHECK(frame_consumer_.get() == NULL); |
| 64 frame_consumer_ = frame_consumer; | 61 frame_consumer_ = frame_consumer; |
| 65 } | 62 } |
| 66 | 63 |
| 67 FrameConsumerProxy::~FrameConsumerProxy() { | 64 FrameConsumerProxy::~FrameConsumerProxy() { |
| 68 } | 65 } |
| 69 | 66 |
| 70 } // namespace remoting | 67 } // namespace remoting |
| OLD | NEW |