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

Side by Side Diff: remoting/client/rectangle_update_decoder.cc

Issue 8954003: Revised sub-rectangle scaling for use in Chromoting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Replace bounds-check on loop with a DCHECK. Created 9 years 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
OLDNEW
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 void RectangleUpdateDecoder::SetScaleRatios(double horizontal_ratio, 132 void RectangleUpdateDecoder::SetScaleRatios(double horizontal_ratio,
133 double vertical_ratio) { 133 double vertical_ratio) {
134 if (message_loop_ != MessageLoop::current()) { 134 if (message_loop_ != MessageLoop::current()) {
135 message_loop_->PostTask( 135 message_loop_->PostTask(
136 FROM_HERE, base::Bind(&RectangleUpdateDecoder::SetScaleRatios, 136 FROM_HERE, base::Bind(&RectangleUpdateDecoder::SetScaleRatios,
137 this, horizontal_ratio, vertical_ratio)); 137 this, horizontal_ratio, vertical_ratio));
138 return; 138 return;
139 } 139 }
140 140
141 // TODO(wez): Refresh the frame only if the ratio has changed.
142 if (frame_) {
143 SkIRect frame_rect = SkIRect::MakeWH(frame_->width(), frame_->height());
144 refresh_rects_.push_back(frame_rect);
145 }
146
141 // TODO(hclam): If the scale ratio has changed we should reallocate a 147 // TODO(hclam): If the scale ratio has changed we should reallocate a
142 // VideoFrame of different size. However if the scale ratio is always 148 // VideoFrame of different size. However if the scale ratio is always
143 // smaller than 1.0 we can use the same video frame. 149 // smaller than 1.0 we can use the same video frame.
144 decoder_->SetScaleRatios(horizontal_ratio, vertical_ratio); 150 decoder_->SetScaleRatios(horizontal_ratio, vertical_ratio);
151
152 // TODO(wez): Defer refresh, so that resize, which will affect both scale
153 // factor and clip rect, doesn't lead to unnecessary refreshes.
154 DoRefresh();
145 } 155 }
146 156
147 void RectangleUpdateDecoder::UpdateClipRect(const SkIRect& new_clip_rect) { 157 void RectangleUpdateDecoder::UpdateClipRect(const SkIRect& new_clip_rect) {
148 if (message_loop_ != MessageLoop::current()) { 158 if (message_loop_ != MessageLoop::current()) {
149 message_loop_->PostTask( 159 message_loop_->PostTask(
150 FROM_HERE, base::Bind(&RectangleUpdateDecoder::UpdateClipRect, 160 FROM_HERE, base::Bind(&RectangleUpdateDecoder::UpdateClipRect,
151 this, new_clip_rect)); 161 this, new_clip_rect));
152 return; 162 return;
153 } 163 }
154 164
155 if (new_clip_rect == clip_rect_ || !decoder_.get()) 165 if (new_clip_rect == clip_rect_ || !decoder_.get())
156 return; 166 return;
157 167
168 // TODO(wez): Only refresh newly-exposed portions of the frame.
169 if (frame_) {
170 SkIRect frame_rect = SkIRect::MakeWH(frame_->width(), frame_->height());
171 refresh_rects_.push_back(frame_rect);
172 }
173
174 #if 0
175 // TODO(wez): Fix this code to account for scaling.
176
158 // Find out the rectangles to show because of clip rect is updated. 177 // Find out the rectangles to show because of clip rect is updated.
159 if (new_clip_rect.fTop < clip_rect_.fTop) { 178 if (new_clip_rect.fTop < clip_rect_.fTop) {
160 refresh_rects_.push_back( 179 refresh_rects_.push_back(
161 SkIRect::MakeXYWH(new_clip_rect.fLeft, 180 SkIRect::MakeXYWH(new_clip_rect.fLeft,
162 new_clip_rect.fTop, 181 new_clip_rect.fTop,
163 new_clip_rect.width(), 182 new_clip_rect.width(),
164 clip_rect_.fTop - new_clip_rect.fTop)); 183 clip_rect_.fTop - new_clip_rect.fTop));
165 } 184 }
166 185
167 if (new_clip_rect.fLeft < clip_rect_.fLeft) { 186 if (new_clip_rect.fLeft < clip_rect_.fLeft) {
(...skipping 12 matching lines...) Expand all
180 new_clip_rect.height())); 199 new_clip_rect.height()));
181 } 200 }
182 201
183 if (new_clip_rect.fBottom > clip_rect_.fBottom) { 202 if (new_clip_rect.fBottom > clip_rect_.fBottom) {
184 refresh_rects_.push_back( 203 refresh_rects_.push_back(
185 SkIRect::MakeXYWH(new_clip_rect.fLeft, 204 SkIRect::MakeXYWH(new_clip_rect.fLeft,
186 clip_rect_.fBottom, 205 clip_rect_.fBottom,
187 new_clip_rect.width(), 206 new_clip_rect.width(),
188 new_clip_rect.fBottom - clip_rect_.fBottom)); 207 new_clip_rect.fBottom - clip_rect_.fBottom));
189 } 208 }
209 #endif
190 210
191 clip_rect_ = new_clip_rect; 211 clip_rect_ = new_clip_rect;
192 decoder_->SetClipRect(new_clip_rect); 212 decoder_->SetClipRect(new_clip_rect);
213
214 // TODO(wez): Defer refresh so that multiple events can be batched.
193 DoRefresh(); 215 DoRefresh();
194 } 216 }
195 217
196 void RectangleUpdateDecoder::RefreshFullFrame() { 218 void RectangleUpdateDecoder::RefreshFullFrame() {
197 if (message_loop_ != MessageLoop::current()) { 219 if (message_loop_ != MessageLoop::current()) {
198 message_loop_->PostTask( 220 message_loop_->PostTask(
199 FROM_HERE, base::Bind(&RectangleUpdateDecoder::RefreshFullFrame, this)); 221 FROM_HERE, base::Bind(&RectangleUpdateDecoder::RefreshFullFrame, this));
200 return; 222 return;
201 } 223 }
202 224
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 return; 266 return;
245 } 267 }
246 268
247 delete rects; 269 delete rects;
248 270
249 frame_is_consuming_ = false; 271 frame_is_consuming_ = false;
250 DoRefresh(); 272 DoRefresh();
251 } 273 }
252 274
253 } // namespace remoting 275 } // namespace remoting
OLDNEW
« media/base/yuv_convert.h ('K') | « remoting/client/rectangle_update_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698