From 01e6f61ccf65708aa22d9ebcbf523913447611d7 Mon Sep 17 00:00:00 2001 From: Carlos Amengual Date: Wed, 18 Dec 2024 21:09:09 +0100 Subject: [PATCH] wmf: add equals() and hashCode() to `ColoredTexture` so caching works --- .../transcoder/wmf/tosvg/TextureFactory.java | 21 +++++++++++++++++++ .../echosvg/transcoder/wmf/testChart.svg | 17 ++++++--------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/echosvg-transcoder/src/main/java/io/sf/carte/echosvg/transcoder/wmf/tosvg/TextureFactory.java b/echosvg-transcoder/src/main/java/io/sf/carte/echosvg/transcoder/wmf/tosvg/TextureFactory.java index ba3dd0780..cadbb85ba 100644 --- a/echosvg-transcoder/src/main/java/io/sf/carte/echosvg/transcoder/wmf/tosvg/TextureFactory.java +++ b/echosvg-transcoder/src/main/java/io/sf/carte/echosvg/transcoder/wmf/tosvg/TextureFactory.java @@ -27,6 +27,7 @@ import java.awt.image.BufferedImage; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import io.sf.carte.echosvg.transcoder.wmf.WMFConstants; @@ -196,5 +197,25 @@ private static class ColoredTexture { this.foreground = foreground; this.background = background; } + + @Override + public int hashCode() { + return Objects.hash(background, foreground, textureId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + ColoredTexture other = (ColoredTexture) obj; + return textureId == other.textureId && Objects.equals(background, other.background) + && Objects.equals(foreground, other.foreground); + } + } + } diff --git a/test-references/io/sf/carte/echosvg/transcoder/wmf/testChart.svg b/test-references/io/sf/carte/echosvg/transcoder/wmf/testChart.svg index 76d53655e..6129967bd 100644 --- a/test-references/io/sf/carte/echosvg/transcoder/wmf/testChart.svg +++ b/test-references/io/sf/carte/echosvg/transcoder/wmf/testChart.svg @@ -47,16 +47,11 @@ nrRJUdsAAAAASUVORK5CYII=" xlink:type="simple" xlink:actuate="onLoad" height="10" IAwD0dz/0hFUsPaXLgZm8UCApA57BvjAAX5Q4B82OMIC5zDBNXS4hwZrePECjbwg 7jXDpPgAAAAASUVORK5CYII=" xlink:type="simple" xlink:actuate="onLoad" height="10" preserveAspectRatio="none" xlink:show="embed" />TextBasic Fill Patterns