| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 class ImageDecoder; | 54 class ImageDecoder; |
| 55 class WebTaskRunner; | 55 class WebTaskRunner; |
| 56 | 56 |
| 57 typedef HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrBlobOrImageDataOr
ImageBitmap ImageBitmapSourceUnion; | 57 typedef HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrBlobOrImageDataOr
ImageBitmap ImageBitmapSourceUnion; |
| 58 | 58 |
| 59 class ImageBitmapFactories final : public GarbageCollectedFinalized<ImageBitmapF
actories>, public Supplement<LocalDOMWindow>, public Supplement<WorkerGlobalScop
e> { | 59 class ImageBitmapFactories final : public GarbageCollectedFinalized<ImageBitmapF
actories>, public Supplement<LocalDOMWindow>, public Supplement<WorkerGlobalScop
e> { |
| 60 USING_GARBAGE_COLLECTED_MIXIN(ImageBitmapFactories); | 60 USING_GARBAGE_COLLECTED_MIXIN(ImageBitmapFactories); |
| 61 public: | 61 public: |
| 62 static ScriptPromise createImageBitmap(ScriptState*, EventTarget&, const Ima
geBitmapSourceUnion&, const ImageBitmapOptions&, ExceptionState&); | 62 static ScriptPromise createImageBitmap(ScriptState*, EventTarget&, const Ima
geBitmapSourceUnion&, const ImageBitmapOptions&, ExceptionState&); |
| 63 static ScriptPromise createImageBitmap(ScriptState*, EventTarget&, const Ima
geBitmapSourceUnion&, int sx, int sy, int sw, int sh, const ImageBitmapOptions&,
ExceptionState&); | 63 static ScriptPromise createImageBitmap(ScriptState*, EventTarget&, const Ima
geBitmapSourceUnion&, int sx, int sy, int sw, int sh, const ImageBitmapOptions&,
ExceptionState&); |
| 64 static ScriptPromise createImageBitmap(ScriptState*, EventTarget&, ImageBitm
apSource*, int sx, int sy, int sw, int sh, const ImageBitmapOptions&, ExceptionS
tate&); | 64 static ScriptPromise createImageBitmap(ScriptState*, EventTarget&, ImageBitm
apSource*, Optional<IntRect> cropRect, const ImageBitmapOptions&, ExceptionState
&); |
| 65 static ScriptPromise createImageBitmapFromBlob(ScriptState*, EventTarget&, I
mageBitmapSource*, const IntRect&, const ImageBitmapOptions&); | 65 static ScriptPromise createImageBitmapFromBlob(ScriptState*, EventTarget&, I
mageBitmapSource*, Optional<IntRect> cropRect, const ImageBitmapOptions&, Except
ionState&); |
| 66 | 66 |
| 67 virtual ~ImageBitmapFactories() { } | 67 virtual ~ImageBitmapFactories() { } |
| 68 | 68 |
| 69 DECLARE_TRACE(); | 69 DECLARE_TRACE(); |
| 70 | 70 |
| 71 protected: | 71 protected: |
| 72 static const char* supplementName(); | 72 static const char* supplementName(); |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 class ImageBitmapLoader final : public GarbageCollectedFinalized<ImageBitmap
Loader>, public FileReaderLoaderClient { | 75 class ImageBitmapLoader final : public GarbageCollectedFinalized<ImageBitmap
Loader>, public FileReaderLoaderClient { |
| 76 public: | 76 public: |
| 77 static ImageBitmapLoader* create(ImageBitmapFactories& factory, const In
tRect& cropRect, const ImageBitmapOptions& options, ScriptState* scriptState) | 77 static ImageBitmapLoader* create(ImageBitmapFactories& factory, Optional
<IntRect> cropRect, const ImageBitmapOptions& options, ScriptState* scriptState) |
| 78 { | 78 { |
| 79 return new ImageBitmapLoader(factory, cropRect, scriptState, options
); | 79 return new ImageBitmapLoader(factory, cropRect, scriptState, options
); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void loadBlobAsync(ExecutionContext*, Blob*); | 82 void loadBlobAsync(ExecutionContext*, Blob*); |
| 83 ScriptPromise promise() { return m_resolver->promise(); } | 83 ScriptPromise promise() { return m_resolver->promise(); } |
| 84 | 84 |
| 85 DECLARE_TRACE(); | 85 DECLARE_TRACE(); |
| 86 | 86 |
| 87 ~ImageBitmapLoader() override { } | 87 ~ImageBitmapLoader() override { } |
| 88 | 88 |
| 89 private: | 89 private: |
| 90 ImageBitmapLoader(ImageBitmapFactories&, const IntRect&, ScriptState*, c
onst ImageBitmapOptions&); | 90 ImageBitmapLoader(ImageBitmapFactories&, Optional<IntRect> cropRect, Scr
iptState*, const ImageBitmapOptions&); |
| 91 | 91 |
| 92 void rejectPromise(); | 92 void rejectPromise(); |
| 93 | 93 |
| 94 void scheduleAsyncImageBitmapDecoding(DOMArrayBuffer*); | 94 void scheduleAsyncImageBitmapDecoding(DOMArrayBuffer*); |
| 95 void decodeImageOnDecoderThread(WebTaskRunner*, DOMArrayBuffer*, const S
tring& premultiplyAlphaOption, const String& colorSpaceConversionOption); | 95 void decodeImageOnDecoderThread(WebTaskRunner*, DOMArrayBuffer*, const S
tring& premultiplyAlphaOption, const String& colorSpaceConversionOption); |
| 96 void resolvePromiseOnOriginalThread(PassRefPtr<SkImage>); | 96 void resolvePromiseOnOriginalThread(PassRefPtr<SkImage>); |
| 97 | 97 |
| 98 // FileReaderLoaderClient | 98 // FileReaderLoaderClient |
| 99 void didStartLoading() override { } | 99 void didStartLoading() override { } |
| 100 void didReceiveData() override { } | 100 void didReceiveData() override { } |
| 101 void didFinishLoading() override; | 101 void didFinishLoading() override; |
| 102 void didFail(FileError::ErrorCode) override; | 102 void didFail(FileError::ErrorCode) override; |
| 103 | 103 |
| 104 FileReaderLoader m_loader; | 104 FileReaderLoader m_loader; |
| 105 Member<ImageBitmapFactories> m_factory; | 105 Member<ImageBitmapFactories> m_factory; |
| 106 Member<ScriptPromiseResolver> m_resolver; | 106 Member<ScriptPromiseResolver> m_resolver; |
| 107 IntRect m_cropRect; | 107 Optional<IntRect> m_cropRect; |
| 108 ImageBitmapOptions m_options; | 108 ImageBitmapOptions m_options; |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 static ImageBitmapFactories& from(EventTarget&); | 111 static ImageBitmapFactories& from(EventTarget&); |
| 112 | 112 |
| 113 template<class GlobalObject> | 113 template<class GlobalObject> |
| 114 static ImageBitmapFactories& fromInternal(GlobalObject&); | 114 static ImageBitmapFactories& fromInternal(GlobalObject&); |
| 115 | 115 |
| 116 void addLoader(ImageBitmapLoader*); | 116 void addLoader(ImageBitmapLoader*); |
| 117 void didFinishLoading(ImageBitmapLoader*); | 117 void didFinishLoading(ImageBitmapLoader*); |
| 118 | 118 |
| 119 HeapHashSet<Member<ImageBitmapLoader>> m_pendingLoaders; | 119 HeapHashSet<Member<ImageBitmapLoader>> m_pendingLoaders; |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 } // namespace blink | 122 } // namespace blink |
| 123 | 123 |
| 124 #endif // ImageBitmapFactories_h | 124 #endif // ImageBitmapFactories_h |
| OLD | NEW |