| OLD | NEW |
| 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/util.h" | 5 #include "remoting/base/util.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 "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 258 |
| 259 // Copy bits. | 259 // Copy bits. |
| 260 CopyRect(source_buffer + source_offset, | 260 CopyRect(source_buffer + source_offset, |
| 261 source_stride, | 261 source_stride, |
| 262 dest_buffer + dest_offset, | 262 dest_buffer + dest_offset, |
| 263 dest_stride, | 263 dest_stride, |
| 264 kBytesPerPixelRGB32, | 264 kBytesPerPixelRGB32, |
| 265 SkIRect::MakeWH(dest_rect.width(), dest_rect.height())); | 265 SkIRect::MakeWH(dest_rect.width(), dest_rect.height())); |
| 266 } | 266 } |
| 267 | 267 |
| 268 std::string ReplaceLfByCrLf(const std::string& in) { |
| 269 std::string out; |
| 270 out.resize(2 * in.size()); |
| 271 char* out_p_begin = &out[0]; |
| 272 char* out_p = out_p_begin; |
| 273 const char* in_p_begin = &in[0]; |
| 274 const char* in_p_end = &in[in.size()]; |
| 275 for (const char* in_p = in_p_begin; in_p < in_p_end; ++in_p) { |
| 276 char c = *in_p; |
| 277 if (c == '\n') { |
| 278 *out_p++ = '\r'; |
| 279 } |
| 280 *out_p++ = c; |
| 281 } |
| 282 out.resize(out_p - out_p_begin); |
| 283 return out; |
| 284 } |
| 285 |
| 286 std::string ReplaceCrLfByLf(const std::string& in) { |
| 287 std::string out; |
| 288 out.resize(in.size()); |
| 289 char* out_p_begin = &out[0]; |
| 290 char* out_p = out_p_begin; |
| 291 const char* in_p_begin = &in[0]; |
| 292 const char* in_p_end = &in[in.size()]; |
| 293 for (const char* in_p = in_p_begin; in_p < in_p_end; ++in_p) { |
| 294 char c = *in_p; |
| 295 if ((c == '\r') && (in_p + 1 < in_p_end) && (*(in_p + 1) == '\n')) { |
| 296 *out_p++ = '\n'; |
| 297 ++in_p; |
| 298 } else { |
| 299 *out_p++ = c; |
| 300 } |
| 301 } |
| 302 out.resize(out_p - out_p_begin); |
| 303 return out; |
| 304 } |
| 305 |
| 268 } // namespace remoting | 306 } // namespace remoting |
| OLD | NEW |