Chromium Code Reviews| Index: Source/core/page/ImageBitmap.cpp |
| diff --git a/Source/core/page/ImageBitmap.cpp b/Source/core/page/ImageBitmap.cpp |
| index 2f83dd31d15ef34c1697d544f39b783227b699fb..422dcf0e1adb1eee4b9310a898f54c33da65088a 100644 |
| --- a/Source/core/page/ImageBitmap.cpp |
| +++ b/Source/core/page/ImageBitmap.cpp |
| @@ -113,6 +113,17 @@ ImageBitmap::ImageBitmap(ImageBitmap* bitmap, const IntRect& cropRect) |
| ScriptWrappable::init(this); |
| } |
| +ImageBitmap::ImageBitmap(Image* image, const IntRect& cropRect) |
| + : m_cropRect(cropRect) |
| + , m_imageElement(0) |
| +{ |
| + IntRect srcRect = intersection(cropRect, IntRect(IntPoint(), image->size())); |
| + m_bitmap = cropImage(image, cropRect); |
| + m_bitmapRect = IntRect(IntPoint(max(0, -cropRect.x()), max(0, -cropRect.y())), srcRect.size()); |
| + |
| + ScriptWrappable::init(this); |
| +} |
| + |
| ImageBitmap::~ImageBitmap() |
| { |
| if (m_imageElement) |
| @@ -154,6 +165,13 @@ PassRefPtr<ImageBitmap> ImageBitmap::create(ImageBitmap* bitmap, const IntRect& |
| return imageBitmap.release(); |
| } |
| +PassRefPtr<ImageBitmap> ImageBitmap::create(Image* image, const IntRect& cropRect) |
| +{ |
| + IntRect normalizedCropRect = normalizeRect(cropRect); |
| + RefPtr<ImageBitmap> imageBitmap(adoptRef(new ImageBitmap(image, normalizedCropRect))); |
|
do-not-use
2013/08/12 15:15:59
nit: we don't really need this local variable, we
arbesfeld
2013/08/12 15:49:40
Done.
|
| + return imageBitmap.release(); |
| +} |
| + |
| void ImageBitmap::notifyImageSourceChanged() |
| { |
| m_bitmap = cropImage(m_imageElement->cachedImage()->image(), m_cropRect); |