Revert "gpui: Render SVGs at 2x size when rendered in an `img` (cherry-pick #24332) (#24336)"

Marshall Bowers created

This reverts commit 58834b4e3a3543206edf9c55713521a6eb49e3e2.

Change summary

crates/gpui/src/elements/img.rs | 3 +--
crates/gpui/src/svg_renderer.rs | 3 ---
crates/gpui/src/window.rs       | 9 +++++----
3 files changed, 6 insertions(+), 9 deletions(-)

Detailed changes

crates/gpui/src/elements/img.rs 🔗

@@ -3,7 +3,6 @@ use crate::{
     DefiniteLength, Element, ElementId, GlobalElementId, Hitbox, Image, InteractiveElement,
     Interactivity, IntoElement, LayoutId, Length, ObjectFit, Pixels, RenderImage, Resource,
     SharedString, SharedUri, StyleRefinement, Styled, SvgSize, Task, Window,
-    SMOOTH_SVG_SCALE_FACTOR,
 };
 use anyhow::{anyhow, Result};
 
@@ -611,7 +610,7 @@ impl Asset for ImageAssetLoader {
             } else {
                 let pixmap =
                     // TODO: Can we make svgs always rescale?
-                    svg_renderer.render_pixmap(&bytes, SvgSize::ScaleFactor(SMOOTH_SVG_SCALE_FACTOR))?;
+                    svg_renderer.render_pixmap(&bytes, SvgSize::ScaleFactor(1.0))?;
 
                 let mut buffer =
                     ImageBuffer::from_raw(pixmap.width(), pixmap.height(), pixmap.take()).unwrap();

crates/gpui/src/svg_renderer.rs 🔗

@@ -3,9 +3,6 @@ use anyhow::anyhow;
 use resvg::tiny_skia::Pixmap;
 use std::{hash::Hash, sync::Arc};
 
-/// When rendering SVGs, we render them at twice the size to get a higher-quality result.
-pub const SMOOTH_SVG_SCALE_FACTOR: f32 = 2.;
-
 #[derive(Clone, PartialEq, Hash, Eq)]
 pub(crate) struct RenderSvgParams {
     pub(crate) path: SharedString,

crates/gpui/src/window.rs 🔗

@@ -13,7 +13,7 @@ use crate::{
     Subscription, TaffyLayoutEngine, Task, TextStyle, TextStyleRefinement, TransformationMatrix,
     Underline, UnderlineStyle, WindowAppearance, WindowBackgroundAppearance, WindowBounds,
     WindowControls, WindowDecorations, WindowOptions, WindowParams, WindowTextSystem,
-    SMOOTH_SVG_SCALE_FACTOR, SUBPIXEL_VARIANTS,
+    SUBPIXEL_VARIANTS,
 };
 use anyhow::{anyhow, Context as _, Result};
 use collections::{FxHashMap, FxHashSet};
@@ -2553,11 +2553,12 @@ impl Window {
         let element_opacity = self.element_opacity();
         let scale_factor = self.scale_factor();
         let bounds = bounds.scale(scale_factor);
+        // Render the SVG at twice the size to get a higher quality result.
         let params = RenderSvgParams {
             path,
-            size: bounds.size.map(|pixels| {
-                DevicePixels::from((pixels.0 * SMOOTH_SVG_SCALE_FACTOR).ceil() as i32)
-            }),
+            size: bounds
+                .size
+                .map(|pixels| DevicePixels::from((pixels.0 * 2.).ceil() as i32)),
         };
 
         let Some(tile) =