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

Unified Diff: third_party/WebKit/Source/platform/graphics/ImagePattern.cpp

Issue 2130063002: Correct color bleeding of no-repeat pattern in canvas2d (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/platform/graphics/ImagePattern.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/ImagePattern.cpp b/third_party/WebKit/Source/platform/graphics/ImagePattern.cpp
index 7decc3076d51b8801bba501abae5f31b8111bb41..cb21803367f1c215d8cda66c39b5653bee040aba 100644
--- a/third_party/WebKit/Source/platform/graphics/ImagePattern.cpp
+++ b/third_party/WebKit/Source/platform/graphics/ImagePattern.cpp
@@ -56,7 +56,7 @@ sk_sp<SkShader> ImagePattern::createShader(const SkMatrix& localMatrix) const
// original, then copy the orignal into it.
// FIXME: Is there a better way to pad (not scale) an image in skia?
sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(
- m_tileImage->width() + expandW, m_tileImage->height() + expandH);
+ m_tileImage->width() + expandW * 2, m_tileImage->height() + expandH * 2);
if (!surface)
return SkShader::MakeColorShader(SK_ColorTRANSPARENT);
@@ -64,7 +64,10 @@ sk_sp<SkShader> ImagePattern::createShader(const SkMatrix& localMatrix) const
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
surface->getCanvas()->drawImage(m_tileImage, 0, 0, &paint);
- return surface->makeImageSnapshot()->makeShader(tileModeX, tileModeY, &localMatrix);
+ SkMatrix newLocalMatrix(localMatrix);
+ newLocalMatrix.setTranslate((isRepeatX() ? 0 : -1), (isRepeatY() ? 0 : -1));
+
+ return surface->makeImageSnapshot()->makeShader(tileModeX, tileModeY, &newLocalMatrix);
}
bool ImagePattern::isTextureBacked() const
« 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