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

Unified 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: Rebase. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/decoder_vp8.cc
diff --git a/remoting/base/decoder_vp8.cc b/remoting/base/decoder_vp8.cc
index 03d1d0ebfd596266203a2328c8fc4fba02d5c8fc..fae6adf320a919176218b4c829237bbb1a70764a 100644
--- a/remoting/base/decoder_vp8.cc
+++ b/remoting/base/decoder_vp8.cc
@@ -119,6 +119,16 @@ void DecoderVp8::Invalidate(const SkISize& view_size,
}
}
+static int CalculateYOffset(int x, int y, int stride) {
alexeypa (please no reviews) 2012/06/14 17:00:16 CalculateYOffset and CalculateUVOffset are defined
Wez 2012/06/18 21:51:34 I've made them visible and used them. (The intent
+ DCHECK(((x & 1) == 0) && ((y & 1) == 0));
Sergey Ulanov 2012/06/14 18:04:03 nit: would be more readable as x % 2 == 0 && y % 2
Wez 2012/06/18 21:51:34 This is how they're implemented in remoting/base/u
Sergey Ulanov 2012/06/18 22:29:50 All compilers we compile this code with should be
+ return stride * y + x;
+}
+
+static int CalculateUVOffset(int x, int y, int stride) {
+ DCHECK(((x & 1) == 0) && ((y & 1) == 0));
+ return stride * y / 2 + x / 2;
+}
+
void DecoderVp8::RenderFrame(const SkISize& view_size,
const SkIRect& clip_area,
uint8* image_buffer,
@@ -133,12 +143,39 @@ void DecoderVp8::RenderFrame(const SkISize& view_size,
SkIRect source_clip = SkIRect::MakeWH(last_image_->d_w, last_image_->d_h);
- // ScaleYUVToRGB32WithRect doesn't support up-scaling, and our web-app never
- // intentionally up-scales, so if we see up-scaling (e.g. during host resize
- // or if the user applies page zoom) just don't render anything.
- // TODO(wez): Remove this hack when ScaleYUVToRGB32WithRect can up-scale.
- if (source_clip.width() < view_size.width() ||
alexeypa (please no reviews) 2012/06/14 17:00:16 It is the only place where this check is done? I r
Wez 2012/06/18 21:51:34 This should be the only place.
- source_clip.height() < view_size.height()) {
+ // ScaleYUVToRGB32WithRect does not currently support up-scaling. We won't
+ // be asked to up-scale except during resizes or if page zoom is >100%, so
+ // we work-around the limitation by using the slower ScaleYUVToRGB32.
+ // TODO(wez): Remove this hack if/when ScaleYUVToRGB32WithRect can up-scale.
+ if (!updated_region_.isEmpty() &&
+ (source_clip.width() < view_size.width() ||
+ source_clip.height() < view_size.height())) {
+ // We're scaling only |clip_area| into the |image_buffer|, so we need to
+ // work out which source rectangle that corresponds to.
+ SkIRect source_rect = ScaleRect(clip_area, view_size, screen_size_);
Jamie 2012/06/14 01:14:29 It's not obvious to me that ScaleRect will return
Wez 2012/06/18 21:51:34 It won't - fixed!
+ int y_offset = CalculateYOffset(source_rect.x(),
+ source_rect.y(),
+ last_image_->stride[0]);
+ int uv_offset = CalculateUVOffset(source_rect.x(),
+ source_rect.y(),
+ last_image_->stride[1]);
+ ScaleYUVToRGB32(last_image_->planes[0] + y_offset,
+ last_image_->planes[1] + uv_offset,
+ last_image_->planes[2] + uv_offset,
+ image_buffer,
+ source_rect.width(),
+ source_rect.height(),
+ clip_area.width(),
+ clip_area.height(),
+ last_image_->stride[0],
+ last_image_->stride[1],
+ image_stride,
+ media::YV12,
+ media::ROTATE_0,
+ media::FILTER_BILINEAR);
+
+ output_region->op(clip_area, SkRegion::kUnion_Op);
+ updated_region_.op(source_rect, SkRegion::kDifference_Op);
return;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698