Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp |
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
index b2701331d1dffccff104b5be49378965be011792..fad7774e4d43df7dd25f693e5d45a23e24f3f594 100644 |
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp |
@@ -1260,12 +1260,8 @@ void CanvasRenderingContext2D::drawImage(ImageBitmap* bitmap, |
return; |
ASSERT(bitmap->height() && bitmap->width()); |
- |
FloatRect normalizedSrcRect = normalizeRect(srcRect); |
FloatRect normalizedDstRect = normalizeRect(dstRect); |
- FloatRect actualDstRect(FloatPoint(bitmap->bitmapOffset()), bitmap->bitmapSize()); |
- actualDstRect.scale(normalizedDstRect.width() / bitmap->width(), normalizedDstRect.height() / bitmap->height()); |
Justin Novosad
2013/07/22 15:35:41
This is not correct. What you should be doing here
|
- actualDstRect.moveBy(normalizedDstRect.location()); |
FloatRect imageRect = FloatRect(FloatPoint(), bitmap->bitmapSize()); |
if (!srcRect.width() || !srcRect.height()) { |
@@ -1275,9 +1271,18 @@ void CanvasRenderingContext2D::drawImage(ImageBitmap* bitmap, |
if (!imageRect.contains(normalizedSrcRect)) |
return; |
- Image* imageForRendering = bitmap->bitmapImage(); |
- |
- drawImageInternal(imageForRendering, normalizedSrcRect, actualDstRect, state().m_globalComposite, state().m_globalBlend); |
+ Image* imageForRendering = bitmap->bitmapImage().get(); |
+ if (bitmap->derivedFromCanvas()) { |
+ FloatRect originalCropRect(bitmap->cropRect()); |
+ normalizedSrcRect.moveBy(originalCropRect.location()); |
+ FloatRect actualSrcRect = intersection(originalCropRect, normalizedSrcRect); |
+ drawImageInternal(imageForRendering, actualSrcRect, normalizedDstRect, state().m_globalComposite, state().m_globalBlend); |
+ } else { |
+ FloatRect actualDstRect(FloatPoint(bitmap->bitmapOffset()), bitmap->bitmapSize()); |
+ actualDstRect.scale(normalizedDstRect.width() / bitmap->width(), normalizedDstRect.height() / bitmap->height()); |
+ actualDstRect.moveBy(normalizedDstRect.location()); |
+ drawImageInternal(imageForRendering, normalizedSrcRect, actualDstRect, state().m_globalComposite, state().m_globalBlend); |
+ } |
} |
void CanvasRenderingContext2D::drawImage(HTMLImageElement* image, float x, float y, ExceptionCode& ec) |