OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/rectangle_update_decoder.h" | 5 #include "remoting/client/rectangle_update_decoder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "remoting/base/decoder.h" | 10 #include "remoting/base/decoder.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 if (!decoder_->IsReadyForData()) { | 124 if (!decoder_->IsReadyForData()) { |
125 // TODO(ajwong): This whole thing should move into an invalid state. | 125 // TODO(ajwong): This whole thing should move into an invalid state. |
126 LOG(ERROR) << "Decoder is unable to process data. Dropping packet."; | 126 LOG(ERROR) << "Decoder is unable to process data. Dropping packet."; |
127 return; | 127 return; |
128 } | 128 } |
129 | 129 |
130 if (decoder_->DecodePacket(packet) == Decoder::DECODE_DONE) | 130 if (decoder_->DecodePacket(packet) == Decoder::DECODE_DONE) |
131 SubmitToConsumer(); | 131 SubmitToConsumer(); |
132 } | 132 } |
133 | 133 |
134 void RectangleUpdateDecoder::SetScaleRatios(double horizontal_ratio, | 134 void RectangleUpdateDecoder::SetOutputSize(const SkISize& size) { |
135 double vertical_ratio) { | |
136 if (message_loop_ != MessageLoop::current()) { | 135 if (message_loop_ != MessageLoop::current()) { |
137 message_loop_->PostTask( | 136 message_loop_->PostTask( |
138 FROM_HERE, base::Bind(&RectangleUpdateDecoder::SetScaleRatios, | 137 FROM_HERE, base::Bind(&RectangleUpdateDecoder::SetOutputSize, |
139 this, horizontal_ratio, vertical_ratio)); | 138 this, size)); |
140 return; | 139 return; |
141 } | 140 } |
142 | 141 |
143 // TODO(wez): Refresh the frame only if the ratio has changed. | 142 // TODO(wez): Refresh the frame only if the ratio has changed. |
144 if (frame_) { | 143 if (frame_) { |
145 SkIRect frame_rect = SkIRect::MakeWH(frame_->width(), frame_->height()); | 144 SkIRect frame_rect = SkIRect::MakeWH(frame_->width(), frame_->height()); |
146 refresh_rects_.push_back(frame_rect); | 145 refresh_rects_.push_back(frame_rect); |
147 } | 146 } |
148 | 147 |
149 // TODO(hclam): If the scale ratio has changed we should reallocate a | 148 // TODO(hclam): If the scale ratio has changed we should reallocate a |
150 // VideoFrame of different size. However if the scale ratio is always | 149 // VideoFrame of different size. However if the scale ratio is always |
151 // smaller than 1.0 we can use the same video frame. | 150 // smaller than 1.0 we can use the same video frame. |
152 decoder_->SetScaleRatios(horizontal_ratio, vertical_ratio); | 151 if (decoder_.get()) { |
153 | 152 decoder_->SetOutputSize(size); |
154 // TODO(wez): Defer refresh, so that resize, which will affect both scale | 153 RefreshFullFrame(); |
155 // factor and clip rect, doesn't lead to unnecessary refreshes. | 154 } |
156 DoRefresh(); | |
157 } | 155 } |
158 | 156 |
159 void RectangleUpdateDecoder::UpdateClipRect(const SkIRect& new_clip_rect) { | 157 void RectangleUpdateDecoder::UpdateClipRect(const SkIRect& new_clip_rect) { |
160 if (message_loop_ != MessageLoop::current()) { | 158 if (message_loop_ != MessageLoop::current()) { |
161 message_loop_->PostTask( | 159 message_loop_->PostTask( |
162 FROM_HERE, base::Bind(&RectangleUpdateDecoder::UpdateClipRect, | 160 FROM_HERE, base::Bind(&RectangleUpdateDecoder::UpdateClipRect, |
163 this, new_clip_rect)); | 161 this, new_clip_rect)); |
164 return; | 162 return; |
165 } | 163 } |
166 | 164 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 return; | 229 return; |
232 } | 230 } |
233 | 231 |
234 delete rects; | 232 delete rects; |
235 | 233 |
236 frame_is_consuming_ = false; | 234 frame_is_consuming_ = false; |
237 DoRefresh(); | 235 DoRefresh(); |
238 } | 236 } |
239 | 237 |
240 } // namespace remoting | 238 } // namespace remoting |
OLD | NEW |