| 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 } | 245 } |
| 246 scheduleAsyncImageBitmapDecoding(arrayBuffer); | 246 scheduleAsyncImageBitmapDecoding(arrayBuffer); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode) { | 249 void ImageBitmapFactories::ImageBitmapLoader::didFail(FileError::ErrorCode) { |
| 250 rejectPromise(); | 250 rejectPromise(); |
| 251 } | 251 } |
| 252 | 252 |
| 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 | |
| 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. | |
| 258 const int longTaskByteLengthThreshold = 2000000; | |
| 259 BackgroundTaskRunner::TaskSize taskSize = | |
| 260 BackgroundTaskRunner::TaskSizeShortRunningTask; | |
| 261 if (arrayBuffer->byteLength() >= longTaskByteLengthThreshold) | |
| 262 taskSize = BackgroundTaskRunner::TaskSizeLongRunningTask; | |
| 263 RefPtr<WebTaskRunner> taskRunner = | 255 RefPtr<WebTaskRunner> taskRunner = |
| 264 Platform::current()->currentThread()->getWebTaskRunner(); | 256 Platform::current()->currentThread()->getWebTaskRunner(); |
| 265 BackgroundTaskRunner::postOnBackgroundThread( | 257 BackgroundTaskRunner::postOnBackgroundThread( |
| 266 BLINK_FROM_HERE, | 258 BLINK_FROM_HERE, |
| 267 crossThreadBind( | 259 crossThreadBind( |
| 268 &ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread, | 260 &ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread, |
| 269 wrapCrossThreadPersistent(this), std::move(taskRunner), | 261 wrapCrossThreadPersistent(this), std::move(taskRunner), |
| 270 wrapCrossThreadPersistent(arrayBuffer), m_options.premultiplyAlpha(), | 262 wrapCrossThreadPersistent(arrayBuffer), m_options.premultiplyAlpha(), |
| 271 m_options.colorSpaceConversion()), | 263 m_options.colorSpaceConversion())); |
| 272 taskSize); | |
| 273 } | 264 } |
| 274 | 265 |
| 275 void ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread( | 266 void ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread( |
| 276 RefPtr<WebTaskRunner> taskRunner, | 267 RefPtr<WebTaskRunner> taskRunner, |
| 277 DOMArrayBuffer* arrayBuffer, | 268 DOMArrayBuffer* arrayBuffer, |
| 278 const String& premultiplyAlphaOption, | 269 const String& premultiplyAlphaOption, |
| 279 const String& colorSpaceConversionOption) { | 270 const String& colorSpaceConversionOption) { |
| 280 ASSERT(!isMainThread()); | 271 ASSERT(!isMainThread()); |
| 281 | 272 |
| 282 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; | 273 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 } | 312 } |
| 322 m_factory->didFinishLoading(this); | 313 m_factory->didFinishLoading(this); |
| 323 } | 314 } |
| 324 | 315 |
| 325 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) { | 316 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) { |
| 326 visitor->trace(m_factory); | 317 visitor->trace(m_factory); |
| 327 visitor->trace(m_resolver); | 318 visitor->trace(m_resolver); |
| 328 } | 319 } |
| 329 | 320 |
| 330 } // namespace blink | 321 } // namespace blink |
| OLD | NEW |