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

Unified Diff: ui/gfx/skia_util.cc

Issue 262773010: Fix images drawn with the NineImagePainter class in high DPI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased to tip Created 6 years, 7 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
« ui/gfx/canvas.cc ('K') | « ui/gfx/skia_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/skia_util.cc
diff --git a/ui/gfx/skia_util.cc b/ui/gfx/skia_util.cc
index 44683aed584675d48695caca11a0375d43249fcf..b8100b0b4addcd1ce739355604ed1f72a3e5fccd 100644
--- a/ui/gfx/skia_util.cc
+++ b/ui/gfx/skia_util.cc
@@ -64,13 +64,21 @@ void TransformToFlattenedSkMatrix(const gfx::Transform& transform,
skia::RefPtr<SkShader> CreateImageRepShader(const gfx::ImageSkiaRep& image_rep,
SkShader::TileMode tile_mode,
const SkMatrix& local_matrix) {
+ return CreateImageRepShaderForScale(image_rep, tile_mode, local_matrix,
+ image_rep.scale());
+}
+
+skia::RefPtr<SkShader> CreateImageRepShaderForScale(
+ const gfx::ImageSkiaRep& image_rep,
+ SkShader::TileMode tile_mode,
+ const SkMatrix& local_matrix,
+ SkScalar scale) {
skia::RefPtr<SkShader> shader = skia::AdoptRef(SkShader::CreateBitmapShader(
image_rep.sk_bitmap(), tile_mode, tile_mode));
SkScalar scale_x = local_matrix.getScaleX();
SkScalar scale_y = local_matrix.getScaleY();
- SkScalar bitmap_scale = SkFloatToScalar(image_rep.scale());
- // Unscale matrix by |bitmap_scale| such that the bitmap is drawn at the
+ // Unscale matrix by |scale| such that the bitmap is drawn at the
// correct density.
// Convert skew and translation to pixel coordinates.
// Thus, for |bitmap_scale| = 2:
@@ -78,9 +86,9 @@ skia::RefPtr<SkShader> CreateImageRepShader(const gfx::ImageSkiaRep& image_rep,
// should be converted to
// x scale = 1, x translation = 2 pixels.
SkMatrix shader_scale = local_matrix;
- shader_scale.preScale(bitmap_scale, bitmap_scale);
- shader_scale.setScaleX(SkScalarDiv(scale_x, bitmap_scale));
- shader_scale.setScaleY(SkScalarDiv(scale_y, bitmap_scale));
+ shader_scale.preScale(scale, scale);
+ shader_scale.setScaleX(SkScalarDiv(scale_x, scale));
+ shader_scale.setScaleY(SkScalarDiv(scale_y, scale));
shader->setLocalMatrix(shader_scale);
return shader;
« ui/gfx/canvas.cc ('K') | « ui/gfx/skia_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698