summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-06 23:18:44 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-06 23:18:44 +0000
commit8a15f0149b7ccd709574151ce7eeb1add16e7cc7 (patch)
tree57eb261afb052374a778b4aa18919be0c6dc83f9 /remoting
parent1e7b565652875f8f16e5211d1fecaed17efe26e1 (diff)
downloadchromium_src-8a15f0149b7ccd709574151ce7eeb1add16e7cc7.zip
chromium_src-8a15f0149b7ccd709574151ce7eeb1add16e7cc7.tar.gz
chromium_src-8a15f0149b7ccd709574151ce7eeb1add16e7cc7.tar.bz2
Reverse rows in DecoderZlib for remoting
Windows images are upside down, so when we decode the stream and paint the image we need to reverse the rows. This is a temporary solution since it sets to reverse rows by default. We'll move to use the information from the update stream to determine we should reverse or not. Review URL: http://codereview.chromium.org/2883055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55314 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/base/decoder_zlib.cc21
-rw-r--r--remoting/base/decoder_zlib.h6
-rw-r--r--remoting/base/decoder_zlib_unittest.cc8
3 files changed, 31 insertions, 4 deletions
diff --git a/remoting/base/decoder_zlib.cc b/remoting/base/decoder_zlib.cc
index 3e23f95..e44a2f2 100644
--- a/remoting/base/decoder_zlib.cc
+++ b/remoting/base/decoder_zlib.cc
@@ -18,7 +18,11 @@ DecoderZlib::DecoderZlib()
bytes_per_pixel_(0),
updated_rects_(NULL),
row_pos_(0),
- row_y_(0) {
+ row_y_(0),
+ // TODO(hclam): We should use the information from the update stream
+ // to determine whether we should reverse the rows or not.
+ // But for simplicity we set to be always true.
+ reverse_rows_(true) {
}
bool DecoderZlib::BeginDecode(scoped_refptr<media::VideoFrame> frame,
@@ -106,9 +110,18 @@ bool DecoderZlib::HandleRectData(HostMessage* message) {
const int in_size =
message->update_stream_packet().rect_data().data().size();
const int row_size = rect_width_ * bytes_per_pixel_;
- const int stride = frame_->stride(media::VideoFrame::kRGBPlane);
- uint8* out = frame_->data(media::VideoFrame::kRGBPlane) +
- stride * (rect_y_ + row_y_) + bytes_per_pixel_ * rect_x_;
+ int stride = frame_->stride(media::VideoFrame::kRGBPlane);
+ uint8* rect_begin = frame_->data(media::VideoFrame::kRGBPlane);
+ if (reverse_rows_) {
+ // Advance the pointer to the last row.
+ rect_begin += (frame_->height() - 1) * stride;
+
+ // And then make the stride negative.
+ stride = -stride;
+ }
+
+ uint8* out = rect_begin + stride * (rect_y_ + row_y_) +
+ bytes_per_pixel_ * rect_x_;
// Consume all the data in the message.
bool decompress_again = true;
diff --git a/remoting/base/decoder_zlib.h b/remoting/base/decoder_zlib.h
index 4d20c10..05f8a99 100644
--- a/remoting/base/decoder_zlib.h
+++ b/remoting/base/decoder_zlib.h
@@ -23,6 +23,9 @@ class DecoderZlib : public Decoder {
virtual bool PartialDecode(HostMessage* message);
virtual void EndDecode();
+ // TODO(hclam): Should make this into the Decoder interface.
+ void set_reverse_rows(bool reverse) { reverse_rows_ = reverse; }
+
private:
bool HandleBeginRect(HostMessage* message);
bool HandleRectData(HostMessage* message);
@@ -55,6 +58,9 @@ class DecoderZlib : public Decoder {
// The row number in the rect that we are updaing.
int row_y_;
+ // True if we should decode the image upside down.
+ bool reverse_rows_;
+
DISALLOW_COPY_AND_ASSIGN(DecoderZlib);
};
diff --git a/remoting/base/decoder_zlib_unittest.cc b/remoting/base/decoder_zlib_unittest.cc
index 8ebad1d..388abd0 100644
--- a/remoting/base/decoder_zlib_unittest.cc
+++ b/remoting/base/decoder_zlib_unittest.cc
@@ -16,13 +16,21 @@ namespace remoting {
TEST(DecoderZlibTest, EncodeAndDecode) {
EncoderZlib encoder;
DecoderZlib decoder;
+ decoder.set_reverse_rows(false);
TestEncoderDecoder(&encoder, &decoder, true);
}
TEST(DecoderZlibTest, EncodeAndDecodeSmallOutputBuffer) {
EncoderZlib encoder(64);
DecoderZlib decoder;
+ decoder.set_reverse_rows(false);
TestEncoderDecoder(&encoder, &decoder, true);
}
+TEST(DecoderZlibTest, EncodeAndDecodeNoneStrict) {
+ EncoderZlib encoder;
+ DecoderZlib decoder;
+ TestEncoderDecoder(&encoder, &decoder, false);
+}
+
} // namespace remoting