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

Unified Diff: Source/core/svg/graphics/SVGImage.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: Created 5 years, 8 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/svg/graphics/SVGImage.cpp
diff --git a/Source/core/svg/graphics/SVGImage.cpp b/Source/core/svg/graphics/SVGImage.cpp
index f95f9db4be9d3a9da5fdde66675e7e2c8e9123c8..513187387043c2a8e312056c4ff0f3d05aba6b3a 100644
--- a/Source/core/svg/graphics/SVGImage.cpp
+++ b/Source/core/svg/graphics/SVGImage.cpp
@@ -192,8 +192,8 @@ IntSize SVGImage::containerSize() const
return IntSize(300, 150);
}
-void SVGImage::drawForContainer(GraphicsContext* context, const FloatSize containerSize, float zoom, const FloatRect& dstRect,
- const FloatRect& srcRect, SkXfermode::Mode compositeOp)
+void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const FloatSize containerSize, float zoom, const FloatRect& dstRect,
+ const FloatRect& srcRect)
{
if (!m_page)
return;
@@ -212,7 +212,7 @@ void SVGImage::drawForContainer(GraphicsContext* context, const FloatSize contai
adjustedSrcSize.scale(roundedContainerSize.width() / containerSize.width(), roundedContainerSize.height() / containerSize.height());
scaledSrc.setSize(adjustedSrcSize);
- draw(context, dstRect, scaledSrc, compositeOp, DoNotRespectImageOrientation);
+ draw(canvas, paint, dstRect, scaledSrc, DoNotRespectImageOrientation);
}
bool SVGImage::bitmapForCurrentFrame(SkBitmap* bitmap)
@@ -224,7 +224,8 @@ bool SVGImage::bitmapForCurrentFrame(SkBitmap* bitmap)
if (!buffer)
return false;
- drawForContainer(buffer->context(), size(), 1, rect(), rect(), SkXfermode::kSrcOver_Mode);
+ SkPaint paint;
+ drawForContainer(buffer->canvas(), paint, size(), 1, rect(), rect());
*bitmap = buffer->bitmap();
return true;
@@ -256,7 +257,8 @@ void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize
OwnPtr<FloatClipRecorder> clipRecorder;
if (tile != spacedTile)
clipRecorder = adoptPtr(new FloatClipRecorder(recordingContext, *this, PaintPhaseForeground, tile));
- drawForContainer(&recordingContext, containerSize, zoom, tile, srcRect, SkXfermode::kSrcOver_Mode);
+ SkPaint paint;
+ drawForContainer(recordingContext.canvas(), paint, containerSize, zoom, tile, srcRect);
}
if (displayItemList)
@@ -277,12 +279,15 @@ void SVGImage::drawPatternForContainer(GraphicsContext* context, const FloatSize
context->drawRect(dstRect, paint);
}
-void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, SkXfermode::Mode compositeOp, RespectImageOrientationEnum)
+void SVGImage::draw(SkCanvas* canvas, const SkPaint& paint, const FloatRect& dstRect, const FloatRect& srcRect, RespectImageOrientationEnum)
{
if (!m_page)
return;
- float opacity = context->getNormalizedAlpha() / 255.f;
+ float opacity = paint.getAlpha() / 255.f;
+ SkXfermode::Mode compositeOp;
+ if (!SkXfermode::AsMode(paint.getXfermode(), &compositeOp))
+ compositeOp = SkXfermode::kSrcOver_Mode;
// TODO(fmalita): this recorder is only needed because CompositingRecorder below appears to be
// dropping the current color filter on the floor. Find a proper fix and get rid of it.
@@ -321,7 +326,7 @@ void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl
ASSERT(!view->needsLayout());
}
RefPtr<const SkPicture> recording = recordingContext->endRecording();
- context->drawPicture(recording.get());
+ canvas->drawPicture(recording.get());
if (imageObserver())
imageObserver()->didDraw(this);

Powered by Google App Engine
This is Rietveld 408576698