Chromium Code Reviews| Index: Source/core/page/ImageBitmap.cpp |
| diff --git a/Source/core/page/ImageBitmap.cpp b/Source/core/page/ImageBitmap.cpp |
| index ffe3af0dfa65d59ae71c04122efe6fad942d5949..80c379fa68f0334b94a9fd0f19839336fa7b6eea 100644 |
| --- a/Source/core/page/ImageBitmap.cpp |
| +++ b/Source/core/page/ImageBitmap.cpp |
| @@ -119,6 +119,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) |
| @@ -160,6 +171,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 21:46:19
nit: Useless local variable. We can return adoptRe
|
| + return imageBitmap.release(); |
| +} |
| + |
| void ImageBitmap::notifyImageSourceChanged() |
| { |
| m_bitmap = cropImage(m_imageElement->cachedImage()->image(), m_cropRect); |