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/dom/ScriptExecutionContext.h" | 9 #include "core/html/HTMLImageElement.h" |
10 #include "core/platform/graphics/BitmapImage.h" | 10 #include "core/platform/graphics/Image.h" |
11 #include "core/platform/graphics/ImageBuffer.h" | 11 #include "core/platform/graphics/ImageBuffer.h" |
12 #include "core/platform/graphics/IntRect.h" | 12 #include "core/platform/graphics/IntRect.h" |
13 #include "wtf/PassRefPtr.h" | 13 #include "wtf/PassRefPtr.h" |
14 #include "wtf/RefCounted.h" | 14 #include "wtf/RefCounted.h" |
15 | 15 |
16 namespace WebCore { | 16 namespace WebCore { |
17 | 17 |
18 class HTMLCanvasElement; | 18 class HTMLCanvasElement; |
19 class HTMLImageElement; | |
20 class HTMLVideoElement; | 19 class HTMLVideoElement; |
21 class ImageData; | 20 class ImageData; |
22 | 21 |
23 class ImageBitmap : public RefCounted<ImageBitmap>, public ScriptWrappable { | 22 class ImageBitmap : public RefCounted<ImageBitmap>, public ScriptWrappable, publ
ic ImageLoaderClient { |
24 | 23 |
25 public: | 24 public: |
26 static PassRefPtr<ImageBitmap> create(HTMLImageElement*, IntRect); | 25 static PassRefPtr<ImageBitmap> create(HTMLImageElement*, const IntRect&); |
27 static PassRefPtr<ImageBitmap> create(HTMLVideoElement*, IntRect); | 26 static PassRefPtr<ImageBitmap> create(HTMLVideoElement*, const IntRect&); |
28 static PassRefPtr<ImageBitmap> create(HTMLCanvasElement*, IntRect); | 27 static PassRefPtr<ImageBitmap> create(HTMLCanvasElement*, const IntRect&); |
29 static PassRefPtr<ImageBitmap> create(ImageData*, IntRect); | 28 static PassRefPtr<ImageBitmap> create(ImageData*, const IntRect&); |
30 static PassRefPtr<ImageBitmap> create(ImageBitmap*, IntRect); | 29 static PassRefPtr<ImageBitmap> create(ImageBitmap*, const IntRect&); |
31 | 30 |
32 BitmapImage* bitmapImage() const { return m_bitmap.get(); } | 31 PassRefPtr<Image> bitmapImage() const; |
| 32 PassRefPtr<HTMLImageElement> imageElement() const { return m_imageElement; } |
33 | 33 |
34 int bitmapWidth() const { return m_bitmap->width(); } | 34 IntRect bitmapRect() const { return m_bitmapRect; } |
35 int bitmapHeight() const { return m_bitmap->height(); } | |
36 IntSize bitmapSize() const { return m_bitmap->size(); } | |
37 IntPoint bitmapOffset() const { return m_bitmapOffset; } | |
38 | 35 |
39 int width() const { return m_size.width(); } | 36 int width() const { return m_cropRect.width(); } |
40 int height() const { return m_size.height(); } | 37 int height() const { return m_cropRect.height(); } |
41 IntSize size() const { return m_size; } | 38 IntSize size() const { return m_cropRect.size(); } |
42 | 39 |
43 ~ImageBitmap() { }; | 40 ~ImageBitmap(); |
44 | 41 |
45 private: | 42 private: |
46 ImageBitmap(HTMLImageElement*, IntRect); | 43 ImageBitmap(HTMLImageElement*, const IntRect&); |
47 ImageBitmap(HTMLVideoElement*, IntRect); | 44 ImageBitmap(HTMLVideoElement*, const IntRect&); |
48 ImageBitmap(HTMLCanvasElement*, IntRect); | 45 ImageBitmap(HTMLCanvasElement*, const IntRect&); |
49 ImageBitmap(ImageData*, IntRect); | 46 ImageBitmap(ImageData*, const IntRect&); |
50 ImageBitmap(ImageBitmap*, IntRect); | 47 ImageBitmap(ImageBitmap*, const IntRect&); |
51 | 48 |
52 RefPtr<BitmapImage> m_bitmap; | 49 // ImageLoaderClient |
| 50 virtual void notifyImageSourceChanged(); |
| 51 virtual bool requestsHighLiveResourceCachePriority() { return true; } |
| 52 |
| 53 // ImageBitmaps constructed from HTMLImageElements hold a reference to the H
TMLImageElement until |
| 54 // the image source changes. |
| 55 RefPtr<HTMLImageElement> m_imageElement; |
| 56 RefPtr<Image> m_bitmap; |
53 OwnPtr<ImageBuffer> m_buffer; | 57 OwnPtr<ImageBuffer> m_buffer; |
54 | 58 |
55 IntPoint m_bitmapOffset; // offset applied to the image when it is drawn to
the context | 59 IntRect m_bitmapRect; // The rect where the underlying Image should be place
d in reference to the ImageBitmap. |
56 IntSize m_size; // user defined size of the ImageBitmap | 60 IntRect m_cropRect; |
57 }; | 61 }; |
58 | 62 |
59 } // namespace WebCore | 63 } // namespace WebCore |
60 | 64 |
61 #endif // ImageBitmap_h | 65 #endif // ImageBitmap_h |
OLD | NEW |