Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | #include "precompiled.h" |
michael@0 | 2 | // |
michael@0 | 3 | // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. |
michael@0 | 4 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | // found in the LICENSE file. |
michael@0 | 6 | // |
michael@0 | 7 | |
michael@0 | 8 | // Image.h: Implements the rx::Image class, an abstract base class for the |
michael@0 | 9 | // renderer-specific classes which will define the interface to the underlying |
michael@0 | 10 | // surfaces or resources. |
michael@0 | 11 | |
michael@0 | 12 | #include "libGLESv2/renderer/Image.h" |
michael@0 | 13 | |
michael@0 | 14 | namespace rx |
michael@0 | 15 | { |
michael@0 | 16 | |
michael@0 | 17 | Image::Image() |
michael@0 | 18 | { |
michael@0 | 19 | mWidth = 0; |
michael@0 | 20 | mHeight = 0; |
michael@0 | 21 | mInternalFormat = GL_NONE; |
michael@0 | 22 | mActualFormat = GL_NONE; |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | void Image::loadAlphaDataToBGRA(GLsizei width, GLsizei height, |
michael@0 | 26 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 27 | { |
michael@0 | 28 | const unsigned char *source = NULL; |
michael@0 | 29 | unsigned char *dest = NULL; |
michael@0 | 30 | |
michael@0 | 31 | for (int y = 0; y < height; y++) |
michael@0 | 32 | { |
michael@0 | 33 | source = static_cast<const unsigned char*>(input) + y * inputPitch; |
michael@0 | 34 | dest = static_cast<unsigned char*>(output) + y * outputPitch; |
michael@0 | 35 | for (int x = 0; x < width; x++) |
michael@0 | 36 | { |
michael@0 | 37 | dest[4 * x + 0] = 0; |
michael@0 | 38 | dest[4 * x + 1] = 0; |
michael@0 | 39 | dest[4 * x + 2] = 0; |
michael@0 | 40 | dest[4 * x + 3] = source[x]; |
michael@0 | 41 | } |
michael@0 | 42 | } |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | void Image::loadAlphaDataToNative(GLsizei width, GLsizei height, |
michael@0 | 46 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 47 | { |
michael@0 | 48 | const unsigned char *source = NULL; |
michael@0 | 49 | unsigned char *dest = NULL; |
michael@0 | 50 | |
michael@0 | 51 | for (int y = 0; y < height; y++) |
michael@0 | 52 | { |
michael@0 | 53 | source = static_cast<const unsigned char*>(input) + y * inputPitch; |
michael@0 | 54 | dest = static_cast<unsigned char*>(output) + y * outputPitch; |
michael@0 | 55 | memcpy(dest, source, width); |
michael@0 | 56 | } |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | void Image::loadAlphaFloatDataToRGBA(GLsizei width, GLsizei height, |
michael@0 | 60 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 61 | { |
michael@0 | 62 | const float *source = NULL; |
michael@0 | 63 | float *dest = NULL; |
michael@0 | 64 | |
michael@0 | 65 | for (int y = 0; y < height; y++) |
michael@0 | 66 | { |
michael@0 | 67 | source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 68 | dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputPitch); |
michael@0 | 69 | for (int x = 0; x < width; x++) |
michael@0 | 70 | { |
michael@0 | 71 | dest[4 * x + 0] = 0; |
michael@0 | 72 | dest[4 * x + 1] = 0; |
michael@0 | 73 | dest[4 * x + 2] = 0; |
michael@0 | 74 | dest[4 * x + 3] = source[x]; |
michael@0 | 75 | } |
michael@0 | 76 | } |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | void Image::loadAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, |
michael@0 | 80 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 81 | { |
michael@0 | 82 | const unsigned short *source = NULL; |
michael@0 | 83 | unsigned short *dest = NULL; |
michael@0 | 84 | |
michael@0 | 85 | for (int y = 0; y < height; y++) |
michael@0 | 86 | { |
michael@0 | 87 | source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 88 | dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputPitch); |
michael@0 | 89 | for (int x = 0; x < width; x++) |
michael@0 | 90 | { |
michael@0 | 91 | dest[4 * x + 0] = 0; |
michael@0 | 92 | dest[4 * x + 1] = 0; |
michael@0 | 93 | dest[4 * x + 2] = 0; |
michael@0 | 94 | dest[4 * x + 3] = source[x]; |
michael@0 | 95 | } |
michael@0 | 96 | } |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | void Image::loadLuminanceDataToNativeOrBGRA(GLsizei width, GLsizei height, |
michael@0 | 100 | int inputPitch, const void *input, size_t outputPitch, void *output, bool native) |
michael@0 | 101 | { |
michael@0 | 102 | const unsigned char *source = NULL; |
michael@0 | 103 | unsigned char *dest = NULL; |
michael@0 | 104 | |
michael@0 | 105 | for (int y = 0; y < height; y++) |
michael@0 | 106 | { |
michael@0 | 107 | source = static_cast<const unsigned char*>(input) + y * inputPitch; |
michael@0 | 108 | dest = static_cast<unsigned char*>(output) + y * outputPitch; |
michael@0 | 109 | |
michael@0 | 110 | if (!native) // BGRA8 destination format |
michael@0 | 111 | { |
michael@0 | 112 | for (int x = 0; x < width; x++) |
michael@0 | 113 | { |
michael@0 | 114 | dest[4 * x + 0] = source[x]; |
michael@0 | 115 | dest[4 * x + 1] = source[x]; |
michael@0 | 116 | dest[4 * x + 2] = source[x]; |
michael@0 | 117 | dest[4 * x + 3] = 0xFF; |
michael@0 | 118 | } |
michael@0 | 119 | } |
michael@0 | 120 | else // L8 destination format |
michael@0 | 121 | { |
michael@0 | 122 | memcpy(dest, source, width); |
michael@0 | 123 | } |
michael@0 | 124 | } |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | void Image::loadLuminanceFloatDataToRGBA(GLsizei width, GLsizei height, |
michael@0 | 128 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 129 | { |
michael@0 | 130 | const float *source = NULL; |
michael@0 | 131 | float *dest = NULL; |
michael@0 | 132 | |
michael@0 | 133 | for (int y = 0; y < height; y++) |
michael@0 | 134 | { |
michael@0 | 135 | source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 136 | dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputPitch); |
michael@0 | 137 | for (int x = 0; x < width; x++) |
michael@0 | 138 | { |
michael@0 | 139 | dest[4 * x + 0] = source[x]; |
michael@0 | 140 | dest[4 * x + 1] = source[x]; |
michael@0 | 141 | dest[4 * x + 2] = source[x]; |
michael@0 | 142 | dest[4 * x + 3] = 1.0f; |
michael@0 | 143 | } |
michael@0 | 144 | } |
michael@0 | 145 | } |
michael@0 | 146 | |
michael@0 | 147 | void Image::loadLuminanceFloatDataToRGB(GLsizei width, GLsizei height, |
michael@0 | 148 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 149 | { |
michael@0 | 150 | const float *source = NULL; |
michael@0 | 151 | float *dest = NULL; |
michael@0 | 152 | |
michael@0 | 153 | for (int y = 0; y < height; y++) |
michael@0 | 154 | { |
michael@0 | 155 | source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 156 | dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputPitch); |
michael@0 | 157 | for (int x = 0; x < width; x++) |
michael@0 | 158 | { |
michael@0 | 159 | dest[3 * x + 0] = source[x]; |
michael@0 | 160 | dest[3 * x + 1] = source[x]; |
michael@0 | 161 | dest[3 * x + 2] = source[x]; |
michael@0 | 162 | } |
michael@0 | 163 | } |
michael@0 | 164 | } |
michael@0 | 165 | |
michael@0 | 166 | void Image::loadLuminanceHalfFloatDataToRGBA(GLsizei width, GLsizei height, |
michael@0 | 167 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 168 | { |
michael@0 | 169 | const unsigned short *source = NULL; |
michael@0 | 170 | unsigned short *dest = NULL; |
michael@0 | 171 | |
michael@0 | 172 | for (int y = 0; y < height; y++) |
michael@0 | 173 | { |
michael@0 | 174 | source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 175 | dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputPitch); |
michael@0 | 176 | for (int x = 0; x < width; x++) |
michael@0 | 177 | { |
michael@0 | 178 | dest[4 * x + 0] = source[x]; |
michael@0 | 179 | dest[4 * x + 1] = source[x]; |
michael@0 | 180 | dest[4 * x + 2] = source[x]; |
michael@0 | 181 | dest[4 * x + 3] = 0x3C00; // SEEEEEMMMMMMMMMM, S = 0, E = 15, M = 0: 16bit flpt representation of 1 |
michael@0 | 182 | } |
michael@0 | 183 | } |
michael@0 | 184 | } |
michael@0 | 185 | |
michael@0 | 186 | void Image::loadLuminanceAlphaDataToNativeOrBGRA(GLsizei width, GLsizei height, |
michael@0 | 187 | int inputPitch, const void *input, size_t outputPitch, void *output, bool native) |
michael@0 | 188 | { |
michael@0 | 189 | const unsigned char *source = NULL; |
michael@0 | 190 | unsigned char *dest = NULL; |
michael@0 | 191 | |
michael@0 | 192 | for (int y = 0; y < height; y++) |
michael@0 | 193 | { |
michael@0 | 194 | source = static_cast<const unsigned char*>(input) + y * inputPitch; |
michael@0 | 195 | dest = static_cast<unsigned char*>(output) + y * outputPitch; |
michael@0 | 196 | |
michael@0 | 197 | if (!native) // BGRA8 destination format |
michael@0 | 198 | { |
michael@0 | 199 | for (int x = 0; x < width; x++) |
michael@0 | 200 | { |
michael@0 | 201 | dest[4 * x + 0] = source[2*x+0]; |
michael@0 | 202 | dest[4 * x + 1] = source[2*x+0]; |
michael@0 | 203 | dest[4 * x + 2] = source[2*x+0]; |
michael@0 | 204 | dest[4 * x + 3] = source[2*x+1]; |
michael@0 | 205 | } |
michael@0 | 206 | } |
michael@0 | 207 | else |
michael@0 | 208 | { |
michael@0 | 209 | memcpy(dest, source, width * 2); |
michael@0 | 210 | } |
michael@0 | 211 | } |
michael@0 | 212 | } |
michael@0 | 213 | |
michael@0 | 214 | void Image::loadLuminanceAlphaFloatDataToRGBA(GLsizei width, GLsizei height, |
michael@0 | 215 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 216 | { |
michael@0 | 217 | const float *source = NULL; |
michael@0 | 218 | float *dest = NULL; |
michael@0 | 219 | |
michael@0 | 220 | for (int y = 0; y < height; y++) |
michael@0 | 221 | { |
michael@0 | 222 | source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 223 | dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputPitch); |
michael@0 | 224 | for (int x = 0; x < width; x++) |
michael@0 | 225 | { |
michael@0 | 226 | dest[4 * x + 0] = source[2*x+0]; |
michael@0 | 227 | dest[4 * x + 1] = source[2*x+0]; |
michael@0 | 228 | dest[4 * x + 2] = source[2*x+0]; |
michael@0 | 229 | dest[4 * x + 3] = source[2*x+1]; |
michael@0 | 230 | } |
michael@0 | 231 | } |
michael@0 | 232 | } |
michael@0 | 233 | |
michael@0 | 234 | void Image::loadLuminanceAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, |
michael@0 | 235 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 236 | { |
michael@0 | 237 | const unsigned short *source = NULL; |
michael@0 | 238 | unsigned short *dest = NULL; |
michael@0 | 239 | |
michael@0 | 240 | for (int y = 0; y < height; y++) |
michael@0 | 241 | { |
michael@0 | 242 | source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 243 | dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputPitch); |
michael@0 | 244 | for (int x = 0; x < width; x++) |
michael@0 | 245 | { |
michael@0 | 246 | dest[4 * x + 0] = source[2*x+0]; |
michael@0 | 247 | dest[4 * x + 1] = source[2*x+0]; |
michael@0 | 248 | dest[4 * x + 2] = source[2*x+0]; |
michael@0 | 249 | dest[4 * x + 3] = source[2*x+1]; |
michael@0 | 250 | } |
michael@0 | 251 | } |
michael@0 | 252 | } |
michael@0 | 253 | |
michael@0 | 254 | void Image::loadRGBUByteDataToBGRX(GLsizei width, GLsizei height, |
michael@0 | 255 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 256 | { |
michael@0 | 257 | const unsigned char *source = NULL; |
michael@0 | 258 | unsigned char *dest = NULL; |
michael@0 | 259 | |
michael@0 | 260 | for (int y = 0; y < height; y++) |
michael@0 | 261 | { |
michael@0 | 262 | source = static_cast<const unsigned char*>(input) + y * inputPitch; |
michael@0 | 263 | dest = static_cast<unsigned char*>(output) + y * outputPitch; |
michael@0 | 264 | for (int x = 0; x < width; x++) |
michael@0 | 265 | { |
michael@0 | 266 | dest[4 * x + 0] = source[x * 3 + 2]; |
michael@0 | 267 | dest[4 * x + 1] = source[x * 3 + 1]; |
michael@0 | 268 | dest[4 * x + 2] = source[x * 3 + 0]; |
michael@0 | 269 | dest[4 * x + 3] = 0xFF; |
michael@0 | 270 | } |
michael@0 | 271 | } |
michael@0 | 272 | } |
michael@0 | 273 | |
michael@0 | 274 | void Image::loadRGBUByteDataToRGBA(GLsizei width, GLsizei height, |
michael@0 | 275 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 276 | { |
michael@0 | 277 | const unsigned char *source = NULL; |
michael@0 | 278 | unsigned char *dest = NULL; |
michael@0 | 279 | |
michael@0 | 280 | for (int y = 0; y < height; y++) |
michael@0 | 281 | { |
michael@0 | 282 | source = static_cast<const unsigned char*>(input) + y * inputPitch; |
michael@0 | 283 | dest = static_cast<unsigned char*>(output) + y * outputPitch; |
michael@0 | 284 | for (int x = 0; x < width; x++) |
michael@0 | 285 | { |
michael@0 | 286 | dest[4 * x + 0] = source[x * 3 + 0]; |
michael@0 | 287 | dest[4 * x + 1] = source[x * 3 + 1]; |
michael@0 | 288 | dest[4 * x + 2] = source[x * 3 + 2]; |
michael@0 | 289 | dest[4 * x + 3] = 0xFF; |
michael@0 | 290 | } |
michael@0 | 291 | } |
michael@0 | 292 | } |
michael@0 | 293 | |
michael@0 | 294 | void Image::loadRGB565DataToBGRA(GLsizei width, GLsizei height, |
michael@0 | 295 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 296 | { |
michael@0 | 297 | const unsigned short *source = NULL; |
michael@0 | 298 | unsigned char *dest = NULL; |
michael@0 | 299 | |
michael@0 | 300 | for (int y = 0; y < height; y++) |
michael@0 | 301 | { |
michael@0 | 302 | source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 303 | dest = static_cast<unsigned char*>(output) + y * outputPitch; |
michael@0 | 304 | for (int x = 0; x < width; x++) |
michael@0 | 305 | { |
michael@0 | 306 | unsigned short rgba = source[x]; |
michael@0 | 307 | dest[4 * x + 0] = ((rgba & 0x001F) << 3) | ((rgba & 0x001F) >> 2); |
michael@0 | 308 | dest[4 * x + 1] = ((rgba & 0x07E0) >> 3) | ((rgba & 0x07E0) >> 9); |
michael@0 | 309 | dest[4 * x + 2] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13); |
michael@0 | 310 | dest[4 * x + 3] = 0xFF; |
michael@0 | 311 | } |
michael@0 | 312 | } |
michael@0 | 313 | } |
michael@0 | 314 | |
michael@0 | 315 | void Image::loadRGB565DataToRGBA(GLsizei width, GLsizei height, |
michael@0 | 316 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 317 | { |
michael@0 | 318 | const unsigned short *source = NULL; |
michael@0 | 319 | unsigned char *dest = NULL; |
michael@0 | 320 | |
michael@0 | 321 | for (int y = 0; y < height; y++) |
michael@0 | 322 | { |
michael@0 | 323 | source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 324 | dest = static_cast<unsigned char*>(output) + y * outputPitch; |
michael@0 | 325 | for (int x = 0; x < width; x++) |
michael@0 | 326 | { |
michael@0 | 327 | unsigned short rgba = source[x]; |
michael@0 | 328 | dest[4 * x + 0] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13); |
michael@0 | 329 | dest[4 * x + 1] = ((rgba & 0x07E0) >> 3) | ((rgba & 0x07E0) >> 9); |
michael@0 | 330 | dest[4 * x + 2] = ((rgba & 0x001F) << 3) | ((rgba & 0x001F) >> 2); |
michael@0 | 331 | dest[4 * x + 3] = 0xFF; |
michael@0 | 332 | } |
michael@0 | 333 | } |
michael@0 | 334 | } |
michael@0 | 335 | |
michael@0 | 336 | void Image::loadRGBFloatDataToRGBA(GLsizei width, GLsizei height, |
michael@0 | 337 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 338 | { |
michael@0 | 339 | const float *source = NULL; |
michael@0 | 340 | float *dest = NULL; |
michael@0 | 341 | |
michael@0 | 342 | for (int y = 0; y < height; y++) |
michael@0 | 343 | { |
michael@0 | 344 | source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 345 | dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputPitch); |
michael@0 | 346 | for (int x = 0; x < width; x++) |
michael@0 | 347 | { |
michael@0 | 348 | dest[4 * x + 0] = source[x * 3 + 0]; |
michael@0 | 349 | dest[4 * x + 1] = source[x * 3 + 1]; |
michael@0 | 350 | dest[4 * x + 2] = source[x * 3 + 2]; |
michael@0 | 351 | dest[4 * x + 3] = 1.0f; |
michael@0 | 352 | } |
michael@0 | 353 | } |
michael@0 | 354 | } |
michael@0 | 355 | |
michael@0 | 356 | void Image::loadRGBFloatDataToNative(GLsizei width, GLsizei height, |
michael@0 | 357 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 358 | { |
michael@0 | 359 | const float *source = NULL; |
michael@0 | 360 | float *dest = NULL; |
michael@0 | 361 | |
michael@0 | 362 | for (int y = 0; y < height; y++) |
michael@0 | 363 | { |
michael@0 | 364 | source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 365 | dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputPitch); |
michael@0 | 366 | memcpy(dest, source, width * 12); |
michael@0 | 367 | } |
michael@0 | 368 | } |
michael@0 | 369 | |
michael@0 | 370 | void Image::loadRGBHalfFloatDataToRGBA(GLsizei width, GLsizei height, |
michael@0 | 371 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 372 | { |
michael@0 | 373 | const unsigned short *source = NULL; |
michael@0 | 374 | unsigned short *dest = NULL; |
michael@0 | 375 | |
michael@0 | 376 | for (int y = 0; y < height; y++) |
michael@0 | 377 | { |
michael@0 | 378 | source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 379 | dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputPitch); |
michael@0 | 380 | for (int x = 0; x < width; x++) |
michael@0 | 381 | { |
michael@0 | 382 | dest[4 * x + 0] = source[x * 3 + 0]; |
michael@0 | 383 | dest[4 * x + 1] = source[x * 3 + 1]; |
michael@0 | 384 | dest[4 * x + 2] = source[x * 3 + 2]; |
michael@0 | 385 | dest[4 * x + 3] = 0x3C00; // SEEEEEMMMMMMMMMM, S = 0, E = 15, M = 0: 16bit flpt representation of 1 |
michael@0 | 386 | } |
michael@0 | 387 | } |
michael@0 | 388 | } |
michael@0 | 389 | |
michael@0 | 390 | void Image::loadRGBAUByteDataToBGRA(GLsizei width, GLsizei height, |
michael@0 | 391 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 392 | { |
michael@0 | 393 | const unsigned int *source = NULL; |
michael@0 | 394 | unsigned int *dest = NULL; |
michael@0 | 395 | for (int y = 0; y < height; y++) |
michael@0 | 396 | { |
michael@0 | 397 | source = reinterpret_cast<const unsigned int*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 398 | dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + y * outputPitch); |
michael@0 | 399 | |
michael@0 | 400 | for (int x = 0; x < width; x++) |
michael@0 | 401 | { |
michael@0 | 402 | unsigned int rgba = source[x]; |
michael@0 | 403 | dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00); |
michael@0 | 404 | } |
michael@0 | 405 | } |
michael@0 | 406 | } |
michael@0 | 407 | |
michael@0 | 408 | void Image::loadRGBAUByteDataToNative(GLsizei width, GLsizei height, |
michael@0 | 409 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 410 | { |
michael@0 | 411 | const unsigned int *source = NULL; |
michael@0 | 412 | unsigned int *dest = NULL; |
michael@0 | 413 | for (int y = 0; y < height; y++) |
michael@0 | 414 | { |
michael@0 | 415 | source = reinterpret_cast<const unsigned int*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 416 | dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + y * outputPitch); |
michael@0 | 417 | |
michael@0 | 418 | memcpy(dest, source, width * 4); |
michael@0 | 419 | } |
michael@0 | 420 | } |
michael@0 | 421 | |
michael@0 | 422 | void Image::loadRGBA4444DataToBGRA(GLsizei width, GLsizei height, |
michael@0 | 423 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 424 | { |
michael@0 | 425 | const unsigned short *source = NULL; |
michael@0 | 426 | unsigned char *dest = NULL; |
michael@0 | 427 | |
michael@0 | 428 | for (int y = 0; y < height; y++) |
michael@0 | 429 | { |
michael@0 | 430 | source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 431 | dest = static_cast<unsigned char*>(output) + y * outputPitch; |
michael@0 | 432 | for (int x = 0; x < width; x++) |
michael@0 | 433 | { |
michael@0 | 434 | unsigned short rgba = source[x]; |
michael@0 | 435 | dest[4 * x + 0] = ((rgba & 0x00F0) << 0) | ((rgba & 0x00F0) >> 4); |
michael@0 | 436 | dest[4 * x + 1] = ((rgba & 0x0F00) >> 4) | ((rgba & 0x0F00) >> 8); |
michael@0 | 437 | dest[4 * x + 2] = ((rgba & 0xF000) >> 8) | ((rgba & 0xF000) >> 12); |
michael@0 | 438 | dest[4 * x + 3] = ((rgba & 0x000F) << 4) | ((rgba & 0x000F) >> 0); |
michael@0 | 439 | } |
michael@0 | 440 | } |
michael@0 | 441 | } |
michael@0 | 442 | |
michael@0 | 443 | void Image::loadRGBA4444DataToRGBA(GLsizei width, GLsizei height, |
michael@0 | 444 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 445 | { |
michael@0 | 446 | const unsigned short *source = NULL; |
michael@0 | 447 | unsigned char *dest = NULL; |
michael@0 | 448 | |
michael@0 | 449 | for (int y = 0; y < height; y++) |
michael@0 | 450 | { |
michael@0 | 451 | source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 452 | dest = static_cast<unsigned char*>(output) + y * outputPitch; |
michael@0 | 453 | for (int x = 0; x < width; x++) |
michael@0 | 454 | { |
michael@0 | 455 | unsigned short rgba = source[x]; |
michael@0 | 456 | dest[4 * x + 0] = ((rgba & 0xF000) >> 8) | ((rgba & 0xF000) >> 12); |
michael@0 | 457 | dest[4 * x + 1] = ((rgba & 0x0F00) >> 4) | ((rgba & 0x0F00) >> 8); |
michael@0 | 458 | dest[4 * x + 2] = ((rgba & 0x00F0) << 0) | ((rgba & 0x00F0) >> 4); |
michael@0 | 459 | dest[4 * x + 3] = ((rgba & 0x000F) << 4) | ((rgba & 0x000F) >> 0); |
michael@0 | 460 | } |
michael@0 | 461 | } |
michael@0 | 462 | } |
michael@0 | 463 | |
michael@0 | 464 | void Image::loadRGBA5551DataToBGRA(GLsizei width, GLsizei height, |
michael@0 | 465 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 466 | { |
michael@0 | 467 | const unsigned short *source = NULL; |
michael@0 | 468 | unsigned char *dest = NULL; |
michael@0 | 469 | |
michael@0 | 470 | for (int y = 0; y < height; y++) |
michael@0 | 471 | { |
michael@0 | 472 | source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 473 | dest = static_cast<unsigned char*>(output) + y * outputPitch; |
michael@0 | 474 | for (int x = 0; x < width; x++) |
michael@0 | 475 | { |
michael@0 | 476 | unsigned short rgba = source[x]; |
michael@0 | 477 | dest[4 * x + 0] = ((rgba & 0x003E) << 2) | ((rgba & 0x003E) >> 3); |
michael@0 | 478 | dest[4 * x + 1] = ((rgba & 0x07C0) >> 3) | ((rgba & 0x07C0) >> 8); |
michael@0 | 479 | dest[4 * x + 2] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13); |
michael@0 | 480 | dest[4 * x + 3] = (rgba & 0x0001) ? 0xFF : 0; |
michael@0 | 481 | } |
michael@0 | 482 | } |
michael@0 | 483 | } |
michael@0 | 484 | |
michael@0 | 485 | void Image::loadRGBA5551DataToRGBA(GLsizei width, GLsizei height, |
michael@0 | 486 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 487 | { |
michael@0 | 488 | const unsigned short *source = NULL; |
michael@0 | 489 | unsigned char *dest = NULL; |
michael@0 | 490 | |
michael@0 | 491 | for (int y = 0; y < height; y++) |
michael@0 | 492 | { |
michael@0 | 493 | source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 494 | dest = static_cast<unsigned char*>(output) + y * outputPitch; |
michael@0 | 495 | for (int x = 0; x < width; x++) |
michael@0 | 496 | { |
michael@0 | 497 | unsigned short rgba = source[x]; |
michael@0 | 498 | dest[4 * x + 0] = ((rgba & 0xF800) >> 8) | ((rgba & 0xF800) >> 13); |
michael@0 | 499 | dest[4 * x + 1] = ((rgba & 0x07C0) >> 3) | ((rgba & 0x07C0) >> 8); |
michael@0 | 500 | dest[4 * x + 2] = ((rgba & 0x003E) << 2) | ((rgba & 0x003E) >> 3); |
michael@0 | 501 | dest[4 * x + 3] = (rgba & 0x0001) ? 0xFF : 0; |
michael@0 | 502 | } |
michael@0 | 503 | } |
michael@0 | 504 | } |
michael@0 | 505 | |
michael@0 | 506 | void Image::loadRGBAFloatDataToRGBA(GLsizei width, GLsizei height, |
michael@0 | 507 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 508 | { |
michael@0 | 509 | const float *source = NULL; |
michael@0 | 510 | float *dest = NULL; |
michael@0 | 511 | |
michael@0 | 512 | for (int y = 0; y < height; y++) |
michael@0 | 513 | { |
michael@0 | 514 | source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); |
michael@0 | 515 | dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputPitch); |
michael@0 | 516 | memcpy(dest, source, width * 16); |
michael@0 | 517 | } |
michael@0 | 518 | } |
michael@0 | 519 | |
michael@0 | 520 | void Image::loadRGBAHalfFloatDataToRGBA(GLsizei width, GLsizei height, |
michael@0 | 521 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 522 | { |
michael@0 | 523 | const unsigned char *source = NULL; |
michael@0 | 524 | unsigned char *dest = NULL; |
michael@0 | 525 | |
michael@0 | 526 | for (int y = 0; y < height; y++) |
michael@0 | 527 | { |
michael@0 | 528 | source = static_cast<const unsigned char*>(input) + y * inputPitch; |
michael@0 | 529 | dest = static_cast<unsigned char*>(output) + y * outputPitch; |
michael@0 | 530 | memcpy(dest, source, width * 8); |
michael@0 | 531 | } |
michael@0 | 532 | } |
michael@0 | 533 | |
michael@0 | 534 | void Image::loadBGRADataToBGRA(GLsizei width, GLsizei height, |
michael@0 | 535 | int inputPitch, const void *input, size_t outputPitch, void *output) |
michael@0 | 536 | { |
michael@0 | 537 | const unsigned char *source = NULL; |
michael@0 | 538 | unsigned char *dest = NULL; |
michael@0 | 539 | |
michael@0 | 540 | for (int y = 0; y < height; y++) |
michael@0 | 541 | { |
michael@0 | 542 | source = static_cast<const unsigned char*>(input) + y * inputPitch; |
michael@0 | 543 | dest = static_cast<unsigned char*>(output) + y * outputPitch; |
michael@0 | 544 | memcpy(dest, source, width*4); |
michael@0 | 545 | } |
michael@0 | 546 | } |
michael@0 | 547 | |
michael@0 | 548 | } |