| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "config.h" | 5 #include "config.h" |
| 6 #include "platform/graphics/gpu/WebGLImageConversion.h" | 6 #include "platform/graphics/gpu/WebGLImageConversion.h" |
| 7 | 7 |
| 8 #include "platform/CheckedInt.h" | 8 #include "platform/CheckedInt.h" |
| 9 #include "platform/graphics/ImageObserver.h" | 9 #include "platform/graphics/ImageObserver.h" |
| 10 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h" | 10 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 //---------------------------------------------------------------------- | 230 //---------------------------------------------------------------------- |
| 231 // Pixel unpacking routines. | 231 // Pixel unpacking routines. |
| 232 template<int format, typename SourceType, typename DstType> | 232 template<int format, typename SourceType, typename DstType> |
| 233 void unpack(const SourceType*, DstType*, unsigned) | 233 void unpack(const SourceType*, DstType*, unsigned) |
| 234 { | 234 { |
| 235 ASSERT_NOT_REACHED(); | 235 ASSERT_NOT_REACHED(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 template<> void unpack<WebGLImageConversion::DataFormatRGB8, uint8_t, uint8_t>(c
onst uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) | 238 template<> void unpack<WebGLImageConversion::DataFormatRGB8, uint8_t, uint8_t>(c
onst uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) |
| 239 { | 239 { |
| 240 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 240 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 241 destination[0] = source[0]; | 241 destination[0] = source[0]; |
| 242 destination[1] = source[1]; | 242 destination[1] = source[1]; |
| 243 destination[2] = source[2]; | 243 destination[2] = source[2]; |
| 244 destination[3] = 0xFF; | 244 destination[3] = 0xFF; |
| 245 source += 3; | 245 source += 3; |
| 246 destination += 4; | 246 destination += 4; |
| 247 } | 247 } |
| 248 } | 248 } |
| 249 | 249 |
| 250 template<> void unpack<WebGLImageConversion::DataFormatBGR8, uint8_t, uint8_t>(c
onst uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) | 250 template<> void unpack<WebGLImageConversion::DataFormatBGR8, uint8_t, uint8_t>(c
onst uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) |
| 251 { | 251 { |
| 252 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 252 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 253 destination[0] = source[2]; | 253 destination[0] = source[2]; |
| 254 destination[1] = source[1]; | 254 destination[1] = source[1]; |
| 255 destination[2] = source[0]; | 255 destination[2] = source[0]; |
| 256 destination[3] = 0xFF; | 256 destination[3] = 0xFF; |
| 257 source += 3; | 257 source += 3; |
| 258 destination += 4; | 258 destination += 4; |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 | 261 |
| 262 template<> void unpack<WebGLImageConversion::DataFormatARGB8, uint8_t, uint8_t>(
const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) | 262 template<> void unpack<WebGLImageConversion::DataFormatARGB8, uint8_t, uint8_t>(
const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) |
| 263 { | 263 { |
| 264 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 264 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 265 destination[0] = source[1]; | 265 destination[0] = source[1]; |
| 266 destination[1] = source[2]; | 266 destination[1] = source[2]; |
| 267 destination[2] = source[3]; | 267 destination[2] = source[3]; |
| 268 destination[3] = source[0]; | 268 destination[3] = source[0]; |
| 269 source += 4; | 269 source += 4; |
| 270 destination += 4; | 270 destination += 4; |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 | 273 |
| 274 template<> void unpack<WebGLImageConversion::DataFormatABGR8, uint8_t, uint8_t>(
const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) | 274 template<> void unpack<WebGLImageConversion::DataFormatABGR8, uint8_t, uint8_t>(
const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) |
| 275 { | 275 { |
| 276 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 276 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 277 destination[0] = source[3]; | 277 destination[0] = source[3]; |
| 278 destination[1] = source[2]; | 278 destination[1] = source[2]; |
| 279 destination[2] = source[1]; | 279 destination[2] = source[1]; |
| 280 destination[3] = source[0]; | 280 destination[3] = source[0]; |
| 281 source += 4; | 281 source += 4; |
| 282 destination += 4; | 282 destination += 4; |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 | 285 |
| 286 template<> void unpack<WebGLImageConversion::DataFormatBGRA8, uint8_t, uint8_t>(
const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) | 286 template<> void unpack<WebGLImageConversion::DataFormatBGRA8, uint8_t, uint8_t>(
const uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) |
| 287 { | 287 { |
| 288 const uint32_t* source32 = reinterpret_cast_ptr<const uint32_t*>(source); | 288 const uint32_t* source32 = reinterpret_cast_ptr<const uint32_t*>(source); |
| 289 uint32_t* destination32 = reinterpret_cast_ptr<uint32_t*>(destination); | 289 uint32_t* destination32 = reinterpret_cast_ptr<uint32_t*>(destination); |
| 290 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 290 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 291 uint32_t bgra = source32[i]; | 291 uint32_t bgra = source32[i]; |
| 292 #if CPU(BIG_ENDIAN) | 292 #if CPU(BIG_ENDIAN) |
| 293 uint32_t brMask = 0xff00ff00; | 293 uint32_t brMask = 0xff00ff00; |
| 294 uint32_t gaMask = 0x00ff00ff; | 294 uint32_t gaMask = 0x00ff00ff; |
| 295 #else | 295 #else |
| 296 uint32_t brMask = 0x00ff00ff; | 296 uint32_t brMask = 0x00ff00ff; |
| 297 uint32_t gaMask = 0xff00ff00; | 297 uint32_t gaMask = 0xff00ff00; |
| 298 #endif | 298 #endif |
| 299 uint32_t rgba = (((bgra >> 16) | (bgra << 16)) & brMask) | (bgra & gaMas
k); | 299 uint32_t rgba = (((bgra >> 16) | (bgra << 16)) & brMask) | (bgra & gaMas
k); |
| 300 destination32[i] = rgba; | 300 destination32[i] = rgba; |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 | 303 |
| 304 template<> void unpack<WebGLImageConversion::DataFormatRGBA5551, uint16_t, uint8
_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow) | 304 template<> void unpack<WebGLImageConversion::DataFormatRGBA5551, uint16_t, uint8
_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow) |
| 305 { | 305 { |
| 306 #if HAVE(ARM_NEON_INTRINSICS) | 306 #if HAVE(ARM_NEON_INTRINSICS) |
| 307 SIMD::unpackOneRowOfRGBA5551ToRGBA8(source, destination, pixelsPerRow); | 307 SIMD::unpackOneRowOfRGBA5551ToRGBA8(source, destination, pixelsPerRow); |
| 308 #endif | 308 #endif |
| 309 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 309 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 310 uint16_t packedValue = source[0]; | 310 uint16_t packedValue = source[0]; |
| 311 uint8_t r = packedValue >> 11; | 311 uint8_t r = packedValue >> 11; |
| 312 uint8_t g = (packedValue >> 6) & 0x1F; | 312 uint8_t g = (packedValue >> 6) & 0x1F; |
| 313 uint8_t b = (packedValue >> 1) & 0x1F; | 313 uint8_t b = (packedValue >> 1) & 0x1F; |
| 314 destination[0] = (r << 3) | (r & 0x7); | 314 destination[0] = (r << 3) | (r & 0x7); |
| 315 destination[1] = (g << 3) | (g & 0x7); | 315 destination[1] = (g << 3) | (g & 0x7); |
| 316 destination[2] = (b << 3) | (b & 0x7); | 316 destination[2] = (b << 3) | (b & 0x7); |
| 317 destination[3] = (packedValue & 0x1) ? 0xFF : 0x0; | 317 destination[3] = (packedValue & 0x1) ? 0xFF : 0x0; |
| 318 source += 1; | 318 source += 1; |
| 319 destination += 4; | 319 destination += 4; |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 | 322 |
| 323 template<> void unpack<WebGLImageConversion::DataFormatRGBA4444, uint16_t, uint8
_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow) | 323 template<> void unpack<WebGLImageConversion::DataFormatRGBA4444, uint16_t, uint8
_t>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow) |
| 324 { | 324 { |
| 325 #if HAVE(ARM_NEON_INTRINSICS) | 325 #if HAVE(ARM_NEON_INTRINSICS) |
| 326 SIMD::unpackOneRowOfRGBA4444ToRGBA8(source, destination, pixelsPerRow); | 326 SIMD::unpackOneRowOfRGBA4444ToRGBA8(source, destination, pixelsPerRow); |
| 327 #endif | 327 #endif |
| 328 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 328 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 329 uint16_t packedValue = source[0]; | 329 uint16_t packedValue = source[0]; |
| 330 uint8_t r = packedValue >> 12; | 330 uint8_t r = packedValue >> 12; |
| 331 uint8_t g = (packedValue >> 8) & 0x0F; | 331 uint8_t g = (packedValue >> 8) & 0x0F; |
| 332 uint8_t b = (packedValue >> 4) & 0x0F; | 332 uint8_t b = (packedValue >> 4) & 0x0F; |
| 333 uint8_t a = packedValue & 0x0F; | 333 uint8_t a = packedValue & 0x0F; |
| 334 destination[0] = r << 4 | r; | 334 destination[0] = r << 4 | r; |
| 335 destination[1] = g << 4 | g; | 335 destination[1] = g << 4 | g; |
| 336 destination[2] = b << 4 | b; | 336 destination[2] = b << 4 | b; |
| 337 destination[3] = a << 4 | a; | 337 destination[3] = a << 4 | a; |
| 338 source += 1; | 338 source += 1; |
| 339 destination += 4; | 339 destination += 4; |
| 340 } | 340 } |
| 341 } | 341 } |
| 342 | 342 |
| 343 template<> void unpack<WebGLImageConversion::DataFormatRGB565, uint16_t, uint8_t
>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow) | 343 template<> void unpack<WebGLImageConversion::DataFormatRGB565, uint16_t, uint8_t
>(const uint16_t* source, uint8_t* destination, unsigned pixelsPerRow) |
| 344 { | 344 { |
| 345 #if HAVE(ARM_NEON_INTRINSICS) | 345 #if HAVE(ARM_NEON_INTRINSICS) |
| 346 SIMD::unpackOneRowOfRGB565ToRGBA8(source, destination, pixelsPerRow); | 346 SIMD::unpackOneRowOfRGB565ToRGBA8(source, destination, pixelsPerRow); |
| 347 #endif | 347 #endif |
| 348 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 348 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 349 uint16_t packedValue = source[0]; | 349 uint16_t packedValue = source[0]; |
| 350 uint8_t r = packedValue >> 11; | 350 uint8_t r = packedValue >> 11; |
| 351 uint8_t g = (packedValue >> 5) & 0x3F; | 351 uint8_t g = (packedValue >> 5) & 0x3F; |
| 352 uint8_t b = packedValue & 0x1F; | 352 uint8_t b = packedValue & 0x1F; |
| 353 destination[0] = (r << 3) | (r & 0x7); | 353 destination[0] = (r << 3) | (r & 0x7); |
| 354 destination[1] = (g << 2) | (g & 0x3); | 354 destination[1] = (g << 2) | (g & 0x3); |
| 355 destination[2] = (b << 3) | (b & 0x7); | 355 destination[2] = (b << 3) | (b & 0x7); |
| 356 destination[3] = 0xFF; | 356 destination[3] = 0xFF; |
| 357 source += 1; | 357 source += 1; |
| 358 destination += 4; | 358 destination += 4; |
| 359 } | 359 } |
| 360 } | 360 } |
| 361 | 361 |
| 362 template<> void unpack<WebGLImageConversion::DataFormatR8, uint8_t, uint8_t>(con
st uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) | 362 template<> void unpack<WebGLImageConversion::DataFormatR8, uint8_t, uint8_t>(con
st uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) |
| 363 { | 363 { |
| 364 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 364 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 365 destination[0] = source[0]; | 365 destination[0] = source[0]; |
| 366 destination[1] = source[0]; | 366 destination[1] = source[0]; |
| 367 destination[2] = source[0]; | 367 destination[2] = source[0]; |
| 368 destination[3] = 0xFF; | 368 destination[3] = 0xFF; |
| 369 source += 1; | 369 source += 1; |
| 370 destination += 4; | 370 destination += 4; |
| 371 } | 371 } |
| 372 } | 372 } |
| 373 | 373 |
| 374 template<> void unpack<WebGLImageConversion::DataFormatRA8, uint8_t, uint8_t>(co
nst uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) | 374 template<> void unpack<WebGLImageConversion::DataFormatRA8, uint8_t, uint8_t>(co
nst uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) |
| 375 { | 375 { |
| 376 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 376 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 377 destination[0] = source[0]; | 377 destination[0] = source[0]; |
| 378 destination[1] = source[0]; | 378 destination[1] = source[0]; |
| 379 destination[2] = source[0]; | 379 destination[2] = source[0]; |
| 380 destination[3] = source[1]; | 380 destination[3] = source[1]; |
| 381 source += 2; | 381 source += 2; |
| 382 destination += 4; | 382 destination += 4; |
| 383 } | 383 } |
| 384 } | 384 } |
| 385 | 385 |
| 386 template<> void unpack<WebGLImageConversion::DataFormatAR8, uint8_t, uint8_t>(co
nst uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) | 386 template<> void unpack<WebGLImageConversion::DataFormatAR8, uint8_t, uint8_t>(co
nst uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) |
| 387 { | 387 { |
| 388 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 388 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 389 destination[0] = source[1]; | 389 destination[0] = source[1]; |
| 390 destination[1] = source[1]; | 390 destination[1] = source[1]; |
| 391 destination[2] = source[1]; | 391 destination[2] = source[1]; |
| 392 destination[3] = source[0]; | 392 destination[3] = source[0]; |
| 393 source += 2; | 393 source += 2; |
| 394 destination += 4; | 394 destination += 4; |
| 395 } | 395 } |
| 396 } | 396 } |
| 397 | 397 |
| 398 template<> void unpack<WebGLImageConversion::DataFormatA8, uint8_t, uint8_t>(con
st uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) | 398 template<> void unpack<WebGLImageConversion::DataFormatA8, uint8_t, uint8_t>(con
st uint8_t* source, uint8_t* destination, unsigned pixelsPerRow) |
| 399 { | 399 { |
| 400 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 400 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 401 destination[0] = 0x0; | 401 destination[0] = 0x0; |
| 402 destination[1] = 0x0; | 402 destination[1] = 0x0; |
| 403 destination[2] = 0x0; | 403 destination[2] = 0x0; |
| 404 destination[3] = source[0]; | 404 destination[3] = source[0]; |
| 405 source += 1; | 405 source += 1; |
| 406 destination += 4; | 406 destination += 4; |
| 407 } | 407 } |
| 408 } | 408 } |
| 409 | 409 |
| 410 template<> void unpack<WebGLImageConversion::DataFormatRGBA8, uint8_t, float>(co
nst uint8_t* source, float* destination, unsigned pixelsPerRow) | 410 template<> void unpack<WebGLImageConversion::DataFormatRGBA8, uint8_t, float>(co
nst uint8_t* source, float* destination, unsigned pixelsPerRow) |
| 411 { | 411 { |
| 412 const float scaleFactor = 1.0f / 255.0f; | 412 const float scaleFactor = 1.0f / 255.0f; |
| 413 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 413 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 414 destination[0] = source[0] * scaleFactor; | 414 destination[0] = source[0] * scaleFactor; |
| 415 destination[1] = source[1] * scaleFactor; | 415 destination[1] = source[1] * scaleFactor; |
| 416 destination[2] = source[2] * scaleFactor; | 416 destination[2] = source[2] * scaleFactor; |
| 417 destination[3] = source[3] * scaleFactor; | 417 destination[3] = source[3] * scaleFactor; |
| 418 source += 4; | 418 source += 4; |
| 419 destination += 4; | 419 destination += 4; |
| 420 } | 420 } |
| 421 } | 421 } |
| 422 | 422 |
| 423 template<> void unpack<WebGLImageConversion::DataFormatBGRA8, uint8_t, float>(co
nst uint8_t* source, float* destination, unsigned pixelsPerRow) | 423 template<> void unpack<WebGLImageConversion::DataFormatBGRA8, uint8_t, float>(co
nst uint8_t* source, float* destination, unsigned pixelsPerRow) |
| 424 { | 424 { |
| 425 const float scaleFactor = 1.0f / 255.0f; | 425 const float scaleFactor = 1.0f / 255.0f; |
| 426 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 426 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 427 destination[0] = source[2] * scaleFactor; | 427 destination[0] = source[2] * scaleFactor; |
| 428 destination[1] = source[1] * scaleFactor; | 428 destination[1] = source[1] * scaleFactor; |
| 429 destination[2] = source[0] * scaleFactor; | 429 destination[2] = source[0] * scaleFactor; |
| 430 destination[3] = source[3] * scaleFactor; | 430 destination[3] = source[3] * scaleFactor; |
| 431 source += 4; | 431 source += 4; |
| 432 destination += 4; | 432 destination += 4; |
| 433 } | 433 } |
| 434 } | 434 } |
| 435 | 435 |
| 436 template<> void unpack<WebGLImageConversion::DataFormatABGR8, uint8_t, float>(co
nst uint8_t* source, float* destination, unsigned pixelsPerRow) | 436 template<> void unpack<WebGLImageConversion::DataFormatABGR8, uint8_t, float>(co
nst uint8_t* source, float* destination, unsigned pixelsPerRow) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 destination[1] = source[1] * scaleFactor; | 480 destination[1] = source[1] * scaleFactor; |
| 481 destination[2] = source[0] * scaleFactor; | 481 destination[2] = source[0] * scaleFactor; |
| 482 destination[3] = 1; | 482 destination[3] = 1; |
| 483 source += 3; | 483 source += 3; |
| 484 destination += 4; | 484 destination += 4; |
| 485 } | 485 } |
| 486 } | 486 } |
| 487 | 487 |
| 488 template<> void unpack<WebGLImageConversion::DataFormatRGB32F, float, float>(con
st float* source, float* destination, unsigned pixelsPerRow) | 488 template<> void unpack<WebGLImageConversion::DataFormatRGB32F, float, float>(con
st float* source, float* destination, unsigned pixelsPerRow) |
| 489 { | 489 { |
| 490 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 490 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 491 destination[0] = source[0]; | 491 destination[0] = source[0]; |
| 492 destination[1] = source[1]; | 492 destination[1] = source[1]; |
| 493 destination[2] = source[2]; | 493 destination[2] = source[2]; |
| 494 destination[3] = 1; | 494 destination[3] = 1; |
| 495 source += 3; | 495 source += 3; |
| 496 destination += 4; | 496 destination += 4; |
| 497 } | 497 } |
| 498 } | 498 } |
| 499 | 499 |
| 500 template<> void unpack<WebGLImageConversion::DataFormatR32F, float, float>(const
float* source, float* destination, unsigned pixelsPerRow) | 500 template<> void unpack<WebGLImageConversion::DataFormatR32F, float, float>(const
float* source, float* destination, unsigned pixelsPerRow) |
| 501 { | 501 { |
| 502 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 502 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 503 destination[0] = source[0]; | 503 destination[0] = source[0]; |
| 504 destination[1] = source[0]; | 504 destination[1] = source[0]; |
| 505 destination[2] = source[0]; | 505 destination[2] = source[0]; |
| 506 destination[3] = 1; | 506 destination[3] = 1; |
| 507 source += 1; | 507 source += 1; |
| 508 destination += 4; | 508 destination += 4; |
| 509 } | 509 } |
| 510 } | 510 } |
| 511 | 511 |
| 512 template<> void unpack<WebGLImageConversion::DataFormatRA32F, float, float>(cons
t float* source, float* destination, unsigned pixelsPerRow) | 512 template<> void unpack<WebGLImageConversion::DataFormatRA32F, float, float>(cons
t float* source, float* destination, unsigned pixelsPerRow) |
| 513 { | 513 { |
| 514 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 514 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 515 destination[0] = source[0]; | 515 destination[0] = source[0]; |
| 516 destination[1] = source[0]; | 516 destination[1] = source[0]; |
| 517 destination[2] = source[0]; | 517 destination[2] = source[0]; |
| 518 destination[3] = source[1]; | 518 destination[3] = source[1]; |
| 519 source += 2; | 519 source += 2; |
| 520 destination += 4; | 520 destination += 4; |
| 521 } | 521 } |
| 522 } | 522 } |
| 523 | 523 |
| 524 template<> void unpack<WebGLImageConversion::DataFormatA32F, float, float>(const
float* source, float* destination, unsigned pixelsPerRow) | 524 template<> void unpack<WebGLImageConversion::DataFormatA32F, float, float>(const
float* source, float* destination, unsigned pixelsPerRow) |
| 525 { | 525 { |
| 526 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 526 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 527 destination[0] = 0; | 527 destination[0] = 0; |
| 528 destination[1] = 0; | 528 destination[1] = 0; |
| 529 destination[2] = 0; | 529 destination[2] = 0; |
| 530 destination[3] = source[0]; | 530 destination[3] = source[0]; |
| 531 source += 1; | 531 source += 1; |
| 532 destination += 4; | 532 destination += 4; |
| 533 } | 533 } |
| 534 } | 534 } |
| 535 | 535 |
| 536 //---------------------------------------------------------------------- | 536 //---------------------------------------------------------------------- |
| 537 // Pixel packing routines. | 537 // Pixel packing routines. |
| 538 // | 538 // |
| 539 | 539 |
| 540 template<int format, int alphaOp, typename SourceType, typename DstType> | 540 template<int format, int alphaOp, typename SourceType, typename DstType> |
| 541 void pack(const SourceType*, DstType*, unsigned) | 541 void pack(const SourceType*, DstType*, unsigned) |
| 542 { | 542 { |
| 543 ASSERT_NOT_REACHED(); | 543 ASSERT_NOT_REACHED(); |
| 544 } | 544 } |
| 545 | 545 |
| 546 template<> void pack<WebGLImageConversion::DataFormatA8, WebGLImageConversion::A
lphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, un
signed pixelsPerRow) | 546 template<> void pack<WebGLImageConversion::DataFormatA8, WebGLImageConversion::A
lphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, un
signed pixelsPerRow) |
| 547 { | 547 { |
| 548 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 548 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 549 destination[0] = source[3]; | 549 destination[0] = source[3]; |
| 550 source += 4; | 550 source += 4; |
| 551 destination += 1; | 551 destination += 1; |
| 552 } | 552 } |
| 553 } | 553 } |
| 554 | 554 |
| 555 template<> void pack<WebGLImageConversion::DataFormatR8, WebGLImageConversion::A
lphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, un
signed pixelsPerRow) | 555 template<> void pack<WebGLImageConversion::DataFormatR8, WebGLImageConversion::A
lphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, un
signed pixelsPerRow) |
| 556 { | 556 { |
| 557 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 557 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 558 destination[0] = source[0]; | 558 destination[0] = source[0]; |
| 559 source += 4; | 559 source += 4; |
| 560 destination += 1; | 560 destination += 1; |
| 561 } | 561 } |
| 562 } | 562 } |
| 563 | 563 |
| 564 template<> void pack<WebGLImageConversion::DataFormatR8, WebGLImageConversion::A
lphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination
, unsigned pixelsPerRow) | 564 template<> void pack<WebGLImageConversion::DataFormatR8, WebGLImageConversion::A
lphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination
, unsigned pixelsPerRow) |
| 565 { | 565 { |
| 566 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 566 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 567 float scaleFactor = source[3] / 255.0f; | 567 float scaleFactor = source[3] / 255.0f; |
| 568 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); | 568 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); |
| 569 destination[0] = sourceR; | 569 destination[0] = sourceR; |
| 570 source += 4; | 570 source += 4; |
| 571 destination += 1; | 571 destination += 1; |
| 572 } | 572 } |
| 573 } | 573 } |
| 574 | 574 |
| 575 // FIXME: this routine is lossy and must be removed. | 575 // FIXME: this routine is lossy and must be removed. |
| 576 template<> void pack<WebGLImageConversion::DataFormatR8, WebGLImageConversion::A
lphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination,
unsigned pixelsPerRow) | 576 template<> void pack<WebGLImageConversion::DataFormatR8, WebGLImageConversion::A
lphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination,
unsigned pixelsPerRow) |
| 577 { | 577 { |
| 578 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 578 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 579 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; | 579 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; |
| 580 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); | 580 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); |
| 581 destination[0] = sourceR; | 581 destination[0] = sourceR; |
| 582 source += 4; | 582 source += 4; |
| 583 destination += 1; | 583 destination += 1; |
| 584 } | 584 } |
| 585 } | 585 } |
| 586 | 586 |
| 587 template<> void pack<WebGLImageConversion::DataFormatRA8, WebGLImageConversion::
AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, u
nsigned pixelsPerRow) | 587 template<> void pack<WebGLImageConversion::DataFormatRA8, WebGLImageConversion::
AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination, u
nsigned pixelsPerRow) |
| 588 { | 588 { |
| 589 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 589 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 590 destination[0] = source[0]; | 590 destination[0] = source[0]; |
| 591 destination[1] = source[3]; | 591 destination[1] = source[3]; |
| 592 source += 4; | 592 source += 4; |
| 593 destination += 2; | 593 destination += 2; |
| 594 } | 594 } |
| 595 } | 595 } |
| 596 | 596 |
| 597 template<> void pack<WebGLImageConversion::DataFormatRA8, WebGLImageConversion::
AlphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destinatio
n, unsigned pixelsPerRow) | 597 template<> void pack<WebGLImageConversion::DataFormatRA8, WebGLImageConversion::
AlphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destinatio
n, unsigned pixelsPerRow) |
| 598 { | 598 { |
| 599 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 599 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 600 float scaleFactor = source[3] / 255.0f; | 600 float scaleFactor = source[3] / 255.0f; |
| 601 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); | 601 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); |
| 602 destination[0] = sourceR; | 602 destination[0] = sourceR; |
| 603 destination[1] = source[3]; | 603 destination[1] = source[3]; |
| 604 source += 4; | 604 source += 4; |
| 605 destination += 2; | 605 destination += 2; |
| 606 } | 606 } |
| 607 } | 607 } |
| 608 | 608 |
| 609 // FIXME: this routine is lossy and must be removed. | 609 // FIXME: this routine is lossy and must be removed. |
| 610 template<> void pack<WebGLImageConversion::DataFormatRA8, WebGLImageConversion::
AlphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination
, unsigned pixelsPerRow) | 610 template<> void pack<WebGLImageConversion::DataFormatRA8, WebGLImageConversion::
AlphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination
, unsigned pixelsPerRow) |
| 611 { | 611 { |
| 612 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 612 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 613 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; | 613 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; |
| 614 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); | 614 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); |
| 615 destination[0] = sourceR; | 615 destination[0] = sourceR; |
| 616 destination[1] = source[3]; | 616 destination[1] = source[3]; |
| 617 source += 4; | 617 source += 4; |
| 618 destination += 2; | 618 destination += 2; |
| 619 } | 619 } |
| 620 } | 620 } |
| 621 | 621 |
| 622 template<> void pack<WebGLImageConversion::DataFormatRGB8, WebGLImageConversion:
:AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination,
unsigned pixelsPerRow) | 622 template<> void pack<WebGLImageConversion::DataFormatRGB8, WebGLImageConversion:
:AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination,
unsigned pixelsPerRow) |
| 623 { | 623 { |
| 624 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 624 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 625 destination[0] = source[0]; | 625 destination[0] = source[0]; |
| 626 destination[1] = source[1]; | 626 destination[1] = source[1]; |
| 627 destination[2] = source[2]; | 627 destination[2] = source[2]; |
| 628 source += 4; | 628 source += 4; |
| 629 destination += 3; | 629 destination += 3; |
| 630 } | 630 } |
| 631 } | 631 } |
| 632 | 632 |
| 633 template<> void pack<WebGLImageConversion::DataFormatRGB8, WebGLImageConversion:
:AlphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destinati
on, unsigned pixelsPerRow) | 633 template<> void pack<WebGLImageConversion::DataFormatRGB8, WebGLImageConversion:
:AlphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destinati
on, unsigned pixelsPerRow) |
| 634 { | 634 { |
| 635 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 635 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 636 float scaleFactor = source[3] / 255.0f; | 636 float scaleFactor = source[3] / 255.0f; |
| 637 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); | 637 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); |
| 638 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); | 638 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); |
| 639 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); | 639 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); |
| 640 destination[0] = sourceR; | 640 destination[0] = sourceR; |
| 641 destination[1] = sourceG; | 641 destination[1] = sourceG; |
| 642 destination[2] = sourceB; | 642 destination[2] = sourceB; |
| 643 source += 4; | 643 source += 4; |
| 644 destination += 3; | 644 destination += 3; |
| 645 } | 645 } |
| 646 } | 646 } |
| 647 | 647 |
| 648 // FIXME: this routine is lossy and must be removed. | 648 // FIXME: this routine is lossy and must be removed. |
| 649 template<> void pack<WebGLImageConversion::DataFormatRGB8, WebGLImageConversion:
:AlphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destinatio
n, unsigned pixelsPerRow) | 649 template<> void pack<WebGLImageConversion::DataFormatRGB8, WebGLImageConversion:
:AlphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destinatio
n, unsigned pixelsPerRow) |
| 650 { | 650 { |
| 651 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 651 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 652 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; | 652 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; |
| 653 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); | 653 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); |
| 654 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); | 654 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); |
| 655 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); | 655 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); |
| 656 destination[0] = sourceR; | 656 destination[0] = sourceR; |
| 657 destination[1] = sourceG; | 657 destination[1] = sourceG; |
| 658 destination[2] = sourceB; | 658 destination[2] = sourceB; |
| 659 source += 4; | 659 source += 4; |
| 660 destination += 3; | 660 destination += 3; |
| 661 } | 661 } |
| 662 } | 662 } |
| 663 | 663 |
| 664 | 664 |
| 665 template<> void pack<WebGLImageConversion::DataFormatRGBA8, WebGLImageConversion
::AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination,
unsigned pixelsPerRow) | 665 template<> void pack<WebGLImageConversion::DataFormatRGBA8, WebGLImageConversion
::AlphaDoNothing, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destination,
unsigned pixelsPerRow) |
| 666 { | 666 { |
| 667 memcpy(destination, source, pixelsPerRow * 4); | 667 memcpy(destination, source, pixelsPerRow * 4); |
| 668 } | 668 } |
| 669 | 669 |
| 670 template<> void pack<WebGLImageConversion::DataFormatRGBA8, WebGLImageConversion
::AlphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destinat
ion, unsigned pixelsPerRow) | 670 template<> void pack<WebGLImageConversion::DataFormatRGBA8, WebGLImageConversion
::AlphaDoPremultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destinat
ion, unsigned pixelsPerRow) |
| 671 { | 671 { |
| 672 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 672 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 673 float scaleFactor = source[3] / 255.0f; | 673 float scaleFactor = source[3] / 255.0f; |
| 674 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); | 674 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); |
| 675 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); | 675 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); |
| 676 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); | 676 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); |
| 677 destination[0] = sourceR; | 677 destination[0] = sourceR; |
| 678 destination[1] = sourceG; | 678 destination[1] = sourceG; |
| 679 destination[2] = sourceB; | 679 destination[2] = sourceB; |
| 680 destination[3] = source[3]; | 680 destination[3] = source[3]; |
| 681 source += 4; | 681 source += 4; |
| 682 destination += 4; | 682 destination += 4; |
| 683 } | 683 } |
| 684 } | 684 } |
| 685 | 685 |
| 686 // FIXME: this routine is lossy and must be removed. | 686 // FIXME: this routine is lossy and must be removed. |
| 687 template<> void pack<WebGLImageConversion::DataFormatRGBA8, WebGLImageConversion
::AlphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destinati
on, unsigned pixelsPerRow) | 687 template<> void pack<WebGLImageConversion::DataFormatRGBA8, WebGLImageConversion
::AlphaDoUnmultiply, uint8_t, uint8_t>(const uint8_t* source, uint8_t* destinati
on, unsigned pixelsPerRow) |
| 688 { | 688 { |
| 689 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 689 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 690 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; | 690 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; |
| 691 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); | 691 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); |
| 692 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); | 692 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); |
| 693 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); | 693 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); |
| 694 destination[0] = sourceR; | 694 destination[0] = sourceR; |
| 695 destination[1] = sourceG; | 695 destination[1] = sourceG; |
| 696 destination[2] = sourceB; | 696 destination[2] = sourceB; |
| 697 destination[3] = source[3]; | 697 destination[3] = source[3]; |
| 698 source += 4; | 698 source += 4; |
| 699 destination += 4; | 699 destination += 4; |
| 700 } | 700 } |
| 701 } | 701 } |
| 702 | 702 |
| 703 template<> void pack<WebGLImageConversion::DataFormatRGBA4444, WebGLImageConvers
ion::AlphaDoNothing, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destina
tion, unsigned pixelsPerRow) | 703 template<> void pack<WebGLImageConversion::DataFormatRGBA4444, WebGLImageConvers
ion::AlphaDoNothing, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destina
tion, unsigned pixelsPerRow) |
| 704 { | 704 { |
| 705 #if HAVE(ARM_NEON_INTRINSICS) | 705 #if HAVE(ARM_NEON_INTRINSICS) |
| 706 SIMD::packOneRowOfRGBA8ToUnsignedShort4444(source, destination, pixelsPerRow
); | 706 SIMD::packOneRowOfRGBA8ToUnsignedShort4444(source, destination, pixelsPerRow
); |
| 707 #endif | 707 #endif |
| 708 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 708 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 709 *destination = (((source[0] & 0xF0) << 8) | 709 *destination = (((source[0] & 0xF0) << 8) |
| 710 | ((source[1] & 0xF0) << 4) | 710 | ((source[1] & 0xF0) << 4) |
| 711 | (source[2] & 0xF0) | 711 | (source[2] & 0xF0) |
| 712 | (source[3] >> 4)); | 712 | (source[3] >> 4)); |
| 713 source += 4; | 713 source += 4; |
| 714 destination += 1; | 714 destination += 1; |
| 715 } | 715 } |
| 716 } | 716 } |
| 717 | 717 |
| 718 template<> void pack<WebGLImageConversion::DataFormatRGBA4444, WebGLImageConvers
ion::AlphaDoPremultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* des
tination, unsigned pixelsPerRow) | 718 template<> void pack<WebGLImageConversion::DataFormatRGBA4444, WebGLImageConvers
ion::AlphaDoPremultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* des
tination, unsigned pixelsPerRow) |
| 719 { | 719 { |
| 720 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 720 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 721 float scaleFactor = source[3] / 255.0f; | 721 float scaleFactor = source[3] / 255.0f; |
| 722 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); | 722 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); |
| 723 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); | 723 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); |
| 724 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); | 724 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); |
| 725 *destination = (((sourceR & 0xF0) << 8) | 725 *destination = (((sourceR & 0xF0) << 8) |
| 726 | ((sourceG & 0xF0) << 4) | 726 | ((sourceG & 0xF0) << 4) |
| 727 | (sourceB & 0xF0) | 727 | (sourceB & 0xF0) |
| 728 | (source[3] >> 4)); | 728 | (source[3] >> 4)); |
| 729 source += 4; | 729 source += 4; |
| 730 destination += 1; | 730 destination += 1; |
| 731 } | 731 } |
| 732 } | 732 } |
| 733 | 733 |
| 734 // FIXME: this routine is lossy and must be removed. | 734 // FIXME: this routine is lossy and must be removed. |
| 735 template<> void pack<WebGLImageConversion::DataFormatRGBA4444, WebGLImageConvers
ion::AlphaDoUnmultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* dest
ination, unsigned pixelsPerRow) | 735 template<> void pack<WebGLImageConversion::DataFormatRGBA4444, WebGLImageConvers
ion::AlphaDoUnmultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* dest
ination, unsigned pixelsPerRow) |
| 736 { | 736 { |
| 737 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 737 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 738 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; | 738 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; |
| 739 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); | 739 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); |
| 740 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); | 740 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); |
| 741 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); | 741 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); |
| 742 *destination = (((sourceR & 0xF0) << 8) | 742 *destination = (((sourceR & 0xF0) << 8) |
| 743 | ((sourceG & 0xF0) << 4) | 743 | ((sourceG & 0xF0) << 4) |
| 744 | (sourceB & 0xF0) | 744 | (sourceB & 0xF0) |
| 745 | (source[3] >> 4)); | 745 | (source[3] >> 4)); |
| 746 source += 4; | 746 source += 4; |
| 747 destination += 1; | 747 destination += 1; |
| 748 } | 748 } |
| 749 } | 749 } |
| 750 | 750 |
| 751 template<> void pack<WebGLImageConversion::DataFormatRGBA5551, WebGLImageConvers
ion::AlphaDoNothing, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destina
tion, unsigned pixelsPerRow) | 751 template<> void pack<WebGLImageConversion::DataFormatRGBA5551, WebGLImageConvers
ion::AlphaDoNothing, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destina
tion, unsigned pixelsPerRow) |
| 752 { | 752 { |
| 753 #if HAVE(ARM_NEON_INTRINSICS) | 753 #if HAVE(ARM_NEON_INTRINSICS) |
| 754 SIMD::packOneRowOfRGBA8ToUnsignedShort5551(source, destination, pixelsPerRow
); | 754 SIMD::packOneRowOfRGBA8ToUnsignedShort5551(source, destination, pixelsPerRow
); |
| 755 #endif | 755 #endif |
| 756 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 756 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 757 *destination = (((source[0] & 0xF8) << 8) | 757 *destination = (((source[0] & 0xF8) << 8) |
| 758 | ((source[1] & 0xF8) << 3) | 758 | ((source[1] & 0xF8) << 3) |
| 759 | ((source[2] & 0xF8) >> 2) | 759 | ((source[2] & 0xF8) >> 2) |
| 760 | (source[3] >> 7)); | 760 | (source[3] >> 7)); |
| 761 source += 4; | 761 source += 4; |
| 762 destination += 1; | 762 destination += 1; |
| 763 } | 763 } |
| 764 } | 764 } |
| 765 | 765 |
| 766 template<> void pack<WebGLImageConversion::DataFormatRGBA5551, WebGLImageConvers
ion::AlphaDoPremultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* des
tination, unsigned pixelsPerRow) | 766 template<> void pack<WebGLImageConversion::DataFormatRGBA5551, WebGLImageConvers
ion::AlphaDoPremultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* des
tination, unsigned pixelsPerRow) |
| 767 { | 767 { |
| 768 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 768 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 769 float scaleFactor = source[3] / 255.0f; | 769 float scaleFactor = source[3] / 255.0f; |
| 770 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); | 770 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); |
| 771 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); | 771 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); |
| 772 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); | 772 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); |
| 773 *destination = (((sourceR & 0xF8) << 8) | 773 *destination = (((sourceR & 0xF8) << 8) |
| 774 | ((sourceG & 0xF8) << 3) | 774 | ((sourceG & 0xF8) << 3) |
| 775 | ((sourceB & 0xF8) >> 2) | 775 | ((sourceB & 0xF8) >> 2) |
| 776 | (source[3] >> 7)); | 776 | (source[3] >> 7)); |
| 777 source += 4; | 777 source += 4; |
| 778 destination += 1; | 778 destination += 1; |
| 779 } | 779 } |
| 780 } | 780 } |
| 781 | 781 |
| 782 // FIXME: this routine is lossy and must be removed. | 782 // FIXME: this routine is lossy and must be removed. |
| 783 template<> void pack<WebGLImageConversion::DataFormatRGBA5551, WebGLImageConvers
ion::AlphaDoUnmultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* dest
ination, unsigned pixelsPerRow) | 783 template<> void pack<WebGLImageConversion::DataFormatRGBA5551, WebGLImageConvers
ion::AlphaDoUnmultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* dest
ination, unsigned pixelsPerRow) |
| 784 { | 784 { |
| 785 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 785 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 786 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; | 786 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; |
| 787 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); | 787 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); |
| 788 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); | 788 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); |
| 789 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); | 789 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); |
| 790 *destination = (((sourceR & 0xF8) << 8) | 790 *destination = (((sourceR & 0xF8) << 8) |
| 791 | ((sourceG & 0xF8) << 3) | 791 | ((sourceG & 0xF8) << 3) |
| 792 | ((sourceB & 0xF8) >> 2) | 792 | ((sourceB & 0xF8) >> 2) |
| 793 | (source[3] >> 7)); | 793 | (source[3] >> 7)); |
| 794 source += 4; | 794 source += 4; |
| 795 destination += 1; | 795 destination += 1; |
| 796 } | 796 } |
| 797 } | 797 } |
| 798 | 798 |
| 799 template<> void pack<WebGLImageConversion::DataFormatRGB565, WebGLImageConversio
n::AlphaDoNothing, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destinati
on, unsigned pixelsPerRow) | 799 template<> void pack<WebGLImageConversion::DataFormatRGB565, WebGLImageConversio
n::AlphaDoNothing, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destinati
on, unsigned pixelsPerRow) |
| 800 { | 800 { |
| 801 #if HAVE(ARM_NEON_INTRINSICS) | 801 #if HAVE(ARM_NEON_INTRINSICS) |
| 802 SIMD::packOneRowOfRGBA8ToUnsignedShort565(source, destination, pixelsPerRow)
; | 802 SIMD::packOneRowOfRGBA8ToUnsignedShort565(source, destination, pixelsPerRow)
; |
| 803 #endif | 803 #endif |
| 804 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 804 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 805 *destination = (((source[0] & 0xF8) << 8) | 805 *destination = (((source[0] & 0xF8) << 8) |
| 806 | ((source[1] & 0xFC) << 3) | 806 | ((source[1] & 0xFC) << 3) |
| 807 | ((source[2] & 0xF8) >> 3)); | 807 | ((source[2] & 0xF8) >> 3)); |
| 808 source += 4; | 808 source += 4; |
| 809 destination += 1; | 809 destination += 1; |
| 810 } | 810 } |
| 811 } | 811 } |
| 812 | 812 |
| 813 template<> void pack<WebGLImageConversion::DataFormatRGB565, WebGLImageConversio
n::AlphaDoPremultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* desti
nation, unsigned pixelsPerRow) | 813 template<> void pack<WebGLImageConversion::DataFormatRGB565, WebGLImageConversio
n::AlphaDoPremultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* desti
nation, unsigned pixelsPerRow) |
| 814 { | 814 { |
| 815 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 815 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 816 float scaleFactor = source[3] / 255.0f; | 816 float scaleFactor = source[3] / 255.0f; |
| 817 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); | 817 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); |
| 818 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); | 818 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); |
| 819 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); | 819 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); |
| 820 *destination = (((sourceR & 0xF8) << 8) | 820 *destination = (((sourceR & 0xF8) << 8) |
| 821 | ((sourceG & 0xFC) << 3) | 821 | ((sourceG & 0xFC) << 3) |
| 822 | ((sourceB & 0xF8) >> 3)); | 822 | ((sourceB & 0xF8) >> 3)); |
| 823 source += 4; | 823 source += 4; |
| 824 destination += 1; | 824 destination += 1; |
| 825 } | 825 } |
| 826 } | 826 } |
| 827 | 827 |
| 828 // FIXME: this routine is lossy and must be removed. | 828 // FIXME: this routine is lossy and must be removed. |
| 829 template<> void pack<WebGLImageConversion::DataFormatRGB565, WebGLImageConversio
n::AlphaDoUnmultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destin
ation, unsigned pixelsPerRow) | 829 template<> void pack<WebGLImageConversion::DataFormatRGB565, WebGLImageConversio
n::AlphaDoUnmultiply, uint8_t, uint16_t>(const uint8_t* source, uint16_t* destin
ation, unsigned pixelsPerRow) |
| 830 { | 830 { |
| 831 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 831 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 832 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; | 832 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; |
| 833 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); | 833 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * s
caleFactor); |
| 834 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); | 834 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * s
caleFactor); |
| 835 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); | 835 uint8_t sourceB = static_cast<uint8_t>(static_cast<float>(source[2]) * s
caleFactor); |
| 836 *destination = (((sourceR & 0xF8) << 8) | 836 *destination = (((sourceR & 0xF8) << 8) |
| 837 | ((sourceG & 0xFC) << 3) | 837 | ((sourceG & 0xFC) << 3) |
| 838 | ((sourceB & 0xF8) >> 3)); | 838 | ((sourceB & 0xF8) >> 3)); |
| 839 source += 4; | 839 source += 4; |
| 840 destination += 1; | 840 destination += 1; |
| 841 } | 841 } |
| 842 } | 842 } |
| 843 | 843 |
| 844 template<> void pack<WebGLImageConversion::DataFormatRGB32F, WebGLImageConversio
n::AlphaDoNothing, float, float>(const float* source, float* destination, unsign
ed pixelsPerRow) | 844 template<> void pack<WebGLImageConversion::DataFormatRGB32F, WebGLImageConversio
n::AlphaDoNothing, float, float>(const float* source, float* destination, unsign
ed pixelsPerRow) |
| 845 { | 845 { |
| 846 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 846 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 847 destination[0] = source[0]; | 847 destination[0] = source[0]; |
| 848 destination[1] = source[1]; | 848 destination[1] = source[1]; |
| 849 destination[2] = source[2]; | 849 destination[2] = source[2]; |
| 850 source += 4; | 850 source += 4; |
| 851 destination += 3; | 851 destination += 3; |
| 852 } | 852 } |
| 853 } | 853 } |
| 854 | 854 |
| 855 template<> void pack<WebGLImageConversion::DataFormatRGB32F, WebGLImageConversio
n::AlphaDoPremultiply, float, float>(const float* source, float* destination, un
signed pixelsPerRow) | 855 template<> void pack<WebGLImageConversion::DataFormatRGB32F, WebGLImageConversio
n::AlphaDoPremultiply, float, float>(const float* source, float* destination, un
signed pixelsPerRow) |
| 856 { | 856 { |
| 857 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 857 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 858 float scaleFactor = source[3]; | 858 float scaleFactor = source[3]; |
| 859 destination[0] = source[0] * scaleFactor; | 859 destination[0] = source[0] * scaleFactor; |
| 860 destination[1] = source[1] * scaleFactor; | 860 destination[1] = source[1] * scaleFactor; |
| 861 destination[2] = source[2] * scaleFactor; | 861 destination[2] = source[2] * scaleFactor; |
| 862 source += 4; | 862 source += 4; |
| 863 destination += 3; | 863 destination += 3; |
| 864 } | 864 } |
| 865 } | 865 } |
| 866 | 866 |
| 867 template<> void pack<WebGLImageConversion::DataFormatRGB32F, WebGLImageConversio
n::AlphaDoUnmultiply, float, float>(const float* source, float* destination, uns
igned pixelsPerRow) | 867 template<> void pack<WebGLImageConversion::DataFormatRGB32F, WebGLImageConversio
n::AlphaDoUnmultiply, float, float>(const float* source, float* destination, uns
igned pixelsPerRow) |
| 868 { | 868 { |
| 869 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 869 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 870 float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f; | 870 float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f; |
| 871 destination[0] = source[0] * scaleFactor; | 871 destination[0] = source[0] * scaleFactor; |
| 872 destination[1] = source[1] * scaleFactor; | 872 destination[1] = source[1] * scaleFactor; |
| 873 destination[2] = source[2] * scaleFactor; | 873 destination[2] = source[2] * scaleFactor; |
| 874 source += 4; | 874 source += 4; |
| 875 destination += 3; | 875 destination += 3; |
| 876 } | 876 } |
| 877 } | 877 } |
| 878 | 878 |
| 879 // Used only during RGBA8 or BGRA8 -> floating-point uploads. | 879 // Used only during RGBA8 or BGRA8 -> floating-point uploads. |
| 880 template<> void pack<WebGLImageConversion::DataFormatRGBA32F, WebGLImageConversi
on::AlphaDoNothing, float, float>(const float* source, float* destination, unsig
ned pixelsPerRow) | 880 template<> void pack<WebGLImageConversion::DataFormatRGBA32F, WebGLImageConversi
on::AlphaDoNothing, float, float>(const float* source, float* destination, unsig
ned pixelsPerRow) |
| 881 { | 881 { |
| 882 memcpy(destination, source, pixelsPerRow * 4 * sizeof(float)); | 882 memcpy(destination, source, pixelsPerRow * 4 * sizeof(float)); |
| 883 } | 883 } |
| 884 | 884 |
| 885 template<> void pack<WebGLImageConversion::DataFormatRGBA32F, WebGLImageConversi
on::AlphaDoPremultiply, float, float>(const float* source, float* destination, u
nsigned pixelsPerRow) | 885 template<> void pack<WebGLImageConversion::DataFormatRGBA32F, WebGLImageConversi
on::AlphaDoPremultiply, float, float>(const float* source, float* destination, u
nsigned pixelsPerRow) |
| 886 { | 886 { |
| 887 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 887 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 888 float scaleFactor = source[3]; | 888 float scaleFactor = source[3]; |
| 889 destination[0] = source[0] * scaleFactor; | 889 destination[0] = source[0] * scaleFactor; |
| 890 destination[1] = source[1] * scaleFactor; | 890 destination[1] = source[1] * scaleFactor; |
| 891 destination[2] = source[2] * scaleFactor; | 891 destination[2] = source[2] * scaleFactor; |
| 892 destination[3] = source[3]; | 892 destination[3] = source[3]; |
| 893 source += 4; | 893 source += 4; |
| 894 destination += 4; | 894 destination += 4; |
| 895 } | 895 } |
| 896 } | 896 } |
| 897 | 897 |
| 898 template<> void pack<WebGLImageConversion::DataFormatRGBA32F, WebGLImageConversi
on::AlphaDoUnmultiply, float, float>(const float* source, float* destination, un
signed pixelsPerRow) | 898 template<> void pack<WebGLImageConversion::DataFormatRGBA32F, WebGLImageConversi
on::AlphaDoUnmultiply, float, float>(const float* source, float* destination, un
signed pixelsPerRow) |
| 899 { | 899 { |
| 900 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 900 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 901 float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f; | 901 float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f; |
| 902 destination[0] = source[0] * scaleFactor; | 902 destination[0] = source[0] * scaleFactor; |
| 903 destination[1] = source[1] * scaleFactor; | 903 destination[1] = source[1] * scaleFactor; |
| 904 destination[2] = source[2] * scaleFactor; | 904 destination[2] = source[2] * scaleFactor; |
| 905 destination[3] = source[3]; | 905 destination[3] = source[3]; |
| 906 source += 4; | 906 source += 4; |
| 907 destination += 4; | 907 destination += 4; |
| 908 } | 908 } |
| 909 } | 909 } |
| 910 | 910 |
| 911 template<> void pack<WebGLImageConversion::DataFormatA32F, WebGLImageConversion:
:AlphaDoNothing, float, float>(const float* source, float* destination, unsigned
pixelsPerRow) | 911 template<> void pack<WebGLImageConversion::DataFormatA32F, WebGLImageConversion:
:AlphaDoNothing, float, float>(const float* source, float* destination, unsigned
pixelsPerRow) |
| 912 { | 912 { |
| 913 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 913 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 914 destination[0] = source[3]; | 914 destination[0] = source[3]; |
| 915 source += 4; | 915 source += 4; |
| 916 destination += 1; | 916 destination += 1; |
| 917 } | 917 } |
| 918 } | 918 } |
| 919 | 919 |
| 920 template<> void pack<WebGLImageConversion::DataFormatR32F, WebGLImageConversion:
:AlphaDoNothing, float, float>(const float* source, float* destination, unsigned
pixelsPerRow) | 920 template<> void pack<WebGLImageConversion::DataFormatR32F, WebGLImageConversion:
:AlphaDoNothing, float, float>(const float* source, float* destination, unsigned
pixelsPerRow) |
| 921 { | 921 { |
| 922 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 922 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 923 destination[0] = source[0]; | 923 destination[0] = source[0]; |
| 924 source += 4; | 924 source += 4; |
| 925 destination += 1; | 925 destination += 1; |
| 926 } | 926 } |
| 927 } | 927 } |
| 928 | 928 |
| 929 template<> void pack<WebGLImageConversion::DataFormatR32F, WebGLImageConversion:
:AlphaDoPremultiply, float, float>(const float* source, float* destination, unsi
gned pixelsPerRow) | 929 template<> void pack<WebGLImageConversion::DataFormatR32F, WebGLImageConversion:
:AlphaDoPremultiply, float, float>(const float* source, float* destination, unsi
gned pixelsPerRow) |
| 930 { | 930 { |
| 931 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 931 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 932 float scaleFactor = source[3]; | 932 float scaleFactor = source[3]; |
| 933 destination[0] = source[0] * scaleFactor; | 933 destination[0] = source[0] * scaleFactor; |
| 934 source += 4; | 934 source += 4; |
| 935 destination += 1; | 935 destination += 1; |
| 936 } | 936 } |
| 937 } | 937 } |
| 938 | 938 |
| 939 template<> void pack<WebGLImageConversion::DataFormatR32F, WebGLImageConversion:
:AlphaDoUnmultiply, float, float>(const float* source, float* destination, unsig
ned pixelsPerRow) | 939 template<> void pack<WebGLImageConversion::DataFormatR32F, WebGLImageConversion:
:AlphaDoUnmultiply, float, float>(const float* source, float* destination, unsig
ned pixelsPerRow) |
| 940 { | 940 { |
| 941 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 941 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 942 float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f; | 942 float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f; |
| 943 destination[0] = source[0] * scaleFactor; | 943 destination[0] = source[0] * scaleFactor; |
| 944 source += 4; | 944 source += 4; |
| 945 destination += 1; | 945 destination += 1; |
| 946 } | 946 } |
| 947 } | 947 } |
| 948 | 948 |
| 949 template<> void pack<WebGLImageConversion::DataFormatRA32F, WebGLImageConversion
::AlphaDoNothing, float, float>(const float* source, float* destination, unsigne
d pixelsPerRow) | 949 template<> void pack<WebGLImageConversion::DataFormatRA32F, WebGLImageConversion
::AlphaDoNothing, float, float>(const float* source, float* destination, unsigne
d pixelsPerRow) |
| 950 { | 950 { |
| 951 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 951 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 952 destination[0] = source[0]; | 952 destination[0] = source[0]; |
| 953 destination[1] = source[3]; | 953 destination[1] = source[3]; |
| 954 source += 4; | 954 source += 4; |
| 955 destination += 2; | 955 destination += 2; |
| 956 } | 956 } |
| 957 } | 957 } |
| 958 | 958 |
| 959 template<> void pack<WebGLImageConversion::DataFormatRA32F, WebGLImageConversion
::AlphaDoPremultiply, float, float>(const float* source, float* destination, uns
igned pixelsPerRow) | 959 template<> void pack<WebGLImageConversion::DataFormatRA32F, WebGLImageConversion
::AlphaDoPremultiply, float, float>(const float* source, float* destination, uns
igned pixelsPerRow) |
| 960 { | 960 { |
| 961 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 961 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 962 float scaleFactor = source[3]; | 962 float scaleFactor = source[3]; |
| 963 destination[0] = source[0] * scaleFactor; | 963 destination[0] = source[0] * scaleFactor; |
| 964 destination[1] = source[3]; | 964 destination[1] = source[3]; |
| 965 source += 4; | 965 source += 4; |
| 966 destination += 2; | 966 destination += 2; |
| 967 } | 967 } |
| 968 } | 968 } |
| 969 | 969 |
| 970 template<> void pack<WebGLImageConversion::DataFormatRA32F, WebGLImageConversion
::AlphaDoUnmultiply, float, float>(const float* source, float* destination, unsi
gned pixelsPerRow) | 970 template<> void pack<WebGLImageConversion::DataFormatRA32F, WebGLImageConversion
::AlphaDoUnmultiply, float, float>(const float* source, float* destination, unsi
gned pixelsPerRow) |
| 971 { | 971 { |
| 972 for (unsigned int i = 0; i < pixelsPerRow; ++i) { | 972 for (unsigned i = 0; i < pixelsPerRow; ++i) { |
| 973 float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f; | 973 float scaleFactor = source[3] ? 1.0f / source[3] : 1.0f; |
| 974 destination[0] = source[0] * scaleFactor; | 974 destination[0] = source[0] * scaleFactor; |
| 975 destination[1] = source[3]; | 975 destination[1] = source[3]; |
| 976 source += 4; | 976 source += 4; |
| 977 destination += 2; | 977 destination += 2; |
| 978 } | 978 } |
| 979 } | 979 } |
| 980 | 980 |
| 981 template<> void pack<WebGLImageConversion::DataFormatRGBA16F, WebGLImageConversi
on::AlphaDoNothing, float, uint16_t>(const float* source, uint16_t* destination,
unsigned pixelsPerRow) | 981 template<> void pack<WebGLImageConversion::DataFormatRGBA16F, WebGLImageConversi
on::AlphaDoNothing, float, uint16_t>(const float* source, uint16_t* destination,
unsigned pixelsPerRow) |
| 982 { | 982 { |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1763 } | 1763 } |
| 1764 | 1764 |
| 1765 FormatConverter converter(width, height, sourceData, destinationData, srcStr
ide, dstStride); | 1765 FormatConverter converter(width, height, sourceData, destinationData, srcStr
ide, dstStride); |
| 1766 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); | 1766 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); |
| 1767 if (!converter.Success()) | 1767 if (!converter.Success()) |
| 1768 return false; | 1768 return false; |
| 1769 return true; | 1769 return true; |
| 1770 } | 1770 } |
| 1771 | 1771 |
| 1772 } // namespace WebCore | 1772 } // namespace WebCore |
| OLD | NEW |