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