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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 216 |
217 void ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread(WebTask
Runner* taskRunner) | 217 void ImageBitmapFactories::ImageBitmapLoader::decodeImageOnDecoderThread(WebTask
Runner* taskRunner) |
218 { | 218 { |
219 ASSERT(!isMainThread()); | 219 ASSERT(!isMainThread()); |
220 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create((char*)m_loader.arr
ayBufferResult()->data(), static_cast<size_t>(m_loader.arrayBufferResult()->byte
Length())); | 220 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create((char*)m_loader.arr
ayBufferResult()->data(), static_cast<size_t>(m_loader.arrayBufferResult()->byte
Length())); |
221 | 221 |
222 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; | 222 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; |
223 if (m_options.premultiplyAlpha() == "none") | 223 if (m_options.premultiplyAlpha() == "none") |
224 alphaOp = ImageDecoder::AlphaNotPremultiplied; | 224 alphaOp = ImageDecoder::AlphaNotPremultiplied; |
225 OwnPtr<ImageDecoder> decoder(ImageDecoder::create(*sharedBuffer, alphaOp, Im
ageDecoder::GammaAndColorProfileApplied)); | 225 OwnPtr<ImageDecoder> decoder(ImageDecoder::create(*sharedBuffer, alphaOp, Im
ageDecoder::GammaAndColorProfileApplied)); |
226 if (decoder) | 226 RefPtr<SkImage> frame; |
| 227 if (decoder) { |
227 decoder->setData(sharedBuffer.get(), true); | 228 decoder->setData(sharedBuffer.get(), true); |
228 taskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&ImageBitmapFactories::
ImageBitmapLoader::resolvePromiseOnOriginalThread, AllowCrossThreadAccess(this),
decoder.release())); | 229 frame = ImageBitmap::getSkImageFromDecoder(decoder.release()); |
| 230 } |
| 231 taskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&ImageBitmapFactories::
ImageBitmapLoader::resolvePromiseOnOriginalThread, AllowCrossThreadAccess(this),
frame.release())); |
229 } | 232 } |
230 | 233 |
231 void ImageBitmapFactories::ImageBitmapLoader::resolvePromiseOnOriginalThread(Pas
sOwnPtr<ImageDecoder> decoder) | 234 void ImageBitmapFactories::ImageBitmapLoader::resolvePromiseOnOriginalThread(Pas
sRefPtr<SkImage> frame) |
232 { | 235 { |
233 if (!decoder) { | 236 if (!frame) { |
234 rejectPromise(); | 237 rejectPromise(); |
235 return; | 238 return; |
236 } | 239 } |
237 RefPtr<SkImage> frame = ImageBitmap::getSkImageFromDecoder(decoder); | |
238 ASSERT(!frame || (frame->width() && frame->height())); | 240 ASSERT(!frame || (frame->width() && frame->height())); |
239 if (!frame) { | 241 if (!frame) { |
240 rejectPromise(); | 242 rejectPromise(); |
241 return; | 243 return; |
242 } | 244 } |
243 | 245 |
244 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(frame); | 246 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(frame); |
245 image->setOriginClean(true); | 247 image->setOriginClean(true); |
246 if (!m_cropRect.width() && !m_cropRect.height()) { | 248 if (!m_cropRect.width() && !m_cropRect.height()) { |
247 // No cropping variant was called. | 249 // No cropping variant was called. |
(...skipping 10 matching lines...) Expand all Loading... |
258 m_factory->didFinishLoading(this); | 260 m_factory->didFinishLoading(this); |
259 } | 261 } |
260 | 262 |
261 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) | 263 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) |
262 { | 264 { |
263 visitor->trace(m_factory); | 265 visitor->trace(m_factory); |
264 visitor->trace(m_resolver); | 266 visitor->trace(m_resolver); |
265 } | 267 } |
266 | 268 |
267 } // namespace blink | 269 } // namespace blink |
OLD | NEW |