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

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

Issue 181693006: Refactoring source image usage in CanvasRenderingContext2D (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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/frame/ImageBitmap.cpp
diff --git a/Source/core/frame/ImageBitmap.cpp b/Source/core/frame/ImageBitmap.cpp
index 53567bd01655417a20ddcb3b9c280d32ba29d7a1..e902ca5558e74e307314e3140b76843d318a4c1e 100644
--- a/Source/core/frame/ImageBitmap.cpp
+++ b/Source/core/frame/ImageBitmap.cpp
@@ -200,4 +200,29 @@ PassRefPtr<Image> ImageBitmap::bitmapImage() const
return m_bitmap;
}
+PassRefPtr<Image> ImageBitmap::getSourceImageForCanvas(HTMLCanvasElement*, ExceptionState&, CanvasImageSourceUsage usage, bool* isVolatile) const
+{
+ if (isVolatile)
+ *isVolatile = false;
+ return bitmapImage();
+}
+
+void ImageBitmap::adjustDrawRects(FloatRect* srcRect, FloatRect* dstRect) const
+{
+ FloatRect intersectRect = intersection(m_bitmapRect, *srcRect);
+ FloatRect newSrcRect = intersectRect;
+ newSrcRect.move(m_bitmapOffset - m_bitmapRect.location());
+ FloatRect newDstRect(FloatPoint(intersectRect.location() - srcRect->location()), m_bitmapRect.size());
+ newDstRect.scale(dstRect->width() / srcRect->width() * intersectRect.width() / m_bitmapRect.width(),
+ dstRect->height() / srcRect->height() * intersectRect.height() / m_bitmapRect.height());
+ newDstRect.moveBy(dstRect->location());
+ *srcRect = newSrcRect;
+ *dstRect = newDstRect;
+}
+
+FloatSize ImageBitmap::sourceSize() const
+{
+ return FloatSize(width(), height());
+}
+
}

Powered by Google App Engine
This is Rietveld 408576698