diff options
author | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-15 16:35:33 +0000 |
---|---|---|
committer | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-15 16:35:33 +0000 |
commit | 7c186b16ffa7f386a60223157daa08a897052681 (patch) | |
tree | 942d5756bac3c6ea0665deab9873ca3c70c4e538 /remoting/host/encoder_verbatim.cc | |
parent | ded827d5bbdf31d0903d12ce326534cd4b956dbf (diff) | |
download | chromium_src-7c186b16ffa7f386a60223157daa08a897052681.zip chromium_src-7c186b16ffa7f386a60223157daa08a897052681.tar.gz chromium_src-7c186b16ffa7f386a60223157daa08a897052681.tar.bz2 |
Revamp threading a bit so that arguments are passed through and owned by the various threads instead of being all owned by the session manager.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/2807002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49803 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/encoder_verbatim.cc')
-rw-r--r-- | remoting/host/encoder_verbatim.cc | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/remoting/host/encoder_verbatim.cc b/remoting/host/encoder_verbatim.cc index 58525f1..f054ae8 100644 --- a/remoting/host/encoder_verbatim.cc +++ b/remoting/host/encoder_verbatim.cc @@ -13,22 +13,35 @@ namespace remoting { using media::DataBuffer; void EncoderVerbatim::Encode(const DirtyRects& dirty_rects, - const uint8** input_data, + const uint8* const* input_data, const int* strides, bool key_frame, - UpdateStreamPacketHeader* header, - scoped_refptr<DataBuffer>* output_data, - bool* encode_done, - Task* data_available_task) { + DataAvailableCallback* data_available_callback) { int num_rects = dirty_rects.size(); for (int i = 0; i < num_rects; i++) { - if (EncodeRect(dirty_rects[i], input_data, strides, header, output_data)) { - *encode_done = (i == num_rects - 1); // Set for last rect. - data_available_task->Run(); + scoped_refptr<DataBuffer> data; + gfx::Rect dirty_rect = dirty_rects[i]; + PixelFormat pixel_format; + UpdateStreamEncoding encoding; + scoped_ptr<UpdateStreamPacketHeader> header(new UpdateStreamPacketHeader); + if (EncodeRect(dirty_rect, + input_data, + strides, + header.get(), + &data)) { + EncodingState state = EncodingInProgress; + if (i == 0) { + state |= EncodingStarting; + } else if (i == num_rects - 1) { + state |= EncodingEnded; + } + data_available_callback->Run(header.release(), + data, + state); } } - delete data_available_task; + delete data_available_callback; } void EncoderVerbatim::SetSize(int width, int height) { @@ -54,9 +67,9 @@ void EncoderVerbatim::SetPixelFormat(PixelFormat pixel_format) { } bool EncoderVerbatim::EncodeRect(const gfx::Rect& dirty, - const uint8** input_data, + const uint8* const* input_data, const int* strides, - UpdateStreamPacketHeader* header, + UpdateStreamPacketHeader *header, scoped_refptr<DataBuffer>* output_data) { const int kPlanes = 3; @@ -74,10 +87,9 @@ bool EncoderVerbatim::EncodeRect(const gfx::Rect& dirty, header->set_encoding(EncodingNone); header->set_pixel_format(pixel_format_); - *output_data = new DataBuffer(output_size); - (*output_data)->SetDataSize(output_size); - + *output_data = new DataBuffer(new uint8[output_size], output_size); uint8* out = (*output_data)->GetWritableData(); + for (int i = 0; i < kPlanes; ++i) { const uint8* in = input_data[i]; // Skip over planes that don't have data. |