| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 return value.getAsImageData(); | 61 return value.getAsImageData(); |
| 62 if (value.isImageBitmap()) | 62 if (value.isImageBitmap()) |
| 63 return value.getAsImageBitmap().get(); | 63 return value.getAsImageBitmap().get(); |
| 64 ASSERT_NOT_REACHED(); | 64 ASSERT_NOT_REACHED(); |
| 65 return nullptr; | 65 return nullptr; |
| 66 } | 66 } |
| 67 | 67 |
| 68 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState,
EventTarget& eventTarget, const ImageBitmapSourceUnion& bitmapSource, ExceptionS
tate& exceptionState) | 68 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState,
EventTarget& eventTarget, const ImageBitmapSourceUnion& bitmapSource, ExceptionS
tate& exceptionState) |
| 69 { | 69 { |
| 70 ImageBitmapOptions options; | 70 ImageBitmapOptions options; |
| 71 options.setPremultiplyAlpha(true); |
| 71 return createImageBitmap(scriptState, eventTarget, bitmapSource, options, ex
ceptionState); | 72 return createImageBitmap(scriptState, eventTarget, bitmapSource, options, ex
ceptionState); |
| 72 } | 73 } |
| 73 | 74 |
| 74 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState,
EventTarget& eventTarget, const ImageBitmapSourceUnion& bitmapSource, const Imag
eBitmapOptions& options, ExceptionState& exceptionState) | 75 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState,
EventTarget& eventTarget, const ImageBitmapSourceUnion& bitmapSource, const Imag
eBitmapOptions& options, ExceptionState& exceptionState) |
| 75 { | 76 { |
| 76 ImageBitmapSource* bitmapSourceInternal = toImageBitmapSourceInternal(bitmap
Source); | 77 ImageBitmapSource* bitmapSourceInternal = toImageBitmapSourceInternal(bitmap
Source); |
| 77 if (bitmapSourceInternal->isBlob()) { | 78 if (bitmapSourceInternal->isBlob()) { |
| 78 Blob* blob = static_cast<Blob*>(bitmapSourceInternal); | 79 Blob* blob = static_cast<Blob*>(bitmapSourceInternal); |
| 79 ImageBitmapLoader* loader = ImageBitmapFactories::ImageBitmapLoader::cre
ate(from(eventTarget), IntRect(), options, scriptState); | 80 ImageBitmapLoader* loader = ImageBitmapFactories::ImageBitmapLoader::cre
ate(from(eventTarget), IntRect(), options, scriptState); |
| 80 ScriptPromise promise = loader->promise(); | 81 ScriptPromise promise = loader->promise(); |
| 81 from(eventTarget).addLoader(loader); | 82 from(eventTarget).addLoader(loader); |
| 82 loader->loadBlobAsync(eventTarget.executionContext(), blob); | 83 loader->loadBlobAsync(eventTarget.executionContext(), blob); |
| 83 return promise; | 84 return promise; |
| 84 } | 85 } |
| 85 IntSize srcSize = bitmapSourceInternal->bitmapSourceSize(); | 86 IntSize srcSize = bitmapSourceInternal->bitmapSourceSize(); |
| 86 return createImageBitmap(scriptState, eventTarget, bitmapSourceInternal, 0,
0, srcSize.width(), srcSize.height(), options, exceptionState); | 87 return createImageBitmap(scriptState, eventTarget, bitmapSourceInternal, 0,
0, srcSize.width(), srcSize.height(), options, exceptionState); |
| 87 } | 88 } |
| 88 | 89 |
| 89 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState,
EventTarget& eventTarget, const ImageBitmapSourceUnion& bitmapSource, int sx, in
t sy, int sw, int sh, ExceptionState& exceptionState) | 90 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState,
EventTarget& eventTarget, const ImageBitmapSourceUnion& bitmapSource, int sx, in
t sy, int sw, int sh, ExceptionState& exceptionState) |
| 90 { | 91 { |
| 91 ImageBitmapOptions options; | 92 ImageBitmapOptions options; |
| 93 options.setPremultiplyAlpha(true); |
| 92 return createImageBitmap(scriptState, eventTarget, bitmapSource, sx, sy, sw,
sh, options, exceptionState); | 94 return createImageBitmap(scriptState, eventTarget, bitmapSource, sx, sy, sw,
sh, options, exceptionState); |
| 93 } | 95 } |
| 94 | 96 |
| 95 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState,
EventTarget& eventTarget, const ImageBitmapSourceUnion& bitmapSource, int sx, in
t sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& excepti
onState) | 97 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState,
EventTarget& eventTarget, const ImageBitmapSourceUnion& bitmapSource, int sx, in
t sy, int sw, int sh, const ImageBitmapOptions& options, ExceptionState& excepti
onState) |
| 96 { | 98 { |
| 97 ImageBitmapSource* bitmapSourceInternal = toImageBitmapSourceInternal(bitmap
Source); | 99 ImageBitmapSource* bitmapSourceInternal = toImageBitmapSourceInternal(bitmap
Source); |
| 98 return createImageBitmap(scriptState, eventTarget, bitmapSourceInternal, sx,
sy, sw, sh, options, exceptionState); | 100 return createImageBitmap(scriptState, eventTarget, bitmapSourceInternal, sx,
sy, sw, sh, options, exceptionState); |
| 99 } | 101 } |
| 100 | 102 |
| 101 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState,
EventTarget& eventTarget, ImageBitmapSource* bitmapSource, int sx, int sy, int s
w, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState) | 103 ScriptPromise ImageBitmapFactories::createImageBitmap(ScriptState* scriptState,
EventTarget& eventTarget, ImageBitmapSource* bitmapSource, int sx, int sy, int s
w, int sh, const ImageBitmapOptions& options, ExceptionState& exceptionState) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 { | 152 { |
| 151 ASSERT(m_pendingLoaders.contains(loader)); | 153 ASSERT(m_pendingLoaders.contains(loader)); |
| 152 m_pendingLoaders.remove(loader); | 154 m_pendingLoaders.remove(loader); |
| 153 } | 155 } |
| 154 | 156 |
| 155 ImageBitmapFactories::ImageBitmapLoader::ImageBitmapLoader(ImageBitmapFactories&
factory, const IntRect& cropRect, ScriptState* scriptState, const ImageBitmapOp
tions& options) | 157 ImageBitmapFactories::ImageBitmapLoader::ImageBitmapLoader(ImageBitmapFactories&
factory, const IntRect& cropRect, ScriptState* scriptState, const ImageBitmapOp
tions& options) |
| 156 : m_loader(FileReaderLoader::ReadAsArrayBuffer, this) | 158 : m_loader(FileReaderLoader::ReadAsArrayBuffer, this) |
| 157 , m_factory(&factory) | 159 , m_factory(&factory) |
| 158 , m_resolver(ScriptPromiseResolver::create(scriptState)) | 160 , m_resolver(ScriptPromiseResolver::create(scriptState)) |
| 159 , m_cropRect(cropRect) | 161 , m_cropRect(cropRect) |
| 160 , m_options(options) | |
| 161 { | 162 { |
| 163 m_options.setPremultiplyAlpha(true); |
| 162 } | 164 } |
| 163 | 165 |
| 164 void ImageBitmapFactories::ImageBitmapLoader::loadBlobAsync(ExecutionContext* co
ntext, Blob* blob) | 166 void ImageBitmapFactories::ImageBitmapLoader::loadBlobAsync(ExecutionContext* co
ntext, Blob* blob) |
| 165 { | 167 { |
| 166 m_loader.start(context, blob->blobDataHandle()); | 168 m_loader.start(context, blob->blobDataHandle()); |
| 167 } | 169 } |
| 168 | 170 |
| 169 DEFINE_TRACE(ImageBitmapFactories) | 171 DEFINE_TRACE(ImageBitmapFactories) |
| 170 { | 172 { |
| 171 visitor->trace(m_pendingLoaders); | 173 visitor->trace(m_pendingLoaders); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 rejectPromise(); | 216 rejectPromise(); |
| 215 } | 217 } |
| 216 | 218 |
| 217 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) | 219 DEFINE_TRACE(ImageBitmapFactories::ImageBitmapLoader) |
| 218 { | 220 { |
| 219 visitor->trace(m_factory); | 221 visitor->trace(m_factory); |
| 220 visitor->trace(m_resolver); | 222 visitor->trace(m_resolver); |
| 221 } | 223 } |
| 222 | 224 |
| 223 } // namespace blink | 225 } // namespace blink |
| OLD | NEW |