| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Gabor Rapcsanyi (rgabor@inf.u-szeged.hu), University of Sz
eged | 2 * Copyright (C) 2012 Gabor Rapcsanyi (rgabor@inf.u-szeged.hu), University of Sz
eged |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 RGBA5551.val[1] = vorr_u8(componentR, componentG3bit); | 227 RGBA5551.val[1] = vorr_u8(componentR, componentG3bit); |
| 228 vst2_u8(dst, RGBA5551); | 228 vst2_u8(dst, RGBA5551); |
| 229 dst += 16; | 229 dst += 16; |
| 230 } | 230 } |
| 231 | 231 |
| 232 source += componentsSize; | 232 source += componentsSize; |
| 233 destination += componentsSize / 4; | 233 destination += componentsSize / 4; |
| 234 pixelsPerRow = tailComponents / 4; | 234 pixelsPerRow = tailComponents / 4; |
| 235 } | 235 } |
| 236 | 236 |
| 237 ALWAYS_INLINE void unpackOneRowOfRGB565ToRGBA8(const uint16_t*& source, uint8_t*
& destination, unsigned& pixelsPerRow) | |
| 238 { | |
| 239 unsigned tailPixels = pixelsPerRow % 8; | |
| 240 unsigned pixelSize = pixelsPerRow - tailPixels; | |
| 241 | |
| 242 uint16x8_t immediate0x3f = vdupq_n_u16(0x3F); | |
| 243 uint16x8_t immediate0x1f = vdupq_n_u16(0x1F); | |
| 244 uint8x8_t immediate0x3 = vdup_n_u8(0x3); | |
| 245 uint8x8_t immediate0x7 = vdup_n_u8(0x7); | |
| 246 | |
| 247 uint8x8_t componentA = vdup_n_u8(0xFF); | |
| 248 | |
| 249 for (unsigned i = 0; i < pixelSize; i += 8) { | |
| 250 uint16x8_t eightPixels = vld1q_u16(source + i); | |
| 251 | |
| 252 uint8x8_t componentR = vqmovn_u16(vshrq_n_u16(eightPixels, 11)); | |
| 253 uint8x8_t componentG = vqmovn_u16(vandq_u16(vshrq_n_u16(eightPixels, 5),
immediate0x3f)); | |
| 254 uint8x8_t componentB = vqmovn_u16(vandq_u16(eightPixels, immediate0x1f))
; | |
| 255 | |
| 256 componentR = vorr_u8(vshl_n_u8(componentR, 3), vand_u8(componentR, immed
iate0x7)); | |
| 257 componentG = vorr_u8(vshl_n_u8(componentG, 2), vand_u8(componentG, immed
iate0x3)); | |
| 258 componentB = vorr_u8(vshl_n_u8(componentB, 3), vand_u8(componentB, immed
iate0x7)); | |
| 259 | |
| 260 uint8x8x4_t destComponents = {{componentR, componentG, componentB, compo
nentA}}; | |
| 261 vst4_u8(destination, destComponents); | |
| 262 destination += 32; | |
| 263 } | |
| 264 | |
| 265 source += pixelSize; | |
| 266 pixelsPerRow = tailPixels; | |
| 267 } | |
| 268 | |
| 269 ALWAYS_INLINE void packOneRowOfRGBA8ToUnsignedShort565(const uint8_t*& source, u
int16_t*& destination, unsigned& pixelsPerRow) | 237 ALWAYS_INLINE void packOneRowOfRGBA8ToUnsignedShort565(const uint8_t*& source, u
int16_t*& destination, unsigned& pixelsPerRow) |
| 270 { | 238 { |
| 271 unsigned componentsPerRow = pixelsPerRow * 4; | 239 unsigned componentsPerRow = pixelsPerRow * 4; |
| 272 unsigned tailComponents = componentsPerRow % 32; | 240 unsigned tailComponents = componentsPerRow % 32; |
| 273 unsigned componentsSize = componentsPerRow - tailComponents; | 241 unsigned componentsSize = componentsPerRow - tailComponents; |
| 274 uint8_t* dst = reinterpret_cast<uint8_t*>(destination); | 242 uint8_t* dst = reinterpret_cast<uint8_t*>(destination); |
| 275 | 243 |
| 276 uint8x8_t immediate0xf8 = vdup_n_u8(0xF8); | 244 uint8x8_t immediate0xf8 = vdup_n_u8(0xF8); |
| 277 uint8x8_t immediate0x1c = vdup_n_u8(0x1C); | 245 uint8x8_t immediate0x1c = vdup_n_u8(0x1C); |
| 278 for (unsigned i = 0; i < componentsSize; i += 32) { | 246 for (unsigned i = 0; i < componentsSize; i += 32) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 295 pixelsPerRow = tailComponents / 4; | 263 pixelsPerRow = tailComponents / 4; |
| 296 } | 264 } |
| 297 | 265 |
| 298 } // namespace SIMD | 266 } // namespace SIMD |
| 299 | 267 |
| 300 } // namespace blink | 268 } // namespace blink |
| 301 | 269 |
| 302 #endif // HAVE(ARM_NEON_INTRINSICS) | 270 #endif // HAVE(ARM_NEON_INTRINSICS) |
| 303 | 271 |
| 304 #endif // WebGLImageConversionNEON_h | 272 #endif // WebGLImageConversionNEON_h |
| OLD | NEW |