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

Unified Diff: third_party/WebKit/Source/core/paint/NinePieceImageGrid.cpp

Issue 1901103002: Compensate for source scaling in hidpi mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add DOCTYPE to added test. Created 4 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: third_party/WebKit/Source/core/paint/NinePieceImageGrid.cpp
diff --git a/third_party/WebKit/Source/core/paint/NinePieceImageGrid.cpp b/third_party/WebKit/Source/core/paint/NinePieceImageGrid.cpp
index 16c1dadda9d6cbaab9c559e9835eeb250d7c2f19..2980a044f67b6ca7012a3d99efd0dfacf941c165 100644
--- a/third_party/WebKit/Source/core/paint/NinePieceImageGrid.cpp
+++ b/third_party/WebKit/Source/core/paint/NinePieceImageGrid.cpp
@@ -226,8 +226,10 @@ void NinePieceImageGrid::setDrawInfoMiddle(NinePieceDrawInfo& drawInfo) const
drawInfo.tileRule = { m_horizontalTileRule, m_verticalTileRule };
}
-NinePieceImageGrid::NinePieceDrawInfo NinePieceImageGrid::getNinePieceDrawInfo(NinePiece piece) const
+NinePieceImageGrid::NinePieceDrawInfo NinePieceImageGrid::getNinePieceDrawInfo(NinePiece piece, float imageScaleFactor) const
{
+ DCHECK_NE(imageScaleFactor, 0);
+
NinePieceDrawInfo drawInfo;
drawInfo.isCornerPiece =
piece == TopLeftPiece || piece == TopRightPiece || piece == BottomLeftPiece || piece == BottomRightPiece;
@@ -239,6 +241,15 @@ NinePieceImageGrid::NinePieceDrawInfo NinePieceImageGrid::getNinePieceDrawInfo(N
else
setDrawInfoMiddle(drawInfo);
+ if (imageScaleFactor != 1) {
+ // The nine piece grid is computed in unscaled image coordinates but must be drawn using
+ // scaled image coordinates.
+ drawInfo.source.scale(imageScaleFactor);
+
+ // Compensate for source scaling by scaling down the individual tiles.
+ drawInfo.tileScale.scale(1 / imageScaleFactor);
+ }
+
return drawInfo;
}

Powered by Google App Engine
This is Rietveld 408576698