Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1104)

Unified Diff: Source/core/page/ImageBitmap.cpp

Issue 20748002: Blob creation methods for ImageBitmap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add OWNERS file. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698