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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 void ImageBitmapFactories::ImageBitmapLoader::scheduleAsyncImageBitmapDecoding(D
OMArrayBuffer* arrayBuffer) | 214 void ImageBitmapFactories::ImageBitmapLoader::scheduleAsyncImageBitmapDecoding(D
OMArrayBuffer* arrayBuffer) |
215 { | 215 { |
216 // For a 4000*4000 png image where each 10*10 tile is filled in by a random
RGBA value, | 216 // For a 4000*4000 png image where each 10*10 tile is filled in by a random
RGBA value, |
217 // the byteLength is around 2M, and it typically takes around 4.5ms to decod
e on a | 217 // the byteLength is around 2M, and it typically takes around 4.5ms to decod
e on a |
218 // current model of Linux desktop. | 218 // current model of Linux desktop. |
219 const int longTaskByteLengthThreshold = 2000000; | 219 const int longTaskByteLengthThreshold = 2000000; |
220 BackgroundTaskRunner::TaskSize taskSize = BackgroundTaskRunner::TaskSizeShor
tRunningTask; | 220 BackgroundTaskRunner::TaskSize taskSize = BackgroundTaskRunner::TaskSizeShor
tRunningTask; |
221 if (arrayBuffer->byteLength() >= longTaskByteLengthThreshold) | 221 if (arrayBuffer->byteLength() >= longTaskByteLengthThreshold) |
222 taskSize = BackgroundTaskRunner::TaskSizeLongRunningTask; | 222 taskSize = BackgroundTaskRunner::TaskSizeLongRunningTask; |
223 WebTaskRunner* taskRunner = Platform::current()->currentThread()->getWebTask
Runner(); | 223 WebTaskRunner* taskRunner = Platform::current()->currentThread()->getWebTask
Runner(); |
224 BackgroundTaskRunner::postOnBackgroundThread(BLINK_FROM_HERE, threadSafeBind
(&ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread, wrapCross
ThreadPersistent(this), AllowCrossThreadAccess(taskRunner), wrapCrossThreadPersi
stent(arrayBuffer)), taskSize); | 224 BackgroundTaskRunner::postOnBackgroundThread(BLINK_FROM_HERE, threadSafeBind
(&ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread, wrapCross
ThreadPersistent(this), crossThreadUnretained(taskRunner), wrapCrossThreadPersis
tent(arrayBuffer)), taskSize); |
225 } | 225 } |
226 | 226 |
227 void ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread(WebTask
Runner* taskRunner, DOMArrayBuffer* arrayBuffer) | 227 void ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread(WebTask
Runner* taskRunner, DOMArrayBuffer* arrayBuffer) |
228 { | 228 { |
229 ASSERT(!isMainThread()); | 229 ASSERT(!isMainThread()); |
230 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(static_cast<char*>(
arrayBuffer->data()), static_cast<size_t>(arrayBuffer->byteLength())); | 230 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(static_cast<char*>(
arrayBuffer->data()), static_cast<size_t>(arrayBuffer->byteLength())); |
231 | 231 |
232 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; | 232 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; |
233 if (m_options.premultiplyAlpha() == "none") | 233 if (m_options.premultiplyAlpha() == "none") |
234 alphaOp = ImageDecoder::AlphaNotPremultiplied; | 234 alphaOp = ImageDecoder::AlphaNotPremultiplied; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 m_factory->didFinishLoading(this); | 269 m_factory->didFinishLoading(this); |
270 } | 270 } |
271 | 271 |
272 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) | 272 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) |
273 { | 273 { |
274 visitor->trace(m_factory); | 274 visitor->trace(m_factory); |
275 visitor->trace(m_resolver); | 275 visitor->trace(m_resolver); |
276 } | 276 } |
277 | 277 |
278 } // namespace blink | 278 } // namespace blink |
OLD | NEW |