From 37441ae26963a69eb360587bc8a217f440590690 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Sat, 30 Jan 2016 18:29:54 +0300 Subject: [PATCH] optimize scalability of EmptyIcon --- platform/util/src/com/intellij/util/ui/EmptyIcon.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/platform/util/src/com/intellij/util/ui/EmptyIcon.java b/platform/util/src/com/intellij/util/ui/EmptyIcon.java index b1f84c8d0590..8ff79ab1015c 100644 --- a/platform/util/src/com/intellij/util/ui/EmptyIcon.java +++ b/platform/util/src/com/intellij/util/ui/EmptyIcon.java @@ -80,12 +80,12 @@ public class EmptyIcon implements Icon, ScalableIcon { @Override public int getIconWidth() { - return width; + return scale == 1f ? width : (int) (width * scale); } @Override public int getIconHeight() { - return height; + return scale == 1f ? height : (int) (height * scale); } @Override @@ -120,7 +120,12 @@ public class EmptyIcon implements Icon, ScalableIcon { @Override public Icon scale(float scaleFactor) { if (scaleFactor != scale) { - EmptyIcon icon = this instanceof UIResource ? new EmptyIconUIResource(width, height) : new EmptyIcon(width, height); + EmptyIcon icon; + if (scale != 1f) { + icon = this; + } else { + icon = this instanceof UIResource ? new EmptyIconUIResource(width, height) : new EmptyIcon(width, height); + } icon.scale = scaleFactor; return icon; }