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 "third_party/skia/include/core/SkRefCnt.h" |
19 #include "wtf/PassRefPtr.h" | 20 #include "wtf/PassRefPtr.h" |
20 #include <memory> | 21 #include <memory> |
21 | 22 |
22 namespace blink { | 23 namespace blink { |
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 { |
(...skipping 12 matching lines...) Expand all Loading... |
41 static ImageBitmap* create(HTMLVideoElement*, Optional<IntRect>, Document*,
const ImageBitmapOptions& = ImageBitmapOptions()); | 42 static ImageBitmap* create(HTMLVideoElement*, Optional<IntRect>, Document*,
const ImageBitmapOptions& = ImageBitmapOptions()); |
42 static ImageBitmap* create(HTMLCanvasElement*, Optional<IntRect>, const Imag
eBitmapOptions& = ImageBitmapOptions()); | 43 static ImageBitmap* create(HTMLCanvasElement*, Optional<IntRect>, const Imag
eBitmapOptions& = ImageBitmapOptions()); |
43 static ImageBitmap* create(ImageData*, Optional<IntRect>, const ImageBitmapO
ptions& = ImageBitmapOptions()); | 44 static ImageBitmap* create(ImageData*, Optional<IntRect>, const ImageBitmapO
ptions& = ImageBitmapOptions()); |
44 static ImageBitmap* create(ImageBitmap*, Optional<IntRect>, const ImageBitma
pOptions& = ImageBitmapOptions()); | 45 static ImageBitmap* create(ImageBitmap*, Optional<IntRect>, const ImageBitma
pOptions& = ImageBitmapOptions()); |
45 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>); | 46 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>); |
46 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>, Optional<IntRect>,
const ImageBitmapOptions& = ImageBitmapOptions()); | 47 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>, Optional<IntRect>,
const ImageBitmapOptions& = ImageBitmapOptions()); |
47 // This function is called by structured-cloning an ImageBitmap. | 48 // This function is called by structured-cloning an ImageBitmap. |
48 // isImageBitmapPremultiplied indicates whether the original ImageBitmap is
premultiplied or not. | 49 // isImageBitmapPremultiplied indicates whether the original ImageBitmap is
premultiplied or not. |
49 // isImageBitmapOriginClean indicates whether the original ImageBitmap is or
igin clean or not. | 50 // isImageBitmapOriginClean indicates whether the original ImageBitmap is or
igin clean or not. |
50 static ImageBitmap* create(std::unique_ptr<uint8_t[]> data, uint32_t width,
uint32_t height, bool isImageBitmapPremultiplied, bool isImageBitmapOriginClean)
; | 51 static ImageBitmap* create(std::unique_ptr<uint8_t[]> data, uint32_t width,
uint32_t height, bool isImageBitmapPremultiplied, bool isImageBitmapOriginClean)
; |
51 static PassRefPtr<SkImage> getSkImageFromDecoder(std::unique_ptr<ImageDecode
r>); | 52 static sk_sp<SkImage> getSkImageFromDecoder(std::unique_ptr<ImageDecoder>); |
52 static bool isResizeOptionValid(const ImageBitmapOptions&, ExceptionState&); | 53 static bool isResizeOptionValid(const ImageBitmapOptions&, ExceptionState&); |
53 static bool isSourceSizeValid(int sourceWidth, int sourceHeight, ExceptionSt
ate&); | 54 static bool isSourceSizeValid(int sourceWidth, int sourceHeight, ExceptionSt
ate&); |
54 | 55 |
55 // Type and helper function required by CallbackPromiseAdapter: | 56 // Type and helper function required by CallbackPromiseAdapter: |
56 using WebType = sk_sp<SkImage>; | 57 using WebType = sk_sp<SkImage>; |
57 static ImageBitmap* take(ScriptPromiseResolver*, sk_sp<SkImage>); | 58 static ImageBitmap* take(ScriptPromiseResolver*, sk_sp<SkImage>); |
58 | 59 |
59 StaticBitmapImage* bitmapImage() const { return (m_image) ? m_image.get() :
nullptr; } | 60 StaticBitmapImage* bitmapImage() const { return (m_image) ? m_image.get() :
nullptr; } |
60 PassRefPtr<Uint8Array> copyBitmapData(AlphaDisposition = DontPremultiplyAlph
a, DataColorFormat = RGBAColorType); | 61 PassRefPtr<Uint8Array> copyBitmapData(AlphaDisposition = DontPremultiplyAlph
a, DataColorFormat = RGBAColorType); |
61 unsigned long width() const; | 62 unsigned long width() const; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 ImageBitmap(PassRefPtr<StaticBitmapImage>, Optional<IntRect>, const ImageBit
mapOptions&); | 97 ImageBitmap(PassRefPtr<StaticBitmapImage>, Optional<IntRect>, const ImageBit
mapOptions&); |
97 ImageBitmap(std::unique_ptr<uint8_t[]> data, uint32_t width, uint32_t height
, bool isImageBitmapPremultiplied, bool isImageBitmapOriginClean); | 98 ImageBitmap(std::unique_ptr<uint8_t[]> data, uint32_t width, uint32_t height
, bool isImageBitmapPremultiplied, bool isImageBitmapOriginClean); |
98 | 99 |
99 RefPtr<StaticBitmapImage> m_image; | 100 RefPtr<StaticBitmapImage> m_image; |
100 bool m_isNeutered = false; | 101 bool m_isNeutered = false; |
101 }; | 102 }; |
102 | 103 |
103 } // namespace blink | 104 } // namespace blink |
104 | 105 |
105 #endif // ImageBitmap_h | 106 #endif // ImageBitmap_h |
OLD | NEW |