OLD | NEW |
---|---|
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/client/decoder_verbatim.h" | 5 #include "remoting/client/decoder_verbatim.h" |
6 | 6 |
7 #include "remoting/base/protocol_util.h" | 7 #include "remoting/base/protocol_util.h" |
8 | 8 |
9 namespace remoting { | 9 namespace remoting { |
10 | 10 |
11 DecoderVerbatim::DecoderVerbatim() | 11 DecoderVerbatim::DecoderVerbatim() |
12 : updated_rects_(NULL) { | 12 : updated_rects_(NULL), |
13 reverse_rows_(true) { | |
dmac
2010/06/28 20:41:51
how do we plan to set this per platform?
| |
13 } | 14 } |
14 | 15 |
15 bool DecoderVerbatim::BeginDecode(scoped_refptr<media::VideoFrame> frame, | 16 bool DecoderVerbatim::BeginDecode(scoped_refptr<media::VideoFrame> frame, |
16 UpdatedRects* updated_rects, | 17 UpdatedRects* updated_rects, |
17 Task* partial_decode_done, | 18 Task* partial_decode_done, |
18 Task* decode_done) { | 19 Task* decode_done) { |
19 DCHECK(!partial_decode_done_.get()); | 20 DCHECK(!partial_decode_done_.get()); |
20 DCHECK(!decode_done_.get()); | 21 DCHECK(!decode_done_.get()); |
21 DCHECK(!updated_rects_); | 22 DCHECK(!updated_rects_); |
22 | 23 |
(...skipping 21 matching lines...) Expand all Loading... | |
44 NOTREACHED() << "Pixel format of message doesn't match the video frame. " | 45 NOTREACHED() << "Pixel format of message doesn't match the video frame. " |
45 "Expected vs received = " | 46 "Expected vs received = " |
46 << frame_->format() << " vs " << pixel_format | 47 << frame_->format() << " vs " << pixel_format |
47 << " Color space conversion required."; | 48 << " Color space conversion required."; |
48 } | 49 } |
49 | 50 |
50 int bytes_per_pixel = GetBytesPerPixel(pixel_format); | 51 int bytes_per_pixel = GetBytesPerPixel(pixel_format); |
51 // Copy the data line by line. | 52 // Copy the data line by line. |
52 const int src_stride = bytes_per_pixel * width; | 53 const int src_stride = bytes_per_pixel * width; |
53 const char* src = message->update_stream_packet().data().c_str(); | 54 const char* src = message->update_stream_packet().data().c_str(); |
55 int src_stride_dir = src_stride; | |
56 if (reverse_rows_) { | |
57 // Copy rows from bottom to top to flip the image vertically. | |
58 src += (height - 1) * src_stride; | |
59 // Change the direction of the stride to work bottom to top. | |
60 src_stride_dir *= -1; | |
61 } | |
54 const int dest_stride = frame_->stride(media::VideoFrame::kRGBPlane); | 62 const int dest_stride = frame_->stride(media::VideoFrame::kRGBPlane); |
55 uint8* dest = frame_->data(media::VideoFrame::kRGBPlane) + | 63 uint8* dest = frame_->data(media::VideoFrame::kRGBPlane) + |
56 dest_stride * y + bytes_per_pixel * x; | 64 dest_stride * y + bytes_per_pixel * x; |
57 for (int i = 0; i < height; ++i) { | 65 for (int i = 0; i < height; ++i) { |
58 memcpy(dest, src, src_stride); | 66 memcpy(dest, src, src_stride); |
59 dest += dest_stride; | 67 dest += dest_stride; |
60 src += src_stride; | 68 src += src_stride_dir; |
61 } | 69 } |
62 | 70 |
63 updated_rects_->clear(); | 71 updated_rects_->clear(); |
64 updated_rects_->push_back(gfx::Rect(x, y, width, height)); | 72 updated_rects_->push_back(gfx::Rect(x, y, width, height)); |
65 partial_decode_done_->Run(); | 73 partial_decode_done_->Run(); |
66 return true; | 74 return true; |
67 } | 75 } |
68 | 76 |
69 void DecoderVerbatim::EndDecode() { | 77 void DecoderVerbatim::EndDecode() { |
70 decode_done_->Run(); | 78 decode_done_->Run(); |
71 | 79 |
72 partial_decode_done_.reset(); | 80 partial_decode_done_.reset(); |
73 decode_done_.reset(); | 81 decode_done_.reset(); |
74 frame_ = NULL; | 82 frame_ = NULL; |
75 updated_rects_ = NULL; | 83 updated_rects_ = NULL; |
76 } | 84 } |
77 | 85 |
78 } // namespace remoting | 86 } // namespace remoting |
OLD | NEW |