| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "core/imagebitmap/ImageBitmapOptions.h" | 43 #include "core/imagebitmap/ImageBitmapOptions.h" |
| 44 #include "core/svg/graphics/SVGImage.h" | 44 #include "core/svg/graphics/SVGImage.h" |
| 45 #include "core/workers/WorkerGlobalScope.h" | 45 #include "core/workers/WorkerGlobalScope.h" |
| 46 #include "platform/SharedBuffer.h" | 46 #include "platform/SharedBuffer.h" |
| 47 #include "platform/ThreadSafeFunctional.h" | 47 #include "platform/ThreadSafeFunctional.h" |
| 48 #include "platform/image-decoders/ImageDecoder.h" | 48 #include "platform/image-decoders/ImageDecoder.h" |
| 49 #include "platform/threading/BackgroundTaskRunner.h" | 49 #include "platform/threading/BackgroundTaskRunner.h" |
| 50 #include "public/platform/Platform.h" | 50 #include "public/platform/Platform.h" |
| 51 #include "public/platform/WebThread.h" | 51 #include "public/platform/WebThread.h" |
| 52 #include "public/platform/WebTraceLocation.h" | 52 #include "public/platform/WebTraceLocation.h" |
| 53 #include <memory> |
| 53 #include <v8.h> | 54 #include <v8.h> |
| 54 | 55 |
| 55 namespace blink { | 56 namespace blink { |
| 56 | 57 |
| 57 static inline ImageBitmapSource* toImageBitmapSourceInternal(const ImageBitmapSo
urceUnion& value, ExceptionState& exceptionState, bool hasCropRect) | 58 static inline ImageBitmapSource* toImageBitmapSourceInternal(const ImageBitmapSo
urceUnion& value, ExceptionState& exceptionState, bool hasCropRect) |
| 58 { | 59 { |
| 59 if (value.isHTMLImageElement()) { | 60 if (value.isHTMLImageElement()) { |
| 60 HTMLImageElement* imageElement = value.getAsHTMLImageElement(); | 61 HTMLImageElement* imageElement = value.getAsHTMLImageElement(); |
| 61 if (!imageElement || !imageElement->cachedImage()) { | 62 if (!imageElement || !imageElement->cachedImage()) { |
| 62 exceptionState.throwDOMException(InvalidStateError, "No image can be
retrieved from the provided element."); | 63 exceptionState.throwDOMException(InvalidStateError, "No image can be
retrieved from the provided element."); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 { | 228 { |
| 228 ASSERT(!isMainThread()); | 229 ASSERT(!isMainThread()); |
| 229 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())); |
| 230 | 231 |
| 231 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; | 232 ImageDecoder::AlphaOption alphaOp = ImageDecoder::AlphaPremultiplied; |
| 232 if (m_options.premultiplyAlpha() == "none") | 233 if (m_options.premultiplyAlpha() == "none") |
| 233 alphaOp = ImageDecoder::AlphaNotPremultiplied; | 234 alphaOp = ImageDecoder::AlphaNotPremultiplied; |
| 234 ImageDecoder::GammaAndColorProfileOption colorSpaceOp = ImageDecoder::GammaA
ndColorProfileApplied; | 235 ImageDecoder::GammaAndColorProfileOption colorSpaceOp = ImageDecoder::GammaA
ndColorProfileApplied; |
| 235 if (m_options.colorSpaceConversion() == "none") | 236 if (m_options.colorSpaceConversion() == "none") |
| 236 colorSpaceOp = ImageDecoder::GammaAndColorProfileIgnored; | 237 colorSpaceOp = ImageDecoder::GammaAndColorProfileIgnored; |
| 237 OwnPtr<ImageDecoder> decoder(ImageDecoder::create(*sharedBuffer, alphaOp, co
lorSpaceOp)); | 238 std::unique_ptr<ImageDecoder> decoder(ImageDecoder::create(*sharedBuffer, al
phaOp, colorSpaceOp)); |
| 238 RefPtr<SkImage> frame; | 239 RefPtr<SkImage> frame; |
| 239 if (decoder) { | 240 if (decoder) { |
| 240 decoder->setData(sharedBuffer.get(), true); | 241 decoder->setData(sharedBuffer.get(), true); |
| 241 frame = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); | 242 frame = ImageBitmap::getSkImageFromDecoder(std::move(decoder)); |
| 242 } | 243 } |
| 243 taskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&ImageBitmapFactories::
ImageBitmapLoader::resolvePromiseOnOriginalThread, wrapCrossThreadPersistent(thi
s), frame.release())); | 244 taskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&ImageBitmapFactories::
ImageBitmapLoader::resolvePromiseOnOriginalThread, wrapCrossThreadPersistent(thi
s), frame.release())); |
| 244 } | 245 } |
| 245 | 246 |
| 246 void ImageBitmapFactories::ImageBitmapLoader::resolvePromiseOnOriginalThread(Pas
sRefPtr<SkImage> frame) | 247 void ImageBitmapFactories::ImageBitmapLoader::resolvePromiseOnOriginalThread(Pas
sRefPtr<SkImage> frame) |
| 247 { | 248 { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 268 m_factory->didFinishLoading(this); | 269 m_factory->didFinishLoading(this); |
| 269 } | 270 } |
| 270 | 271 |
| 271 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) | 272 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) |
| 272 { | 273 { |
| 273 visitor->trace(m_factory); | 274 visitor->trace(m_factory); |
| 274 visitor->trace(m_resolver); | 275 visitor->trace(m_resolver); |
| 275 } | 276 } |
| 276 | 277 |
| 277 } // namespace blink | 278 } // namespace blink |
| OLD | NEW |