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

Unified Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 19705006: Use SkImage as a backing store for copying 2d Contexts to ImageBitmaps. Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Change SkImage to use srcRect pointer. Created 7 years, 5 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/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)

Powered by Google App Engine
This is Rietveld 408576698