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

Unified Diff: third_party/WebKit/Source/core/frame/ImageBitmap.cpp

Issue 2144733011: Use SkCanvas transform instead of flipSkImageVertically (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/frame/ImageBitmap.cpp
diff --git a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
index 70c271251e41b316f7924cd1518d4ef2253c299b..d614506a5ab4cdfd4d50a589b35002bd0e239507 100644
--- a/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
+++ b/third_party/WebKit/Source/core/frame/ImageBitmap.cpp
@@ -255,6 +255,10 @@ static PassRefPtr<StaticBitmapImage> cropImage(Image* image, const ParsedOptions
dstLeft = -parsedOptions.cropRect.x();
if (parsedOptions.cropRect.y() < 0)
dstTop = -parsedOptions.cropRect.y();
+ if (parsedOptions.flipY) {
+ surface->getCanvas()->translate(0, surface->height());
+ surface->getCanvas()->scale(1, -1);
+ }
if (parsedOptions.shouldScaleInput) {
SkRect drawDstRect = SkRect::MakeXYWH(dstLeft, dstTop, parsedOptions.resizeWidth, parsedOptions.resizeHeight);
SkPaint paint;
@@ -264,8 +268,6 @@ static PassRefPtr<StaticBitmapImage> cropImage(Image* image, const ParsedOptions
surface->getCanvas()->drawImage(skiaImage.get(), dstLeft, dstTop);
}
skiaImage = fromSkSp(surface->makeImageSnapshot());
- if (parsedOptions.flipY)
- skiaImage = flipSkImageVertically(skiaImage.get(), PremultiplyAlpha);
if (parsedOptions.premultiplyAlpha) {
if (imageFormat == PremultiplyAlpha)
@@ -314,19 +316,17 @@ ImageBitmap::ImageBitmap(HTMLVideoElement* video, Optional<IntRect> cropRect, Do
if (!buffer)
return;
+ if (parsedOptions.flipY) {
+ buffer->canvas()->translate(0, buffer->size().height());
+ buffer->canvas()->scale(1, -1);
+ }
IntPoint dstPoint = IntPoint(std::max(0, -parsedOptions.cropRect.x()), std::max(0, -parsedOptions.cropRect.y()));
video->paintCurrentFrame(buffer->canvas(), IntRect(dstPoint, srcRect.size()), nullptr);
- if (parsedOptions.flipY || !parsedOptions.premultiplyAlpha) {
- RefPtr<SkImage> skiaImage = buffer->newSkImageSnapshot(PreferNoAcceleration, SnapshotReasonUnknown);
- if (parsedOptions.flipY)
- skiaImage = flipSkImageVertically(skiaImage.get(), PremultiplyAlpha);
- if (!parsedOptions.premultiplyAlpha)
- skiaImage = premulSkImageToUnPremul(skiaImage.get());
- m_image = StaticBitmapImage::create(skiaImage.release());
- } else {
- m_image = StaticBitmapImage::create(buffer->newSkImageSnapshot(PreferNoAcceleration, SnapshotReasonUnknown));
- }
+ RefPtr<SkImage> skiaImage = buffer->newSkImageSnapshot(PreferNoAcceleration, SnapshotReasonUnknown);
+ if (!parsedOptions.premultiplyAlpha)
+ skiaImage = premulSkImageToUnPremul(skiaImage.get());
+ m_image = StaticBitmapImage::create(skiaImage.release());
m_image->setOriginClean(!video->wouldTaintOrigin(document->getSecurityOrigin()));
m_image->setPremultiplied(parsedOptions.premultiplyAlpha);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698