| 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 void ImageBitmapFactories::ImageBitmapLoader::scheduleAsyncImageBitmapDecoding( | 250 void ImageBitmapFactories::ImageBitmapLoader::scheduleAsyncImageBitmapDecoding( |
| 251 DOMArrayBuffer* arrayBuffer) { | 251 DOMArrayBuffer* arrayBuffer) { |
| 252 // For a 4000*4000 png image where each 10*10 tile is filled in by a random | 252 // For a 4000*4000 png image where each 10*10 tile is filled in by a random |
| 253 // RGBA value, the byteLength is around 2M, and it typically takes around | 253 // RGBA value, the byteLength is around 2M, and it typically takes around |
| 254 // 4.5ms to decode on a current model of Linux desktop. | 254 // 4.5ms to decode on a current model of Linux desktop. |
| 255 const int longTaskByteLengthThreshold = 2000000; | 255 const int longTaskByteLengthThreshold = 2000000; |
| 256 BackgroundTaskRunner::TaskSize taskSize = | 256 BackgroundTaskRunner::TaskSize taskSize = |
| 257 BackgroundTaskRunner::TaskSizeShortRunningTask; | 257 BackgroundTaskRunner::TaskSizeShortRunningTask; |
| 258 if (arrayBuffer->byteLength() >= longTaskByteLengthThreshold) | 258 if (arrayBuffer->byteLength() >= longTaskByteLengthThreshold) |
| 259 taskSize = BackgroundTaskRunner::TaskSizeLongRunningTask; | 259 taskSize = BackgroundTaskRunner::TaskSizeLongRunningTask; |
| 260 WebTaskRunner* taskRunner = | 260 RefPtr<WebTaskRunner> taskRunner = |
| 261 Platform::current()->currentThread()->getWebTaskRunner(); | 261 Platform::current()->currentThread()->getWebTaskRunner(); |
| 262 BackgroundTaskRunner::postOnBackgroundThread( | 262 BackgroundTaskRunner::postOnBackgroundThread( |
| 263 BLINK_FROM_HERE, | 263 BLINK_FROM_HERE, |
| 264 crossThreadBind( | 264 crossThreadBind( |
| 265 &ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread, | 265 &ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread, |
| 266 wrapCrossThreadPersistent(this), crossThreadUnretained(taskRunner), | 266 wrapCrossThreadPersistent(this), std::move(taskRunner), |
| 267 wrapCrossThreadPersistent(arrayBuffer), m_options.premultiplyAlpha(), | 267 wrapCrossThreadPersistent(arrayBuffer), m_options.premultiplyAlpha(), |
| 268 m_options.colorSpaceConversion()), | 268 m_options.colorSpaceConversion()), |
| 269 taskSize); | 269 taskSize); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread( | 272 void ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread( |
| 273 WebTaskRunner* taskRunner, | 273 RefPtr<WebTaskRunner> taskRunner, |
| 274 DOMArrayBuffer* arrayBuffer, | 274 DOMArrayBuffer* arrayBuffer, |
| 275 const String& premultiplyAlphaOption, | 275 const String& premultiplyAlphaOption, |
| 276 const String& colorSpaceConversionOption) { | 276 const String& colorSpaceConversionOption) { |
| 277 ASSERT(!isMainThread()); | 277 ASSERT(!isMainThread()); |
| 278 | 278 |
| 279 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; | 279 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; |
| 280 if (premultiplyAlphaOption == "none") | 280 if (premultiplyAlphaOption == "none") |
| 281 alphaOp = ImageDecoder::AlphaNotPremultiplied; | 281 alphaOp = ImageDecoder::AlphaNotPremultiplied; |
| 282 ImageDecoder::ColorSpaceOption colorSpaceOp = | 282 ImageDecoder::ColorSpaceOption colorSpaceOp = |
| 283 ImageDecoder::ColorSpaceTransformed; | 283 ImageDecoder::ColorSpaceTransformed; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } | 320 } |
| 321 m_factory->didFinishLoading(this); | 321 m_factory->didFinishLoading(this); |
| 322 } | 322 } |
| 323 | 323 |
| 324 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) { | 324 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) { |
| 325 visitor->trace(m_factory); | 325 visitor->trace(m_factory); |
| 326 visitor->trace(m_resolver); | 326 visitor->trace(m_resolver); |
| 327 } | 327 } |
| 328 | 328 |
| 329 } // namespace blink | 329 } // namespace blink |
| OLD | NEW |