Theme texture atlas: maintain symbol attributes #63

This commit is contained in:
Emux 2018-01-30 19:56:15 +02:00
parent e304c04f1c
commit 20bdf84d91
No known key found for this signature in database
GPG Key ID: 89C6921D7AF2BDD0
2 changed files with 20 additions and 18 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Copyright 2017 Longri * Copyright 2017 Longri
* Copyright 2017 devemux86 * Copyright 2017-2018 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
@ -75,20 +75,21 @@ public class XmlAtlasThemeBuilder extends XmlThemeBuilder {
return renderTheme; return renderTheme;
} }
private static void replaceRuleSymbols(Rule rule, Map<Object, TextureRegion> regionMap, SymbolBuilder<?> symbolBuilder) { private static void replaceRuleSymbols(Rule rule, Map<Object, TextureRegion> regionMap, SymbolBuilder<?> b) {
for (int i = 0, n = rule.styles.length; i < n; i++) { for (int i = 0, n = rule.styles.length; i < n; i++) {
RenderStyle style = rule.styles[i]; RenderStyle style = rule.styles[i];
if (style instanceof SymbolStyle) { if (style instanceof SymbolStyle) {
int hash = ((SymbolStyle) style).hash; SymbolStyle symbol = (SymbolStyle) style;
TextureRegion region = regionMap.get(hash); TextureRegion region = regionMap.get(symbol.hash);
if (region != null) { if (region != null)
SymbolBuilder<?> b = symbolBuilder.reset(); rule.styles[i] = b.set(symbol)
rule.styles[i] = b.texture(region).build(); .bitmap(null)
} .texture(region)
.build();
} }
} }
for (Rule subRule : rule.subRules) { for (Rule subRule : rule.subRules) {
replaceRuleSymbols(subRule, regionMap, symbolBuilder); replaceRuleSymbols(subRule, regionMap, b);
} }
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright 2017 Longri * Copyright 2017 Longri
* Copyright 2017 devemux86 * Copyright 2017-2018 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
@ -75,20 +75,21 @@ public class XmlMapsforgeAtlasThemeBuilder extends XmlMapsforgeThemeBuilder {
return renderTheme; return renderTheme;
} }
private static void replaceRuleSymbols(Rule rule, Map<Object, TextureRegion> regionMap, SymbolBuilder<?> symbolBuilder) { private static void replaceRuleSymbols(Rule rule, Map<Object, TextureRegion> regionMap, SymbolBuilder<?> b) {
for (int i = 0, n = rule.styles.length; i < n; i++) { for (int i = 0, n = rule.styles.length; i < n; i++) {
RenderStyle style = rule.styles[i]; RenderStyle style = rule.styles[i];
if (style instanceof SymbolStyle) { if (style instanceof SymbolStyle) {
int hash = ((SymbolStyle) style).hash; SymbolStyle symbol = (SymbolStyle) style;
TextureRegion region = regionMap.get(hash); TextureRegion region = regionMap.get(symbol.hash);
if (region != null) { if (region != null)
SymbolBuilder<?> b = symbolBuilder.reset(); rule.styles[i] = b.set(symbol)
rule.styles[i] = b.texture(region).build(); .bitmap(null)
} .texture(region)
.build();
} }
} }
for (Rule subRule : rule.subRules) { for (Rule subRule : rule.subRules) {
replaceRuleSymbols(subRule, regionMap, symbolBuilder); replaceRuleSymbols(subRule, regionMap, b);
} }
} }