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

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: pdr corrections + needsrebaselines 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..fe7974793d887adaf6bc95e818a2064a894c266f 100644
--- a/Source/platform/graphics/StaticBitmapImage.cpp
+++ b/Source/platform/graphics/StaticBitmapImage.cpp
@@ -36,7 +36,7 @@ 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, const ImageFilterQualityHelper* filterHelper)
{
FloatRect normDstRect = adjustForNegativeSize(dstRect);
Stephen White 2015/05/27 15:46:02 This may be redundant with computations done up in
Justin Novosad 2015/05/27 20:08:16 Yep. I tried it in a debug build and there are no
FloatRect normSrcRect = adjustForNegativeSize(srcRect);
@@ -48,18 +48,13 @@ void StaticBitmapImage::draw(GraphicsContext* ctx, const FloatRect& dstRect, con
ASSERT(normSrcRect.width() <= m_image->width() && normSrcRect.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 = WebCoreFloatRectToSKRect(normSrcRect);
+ SkRect dstSkRect = WebCoreFloatRectToSKRect(normDstRect);
+ SkPaint imagePaint(paint);
+ imagePaint.setFilterQuality(filterHelper->computeFilterQuality(this, normDstRect, normSrcRect));
+ imagePaint.setAntiAlias(filterHelper->shouldDrawAntiAliased(normDstRect));
+ // TODO: Add support for filterHelper->shouldClampToSourceRect()
+ canvas->drawImageRect(m_image.get(), &srcSkRect, dstSkRect, &imagePaint);
if (ImageObserver* observer = imageObserver())
observer->didDraw(this);

Powered by Google App Engine
This is Rietveld 408576698