| 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" |
| 11 #include "core/html/canvas/CanvasImageSource.h" | 11 #include "core/html/canvas/CanvasImageSource.h" |
| 12 #include "core/imagebitmap/ImageBitmapOptions.h" | 12 #include "core/imagebitmap/ImageBitmapOptions.h" |
| 13 #include "core/imagebitmap/ImageBitmapSource.h" | 13 #include "core/imagebitmap/ImageBitmapSource.h" |
| 14 #include "platform/geometry/IntRect.h" | 14 #include "platform/geometry/IntRect.h" |
| 15 #include "platform/graphics/Image.h" | 15 #include "platform/graphics/Image.h" |
| 16 #include "platform/graphics/ImageBuffer.h" | 16 #include "platform/graphics/ImageBuffer.h" |
| 17 #include "platform/graphics/StaticBitmapImage.h" | 17 #include "platform/graphics/StaticBitmapImage.h" |
| 18 #include "platform/heap/Handle.h" | 18 #include "platform/heap/Handle.h" |
| 19 #include "wtf/PassRefPtr.h" | 19 #include "wtf/PassRefPtr.h" |
| 20 #include <memory> |
| 20 | 21 |
| 21 namespace blink { | 22 namespace blink { |
| 22 | 23 |
| 23 class HTMLCanvasElement; | 24 class HTMLCanvasElement; |
| 24 class HTMLVideoElement; | 25 class HTMLVideoElement; |
| 25 class ImageData; | 26 class ImageData; |
| 26 class ImageDecoder; | 27 class ImageDecoder; |
| 27 | 28 |
| 28 enum AlphaDisposition { | 29 enum AlphaDisposition { |
| 29 PremultiplyAlpha, | 30 PremultiplyAlpha, |
| 30 DontPremultiplyAlpha, | 31 DontPremultiplyAlpha, |
| 31 }; | 32 }; |
| 32 | 33 |
| 33 class CORE_EXPORT ImageBitmap final : public GarbageCollectedFinalized<ImageBitm
ap>, public ScriptWrappable, public CanvasImageSource, public ImageBitmapSource
{ | 34 class CORE_EXPORT ImageBitmap final : public GarbageCollectedFinalized<ImageBitm
ap>, public ScriptWrappable, public CanvasImageSource, public ImageBitmapSource
{ |
| 34 DEFINE_WRAPPERTYPEINFO(); | 35 DEFINE_WRAPPERTYPEINFO(); |
| 35 public: | 36 public: |
| 36 static ImageBitmap* create(HTMLImageElement*, const IntRect&, Document*, con
st ImageBitmapOptions& = ImageBitmapOptions()); | 37 static ImageBitmap* create(HTMLImageElement*, const IntRect&, Document*, con
st ImageBitmapOptions& = ImageBitmapOptions()); |
| 37 static ImageBitmap* create(HTMLVideoElement*, const IntRect&, Document*, con
st ImageBitmapOptions& = ImageBitmapOptions()); | 38 static ImageBitmap* create(HTMLVideoElement*, const IntRect&, Document*, con
st ImageBitmapOptions& = ImageBitmapOptions()); |
| 38 static ImageBitmap* create(HTMLCanvasElement*, const IntRect&, const ImageBi
tmapOptions& = ImageBitmapOptions()); | 39 static ImageBitmap* create(HTMLCanvasElement*, const IntRect&, const ImageBi
tmapOptions& = ImageBitmapOptions()); |
| 39 static ImageBitmap* create(ImageData*, const IntRect&, const ImageBitmapOpti
ons& = ImageBitmapOptions(), const bool& isImageDataPremultiplied = false); | 40 static ImageBitmap* create(ImageData*, const IntRect&, const ImageBitmapOpti
ons& = ImageBitmapOptions(), const bool& isImageDataPremultiplied = false); |
| 40 static ImageBitmap* create(ImageBitmap*, const IntRect&, const ImageBitmapOp
tions& = ImageBitmapOptions()); | 41 static ImageBitmap* create(ImageBitmap*, const IntRect&, const ImageBitmapOp
tions& = ImageBitmapOptions()); |
| 41 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>); | 42 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>); |
| 42 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>, const IntRect&, co
nst ImageBitmapOptions& = ImageBitmapOptions()); | 43 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>, const IntRect&, co
nst ImageBitmapOptions& = ImageBitmapOptions()); |
| 43 static ImageBitmap* create(WebExternalTextureMailbox&); | 44 static ImageBitmap* create(WebExternalTextureMailbox&); |
| 44 static PassRefPtr<SkImage> getSkImageFromDecoder(PassOwnPtr<ImageDecoder>); | 45 static PassRefPtr<SkImage> getSkImageFromDecoder(std::unique_ptr<ImageDecode
r>); |
| 45 | 46 |
| 46 // Type and helper function required by CallbackPromiseAdapter: | 47 // Type and helper function required by CallbackPromiseAdapter: |
| 47 using WebType = sk_sp<SkImage>; | 48 using WebType = sk_sp<SkImage>; |
| 48 static ImageBitmap* take(ScriptPromiseResolver*, sk_sp<SkImage>); | 49 static ImageBitmap* take(ScriptPromiseResolver*, sk_sp<SkImage>); |
| 49 | 50 |
| 50 StaticBitmapImage* bitmapImage() const { return (m_image) ? m_image.get() :
nullptr; } | 51 StaticBitmapImage* bitmapImage() const { return (m_image) ? m_image.get() :
nullptr; } |
| 51 PassOwnPtr<uint8_t[]> copyBitmapData(AlphaDisposition alphaOp = DontPremulti
plyAlpha); | 52 std::unique_ptr<uint8_t[]> copyBitmapData(AlphaDisposition alphaOp = DontPre
multiplyAlpha); |
| 52 unsigned long width() const; | 53 unsigned long width() const; |
| 53 unsigned long height() const; | 54 unsigned long height() const; |
| 54 IntSize size() const; | 55 IntSize size() const; |
| 55 | 56 |
| 56 bool isNeutered() const { return m_isNeutered; } | 57 bool isNeutered() const { return m_isNeutered; } |
| 57 bool originClean() const { return m_image->originClean(); } | 58 bool originClean() const { return m_image->originClean(); } |
| 58 bool isPremultiplied() const { return m_image->isPremultiplied(); } | 59 bool isPremultiplied() const { return m_image->isPremultiplied(); } |
| 59 PassRefPtr<StaticBitmapImage> transfer(); | 60 PassRefPtr<StaticBitmapImage> transfer(); |
| 60 void close(); | 61 void close(); |
| 61 | 62 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 86 | 87 |
| 87 void parseOptions(const ImageBitmapOptions&, bool&, bool&); | 88 void parseOptions(const ImageBitmapOptions&, bool&, bool&); |
| 88 | 89 |
| 89 RefPtr<StaticBitmapImage> m_image; | 90 RefPtr<StaticBitmapImage> m_image; |
| 90 bool m_isNeutered = false; | 91 bool m_isNeutered = false; |
| 91 }; | 92 }; |
| 92 | 93 |
| 93 } // namespace blink | 94 } // namespace blink |
| 94 | 95 |
| 95 #endif // ImageBitmap_h | 96 #endif // ImageBitmap_h |
| OLD | NEW |