Chromium Code Reviews| 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 "base/logging.h" | 5 #include "base/logging.h" |
| 6 #include "base/stringprintf.h" | 6 #include "base/stringprintf.h" |
| 7 #include "base/time.h" | 7 #include "base/time.h" |
| 8 #include "media/base/video_frame.h" | 8 #include "media/base/video_frame.h" |
| 9 #include "media/base/yuv_convert.h" | 9 #include "media/base/yuv_convert.h" |
| 10 #include "remoting/base/util.h" | 10 #include "remoting/base/util.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 | 141 |
| 142 SkIRect AlignRect(const SkIRect& rect) { | 142 SkIRect AlignRect(const SkIRect& rect) { |
| 143 int x = RoundToTwosMultiple(rect.fLeft); | 143 int x = RoundToTwosMultiple(rect.fLeft); |
| 144 int y = RoundToTwosMultiple(rect.fTop); | 144 int y = RoundToTwosMultiple(rect.fTop); |
| 145 int right = RoundToTwosMultiple(rect.fRight + 1); | 145 int right = RoundToTwosMultiple(rect.fRight + 1); |
| 146 int bottom = RoundToTwosMultiple(rect.fBottom + 1); | 146 int bottom = RoundToTwosMultiple(rect.fBottom + 1); |
| 147 return SkIRect::MakeXYWH(x, y, right - x, bottom - y); | 147 return SkIRect::MakeXYWH(x, y, right - x, bottom - y); |
| 148 } | 148 } |
| 149 | 149 |
| 150 SkIRect ScaleRect(const SkIRect& rect, | 150 SkIRect ScaleRect(const SkIRect& rect, |
| 151 double horizontal_ratio, | 151 const SkISize& in_size, |
| 152 double vertical_ratio) { | 152 const SkISize& out_size) { |
| 153 int x = rect.fLeft * horizontal_ratio; | 153 int x1 = (rect.fLeft * out_size.width()) / in_size.width(); |
|
Sergey Ulanov
2011/12/20 00:05:35
here and below, left() instead of fLeft?
Wez
2011/12/20 07:14:14
Done.
| |
| 154 int y = rect.fTop * vertical_ratio; | 154 int y1 = (rect.fTop * out_size.height()) / in_size.height(); |
| 155 int w = rect.fRight * horizontal_ratio - x; | 155 int x2 = (rect.fRight * out_size.width() + out_size.width()-1) / |
|
Sergey Ulanov
2011/12/20 00:05:35
nit: spaces around minus here and in the next line
Wez
2011/12/20 07:14:14
Done.
| |
| 156 int h = rect.fBottom * vertical_ratio - y; | 156 in_size.width(); |
| 157 | 157 int y2 = (rect.fBottom * out_size.height() + out_size.height()-1) / |
|
Sergey Ulanov
2011/12/20 00:05:35
maybe call it right and bottom instead of x2 and y
Sergey Ulanov
2011/12/20 00:05:35
I think it would be useful to add a comment saying
Wez
2011/12/20 07:14:14
Done.
Wez
2011/12/20 07:14:14
I've updated the comment on ScaleRect() in the hea
| |
| 158 return SkIRect::MakeXYWH(x, y, w, h); | 158 in_size.height(); |
| 159 return SkIRect::MakeXYWH(x1, y1, x2-x1, y2-y1); | |
|
Sergey Ulanov
2011/12/20 00:05:35
Use MakeLTRB() here?
Wez
2011/12/20 07:14:14
Done.
| |
| 159 } | 160 } |
| 160 | 161 |
| 161 void CopyRect(const uint8* src_plane, | 162 void CopyRect(const uint8* src_plane, |
| 162 int src_plane_stride, | 163 int src_plane_stride, |
| 163 uint8* dest_plane, | 164 uint8* dest_plane, |
| 164 int dest_plane_stride, | 165 int dest_plane_stride, |
| 165 int bytes_per_pixel, | 166 int bytes_per_pixel, |
| 166 const SkIRect& rect) { | 167 const SkIRect& rect) { |
| 167 // Get the address of the starting point. | 168 // Get the address of the starting point. |
| 168 const int src_y_offset = src_plane_stride * rect.fTop; | 169 const int src_y_offset = src_plane_stride * rect.fTop; |
| 169 const int dest_y_offset = dest_plane_stride * rect.fTop; | 170 const int dest_y_offset = dest_plane_stride * rect.fTop; |
| 170 const int x_offset = bytes_per_pixel * rect.fLeft; | 171 const int x_offset = bytes_per_pixel * rect.fLeft; |
| 171 src_plane += src_y_offset + x_offset; | 172 src_plane += src_y_offset + x_offset; |
| 172 dest_plane += dest_y_offset + x_offset; | 173 dest_plane += dest_y_offset + x_offset; |
| 173 | 174 |
| 174 // Copy pixels in the rectangle line by line. | 175 // Copy pixels in the rectangle line by line. |
| 175 const int bytes_per_line = bytes_per_pixel * rect.width(); | 176 const int bytes_per_line = bytes_per_pixel * rect.width(); |
| 176 const int height = rect.height(); | 177 const int height = rect.height(); |
| 177 for (int i = 0 ; i < height; ++i) { | 178 for (int i = 0 ; i < height; ++i) { |
| 178 memcpy(dest_plane, src_plane, bytes_per_line); | 179 memcpy(dest_plane, src_plane, bytes_per_line); |
| 179 src_plane += src_plane_stride; | 180 src_plane += src_plane_stride; |
| 180 dest_plane += dest_plane_stride; | 181 dest_plane += dest_plane_stride; |
| 181 } | 182 } |
| 182 } | 183 } |
| 183 | 184 |
| 184 } // namespace remoting | 185 } // namespace remoting |
| OLD | NEW |