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

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

Issue 9568048: Allow the Chromoting client plugin to support up-scaling, albeit slowly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 8 years, 6 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 | « no previous file | remoting/base/util.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/decoder_vp8.h" 5 #include "remoting/base/decoder_vp8.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/base/media.h" 10 #include "media/base/media.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 SkRegion* output_region) { 126 SkRegion* output_region) {
127 DCHECK_EQ(kReady, state_); 127 DCHECK_EQ(kReady, state_);
128 DCHECK(!view_size.isEmpty()); 128 DCHECK(!view_size.isEmpty());
129 129
130 // Early-return and do nothing if we haven't yet decoded any frames. 130 // Early-return and do nothing if we haven't yet decoded any frames.
131 if (!last_image_) 131 if (!last_image_)
132 return; 132 return;
133 133
134 SkIRect source_clip = SkIRect::MakeWH(last_image_->d_w, last_image_->d_h); 134 SkIRect source_clip = SkIRect::MakeWH(last_image_->d_w, last_image_->d_h);
135 135
136 // ScaleYUVToRGB32WithRect doesn't support up-scaling, and our web-app never 136 // ScaleYUVToRGB32WithRect does not currently support up-scaling. We won't
137 // intentionally up-scales, so if we see up-scaling (e.g. during host resize 137 // be asked to up-scale except during resizes or if page zoom is >100%, so
138 // or if the user applies page zoom) just don't render anything. 138 // we work-around the limitation by using the slower ScaleYUVToRGB32.
139 // TODO(wez): Remove this hack when ScaleYUVToRGB32WithRect can up-scale. 139 // TODO(wez): Remove this hack if/when ScaleYUVToRGB32WithRect can up-scale.
140 if (source_clip.width() < view_size.width() || 140 if (!updated_region_.isEmpty() &&
141 source_clip.height() < view_size.height()) { 141 (source_clip.width() < view_size.width() ||
142 source_clip.height() < view_size.height())) {
143 // We're scaling only |clip_area| into the |image_buffer|, so we need to
144 // work out which source rectangle that corresponds to.
145 SkIRect source_rect = ScaleRect(clip_area, view_size, screen_size_);
146 source_rect = SkIRect::MakeLTRB(RoundToTwosMultiple(source_rect.left()),
147 RoundToTwosMultiple(source_rect.top()),
148 source_rect.right(),
149 source_rect.bottom());
150 int y_offset = CalculateYOffset(source_rect.x(),
151 source_rect.y(),
152 last_image_->stride[0]);
153 int uv_offset = CalculateUVOffset(source_rect.x(),
154 source_rect.y(),
155 last_image_->stride[1]);
156 ScaleYUVToRGB32(last_image_->planes[0] + y_offset,
157 last_image_->planes[1] + uv_offset,
158 last_image_->planes[2] + uv_offset,
159 image_buffer,
160 source_rect.width(),
161 source_rect.height(),
162 clip_area.width(),
163 clip_area.height(),
164 last_image_->stride[0],
165 last_image_->stride[1],
166 image_stride,
167 media::YV12,
168 media::ROTATE_0,
169 media::FILTER_BILINEAR);
170
171 output_region->op(clip_area, SkRegion::kUnion_Op);
172 updated_region_.op(source_rect, SkRegion::kDifference_Op);
142 return; 173 return;
143 } 174 }
144 175
145 for (SkRegion::Iterator i(updated_region_); !i.done(); i.next()) { 176 for (SkRegion::Iterator i(updated_region_); !i.done(); i.next()) {
146 // Determine the scaled area affected by this rectangle changing. 177 // Determine the scaled area affected by this rectangle changing.
147 SkIRect rect = i.rect(); 178 SkIRect rect = i.rect();
148 if (!rect.intersect(source_clip)) 179 if (!rect.intersect(source_clip))
149 continue; 180 continue;
150 rect = ScaleRect(rect, screen_size_, view_size); 181 rect = ScaleRect(rect, screen_size_, view_size);
151 if (!rect.intersect(clip_area)) 182 if (!rect.intersect(clip_area))
(...skipping 13 matching lines...) Expand all
165 rect); 196 rect);
166 197
167 output_region->op(rect, SkRegion::kUnion_Op); 198 output_region->op(rect, SkRegion::kUnion_Op);
168 } 199 }
169 200
170 updated_region_.op(ScaleRect(clip_area, view_size, screen_size_), 201 updated_region_.op(ScaleRect(clip_area, view_size, screen_size_),
171 SkRegion::kDifference_Op); 202 SkRegion::kDifference_Op);
172 } 203 }
173 204
174 } // namespace remoting 205 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/base/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698