| 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/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "ppapi/cpp/image_data.h" |
| 10 |
| 11 using base::Passed; |
| 9 | 12 |
| 10 namespace remoting { | 13 namespace remoting { |
| 11 | 14 |
| 12 FrameConsumerProxy::FrameConsumerProxy( | 15 FrameConsumerProxy::FrameConsumerProxy( |
| 13 FrameConsumer* frame_consumer, | 16 FrameConsumer* frame_consumer, |
| 14 base::MessageLoopProxy* frame_consumer_message_loop) | 17 base::MessageLoopProxy* frame_consumer_message_loop) |
| 15 : frame_consumer_(frame_consumer), | 18 : frame_consumer_(frame_consumer), |
| 16 frame_consumer_message_loop_(frame_consumer_message_loop) { | 19 frame_consumer_message_loop_(frame_consumer_message_loop) { |
| 17 } | 20 } |
| 18 | 21 |
| 19 FrameConsumerProxy::~FrameConsumerProxy() { | 22 FrameConsumerProxy::~FrameConsumerProxy() { |
| 20 } | 23 } |
| 21 | 24 |
| 22 void FrameConsumerProxy::AllocateFrame( | 25 void FrameConsumerProxy::OnFrameReady( |
| 23 media::VideoFrame::Format format, | 26 const SkISize& screen_size, |
| 24 const SkISize& size, | 27 SkISize* view_size_out, |
| 25 scoped_refptr<media::VideoFrame>* frame_out, | 28 SkIRect* clip_area_out, |
| 29 scoped_ptr<pp::ImageData>* backing_store_out, |
| 26 const base::Closure& done) { | 30 const base::Closure& done) { |
| 27 if (!frame_consumer_message_loop_->BelongsToCurrentThread()) { | 31 if (!frame_consumer_message_loop_->BelongsToCurrentThread()) { |
| 28 frame_consumer_message_loop_->PostTask(FROM_HERE, base::Bind( | 32 frame_consumer_message_loop_->PostTask(FROM_HERE, base::Bind( |
| 29 &FrameConsumerProxy::AllocateFrame, this, format, size, frame_out, | 33 &FrameConsumerProxy::OnFrameReady, this, |
| 30 done)); | 34 screen_size, view_size_out, clip_area_out, backing_store_out, done)); |
| 31 return; | |
| 32 } | |
| 33 | |
| 34 if (frame_consumer_) { | |
| 35 frame_consumer_->AllocateFrame(format, size, frame_out, done); | |
| 36 } | |
| 37 } | |
| 38 | |
| 39 void FrameConsumerProxy::ReleaseFrame(media::VideoFrame* frame) { | |
| 40 if (!frame_consumer_message_loop_->BelongsToCurrentThread()) { | |
| 41 frame_consumer_message_loop_->PostTask(FROM_HERE, base::Bind( | |
| 42 &FrameConsumerProxy::ReleaseFrame, this, make_scoped_refptr(frame))); | |
| 43 return; | 35 return; |
| 44 } | 36 } |
| 45 | 37 |
| 46 if (frame_consumer_) | 38 if (frame_consumer_) |
| 47 frame_consumer_->ReleaseFrame(frame); | 39 frame_consumer_->OnFrameReady(screen_size, view_size_out, clip_area_out, |
| 40 backing_store_out, done); |
| 48 } | 41 } |
| 49 | 42 |
| 50 void FrameConsumerProxy::OnPartialFrameOutput(media::VideoFrame* frame, | 43 void FrameConsumerProxy::OnPaintDone(scoped_ptr<pp::ImageData> backing_store, |
| 51 SkRegion* region, | 44 scoped_ptr<SkRegion> updated_region) { |
| 52 const base::Closure& done) { | |
| 53 if (!frame_consumer_message_loop_->BelongsToCurrentThread()) { | 45 if (!frame_consumer_message_loop_->BelongsToCurrentThread()) { |
| 54 frame_consumer_message_loop_->PostTask(FROM_HERE, base::Bind( | 46 frame_consumer_message_loop_->PostTask(FROM_HERE, base::Bind( |
| 55 &FrameConsumerProxy::OnPartialFrameOutput, this, | 47 &FrameConsumerProxy::OnPaintDone, this, |
| 56 make_scoped_refptr(frame), region, done)); | 48 Passed(&backing_store), Passed(&updated_region))); |
| 57 return; | 49 return; |
| 58 } | 50 } |
| 59 | 51 |
| 60 if (frame_consumer_) | 52 if (frame_consumer_) |
| 61 frame_consumer_->OnPartialFrameOutput(frame, region, done); | 53 frame_consumer_->OnPaintDone(backing_store.Pass(), updated_region.Pass()); |
| 62 } | 54 } |
| 63 | 55 |
| 64 void FrameConsumerProxy::Detach() { | 56 void FrameConsumerProxy::Detach() { |
| 65 DCHECK(frame_consumer_message_loop_->BelongsToCurrentThread()); | 57 DCHECK(frame_consumer_message_loop_->BelongsToCurrentThread()); |
| 66 frame_consumer_ = NULL; | 58 frame_consumer_ = NULL; |
| 67 } | 59 } |
| 68 | 60 |
| 69 } // namespace remoting | 61 } // namespace remoting |
| OLD | NEW |