| 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/html/HTMLImageElement.h" | 9 #include "core/html/HTMLImageElement.h" |
| 10 #include "core/html/canvas/CanvasImageSource.h" | 10 #include "core/html/canvas/CanvasImageSource.h" |
| 11 #include "platform/geometry/IntRect.h" | 11 #include "platform/geometry/IntRect.h" |
| 12 #include "platform/graphics/Image.h" | 12 #include "platform/graphics/Image.h" |
| 13 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
| 14 #include "wtf/PassRefPtr.h" | 14 #include "wtf/PassRefPtr.h" |
| 15 #include "wtf/RefCounted.h" | 15 #include "wtf/RefCounted.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 class HTMLCanvasElement; | 19 class HTMLCanvasElement; |
| 20 class HTMLVideoElement; | |
| 21 class ImageData; | 20 class ImageData; |
| 22 | 21 |
| 23 class ImageBitmap final : public RefCounted<ImageBitmap>, public ScriptWrappable
, public ImageLoaderClient, public CanvasImageSource { | 22 class ImageBitmap final : public RefCounted<ImageBitmap>, public ScriptWrappable
, public ImageLoaderClient, public CanvasImageSource { |
| 24 DEFINE_WRAPPERTYPEINFO(); | 23 DEFINE_WRAPPERTYPEINFO(); |
| 25 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageBitmap); | 24 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageBitmap); |
| 26 public: | 25 public: |
| 27 static PassRefPtr<ImageBitmap> create(HTMLImageElement*, const IntRect&); | 26 static PassRefPtr<ImageBitmap> create(HTMLImageElement*, const IntRect&); |
| 28 static PassRefPtr<ImageBitmap> create(HTMLVideoElement*, const IntRect&); | |
| 29 static PassRefPtr<ImageBitmap> create(HTMLCanvasElement*, const IntRect&); | 27 static PassRefPtr<ImageBitmap> create(HTMLCanvasElement*, const IntRect&); |
| 30 static PassRefPtr<ImageBitmap> create(ImageData*, const IntRect&); | 28 static PassRefPtr<ImageBitmap> create(ImageData*, const IntRect&); |
| 31 static PassRefPtr<ImageBitmap> create(ImageBitmap*, const IntRect&); | 29 static PassRefPtr<ImageBitmap> create(ImageBitmap*, const IntRect&); |
| 32 static PassRefPtr<ImageBitmap> create(Image*, const IntRect&); | 30 static PassRefPtr<ImageBitmap> create(Image*, const IntRect&); |
| 33 | 31 |
| 34 PassRefPtr<Image> bitmapImage() const; | 32 PassRefPtr<Image> bitmapImage() const; |
| 35 PassRefPtr<HTMLImageElement> imageElement() const { return m_imageElement; } | 33 PassRefPtr<HTMLImageElement> imageElement() const { return m_imageElement; } |
| 36 | 34 |
| 37 IntRect bitmapRect() const { return m_bitmapRect; } | 35 IntRect bitmapRect() const { return m_bitmapRect; } |
| 38 | 36 |
| 39 int width() const { return m_cropRect.width(); } | 37 int width() const { return m_cropRect.width(); } |
| 40 int height() const { return m_cropRect.height(); } | 38 int height() const { return m_cropRect.height(); } |
| 41 IntSize size() const { return m_cropRect.size(); } | 39 IntSize size() const { return m_cropRect.size(); } |
| 42 | 40 |
| 43 virtual ~ImageBitmap(); | 41 virtual ~ImageBitmap(); |
| 44 | 42 |
| 45 // CanvasImageSource implementation | 43 // CanvasImageSource implementation |
| 46 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceIma
geStatus*) const override; | 44 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceIma
geStatus*) const override; |
| 47 virtual void adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const o
verride; | 45 virtual void adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const o
verride; |
| 48 virtual FloatSize sourceSize() const override; | 46 virtual FloatSize sourceSize() const override; |
| 49 | 47 |
| 50 virtual void trace(Visitor*); | 48 virtual void trace(Visitor*); |
| 51 | 49 |
| 52 private: | 50 private: |
| 53 ImageBitmap(HTMLImageElement*, const IntRect&); | 51 ImageBitmap(HTMLImageElement*, const IntRect&); |
| 54 ImageBitmap(HTMLVideoElement*, const IntRect&); | |
| 55 ImageBitmap(HTMLCanvasElement*, const IntRect&); | 52 ImageBitmap(HTMLCanvasElement*, const IntRect&); |
| 56 ImageBitmap(ImageData*, const IntRect&); | 53 ImageBitmap(ImageData*, const IntRect&); |
| 57 ImageBitmap(ImageBitmap*, const IntRect&); | 54 ImageBitmap(ImageBitmap*, const IntRect&); |
| 58 ImageBitmap(Image*, const IntRect&); | 55 ImageBitmap(Image*, const IntRect&); |
| 59 | 56 |
| 60 // ImageLoaderClient | 57 // ImageLoaderClient |
| 61 virtual void notifyImageSourceChanged() override; | 58 virtual void notifyImageSourceChanged() override; |
| 62 virtual bool requestsHighLiveResourceCachePriority() override { return true;
} | 59 virtual bool requestsHighLiveResourceCachePriority() override { return true;
} |
| 63 | 60 |
| 64 // ImageBitmaps constructed from HTMLImageElements hold a reference to the H
TMLImageElement until | 61 // ImageBitmaps constructed from HTMLImageElements hold a reference to the H
TMLImageElement until |
| 65 // the image source changes. | 62 // the image source changes. |
| 66 RefPtr<HTMLImageElement> m_imageElement; | 63 RefPtr<HTMLImageElement> m_imageElement; |
| 67 RefPtr<Image> m_bitmap; | 64 RefPtr<Image> m_bitmap; |
| 68 | 65 |
| 69 IntRect m_bitmapRect; // The rect where the underlying Image should be place
d in reference to the ImageBitmap. | 66 IntRect m_bitmapRect; // The rect where the underlying Image should be place
d in reference to the ImageBitmap. |
| 70 IntRect m_cropRect; | 67 IntRect m_cropRect; |
| 71 | 68 |
| 72 // The offset by which the desired Image is stored internally. | 69 // The offset by which the desired Image is stored internally. |
| 73 // ImageBitmaps constructed from HTMLImageElements reference the entire Imag
eResource and may have a non-zero bitmap offset. | 70 // ImageBitmaps constructed from HTMLImageElements reference the entire Imag
eResource and may have a non-zero bitmap offset. |
| 74 // ImageBitmaps not constructed from HTMLImageElements always pre-crop and s
tore the image at (0, 0). | 71 // ImageBitmaps not constructed from HTMLImageElements always pre-crop and s
tore the image at (0, 0). |
| 75 IntPoint m_bitmapOffset; | 72 IntPoint m_bitmapOffset; |
| 76 | 73 |
| 77 }; | 74 }; |
| 78 | 75 |
| 79 } // namespace blink | 76 } // namespace blink |
| 80 | 77 |
| 81 #endif // ImageBitmap_h | 78 #endif // ImageBitmap_h |
| OLD | NEW |