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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 ASSERT(!isMainThread()); | 226 ASSERT(!isMainThread()); |
227 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(static_cast<char*>(
arrayBuffer->data()), static_cast<size_t>(arrayBuffer->byteLength())); | 227 RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(static_cast<char*>(
arrayBuffer->data()), static_cast<size_t>(arrayBuffer->byteLength())); |
228 | 228 |
229 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; | 229 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; |
230 if (premultiplyAlphaOption == "none") | 230 if (premultiplyAlphaOption == "none") |
231 alphaOp = ImageDecoder::AlphaNotPremultiplied; | 231 alphaOp = ImageDecoder::AlphaNotPremultiplied; |
232 ImageDecoder::GammaAndColorProfileOption colorSpaceOp = ImageDecoder::GammaA
ndColorProfileApplied; | 232 ImageDecoder::GammaAndColorProfileOption colorSpaceOp = ImageDecoder::GammaA
ndColorProfileApplied; |
233 if (colorSpaceConversionOption == "none") | 233 if (colorSpaceConversionOption == "none") |
234 colorSpaceOp = ImageDecoder::GammaAndColorProfileIgnored; | 234 colorSpaceOp = ImageDecoder::GammaAndColorProfileIgnored; |
235 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::create(sharedBuffer.rele
ase(), true, alphaOp, colorSpaceOp)); | 235 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::create(sharedBuffer.rele
ase(), true, alphaOp, colorSpaceOp)); |
236 RefPtr<SkImage> frame; | 236 sk_sp<SkImage> frame; |
237 if (decoder) { | 237 if (decoder) { |
238 frame = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); | 238 frame = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); |
239 } | 239 } |
240 taskRunner->postTask(BLINK_FROM_HERE, crossThreadBind(&ImageBitmapFactories:
:ImageBitmapLoader::resolvePromiseOnOriginalThread, wrapCrossThreadPersistent(th
is), frame.release())); | 240 taskRunner->postTask(BLINK_FROM_HERE, crossThreadBind(&ImageBitmapFactories:
:ImageBitmapLoader::resolvePromiseOnOriginalThread, wrapCrossThreadPersistent(th
is), std::move(frame))); |
241 } | 241 } |
242 | 242 |
243 void ImageBitmapFactories::ImageBitmapLoader::resolvePromiseOnOriginalThread(Pas
sRefPtr<SkImage> frame) | 243 void ImageBitmapFactories::ImageBitmapLoader::resolvePromiseOnOriginalThread(sk_
sp<SkImage> frame) |
244 { | 244 { |
245 if (!frame) { | 245 if (!frame) { |
246 rejectPromise(); | 246 rejectPromise(); |
247 return; | 247 return; |
248 } | 248 } |
249 ASSERT(frame->width() && frame->height()); | 249 ASSERT(frame->width() && frame->height()); |
250 | 250 |
251 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(frame); | 251 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(std::move(frame)
); |
252 image->setOriginClean(true); | 252 image->setOriginClean(true); |
253 ImageBitmap* imageBitmap = ImageBitmap::create(image, m_cropRect, m_options)
; | 253 ImageBitmap* imageBitmap = ImageBitmap::create(image, m_cropRect, m_options)
; |
254 if (imageBitmap && imageBitmap->bitmapImage()) { | 254 if (imageBitmap && imageBitmap->bitmapImage()) { |
255 m_resolver->resolve(imageBitmap); | 255 m_resolver->resolve(imageBitmap); |
256 } else { | 256 } else { |
257 rejectPromise(); | 257 rejectPromise(); |
258 return; | 258 return; |
259 } | 259 } |
260 m_factory->didFinishLoading(this); | 260 m_factory->didFinishLoading(this); |
261 } | 261 } |
262 | 262 |
263 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) | 263 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) |
264 { | 264 { |
265 visitor->trace(m_factory); | 265 visitor->trace(m_factory); |
266 visitor->trace(m_resolver); | 266 visitor->trace(m_resolver); |
267 } | 267 } |
268 | 268 |
269 } // namespace blink | 269 } // namespace blink |
OLD | NEW |