X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fplat%2FX11.cc;h=2bdb08389767df0bf23d36d86384996d2bec07e2;hb=16c24a73c1c1b2955db0bbbaf5a940215329bca1;hp=c825f2543ad8614b77b93efd831cec08c61fc6fc;hpb=368ee160342aa0e96e2a678129f9e309284c6107;p=org.ibex.core.git diff --git a/src/org/xwt/plat/X11.cc b/src/org/xwt/plat/X11.cc index c825f25..2bdb083 100644 --- a/src/org/xwt/plat/X11.cc +++ b/src/org/xwt/plat/X11.cc @@ -69,16 +69,17 @@ static void ensureShmSize(int size) { void org::xwt::plat::X11$X11PixelBuffer::fastDrawPicture(org::xwt::Picture* s, jint dx, jint dy, jint cx1, jint cy1, jint cx2, jint cy2) { org::xwt::plat::X11$X11Picture* source = (org::xwt::plat::X11$X11Picture*)s; - + if (source->doublebuf->stipple != NULL) { XSetClipMask(display, (*((GC*)clipped_gc)), *((Pixmap*)source->doublebuf->stipple)); - XSetClipOrigin(display, (*((GC*)clipped_gc)), cx1 - dx, cy1 - dy); + XSetClipOrigin(display, (*((GC*)clipped_gc)), dx, dy); } else { XSetClipMask(display, (*((GC*)clipped_gc)), None); } + XCopyArea(display, *((Pixmap*)source->doublebuf->pm), (*((Pixmap*)pm)), (*((GC*)clipped_gc)), - cx1 - dx, cy1 - cy, cx2 - cx1, cy2 - cy1, dx, dy); + cx1 - dx, cy1 - dy, cx2 - cx1, cy2 - cy1, cx1, cy1); } void org::xwt::plat::X11$X11PixelBuffer::slowDrawPicture(org::xwt::Picture* s, @@ -111,51 +112,55 @@ void org::xwt::plat::X11$X11PixelBuffer::slowDrawPicture(org::xwt::Picture* s, char* current_pixel = (xi->data + y * xi->bytes_per_line) + (shared_pixmap ? cx1 * (xi->bits_per_pixel / 8) : - 1 * cy1 * xi->bytes_per_line); - for(int x=cx1; x < cx1; x++, current_pixel += xi->bits_per_pixel / 8) { + for(int x=cx1; x < cx2; x++, current_pixel += xi->bits_per_pixel / 8) { int source_x = x - dx; int source_y = y - dy; + // FEATURE: be smarter here; can we do something better for the alphaonly case? int sourcepixel = sourcedata[source_x + source_y * source->getWidth()]; int alpha = (sourcepixel & 0xFF000000) >> 24; - - // FEATURE: be smarter here; can we do something better for the alphaonly case? if (alphaOnly) sourcepixel = rgb; int source_red = (sourcepixel & 0x00FF0000) >> 16; int source_green = (sourcepixel & 0x0000FF00) >> 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; @@ -726,12 +731,12 @@ void org::xwt::plat::X11::natInit() { visual = DefaultVisual(display, screen_num); char buf[255]; sprintf(buf, "X11 DISPLAY: %s", XDisplayString(display)); - org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf)); + org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf)); sprintf(buf, "X11 SHM: %s", shm_supported ? "enabled" : "disabled"); - org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf)); + org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf)); sprintf(buf, "X11 Visual: %x %x %x bits: %i visualid: %i depth: %i", visual->red_mask, visual->green_mask, visual->blue_mask, visual->bits_per_rgb, visual->visualid, colorDepth); - org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf)); + org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf)); // FIXME: don't know why (True, False) is the best solution... if(XmuLookupStandardColormap(display, screen_num, visual->visualid, colorDepth, XA_RGB_BEST_MAP, True, False) == 0) @@ -749,13 +754,13 @@ void org::xwt::plat::X11::natInit() { colormap_info = best_map_info; sprintf(buf, " red_max / red_mult: %x %x", colormap_info->red_max, colormap_info->red_mult); - org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf)); + org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf)); sprintf(buf, " green_max / green_mult: %x %x", colormap_info->green_max, colormap_info->green_mult); - org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf)); + org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf)); sprintf(buf, " blue_max / blue_mult: %x %x", colormap_info->blue_max, colormap_info->blue_mult); - org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf)); + org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf)); sprintf(buf, " base_pixel: %x", colormap_info->base_pixel); - org::xwt::util::Log::log(this->getClass(), JvNewStringLatin1(buf)); + org::xwt::util::Log::info(this->getClass(), JvNewStringLatin1(buf)); }