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

Unified Diff: Source/platform/graphics/StaticBitmapImage.cpp

Issue 1093673002: Removing the dependency on GraphicsContext for drawing images in 2D canvas (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 5 years, 7 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/platform/graphics/StaticBitmapImage.cpp
diff --git a/Source/platform/graphics/StaticBitmapImage.cpp b/Source/platform/graphics/StaticBitmapImage.cpp
index 52b88e9fe2d976f63d0409e00fd457f47a8e1609..4f98b63c4cb855c38db832928366bdab6b52d9d3 100644
--- a/Source/platform/graphics/StaticBitmapImage.cpp
+++ b/Source/platform/graphics/StaticBitmapImage.cpp
@@ -36,30 +36,22 @@ bool StaticBitmapImage::currentFrameKnownToBeOpaque()
return m_image->isOpaque();
}
-void StaticBitmapImage::draw(GraphicsContext* ctx, const FloatRect& dstRect, const FloatRect& srcRect, SkXfermode::Mode compositeOp, RespectImageOrientationEnum)
+void StaticBitmapImage::draw(SkCanvas* canvas, const SkPaint& paint, const FloatRect& dstRect, const FloatRect& srcRect, RespectImageOrientationEnum, ImageClampingMode)
{
- FloatRect normDstRect = adjustForNegativeSize(dstRect);
- FloatRect normSrcRect = adjustForNegativeSize(srcRect);
+ ASSERT(dstRect.width() >= 0 && dstRect.height() >= 0);
+ ASSERT(srcRect.width() >= 0 && srcRect.height() >= 0);
- normSrcRect.intersect(FloatRect(0, 0, m_image->width(), m_image->height()));
+ FloatRect adjustedSrcRect = srcRect;
+ adjustedSrcRect.intersect(FloatRect(0, 0, m_image->width(), m_image->height()));
- if (normSrcRect.isEmpty() || normDstRect.isEmpty())
+ if (adjustedSrcRect.isEmpty() || dstRect.isEmpty())
return; // Nothing to draw.
- ASSERT(normSrcRect.width() <= m_image->width() && normSrcRect.height() <= m_image->height());
+ ASSERT(adjustedSrcRect.width() <= m_image->width() && adjustedSrcRect.height() <= m_image->height());
- {
- SkCanvas* canvas = ctx->canvas();
-
- SkPaint paint;
- int initialSaveCount = ctx->preparePaintForDrawRectToRect(&paint, srcRect, dstRect, compositeOp, !currentFrameKnownToBeOpaque());
-
- SkRect srcSkRect = WebCoreFloatRectToSKRect(normSrcRect);
- SkRect dstSkRect = WebCoreFloatRectToSKRect(normDstRect);
-
- canvas->drawImageRect(m_image.get(), &srcSkRect, dstSkRect, &paint);
- canvas->restoreToCount(initialSaveCount);
- }
+ SkRect srcSkRect = adjustedSrcRect;
+ // TODO: Add support for ImageClampingMode
+ canvas->drawImageRect(m_image.get(), &srcSkRect, dstRect, &paint);
if (ImageObserver* observer = imageObserver())
observer->didDraw(this);

Powered by Google App Engine
This is Rietveld 408576698