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/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 | 65 |
66 // Copy pixels in the rectangle line by line. | 66 // Copy pixels in the rectangle line by line. |
67 const int bytes_per_line = kBytesPerPixelRGB32 * dest_rect.width(); | 67 const int bytes_per_line = kBytesPerPixelRGB32 * dest_rect.width(); |
68 for (int i = 0 ; i < dest_rect.height(); ++i) { | 68 for (int i = 0 ; i < dest_rect.height(); ++i) { |
69 memcpy(dest_buffer, source_buffer, bytes_per_line); | 69 memcpy(dest_buffer, source_buffer, bytes_per_line); |
70 source_buffer += source_stride; | 70 source_buffer += source_stride; |
71 dest_buffer += dest_stride; | 71 dest_buffer += dest_stride; |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 void CopyAndSwapRB(const uint8_t* source, uint8_t* dest, int length) { | |
Sergey Ulanov
2016/07/19 00:42:48
Please use RGBAToARGB() from libyuv. It's optimize
Yuwei
2016/07/19 04:11:52
Wouldn't it be BGRAToRGBA()? Looks like there is n
Yuwei
2016/07/19 20:34:23
Done. Using libyuv::ABGRToARGB
Sergey Ulanov
2016/07/20 18:06:11
memcpy() itself should be already optimized.
| |
76 for (int i = 0; i < length / kBytesPerPixelRGB32; i++) { | |
77 dest[i * kBytesPerPixelRGB32] = source[i * kBytesPerPixelRGB32 + 2]; | |
78 dest[i * kBytesPerPixelRGB32 + 1] = source[i * kBytesPerPixelRGB32 + 1]; | |
79 dest[i * kBytesPerPixelRGB32 + 2] = source[i * kBytesPerPixelRGB32 + 0]; | |
80 dest[i * kBytesPerPixelRGB32 + 3] = source[i * kBytesPerPixelRGB32 + 3]; | |
81 } | |
82 } | |
83 | |
75 std::string ReplaceLfByCrLf(const std::string& in) { | 84 std::string ReplaceLfByCrLf(const std::string& in) { |
76 std::string out; | 85 std::string out; |
77 out.resize(2 * in.size()); | 86 out.resize(2 * in.size()); |
78 char* out_p_begin = &out[0]; | 87 char* out_p_begin = &out[0]; |
79 char* out_p = out_p_begin; | 88 char* out_p = out_p_begin; |
80 const char* in_p_begin = &in[0]; | 89 const char* in_p_begin = &in[0]; |
81 const char* in_p_end = &in[in.size()]; | 90 const char* in_p_end = &in[in.size()]; |
82 for (const char* in_p = in_p_begin; in_p < in_p_end; ++in_p) { | 91 for (const char* in_p = in_p_begin; in_p < in_p_end; ++in_p) { |
83 char c = *in_p; | 92 char c = *in_p; |
84 if (c == '\n') { | 93 if (c == '\n') { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 } | 152 } |
144 | 153 |
145 bool DoesRectContain(const webrtc::DesktopRect& a, | 154 bool DoesRectContain(const webrtc::DesktopRect& a, |
146 const webrtc::DesktopRect& b) { | 155 const webrtc::DesktopRect& b) { |
147 webrtc::DesktopRect intersection(a); | 156 webrtc::DesktopRect intersection(a); |
148 intersection.IntersectWith(b); | 157 intersection.IntersectWith(b); |
149 return intersection.equals(b); | 158 return intersection.equals(b); |
150 } | 159 } |
151 | 160 |
152 } // namespace remoting | 161 } // namespace remoting |
OLD | NEW |