mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 13:05:52 +08:00
Fix: Restore correct rounded-rect corners on 26.2
- V26_2TextureHelper.create now takes raw RGBA again, so V26_2ShapeCache's quarter-circle corner textures are uploaded intact instead of being read as one-byte coverage and appearing grey - Add an explicit createFromCoverage entry point for font atlases, which still expands directly into the NativeImage buffer - Point V26_2FontBackend at createFromCoverage so the font texture optimisation is kept
This commit is contained in:
1 parent
6a045fd46f
commit
8183eae9d1
2 files changed
+39
-12
No files matched your search
+1
-1
@@ -30,7 +30,7 @@ public final class V26_2FontBackend implements FontBackend {
|
||||
int height = atlas.getHeight();
|
||||
byte[] coverage = atlas.getPixels();
|
||||
|
||||
V26_2GpuTexture texture = V26_2TextureHelper.create(
|
||||
V26_2GpuTexture texture = V26_2TextureHelper.createFromCoverage(
|
||||
loader, width, height, coverage);
|
||||
return new V26_2FontTexture(texture.texture, texture.textureView,
|
||||
texture.sampler, width, height);
|
||||
|
||||
+38
-11
@@ -5,13 +5,43 @@ import java.nio.ByteBuffer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Creates a {@code DynamicTexture} from an RGBA byte array without linking
|
||||
* against Mojang's classes.
|
||||
* Creates a {@code DynamicTexture} without linking against Mojang's classes.
|
||||
*
|
||||
* <p>Two input formats are supported so callers cannot mix them up: raw RGBA
|
||||
* (shapes, sprites) and one-byte coverage/font atlases, which are expanded to
|
||||
* white RGB + coverage alpha directly inside the {@code NativeImage} buffer.</p>
|
||||
*/
|
||||
final class V26_2TextureHelper {
|
||||
|
||||
static V26_2GpuTexture create(ClassLoader loader, int width, int height,
|
||||
byte[] coverage) {
|
||||
final byte[] rgba) {
|
||||
return create(loader, width, height, new PixelWriter() {
|
||||
@Override
|
||||
public void write(ByteBuffer buffer) {
|
||||
buffer.put(rgba);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static V26_2GpuTexture createFromCoverage(ClassLoader loader, int width,
|
||||
int height, final byte[] coverage) {
|
||||
return create(loader, width, height, new PixelWriter() {
|
||||
@Override
|
||||
public void write(ByteBuffer buffer) {
|
||||
// Expand straight into the NativeImage buffer: avoids a second
|
||||
// full-size RGBA array on top of the atlas and the image.
|
||||
for (byte alpha : coverage) {
|
||||
buffer.put((byte) 0xFF);
|
||||
buffer.put((byte) 0xFF);
|
||||
buffer.put((byte) 0xFF);
|
||||
buffer.put(alpha);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static V26_2GpuTexture create(ClassLoader loader, int width,
|
||||
int height, PixelWriter writer) {
|
||||
try {
|
||||
Class<?> nativeImageClass = Class.forName(
|
||||
"com.mojang.blaze3d.platform.NativeImage", false, loader);
|
||||
@@ -19,16 +49,9 @@ final class V26_2TextureHelper {
|
||||
.getDeclaredConstructor(int.class, int.class, boolean.class);
|
||||
Object image = nativeImageConstructor.newInstance(width, height, false);
|
||||
|
||||
// Expand straight into the NativeImage buffer: avoids a second
|
||||
// full-size RGBA array on top of the atlas and the image.
|
||||
ByteBuffer buffer = (ByteBuffer) nativeImageClass
|
||||
.getMethod("getPixelBytes").invoke(image);
|
||||
for (byte alpha : coverage) {
|
||||
buffer.put((byte) 0xFF);
|
||||
buffer.put((byte) 0xFF);
|
||||
buffer.put((byte) 0xFF);
|
||||
buffer.put(alpha);
|
||||
}
|
||||
writer.write(buffer);
|
||||
|
||||
Class<?> dynamicTextureClass = Class.forName(
|
||||
"net.minecraft.client.renderer.texture.DynamicTexture", false, loader);
|
||||
@@ -53,6 +76,10 @@ final class V26_2TextureHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private interface PixelWriter {
|
||||
void write(ByteBuffer buffer);
|
||||
}
|
||||
|
||||
private V26_2TextureHelper() {
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user