| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/linux_util.h" | 5 #include "base/linux_util.h" |
| 6 | 6 |
| 7 #include <dirent.h> | 7 #include <dirent.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <glib.h> | 9 #include <glib.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 115 } |
| 116 | 116 |
| 117 *inode_out = inode_ul; | 117 *inode_out = inode_ul; |
| 118 return true; | 118 return true; |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace | 121 } // namespace |
| 122 | 122 |
| 123 namespace base { | 123 namespace base { |
| 124 | 124 |
| 125 uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride) { | |
| 126 if (stride == 0) | |
| 127 stride = width * 4; | |
| 128 | |
| 129 uint8_t* new_pixels = static_cast<uint8_t*>(malloc(height * stride)); | |
| 130 | |
| 131 // We have to copy the pixels and swap from BGRA to RGBA. | |
| 132 for (int i = 0; i < height; ++i) { | |
| 133 for (int j = 0; j < width; ++j) { | |
| 134 int idx = i * stride + j * 4; | |
| 135 new_pixels[idx] = pixels[idx + 2]; | |
| 136 new_pixels[idx + 1] = pixels[idx + 1]; | |
| 137 new_pixels[idx + 2] = pixels[idx]; | |
| 138 new_pixels[idx + 3] = pixels[idx + 3]; | |
| 139 } | |
| 140 } | |
| 141 | |
| 142 return new_pixels; | |
| 143 } | |
| 144 | |
| 145 // We use this static string to hold the Linux distro info. If we | 125 // We use this static string to hold the Linux distro info. If we |
| 146 // crash, the crash handler code will send this in the crash dump. | 126 // crash, the crash handler code will send this in the crash dump. |
| 147 std::string linux_distro = | 127 std::string linux_distro = |
| 148 #if defined(OS_CHROMEOS) | 128 #if defined(OS_CHROMEOS) |
| 149 "CrOS"; | 129 "CrOS"; |
| 150 #else // if defined(OS_LINUX) | 130 #else // if defined(OS_LINUX) |
| 151 "Unknown"; | 131 "Unknown"; |
| 152 #endif | 132 #endif |
| 153 | 133 |
| 154 std::string GetLinuxDistro() { | 134 std::string GetLinuxDistro() { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 } | 235 } |
| 256 } | 236 } |
| 257 | 237 |
| 258 closedir(fd); | 238 closedir(fd); |
| 259 } | 239 } |
| 260 | 240 |
| 261 return already_found; | 241 return already_found; |
| 262 } | 242 } |
| 263 | 243 |
| 264 } // namespace base | 244 } // namespace base |
| OLD | NEW |