From 72e9e5cdb5055acb2c395e629c28042899462462 Mon Sep 17 00:00:00 2001 From: megacz Date: Fri, 30 Jan 2004 07:44:26 +0000 Subject: [PATCH] 2004/01/13 19:27:17 darcs-hash:20040130074426-2ba56-9cf62ff5f44fae9f105269b67a9283c016692096.gz --- src/org/xwt/Platform.java | 6 ++++-- src/org/xwt/Scheduler.java | 4 +++- src/org/xwt/plat/Darwin.java | 5 +++-- src/org/xwt/plat/OpenGL.java | 7 ++++--- src/org/xwt/plat/Win32.java | 5 +++-- src/org/xwt/plat/X11.cc | 33 +++++++++++++++++++-------------- src/org/xwt/plat/X11.java | 11 ++++++----- src/org/xwt/translators/Freetype.java | 1 + 8 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/org/xwt/Platform.java b/src/org/xwt/Platform.java index e364a50..0d02cd0 100644 --- a/src/org/xwt/Platform.java +++ b/src/org/xwt/Platform.java @@ -271,12 +271,14 @@ public abstract class Platform { public DefaultGlyph(org.xwt.Font f, char c) { super(f, c); } public Picture getPicture() { if (p == null && isLoaded) { - p = createPicture(null); + Picture p = createPicture(null); p.data = new int[data.length]; for(int i=0; i> 8; int source_blue = (sourcepixel & 0x000000FF); int red = 0, blue = 0, green = 0; - + int targetpixel; if (alpha == 0x00) continue; if (alpha != 0xFF) { - int targetpixel; switch (xi->bits_per_pixel) { case 8: targetpixel = (int)(*current_pixel); break; + case 15: case 16: targetpixel = (int)(*((uint16_t*)current_pixel)); break; - case 24: targetpixel = (((int)*current_pixel) << 16) | (((int)*(current_pixel + 1)) << 8) | (((int)*(current_pixel + 2))); break; + + // FIXME assumes endianness... + case 24: targetpixel = + (((int)*current_pixel) << 16) | + (((int)*(current_pixel + 1)) << 8) | + (((int)*(current_pixel + 2))); break; case 32: targetpixel = *((int*)current_pixel); break; default: org::xwt::Platform::criticalAbort(JvNewStringLatin1("ERROR: bpp not a multiple of 8!")); } - targetpixel -= colormap_info->base_pixel; - + // if you're on some wierd display that isn't either RGB or BGR, that's your problem, not mine if (colormap_info->red_mult > colormap_info->green_mult && colormap_info->green_mult > colormap_info->blue_mult) { red = targetpixel / colormap_info->red_mult; green = (targetpixel - red * colormap_info->red_mult) / colormap_info->green_mult; - blue = (targetpixel - red * colormap_info->red_mult - green * colormap_info->green_mult) / colormap_info->blue_mult; + blue = (targetpixel-red * colormap_info->red_mult-green * colormap_info->green_mult)/colormap_info->blue_mult; } else { blue = targetpixel / colormap_info->blue_mult; green = (targetpixel - blue * colormap_info->blue_mult) / colormap_info->green_mult; - red = (targetpixel - blue * colormap_info->blue_mult - green * colormap_info->green_mult) / colormap_info->red_mult; + red = (targetpixel-blue * colormap_info->blue_mult-green * colormap_info->green_mult)/colormap_info->red_mult; } } - - red = ((source_red * colormap_info->red_max * alpha) + (red * 0xFF * (0xFF - alpha))) / (0xFF * 0xFF); - green = ((source_green * colormap_info->green_max * alpha) + (green * 0xFF * (0xFF - alpha))) / (0xFF * 0xFF); - blue = ((source_blue * colormap_info->blue_max * alpha) + (blue * 0xFF * (0xFF - alpha))) / (0xFF * 0xFF); - uint32_t destpixel = red * colormap_info->red_mult + green * colormap_info->green_mult + - blue * colormap_info->blue_mult + colormap_info->base_pixel; - + red = ((source_red * (colormap_info->red_max) * alpha) + (red * 0xFF * (0xFF - alpha))) / (0xFF * 0xFF); + green = ((source_green * (colormap_info->green_max) * alpha)+(green * 0xFF * (0xFF - alpha))) / (0xFF * 0xFF); + blue = ((source_blue * (colormap_info->blue_max) * alpha) + (blue * 0xFF * (0xFF - alpha))) / (0xFF * 0xFF); + uint32_t destpixel = + (red * colormap_info->red_mult) + + (green * colormap_info->green_mult) + + (blue * colormap_info->blue_mult) + + colormap_info->base_pixel; switch (xi->bits_per_pixel) { case 8: *current_pixel = (char)(destpixel & 0xFF); break; case 16: *((uint16_t*)current_pixel) = (uint16_t)destpixel; break; diff --git a/src/org/xwt/plat/X11.java b/src/org/xwt/plat/X11.java index a770994..d845f25 100644 --- a/src/org/xwt/plat/X11.java +++ b/src/org/xwt/plat/X11.java @@ -6,6 +6,7 @@ import java.net.*; import java.lang.reflect.*; import java.io.*; import java.util.*; +import org.xwt.js.*; import org.xwt.util.*; import org.xwt.*; @@ -33,7 +34,7 @@ public class X11 extends POSIX { protected String _getAltKeyName() { return System.getProperty("os.name", "").indexOf("SunOS") != -1 ? "Meta" : "Alt"; } - protected Picture _createPicture() { return new X11Picture(); } + protected Picture _createPicture(JS r) { return new X11Picture(r); } protected PixelBuffer _createPixelBuffer(int w, int h, Surface owner) { return new X11PixelBuffer(w, h); } protected Surface _createSurface(Box b, boolean framed) { return new X11Surface(b, framed); } protected boolean _needsAutoClick() { return true; } @@ -97,15 +98,13 @@ public class X11 extends POSIX { */ public static class X11Picture extends Picture { - int width; - int height; - int[] data = null; public X11PixelBuffer doublebuf = null; public int getWidth() { return width; } public int getHeight() { return height; } boolean initialized = false; + public X11Picture(JS r) { super(r); } public void init() { if (initialized) return; initialized = true; @@ -174,7 +173,9 @@ public class X11 extends POSIX { cx2 = Math.min(dx + source.width, cx2); cy2 = Math.min(dy + source.height, cy2); if (cx1 >= cx2 || cy1 >= cy2) return; - slowDrawPicture(((Platform.DefaultGlyph)source).getPicture(), dx, dy, cx1, cy1, cx2, cy2, rgb, true); + X11Picture pic = (X11Picture)((Platform.DefaultGlyph)source).getPicture(); + pic.init(); + slowDrawPicture(pic, dx, dy, cx1, cy1, cx2, cy2, rgb, true); } public void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2) { cx1 = Math.max(dx, cx1); diff --git a/src/org/xwt/translators/Freetype.java b/src/org/xwt/translators/Freetype.java index 7fc5447..b7e71d1 100644 --- a/src/org/xwt/translators/Freetype.java +++ b/src/org/xwt/translators/Freetype.java @@ -57,6 +57,7 @@ public class Freetype { glyph.data = new byte[glyph.width * glyph.height]; int addr = vm.getUserInfo(5); vm.copyin(addr, glyph.data, glyph.width * glyph.height); + glyph.isLoaded = true; } catch (Exception e) { Log.info(this, e); -- 1.7.10.4