| 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 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/imagebitmap/ImageBitmapFactories.h" | 31 #include "core/imagebitmap/ImageBitmapFactories.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ExceptionState.h" | 33 #include "bindings/core/v8/ExceptionState.h" |
| 34 #include "core/dom/DOMException.h" | 34 #include "core/dom/DOMException.h" |
| 35 #include "core/dom/ExecutionContext.h" | 35 #include "core/dom/ExecutionContext.h" |
| 36 #include "core/dom/TaskRunnerHelper.h" |
| 36 #include "core/fileapi/Blob.h" | 37 #include "core/fileapi/Blob.h" |
| 37 #include "core/frame/ImageBitmap.h" | 38 #include "core/frame/ImageBitmap.h" |
| 38 #include "core/frame/LocalDOMWindow.h" | 39 #include "core/frame/LocalDOMWindow.h" |
| 39 #include "core/frame/UseCounter.h" | 40 #include "core/frame/UseCounter.h" |
| 40 #include "core/html/HTMLCanvasElement.h" | 41 #include "core/html/HTMLCanvasElement.h" |
| 41 #include "core/html/HTMLImageElement.h" | 42 #include "core/html/HTMLImageElement.h" |
| 42 #include "core/html/HTMLVideoElement.h" | 43 #include "core/html/HTMLVideoElement.h" |
| 43 #include "core/html/ImageData.h" | 44 #include "core/html/ImageData.h" |
| 44 #include "core/imagebitmap/ImageBitmapOptions.h" | 45 #include "core/imagebitmap/ImageBitmapOptions.h" |
| 45 #include "core/svg/graphics/SVGImage.h" | 46 #include "core/svg/graphics/SVGImage.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 DOMArrayBuffer* arrayBuffer) { | 252 DOMArrayBuffer* arrayBuffer) { |
| 252 // For a 4000*4000 png image where each 10*10 tile is filled in by a random RG
BA value, | 253 // For a 4000*4000 png image where each 10*10 tile is filled in by a random RG
BA value, |
| 253 // the byteLength is around 2M, and it typically takes around 4.5ms to decode
on a | 254 // the byteLength is around 2M, and it typically takes around 4.5ms to decode
on a |
| 254 // current model of Linux desktop. | 255 // current model of Linux desktop. |
| 255 const int longTaskByteLengthThreshold = 2000000; | 256 const int longTaskByteLengthThreshold = 2000000; |
| 256 BackgroundTaskRunner::TaskSize taskSize = | 257 BackgroundTaskRunner::TaskSize taskSize = |
| 257 BackgroundTaskRunner::TaskSizeShortRunningTask; | 258 BackgroundTaskRunner::TaskSizeShortRunningTask; |
| 258 if (arrayBuffer->byteLength() >= longTaskByteLengthThreshold) | 259 if (arrayBuffer->byteLength() >= longTaskByteLengthThreshold) |
| 259 taskSize = BackgroundTaskRunner::TaskSizeLongRunningTask; | 260 taskSize = BackgroundTaskRunner::TaskSizeLongRunningTask; |
| 260 WebTaskRunner* taskRunner = | 261 WebTaskRunner* taskRunner = |
| 261 Platform::current()->currentThread()->getWebTaskRunner(); | 262 TaskRunnerHelper::get(TaskType::Networking, m_resolver->getScriptState()); |
| 262 BackgroundTaskRunner::postOnBackgroundThread( | 263 BackgroundTaskRunner::postOnBackgroundThread( |
| 263 BLINK_FROM_HERE, | 264 BLINK_FROM_HERE, |
| 264 crossThreadBind( | 265 crossThreadBind( |
| 265 &ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread, | 266 &ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread, |
| 266 wrapCrossThreadPersistent(this), crossThreadUnretained(taskRunner), | 267 wrapCrossThreadPersistent(this), WTF::passed(taskRunner->clone()), |
| 267 wrapCrossThreadPersistent(arrayBuffer), m_options.premultiplyAlpha(), | 268 wrapCrossThreadPersistent(arrayBuffer), m_options.premultiplyAlpha(), |
| 268 m_options.colorSpaceConversion()), | 269 m_options.colorSpaceConversion()), |
| 269 taskSize); | 270 taskSize); |
| 270 } | 271 } |
| 271 | 272 |
| 272 void ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread( | 273 void ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread( |
| 273 WebTaskRunner* taskRunner, | 274 std::unique_ptr<WebTaskRunner> taskRunner, |
| 274 DOMArrayBuffer* arrayBuffer, | 275 DOMArrayBuffer* arrayBuffer, |
| 275 const String& premultiplyAlphaOption, | 276 const String& premultiplyAlphaOption, |
| 276 const String& colorSpaceConversionOption) { | 277 const String& colorSpaceConversionOption) { |
| 277 ASSERT(!isMainThread()); | 278 ASSERT(!isMainThread()); |
| 278 | 279 |
| 279 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; | 280 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; |
| 280 if (premultiplyAlphaOption == "none") | 281 if (premultiplyAlphaOption == "none") |
| 281 alphaOp = ImageDecoder::AlphaNotPremultiplied; | 282 alphaOp = ImageDecoder::AlphaNotPremultiplied; |
| 282 ImageDecoder::GammaAndColorProfileOption colorSpaceOp = | 283 ImageDecoder::GammaAndColorProfileOption colorSpaceOp = |
| 283 ImageDecoder::GammaAndColorProfileApplied; | 284 ImageDecoder::GammaAndColorProfileApplied; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 } | 318 } |
| 318 m_factory->didFinishLoading(this); | 319 m_factory->didFinishLoading(this); |
| 319 } | 320 } |
| 320 | 321 |
| 321 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) { | 322 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) { |
| 322 visitor->trace(m_factory); | 323 visitor->trace(m_factory); |
| 323 visitor->trace(m_resolver); | 324 visitor->trace(m_resolver); |
| 324 } | 325 } |
| 325 | 326 |
| 326 } // namespace blink | 327 } // namespace blink |
| OLD | NEW |