Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ImageBitmap_h | 5 #ifndef ImageBitmap_h |
| 6 #define ImageBitmap_h | 6 #define ImageBitmap_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
| 9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
| 10 #include "core/html/HTMLImageElement.h" | 10 #include "core/html/HTMLImageElement.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 class HTMLCanvasElement; | 24 class HTMLCanvasElement; |
| 25 class HTMLVideoElement; | 25 class HTMLVideoElement; |
| 26 class ImageData; | 26 class ImageData; |
| 27 class ImageDecoder; | 27 class ImageDecoder; |
| 28 | 28 |
| 29 enum AlphaDisposition { | 29 enum AlphaDisposition { |
| 30 PremultiplyAlpha, | 30 PremultiplyAlpha, |
| 31 DontPremultiplyAlpha, | 31 DontPremultiplyAlpha, |
| 32 }; | 32 }; |
| 33 enum DataColorFormat { | |
| 34 RGBAColorType, | |
| 35 N32ColorType, | |
| 36 }; | |
| 33 | 37 |
| 34 class CORE_EXPORT ImageBitmap final : public GarbageCollectedFinalized<ImageBitm ap>, public ScriptWrappable, public CanvasImageSource, public ImageBitmapSource { | 38 class CORE_EXPORT ImageBitmap final : public GarbageCollectedFinalized<ImageBitm ap>, public ScriptWrappable, public CanvasImageSource, public ImageBitmapSource { |
| 35 DEFINE_WRAPPERTYPEINFO(); | 39 DEFINE_WRAPPERTYPEINFO(); |
| 36 public: | 40 public: |
| 37 static ImageBitmap* create(HTMLImageElement*, const IntRect&, Document*, con st ImageBitmapOptions& = ImageBitmapOptions()); | 41 static ImageBitmap* create(HTMLImageElement*, const IntRect&, Document*, con st ImageBitmapOptions& = ImageBitmapOptions()); |
| 38 static ImageBitmap* create(HTMLVideoElement*, const IntRect&, Document*, con st ImageBitmapOptions& = ImageBitmapOptions()); | 42 static ImageBitmap* create(HTMLVideoElement*, const IntRect&, Document*, con st ImageBitmapOptions& = ImageBitmapOptions()); |
| 39 static ImageBitmap* create(HTMLCanvasElement*, const IntRect&, const ImageBi tmapOptions& = ImageBitmapOptions()); | 43 static ImageBitmap* create(HTMLCanvasElement*, const IntRect&, const ImageBi tmapOptions& = ImageBitmapOptions()); |
| 40 static ImageBitmap* create(ImageData*, const IntRect&, const ImageBitmapOpti ons& = ImageBitmapOptions(), const bool& isImageDataPremultiplied = false, const bool& isImageDataOriginClean = true); | 44 static ImageBitmap* create(ImageData*, const IntRect&, const ImageBitmapOpti ons& = ImageBitmapOptions()); |
| 41 static ImageBitmap* create(ImageBitmap*, const IntRect&, const ImageBitmapOp tions& = ImageBitmapOptions()); | 45 static ImageBitmap* create(ImageBitmap*, const IntRect&, const ImageBitmapOp tions& = ImageBitmapOptions()); |
| 42 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>); | 46 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>); |
| 43 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>, const IntRect&, co nst ImageBitmapOptions& = ImageBitmapOptions()); | 47 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>, const IntRect&, co nst ImageBitmapOptions& = ImageBitmapOptions()); |
| 44 static ImageBitmap* create(WebExternalTextureMailbox&); | 48 static ImageBitmap* create(WebExternalTextureMailbox&); |
| 49 // This function is called by structured-cloning an ImageBitmap. | |
| 50 // isImageBitmapPremultiplied indicates whether the original ImageBitmap is premultiplied or not. | |
| 51 // isImageBitmapOriginClean indicates whether the original ImageBitmap is or igin clean or not. | |
| 52 static ImageBitmap* create(std::unique_ptr<uint8_t[]> data, uint32_t width, uint32_t height, bool isImageBitmapPremultiplied, bool isImageBitmapOriginClean) ; | |
| 45 static PassRefPtr<SkImage> getSkImageFromDecoder(std::unique_ptr<ImageDecode r>); | 53 static PassRefPtr<SkImage> getSkImageFromDecoder(std::unique_ptr<ImageDecode r>); |
| 46 | 54 |
| 47 // Type and helper function required by CallbackPromiseAdapter: | 55 // Type and helper function required by CallbackPromiseAdapter: |
| 48 using WebType = sk_sp<SkImage>; | 56 using WebType = sk_sp<SkImage>; |
| 49 static ImageBitmap* take(ScriptPromiseResolver*, sk_sp<SkImage>); | 57 static ImageBitmap* take(ScriptPromiseResolver*, sk_sp<SkImage>); |
| 50 | 58 |
| 51 StaticBitmapImage* bitmapImage() const { return (m_image) ? m_image.get() : nullptr; } | 59 StaticBitmapImage* bitmapImage() const { return (m_image) ? m_image.get() : nullptr; } |
| 52 std::unique_ptr<uint8_t[]> copyBitmapData(AlphaDisposition alphaOp = DontPre multiplyAlpha); | 60 std::unique_ptr<uint8_t[]> copyBitmapData(AlphaDisposition alphaOp = DontPre multiplyAlpha, DataColorFormat format = RGBAColorType); |
| 53 unsigned long width() const; | 61 unsigned long width() const; |
| 54 unsigned long height() const; | 62 unsigned long height() const; |
| 55 IntSize size() const; | 63 IntSize size() const; |
| 56 | 64 |
| 57 bool isNeutered() const { return m_isNeutered; } | 65 bool isNeutered() const { return m_isNeutered; } |
| 58 bool originClean() const { return m_image->originClean(); } | 66 bool originClean() const { return m_image->originClean(); } |
| 59 bool isPremultiplied() const { return m_image->isPremultiplied(); } | 67 bool isPremultiplied() const { return m_image->isPremultiplied(); } |
| 60 PassRefPtr<StaticBitmapImage> transfer(); | 68 PassRefPtr<StaticBitmapImage> transfer(); |
| 61 void close(); | 69 void close(); |
| 62 bool isTextureBacked() const; | 70 bool isTextureBacked() const; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 75 // ImageBitmapSource implementation | 83 // ImageBitmapSource implementation |
| 76 IntSize bitmapSourceSize() const override { return size(); } | 84 IntSize bitmapSourceSize() const override { return size(); } |
| 77 ScriptPromise createImageBitmap(ScriptState*, EventTarget&, int sx, int sy, int sw, int sh, const ImageBitmapOptions&, ExceptionState&) override; | 85 ScriptPromise createImageBitmap(ScriptState*, EventTarget&, int sx, int sy, int sw, int sh, const ImageBitmapOptions&, ExceptionState&) override; |
| 78 | 86 |
| 79 DECLARE_VIRTUAL_TRACE(); | 87 DECLARE_VIRTUAL_TRACE(); |
| 80 | 88 |
| 81 private: | 89 private: |
| 82 ImageBitmap(HTMLImageElement*, const IntRect&, Document*, const ImageBitmapO ptions&); | 90 ImageBitmap(HTMLImageElement*, const IntRect&, Document*, const ImageBitmapO ptions&); |
| 83 ImageBitmap(HTMLVideoElement*, const IntRect&, Document*, const ImageBitmapO ptions&); | 91 ImageBitmap(HTMLVideoElement*, const IntRect&, Document*, const ImageBitmapO ptions&); |
| 84 ImageBitmap(HTMLCanvasElement*, const IntRect&, const ImageBitmapOptions&); | 92 ImageBitmap(HTMLCanvasElement*, const IntRect&, const ImageBitmapOptions&); |
| 85 ImageBitmap(ImageData*, const IntRect&, const ImageBitmapOptions&, const boo l&, const bool&); | 93 ImageBitmap(ImageData*, const IntRect&, const ImageBitmapOptions&); |
| 86 ImageBitmap(ImageBitmap*, const IntRect&, const ImageBitmapOptions&); | 94 ImageBitmap(ImageBitmap*, const IntRect&, const ImageBitmapOptions&); |
| 87 ImageBitmap(PassRefPtr<StaticBitmapImage>); | 95 ImageBitmap(PassRefPtr<StaticBitmapImage>); |
| 88 ImageBitmap(PassRefPtr<StaticBitmapImage>, const IntRect&, const ImageBitmap Options&); | 96 ImageBitmap(PassRefPtr<StaticBitmapImage>, const IntRect&, const ImageBitmap Options&); |
| 89 ImageBitmap(WebExternalTextureMailbox&); | 97 ImageBitmap(WebExternalTextureMailbox&); |
| 98 ImageBitmap(std::unique_ptr<uint8_t[]>, uint32_t, uint32_t, bool, bool); | |
|
jbroman
2016/06/29 18:03:53
Please give the parameters names here as well.
| |
| 90 | 99 |
| 91 void parseOptions(const ImageBitmapOptions&, bool&, bool&); | 100 void parseOptions(const ImageBitmapOptions&, bool&, bool&); |
| 92 | 101 |
| 93 RefPtr<StaticBitmapImage> m_image; | 102 RefPtr<StaticBitmapImage> m_image; |
| 94 bool m_isNeutered = false; | 103 bool m_isNeutered = false; |
| 95 }; | 104 }; |
| 96 | 105 |
| 97 } // namespace blink | 106 } // namespace blink |
| 98 | 107 |
| 99 #endif // ImageBitmap_h | 108 #endif // ImageBitmap_h |
| OLD | NEW |