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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/NinePieceImageGrid.h" 5 #include "core/paint/NinePieceImageGrid.h"
6 6
7 #include "core/style/ComputedStyle.h" 7 #include "core/style/ComputedStyle.h"
8 #include "core/style/NinePieceImage.h" 8 #include "core/style/NinePieceImage.h"
9 #include "platform/LengthFunctions.h" 9 #include "platform/LengthFunctions.h"
10 #include "platform/geometry/FloatSize.h" 10 #include "platform/geometry/FloatSize.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 middleScaleFactor.setWidth((float) destinationSize.width() / sourceS ize.width()); 219 middleScaleFactor.setWidth((float) destinationSize.width() / sourceS ize.width());
220 220
221 if (m_verticalTileRule == (Image::TileRule)StretchImageRule) 221 if (m_verticalTileRule == (Image::TileRule)StretchImageRule)
222 middleScaleFactor.setHeight((float) destinationSize.height() / sourc eSize.height()); 222 middleScaleFactor.setHeight((float) destinationSize.height() / sourc eSize.height());
223 } 223 }
224 224
225 drawInfo.tileScale = middleScaleFactor; 225 drawInfo.tileScale = middleScaleFactor;
226 drawInfo.tileRule = { m_horizontalTileRule, m_verticalTileRule }; 226 drawInfo.tileRule = { m_horizontalTileRule, m_verticalTileRule };
227 } 227 }
228 228
229 NinePieceImageGrid::NinePieceDrawInfo NinePieceImageGrid::getNinePieceDrawInfo(N inePiece piece) const 229 NinePieceImageGrid::NinePieceDrawInfo NinePieceImageGrid::getNinePieceDrawInfo(N inePiece piece, float imageScaleFactor) const
230 { 230 {
231 DCHECK_NE(imageScaleFactor, 0);
232
231 NinePieceDrawInfo drawInfo; 233 NinePieceDrawInfo drawInfo;
232 drawInfo.isCornerPiece = 234 drawInfo.isCornerPiece =
233 piece == TopLeftPiece || piece == TopRightPiece || piece == BottomLeftPi ece || piece == BottomRightPiece; 235 piece == TopLeftPiece || piece == TopRightPiece || piece == BottomLeftPi ece || piece == BottomRightPiece;
234 236
235 if (drawInfo.isCornerPiece) 237 if (drawInfo.isCornerPiece)
236 setDrawInfoCorner(drawInfo, piece); 238 setDrawInfoCorner(drawInfo, piece);
237 else if (piece != MiddlePiece) 239 else if (piece != MiddlePiece)
238 setDrawInfoEdge(drawInfo, piece); 240 setDrawInfoEdge(drawInfo, piece);
239 else 241 else
240 setDrawInfoMiddle(drawInfo); 242 setDrawInfoMiddle(drawInfo);
241 243
244 if (imageScaleFactor != 1) {
245 // The nine piece grid is computed in unscaled image coordinates but mus t be drawn using
246 // scaled image coordinates.
247 drawInfo.source.scale(imageScaleFactor);
248
249 // Compensate for source scaling by scaling down the individual tiles.
250 drawInfo.tileScale.scale(1 / imageScaleFactor);
251 }
252
242 return drawInfo; 253 return drawInfo;
243 } 254 }
244 255
245 } // namespace blink 256 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698