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

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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 DCHECK_EQ(kReady, state_); 112 DCHECK_EQ(kReady, state_);
113 DCHECK(!view_size.isEmpty()); 113 DCHECK(!view_size.isEmpty());
114 114
115 for (SkRegion::Iterator i(region); !i.done(); i.next()) { 115 for (SkRegion::Iterator i(region); !i.done(); i.next()) {
116 SkIRect rect = i.rect(); 116 SkIRect rect = i.rect();
117 rect = ScaleRect(rect, view_size, screen_size_); 117 rect = ScaleRect(rect, view_size, screen_size_);
118 updated_region_.op(rect, SkRegion::kUnion_Op); 118 updated_region_.op(rect, SkRegion::kUnion_Op);
119 } 119 }
120 } 120 }
121 121
122 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
123 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
124 return stride * y + x;
125 }
126
127 static int CalculateUVOffset(int x, int y, int stride) {
128 DCHECK(((x & 1) == 0) && ((y & 1) == 0));
129 return stride * y / 2 + x / 2;
130 }
131
122 void DecoderVp8::RenderFrame(const SkISize& view_size, 132 void DecoderVp8::RenderFrame(const SkISize& view_size,
123 const SkIRect& clip_area, 133 const SkIRect& clip_area,
124 uint8* image_buffer, 134 uint8* image_buffer,
125 int image_stride, 135 int image_stride,
126 SkRegion* output_region) { 136 SkRegion* output_region) {
127 DCHECK_EQ(kReady, state_); 137 DCHECK_EQ(kReady, state_);
128 DCHECK(!view_size.isEmpty()); 138 DCHECK(!view_size.isEmpty());
129 139
130 // Early-return and do nothing if we haven't yet decoded any frames. 140 // Early-return and do nothing if we haven't yet decoded any frames.
131 if (!last_image_) 141 if (!last_image_)
132 return; 142 return;
133 143
134 SkIRect source_clip = SkIRect::MakeWH(last_image_->d_w, last_image_->d_h); 144 SkIRect source_clip = SkIRect::MakeWH(last_image_->d_w, last_image_->d_h);
135 145
136 // ScaleYUVToRGB32WithRect doesn't support up-scaling, and our web-app never 146 // 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 147 // 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. 148 // we work-around the limitation by using the slower ScaleYUVToRGB32.
139 // TODO(wez): Remove this hack when ScaleYUVToRGB32WithRect can up-scale. 149 // TODO(wez): Remove this hack if/when ScaleYUVToRGB32WithRect can up-scale.
140 if (source_clip.width() < view_size.width() || 150 if (!updated_region_.isEmpty() &&
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.
141 source_clip.height() < view_size.height()) { 151 (source_clip.width() < view_size.width() ||
152 source_clip.height() < view_size.height())) {
153 // We're scaling only |clip_area| into the |image_buffer|, so we need to
154 // work out which source rectangle that corresponds to.
155 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!
156 int y_offset = CalculateYOffset(source_rect.x(),
157 source_rect.y(),
158 last_image_->stride[0]);
159 int uv_offset = CalculateUVOffset(source_rect.x(),
160 source_rect.y(),
161 last_image_->stride[1]);
162 ScaleYUVToRGB32(last_image_->planes[0] + y_offset,
163 last_image_->planes[1] + uv_offset,
164 last_image_->planes[2] + uv_offset,
165 image_buffer,
166 source_rect.width(),
167 source_rect.height(),
168 clip_area.width(),
169 clip_area.height(),
170 last_image_->stride[0],
171 last_image_->stride[1],
172 image_stride,
173 media::YV12,
174 media::ROTATE_0,
175 media::FILTER_BILINEAR);
176
177 output_region->op(clip_area, SkRegion::kUnion_Op);
178 updated_region_.op(source_rect, SkRegion::kDifference_Op);
142 return; 179 return;
143 } 180 }
144 181
145 for (SkRegion::Iterator i(updated_region_); !i.done(); i.next()) { 182 for (SkRegion::Iterator i(updated_region_); !i.done(); i.next()) {
146 // Determine the scaled area affected by this rectangle changing. 183 // Determine the scaled area affected by this rectangle changing.
147 SkIRect rect = i.rect(); 184 SkIRect rect = i.rect();
148 if (!rect.intersect(source_clip)) 185 if (!rect.intersect(source_clip))
149 continue; 186 continue;
150 rect = ScaleRect(rect, screen_size_, view_size); 187 rect = ScaleRect(rect, screen_size_, view_size);
151 if (!rect.intersect(clip_area)) 188 if (!rect.intersect(clip_area))
(...skipping 13 matching lines...) Expand all
165 rect); 202 rect);
166 203
167 output_region->op(rect, SkRegion::kUnion_Op); 204 output_region->op(rect, SkRegion::kUnion_Op);
168 } 205 }
169 206
170 updated_region_.op(ScaleRect(clip_area, view_size, screen_size_), 207 updated_region_.op(ScaleRect(clip_area, view_size, screen_size_),
171 SkRegion::kDifference_Op); 208 SkRegion::kDifference_Op);
172 } 209 }
173 210
174 } // namespace remoting 211 } // namespace remoting
OLDNEW
« 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