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