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/v8/ScriptWrappable.h" | 8 #include "bindings/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 "heap/Handle.h" |
11 #include "platform/geometry/IntRect.h" | 12 #include "platform/geometry/IntRect.h" |
12 #include "platform/graphics/Image.h" | 13 #include "platform/graphics/Image.h" |
13 #include "wtf/PassRefPtr.h" | 14 #include "wtf/PassRefPtr.h" |
14 #include "wtf/RefCounted.h" | 15 #include "wtf/RefCounted.h" |
15 | 16 |
16 namespace WebCore { | 17 namespace WebCore { |
17 | 18 |
18 class HTMLCanvasElement; | 19 class HTMLCanvasElement; |
19 class HTMLVideoElement; | 20 class HTMLVideoElement; |
20 class ImageData; | 21 class ImageData; |
21 | 22 |
22 class ImageBitmap FINAL : public RefCounted<ImageBitmap>, public ScriptWrappable
, public ImageLoaderClient, public CanvasImageSource { | 23 class ImageBitmap FINAL : public RefCountedWillBeGarbageCollectedFinalized<Image
Bitmap>, public ScriptWrappable, public ImageLoaderClient, public CanvasImageSou
rce { |
23 | 24 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageBitmap); |
24 public: | 25 public: |
25 static PassRefPtr<ImageBitmap> create(HTMLImageElement*, const IntRect&); | 26 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLImageElement*, const I
ntRect&); |
26 static PassRefPtr<ImageBitmap> create(HTMLVideoElement*, const IntRect&); | 27 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLVideoElement*, const I
ntRect&); |
27 static PassRefPtr<ImageBitmap> create(HTMLCanvasElement*, const IntRect&); | 28 static PassRefPtrWillBeRawPtr<ImageBitmap> create(HTMLCanvasElement*, const
IntRect&); |
28 static PassRefPtr<ImageBitmap> create(ImageData*, const IntRect&); | 29 static PassRefPtrWillBeRawPtr<ImageBitmap> create(ImageData*, const IntRect&
); |
29 static PassRefPtr<ImageBitmap> create(ImageBitmap*, const IntRect&); | 30 static PassRefPtrWillBeRawPtr<ImageBitmap> create(ImageBitmap*, const IntRec
t&); |
30 static PassRefPtr<ImageBitmap> create(Image*, const IntRect&); | 31 static PassRefPtrWillBeRawPtr<ImageBitmap> create(Image*, const IntRect&); |
31 | 32 |
32 PassRefPtr<Image> bitmapImage() const; | 33 PassRefPtr<Image> bitmapImage() const; |
33 PassRefPtr<HTMLImageElement> imageElement() const { return m_imageElement; } | 34 PassRefPtr<HTMLImageElement> imageElement() const { return m_imageElement; } |
34 | 35 |
35 IntRect bitmapRect() const { return m_bitmapRect; } | 36 IntRect bitmapRect() const { return m_bitmapRect; } |
36 | 37 |
37 int width() const { return m_cropRect.width(); } | 38 int width() const { return m_cropRect.width(); } |
38 int height() const { return m_cropRect.height(); } | 39 int height() const { return m_cropRect.height(); } |
39 IntSize size() const { return m_cropRect.size(); } | 40 IntSize size() const { return m_cropRect.size(); } |
40 | 41 |
41 virtual ~ImageBitmap(); | 42 virtual ~ImageBitmap(); |
42 | 43 |
43 // CanvasImageSource implementation | 44 // CanvasImageSource implementation |
44 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceIma
geStatus*) const OVERRIDE; | 45 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceIma
geStatus*) const OVERRIDE; |
45 virtual bool wouldTaintOrigin(SecurityOrigin*) const OVERRIDE { return false
; }; | 46 virtual bool wouldTaintOrigin(SecurityOrigin*) const OVERRIDE { return false
; }; |
46 virtual void adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const O
VERRIDE; | 47 virtual void adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const O
VERRIDE; |
47 virtual FloatSize sourceSize() const OVERRIDE; | 48 virtual FloatSize sourceSize() const OVERRIDE; |
48 | 49 |
| 50 virtual void trace(Visitor*); |
| 51 |
49 private: | 52 private: |
50 ImageBitmap(HTMLImageElement*, const IntRect&); | 53 ImageBitmap(HTMLImageElement*, const IntRect&); |
51 ImageBitmap(HTMLVideoElement*, const IntRect&); | 54 ImageBitmap(HTMLVideoElement*, const IntRect&); |
52 ImageBitmap(HTMLCanvasElement*, const IntRect&); | 55 ImageBitmap(HTMLCanvasElement*, const IntRect&); |
53 ImageBitmap(ImageData*, const IntRect&); | 56 ImageBitmap(ImageData*, const IntRect&); |
54 ImageBitmap(ImageBitmap*, const IntRect&); | 57 ImageBitmap(ImageBitmap*, const IntRect&); |
55 ImageBitmap(Image*, const IntRect&); | 58 ImageBitmap(Image*, const IntRect&); |
56 | 59 |
57 // ImageLoaderClient | 60 // ImageLoaderClient |
58 virtual void notifyImageSourceChanged() OVERRIDE; | 61 virtual void notifyImageSourceChanged() OVERRIDE; |
(...skipping 10 matching lines...) Expand all Loading... |
69 // The offset by which the desired Image is stored internally. | 72 // The offset by which the desired Image is stored internally. |
70 // ImageBitmaps constructed from HTMLImageElements reference the entire Imag
eResource and may have a non-zero bitmap offset. | 73 // ImageBitmaps constructed from HTMLImageElements reference the entire Imag
eResource and may have a non-zero bitmap offset. |
71 // ImageBitmaps not constructed from HTMLImageElements always pre-crop and s
tore the image at (0, 0). | 74 // ImageBitmaps not constructed from HTMLImageElements always pre-crop and s
tore the image at (0, 0). |
72 IntPoint m_bitmapOffset; | 75 IntPoint m_bitmapOffset; |
73 | 76 |
74 }; | 77 }; |
75 | 78 |
76 } // namespace WebCore | 79 } // namespace WebCore |
77 | 80 |
78 #endif // ImageBitmap_h | 81 #endif // ImageBitmap_h |
OLD | NEW |