| 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/ImageBitmapSource.h" |
| 12 #include "platform/geometry/IntRect.h" | 13 #include "platform/geometry/IntRect.h" |
| 13 #include "platform/graphics/Image.h" | 14 #include "platform/graphics/Image.h" |
| 14 #include "platform/graphics/ImageBuffer.h" | 15 #include "platform/graphics/ImageBuffer.h" |
| 15 #include "platform/graphics/StaticBitmapImage.h" | 16 #include "platform/graphics/StaticBitmapImage.h" |
| 16 #include "platform/heap/Handle.h" | 17 #include "platform/heap/Handle.h" |
| 17 #include "wtf/PassRefPtr.h" | 18 #include "wtf/PassRefPtr.h" |
| 18 #include "wtf/RefCounted.h" | 19 #include "wtf/RefCounted.h" |
| 19 | 20 |
| 20 namespace blink { | 21 namespace blink { |
| 21 | 22 |
| 22 class HTMLCanvasElement; | 23 class HTMLCanvasElement; |
| 23 class HTMLVideoElement; | 24 class HTMLVideoElement; |
| 24 class ImageData; | 25 class ImageData; |
| 25 | 26 |
| 26 class CORE_EXPORT ImageBitmap final : public RefCountedWillBeGarbageCollectedFin
alized<ImageBitmap>, public ScriptWrappable, public ImageLoaderClient, public Ca
nvasImageSource { | 27 class CORE_EXPORT ImageBitmap final : public RefCountedWillBeGarbageCollectedFin
alized<ImageBitmap>, public ScriptWrappable, public ImageLoaderClient, public Ca
nvasImageSource, public ImageBitmapSource { |
| 27 DEFINE_WRAPPERTYPEINFO(); | 28 DEFINE_WRAPPERTYPEINFO(); |
| 28 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageBitmap); | 29 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageBitmap); |
| 29 public: | 30 public: |
| 30 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLImageElement*, const I
ntRect&); | 31 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLImageElement*, const I
ntRect&); |
| 31 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLVideoElement*, const I
ntRect&); | 32 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLVideoElement*, const I
ntRect&); |
| 32 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLCanvasElement*, const
IntRect&); | 33 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLCanvasElement*, const
IntRect&); |
| 33 static PassRefPtrWillBeRawPtr<ImageBitmap> create(ImageData*, const IntRect&
); | 34 static PassRefPtrWillBeRawPtr<ImageBitmap> create(ImageData*, const IntRect&
); |
| 34 static PassRefPtrWillBeRawPtr<ImageBitmap> create(ImageBitmap*, const IntRec
t&); | 35 static PassRefPtrWillBeRawPtr<ImageBitmap> create(ImageBitmap*, const IntRec
t&); |
| 35 static PassRefPtrWillBeRawPtr<ImageBitmap> create(Image*, const IntRect&); | 36 static PassRefPtrWillBeRawPtr<ImageBitmap> create(Image*, const IntRect&); |
| 36 static PassRefPtrWillBeRawPtr<ImageBitmap> create(PassRefPtr<StaticBitmapIma
ge>); | 37 static PassRefPtrWillBeRawPtr<ImageBitmap> create(PassRefPtr<StaticBitmapIma
ge>); |
| 37 | 38 |
| 38 StaticBitmapImage* bitmapImage() const { return (m_image) ? m_image.get() :
nullptr; } | 39 StaticBitmapImage* bitmapImage() const { return (m_image) ? m_image.get() :
nullptr; } |
| 39 unsigned long width() const; | 40 unsigned long width() const; |
| 40 unsigned long height() const; | 41 unsigned long height() const; |
| 41 IntSize size() const; | 42 IntSize size() const; |
| 42 | 43 |
| 43 bool isNeutered() const { return m_isNeutered; } | 44 bool isNeutered() const { return m_isNeutered; } |
| 44 PassRefPtr<StaticBitmapImage> transfer(); | 45 PassRefPtr<StaticBitmapImage> transfer(); |
| 45 | 46 |
| 46 ~ImageBitmap() override; | 47 ~ImageBitmap() override; |
| 47 | 48 |
| 48 // CanvasImageSource implementation | 49 // CanvasImageSource implementation |
| 49 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, AccelerationHi
nt) const override; | 50 PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, AccelerationHi
nt) const override; |
| 50 bool wouldTaintOrigin(SecurityOrigin*) const override { return false; } | 51 bool wouldTaintOrigin(SecurityOrigin*) const override { return false; } |
| 51 void adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const override; | 52 void adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const override; |
| 52 FloatSize elementSize() const override; | 53 FloatSize elementSize() const override; |
| 53 | 54 |
| 55 // ImageBitmapSource implementation |
| 56 IntSize bitmapSourceSize() const override { return size(); } |
| 57 ScriptPromise createImageBitmap(ScriptState*, EventTarget&, int sx, int sy,
int sw, int sh, ExceptionState&) override; |
| 58 |
| 54 DECLARE_VIRTUAL_TRACE(); | 59 DECLARE_VIRTUAL_TRACE(); |
| 55 | 60 |
| 56 private: | 61 private: |
| 57 ImageBitmap(HTMLImageElement*, const IntRect&); | 62 ImageBitmap(HTMLImageElement*, const IntRect&); |
| 58 ImageBitmap(HTMLVideoElement*, const IntRect&); | 63 ImageBitmap(HTMLVideoElement*, const IntRect&); |
| 59 ImageBitmap(HTMLCanvasElement*, const IntRect&); | 64 ImageBitmap(HTMLCanvasElement*, const IntRect&); |
| 60 ImageBitmap(ImageData*, const IntRect&); | 65 ImageBitmap(ImageData*, const IntRect&); |
| 61 ImageBitmap(ImageBitmap*, const IntRect&); | 66 ImageBitmap(ImageBitmap*, const IntRect&); |
| 62 ImageBitmap(Image*, const IntRect&); | 67 ImageBitmap(Image*, const IntRect&); |
| 63 ImageBitmap(PassRefPtr<StaticBitmapImage>); | 68 ImageBitmap(PassRefPtr<StaticBitmapImage>); |
| 64 | 69 |
| 65 // ImageLoaderClient | 70 // ImageLoaderClient |
| 66 void notifyImageSourceChanged() override; | 71 void notifyImageSourceChanged() override; |
| 67 bool requestsHighLiveResourceCachePriority() override { return true; } | 72 bool requestsHighLiveResourceCachePriority() override { return true; } |
| 68 | 73 |
| 69 RefPtr<StaticBitmapImage> m_image; | 74 RefPtr<StaticBitmapImage> m_image; |
| 70 bool m_isNeutered = false; | 75 bool m_isNeutered = false; |
| 71 }; | 76 }; |
| 72 | 77 |
| 73 } // namespace blink | 78 } // namespace blink |
| 74 | 79 |
| 75 #endif // ImageBitmap_h | 80 #endif // ImageBitmap_h |
| OLD | NEW |