| 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 #include <memory> |
| 21 | 21 |
| 22 namespace blink { | 22 namespace blink { |
| 23 | |
| 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 enum DataColorFormat { | 32 enum DataColorFormat { |
| 34 RGBAColorType, | 33 RGBAColorType, |
| 35 N32ColorType, | 34 N32ColorType, |
| 36 }; | 35 }; |
| 37 | 36 |
| 38 class CORE_EXPORT ImageBitmap final : public GarbageCollectedFinalized<ImageBitm
ap>, public ScriptWrappable, public CanvasImageSource, public ImageBitmapSource
{ | 37 class CORE_EXPORT ImageBitmap final : public GarbageCollectedFinalized<ImageBitm
ap>, public ScriptWrappable, public CanvasImageSource, public ImageBitmapSource
{ |
| 39 DEFINE_WRAPPERTYPEINFO(); | 38 DEFINE_WRAPPERTYPEINFO(); |
| 40 public: | 39 public: |
| 41 static ImageBitmap* create(HTMLImageElement*, Optional<IntRect>, Document*,
const ImageBitmapOptions& = ImageBitmapOptions()); | 40 static ImageBitmap* create(HTMLImageElement*, Optional<IntRect>, Document*,
const ImageBitmapOptions& = ImageBitmapOptions()); |
| 42 static ImageBitmap* create(HTMLVideoElement*, Optional<IntRect>, Document*,
const ImageBitmapOptions& = ImageBitmapOptions()); | 41 static ImageBitmap* create(HTMLVideoElement*, Optional<IntRect>, Document*,
const ImageBitmapOptions& = ImageBitmapOptions()); |
| 43 static ImageBitmap* create(HTMLCanvasElement*, Optional<IntRect>, const Imag
eBitmapOptions& = ImageBitmapOptions()); | 42 static ImageBitmap* create(HTMLCanvasElement*, Optional<IntRect>, const Imag
eBitmapOptions& = ImageBitmapOptions()); |
| 44 static ImageBitmap* create(ImageData*, Optional<IntRect>, const ImageBitmapO
ptions& = ImageBitmapOptions()); | 43 static ImageBitmap* create(ImageData*, Optional<IntRect>, const ImageBitmapO
ptions& = ImageBitmapOptions()); |
| 45 static ImageBitmap* create(ImageBitmap*, Optional<IntRect>, const ImageBitma
pOptions& = ImageBitmapOptions()); | 44 static ImageBitmap* create(ImageBitmap*, Optional<IntRect>, const ImageBitma
pOptions& = ImageBitmapOptions()); |
| 46 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>); | 45 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>); |
| 47 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>, Optional<IntRect>,
const ImageBitmapOptions& = ImageBitmapOptions()); | 46 static ImageBitmap* create(PassRefPtr<StaticBitmapImage>, Optional<IntRect>,
const ImageBitmapOptions& = ImageBitmapOptions()); |
| 48 static ImageBitmap* create(WebExternalTextureMailbox&); | |
| 49 // This function is called by structured-cloning an ImageBitmap. | 47 // This function is called by structured-cloning an ImageBitmap. |
| 50 // isImageBitmapPremultiplied indicates whether the original ImageBitmap is
premultiplied or not. | 48 // isImageBitmapPremultiplied indicates whether the original ImageBitmap is
premultiplied or not. |
| 51 // isImageBitmapOriginClean indicates whether the original ImageBitmap is or
igin clean or not. | 49 // 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)
; | 50 static ImageBitmap* create(std::unique_ptr<uint8_t[]> data, uint32_t width,
uint32_t height, bool isImageBitmapPremultiplied, bool isImageBitmapOriginClean)
; |
| 53 static PassRefPtr<SkImage> getSkImageFromDecoder(std::unique_ptr<ImageDecode
r>); | 51 static PassRefPtr<SkImage> getSkImageFromDecoder(std::unique_ptr<ImageDecode
r>); |
| 54 static bool isResizeOptionValid(const ImageBitmapOptions&, ExceptionState&); | 52 static bool isResizeOptionValid(const ImageBitmapOptions&, ExceptionState&); |
| 55 static bool isSourceSizeValid(int sourceWidth, int sourceHeight, ExceptionSt
ate&); | 53 static bool isSourceSizeValid(int sourceWidth, int sourceHeight, ExceptionSt
ate&); |
| 56 | 54 |
| 57 // Type and helper function required by CallbackPromiseAdapter: | 55 // Type and helper function required by CallbackPromiseAdapter: |
| 58 using WebType = sk_sp<SkImage>; | 56 using WebType = sk_sp<SkImage>; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 89 DECLARE_VIRTUAL_TRACE(); | 87 DECLARE_VIRTUAL_TRACE(); |
| 90 | 88 |
| 91 private: | 89 private: |
| 92 ImageBitmap(HTMLImageElement*, Optional<IntRect>, Document*, const ImageBitm
apOptions&); | 90 ImageBitmap(HTMLImageElement*, Optional<IntRect>, Document*, const ImageBitm
apOptions&); |
| 93 ImageBitmap(HTMLVideoElement*, Optional<IntRect>, Document*, const ImageBitm
apOptions&); | 91 ImageBitmap(HTMLVideoElement*, Optional<IntRect>, Document*, const ImageBitm
apOptions&); |
| 94 ImageBitmap(HTMLCanvasElement*, Optional<IntRect>, const ImageBitmapOptions&
); | 92 ImageBitmap(HTMLCanvasElement*, Optional<IntRect>, const ImageBitmapOptions&
); |
| 95 ImageBitmap(ImageData*, Optional<IntRect>, const ImageBitmapOptions&); | 93 ImageBitmap(ImageData*, Optional<IntRect>, const ImageBitmapOptions&); |
| 96 ImageBitmap(ImageBitmap*, Optional<IntRect>, const ImageBitmapOptions&); | 94 ImageBitmap(ImageBitmap*, Optional<IntRect>, const ImageBitmapOptions&); |
| 97 ImageBitmap(PassRefPtr<StaticBitmapImage>); | 95 ImageBitmap(PassRefPtr<StaticBitmapImage>); |
| 98 ImageBitmap(PassRefPtr<StaticBitmapImage>, Optional<IntRect>, const ImageBit
mapOptions&); | 96 ImageBitmap(PassRefPtr<StaticBitmapImage>, Optional<IntRect>, const ImageBit
mapOptions&); |
| 99 ImageBitmap(WebExternalTextureMailbox&); | |
| 100 ImageBitmap(std::unique_ptr<uint8_t[]> data, uint32_t width, uint32_t height
, bool isImageBitmapPremultiplied, bool isImageBitmapOriginClean); | 97 ImageBitmap(std::unique_ptr<uint8_t[]> data, uint32_t width, uint32_t height
, bool isImageBitmapPremultiplied, bool isImageBitmapOriginClean); |
| 101 | 98 |
| 102 RefPtr<StaticBitmapImage> m_image; | 99 RefPtr<StaticBitmapImage> m_image; |
| 103 bool m_isNeutered = false; | 100 bool m_isNeutered = false; |
| 104 }; | 101 }; |
| 105 | 102 |
| 106 } // namespace blink | 103 } // namespace blink |
| 107 | 104 |
| 108 #endif // ImageBitmap_h | 105 #endif // ImageBitmap_h |
| OLD | NEW |