Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: remoting/base/encoder_zlib.cc

Issue 3141036: Revert 57112 - Rename (Host|Client)Message to Chromoting(Host|Client)Message.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/base/encoder_zlib.h ('k') | remoting/base/protocol/chromotocol.proto » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/base/encoder_zlib.h" 5 #include "remoting/base/encoder_zlib.h"
6 6
7 #include "gfx/rect.h" 7 #include "gfx/rect.h"
8 #include "media/base/data_buffer.h" 8 #include "media/base/data_buffer.h"
9 #include "remoting/base/capture_data.h" 9 #include "remoting/base/capture_data.h"
10 #include "remoting/base/compressor_zlib.h" 10 #include "remoting/base/compressor_zlib.h"
(...skipping 30 matching lines...) Expand all
41 callback_.reset(); 41 callback_.reset();
42 } 42 }
43 43
44 void EncoderZlib::EncodeRect(CompressorZlib* compressor, 44 void EncoderZlib::EncodeRect(CompressorZlib* compressor,
45 const gfx::Rect& rect, size_t rect_index) { 45 const gfx::Rect& rect, size_t rect_index) {
46 CHECK(capture_data_->data_planes().data[0]); 46 CHECK(capture_data_->data_planes().data[0]);
47 const int strides = capture_data_->data_planes().strides[0]; 47 const int strides = capture_data_->data_planes().strides[0];
48 const int bytes_per_pixel = GetBytesPerPixel(capture_data_->pixel_format()); 48 const int bytes_per_pixel = GetBytesPerPixel(capture_data_->pixel_format());
49 const int row_size = bytes_per_pixel * rect.width(); 49 const int row_size = bytes_per_pixel * rect.width();
50 50
51 ChromotingHostMessage* message = PrepareMessage(&rect); 51 HostMessage* message = PrepareMessage(&rect);
52 const uint8 * in = capture_data_->data_planes().data[0] + 52 const uint8 * in = capture_data_->data_planes().data[0] +
53 rect.y() * strides + 53 rect.y() * strides +
54 rect.x() * bytes_per_pixel; 54 rect.x() * bytes_per_pixel;
55 // TODO(hclam): Fill in the sequence number. 55 // TODO(hclam): Fill in the sequence number.
56 uint8* out = (uint8*)message->mutable_update_stream_packet()-> 56 uint8* out = (uint8*)message->mutable_update_stream_packet()->
57 mutable_rect_data()->mutable_data()->data(); 57 mutable_rect_data()->mutable_data()->data();
58 int filled = 0; 58 int filled = 0;
59 int row_x = 0; 59 int row_x = 0;
60 int row_y = 0; 60 int row_y = 0;
61 bool compress_again = true; 61 bool compress_again = true;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 // Reached the end of input row and we're not at the last row. 101 // Reached the end of input row and we're not at the last row.
102 if (row_x == row_size && row_y < rect.height() - 1) { 102 if (row_x == row_size && row_y < rect.height() - 1) {
103 row_x = 0; 103 row_x = 0;
104 in += strides; 104 in += strides;
105 ++row_y; 105 ++row_y;
106 } 106 }
107 } 107 }
108 } 108 }
109 109
110 ChromotingHostMessage* EncoderZlib::PrepareMessage(const gfx::Rect* rect) { 110 HostMessage* EncoderZlib::PrepareMessage(const gfx::Rect* rect) {
111 ChromotingHostMessage* message = new ChromotingHostMessage(); 111 HostMessage* message = new HostMessage();
112 UpdateStreamPacketMessage* packet = message->mutable_update_stream_packet(); 112 UpdateStreamPacketMessage* packet = message->mutable_update_stream_packet();
113 113
114 // Prepare the begin rect content. 114 // Prepare the begin rect content.
115 if (rect != NULL) { 115 if (rect != NULL) {
116 packet->mutable_begin_rect()->set_x(rect->x()); 116 packet->mutable_begin_rect()->set_x(rect->x());
117 packet->mutable_begin_rect()->set_y(rect->y()); 117 packet->mutable_begin_rect()->set_y(rect->y());
118 packet->mutable_begin_rect()->set_width(rect->width()); 118 packet->mutable_begin_rect()->set_width(rect->width());
119 packet->mutable_begin_rect()->set_height(rect->height()); 119 packet->mutable_begin_rect()->set_height(rect->height());
120 packet->mutable_begin_rect()->set_encoding(EncodingZlib); 120 packet->mutable_begin_rect()->set_encoding(EncodingZlib);
121 packet->mutable_begin_rect()->set_pixel_format( 121 packet->mutable_begin_rect()->set_pixel_format(
122 capture_data_->pixel_format()); 122 capture_data_->pixel_format());
123 } 123 }
124 124
125 packet->mutable_rect_data()->mutable_data()->resize(packet_size_); 125 packet->mutable_rect_data()->mutable_data()->resize(packet_size_);
126 return message; 126 return message;
127 } 127 }
128 128
129 void EncoderZlib::SubmitMessage(ChromotingHostMessage* message, 129 void EncoderZlib::SubmitMessage(HostMessage* message, size_t rect_index) {
130 size_t rect_index) {
131 EncodingState state = EncodingInProgress; 130 EncodingState state = EncodingInProgress;
132 if (rect_index == 0 && message->update_stream_packet().has_begin_rect()) 131 if (rect_index == 0 && message->update_stream_packet().has_begin_rect())
133 state |= EncodingStarting; 132 state |= EncodingStarting;
134 if (rect_index == capture_data_->dirty_rects().size() - 1 && 133 if (rect_index == capture_data_->dirty_rects().size() - 1 &&
135 message->update_stream_packet().has_end_rect()) 134 message->update_stream_packet().has_end_rect())
136 state |= EncodingEnded; 135 state |= EncodingEnded;
137 callback_->Run(message, state); 136 callback_->Run(message, state);
138 } 137 }
139 138
140 } // namespace remoting 139 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/base/encoder_zlib.h ('k') | remoting/base/protocol/chromotocol.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698