Fix images drawn with the NineImagePainter class in high DPI.
This class is used for drawing custom buttons/scrollbars, etc. On Windows high DPI for
fractional scale factors like 1.25/1.5, etc these images appear distorted due to pixel loss
occuring while drawing. The loss happens due to the following reasons.
1. The class uses two different flavors of the Canvas::DrawImageInt function to draw. One flavor
is invoked via a local helper called Fill and the other one is used to draw some images.
The latter causes painting problems for fractional scales as it rounds differently via the
skia helper SkScalarRoundToInt which internally ends up adding 0.5 to the value being ceiled
and ceils it at times.
2. The NineImagePainter class uses ImageSkiaStorage.width and height to get the DIP width and height
respectively. These methods divide the pixel width/height by the scale factor and return the
floored results. This causes pixel loss. E.g. pixel width/height 8 and scale favtor 1.5.
These methods return 5 (5.33 rounded to 5). This causes pixel loss eventually.
3. The bounds of the rect being painted to which is passed into the paint function contain width/height
values which when scaled cause rounding problems.
Fixes for the above issues are as below:-
1. Added a new function DrawImageIntInPixel to the gfx::Canvas class. This function ensures that the
underlying SkCanvas does not scale. It translates the destination rectangle to ensure that the image is
displayed at the desired location.
2. Changed the drawing code in the NineImagePainter class to pass in pixel locations/width/height etc for drawing.
BUG=367543
Review URL: https://codereview.chromium.org/
262773010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268429 0039d316-1c4b-4281-b951-d872f2087c98