| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
| 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 void ImageBitmapFactories::ImageBitmapLoader::scheduleAsyncImageBitmapDecoding( | 253 void ImageBitmapFactories::ImageBitmapLoader::scheduleAsyncImageBitmapDecoding( |
| 254 DOMArrayBuffer* arrayBuffer) { | 254 DOMArrayBuffer* arrayBuffer) { |
| 255 // For a 4000*4000 png image where each 10*10 tile is filled in by a random | 255 // For a 4000*4000 png image where each 10*10 tile is filled in by a random |
| 256 // RGBA value, the byteLength is around 2M, and it typically takes around | 256 // RGBA value, the byteLength is around 2M, and it typically takes around |
| 257 // 4.5ms to decode on a current model of Linux desktop. | 257 // 4.5ms to decode on a current model of Linux desktop. |
| 258 const int longTaskByteLengthThreshold = 2000000; | 258 const int longTaskByteLengthThreshold = 2000000; |
| 259 BackgroundTaskRunner::TaskSize taskSize = | 259 BackgroundTaskRunner::TaskSize taskSize = |
| 260 BackgroundTaskRunner::TaskSizeShortRunningTask; | 260 BackgroundTaskRunner::TaskSizeShortRunningTask; |
| 261 if (arrayBuffer->byteLength() >= longTaskByteLengthThreshold) | 261 if (arrayBuffer->byteLength() >= longTaskByteLengthThreshold) |
| 262 taskSize = BackgroundTaskRunner::TaskSizeLongRunningTask; | 262 taskSize = BackgroundTaskRunner::TaskSizeLongRunningTask; |
| 263 WebTaskRunner* taskRunner = | 263 RefPtr<WebTaskRunner> taskRunner = |
| 264 Platform::current()->currentThread()->getWebTaskRunner(); | 264 Platform::current()->currentThread()->getWebTaskRunner(); |
| 265 BackgroundTaskRunner::postOnBackgroundThread( | 265 BackgroundTaskRunner::postOnBackgroundThread( |
| 266 BLINK_FROM_HERE, | 266 BLINK_FROM_HERE, |
| 267 crossThreadBind( | 267 crossThreadBind( |
| 268 &ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread, | 268 &ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread, |
| 269 wrapCrossThreadPersistent(this), crossThreadUnretained(taskRunner), | 269 wrapCrossThreadPersistent(this), std::move(taskRunner), |
| 270 wrapCrossThreadPersistent(arrayBuffer), m_options.premultiplyAlpha(), | 270 wrapCrossThreadPersistent(arrayBuffer), m_options.premultiplyAlpha(), |
| 271 m_options.colorSpaceConversion()), | 271 m_options.colorSpaceConversion()), |
| 272 taskSize); | 272 taskSize); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread( | 275 void ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread( |
| 276 WebTaskRunner* taskRunner, | 276 RefPtr<WebTaskRunner> taskRunner, |
| 277 DOMArrayBuffer* arrayBuffer, | 277 DOMArrayBuffer* arrayBuffer, |
| 278 const String& premultiplyAlphaOption, | 278 const String& premultiplyAlphaOption, |
| 279 const String& colorSpaceConversionOption) { | 279 const String& colorSpaceConversionOption) { |
| 280 ASSERT(!isMainThread()); | 280 ASSERT(!isMainThread()); |
| 281 | 281 |
| 282 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; | 282 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; |
| 283 if (premultiplyAlphaOption == "none") | 283 if (premultiplyAlphaOption == "none") |
| 284 alphaOp = ImageDecoder::AlphaNotPremultiplied; | 284 alphaOp = ImageDecoder::AlphaNotPremultiplied; |
| 285 bool ignoreColorSpace = false; | 285 bool ignoreColorSpace = false; |
| 286 if (colorSpaceConversionOption == "none") | 286 if (colorSpaceConversionOption == "none") |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 } | 321 } |
| 322 m_factory->didFinishLoading(this); | 322 m_factory->didFinishLoading(this); |
| 323 } | 323 } |
| 324 | 324 |
| 325 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) { | 325 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) { |
| 326 visitor->trace(m_factory); | 326 visitor->trace(m_factory); |
| 327 visitor->trace(m_resolver); | 327 visitor->trace(m_resolver); |
| 328 } | 328 } |
| 329 | 329 |
| 330 } // namespace blink | 330 } // namespace blink |
| OLD | NEW |