X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fplat%2FX11.cc;h=801234024af1c87a54901d8dc75504cae274ee83;hb=30aa8aa58f30808651a02e089c84998d6e054cbb;hp=cd5ce11c3e4cb479dba35d14d050884208b7bf93;hpb=9cc9bed6bfca1693977031301f5405cf05f05698;p=org.ibex.core.git diff --git a/src/org/xwt/plat/X11.cc b/src/org/xwt/plat/X11.cc index cd5ce11..8012340 100644 --- a/src/org/xwt/plat/X11.cc +++ b/src/org/xwt/plat/X11.cc @@ -67,29 +67,23 @@ static void ensureShmSize(int size) { } void org::xwt::plat::X11$X11PixelBuffer::fastDrawPicture(org::xwt::Picture* s, - jint dx1, jint dy1, jint dx2, jint dy2, jint sx1, jint sy1, jint sx2, jint sy2) { + jint dx, jint dy, jint cx1, jint cy1, jint cx2, jint cy2) { org::xwt::plat::X11$X11Picture* source = (org::xwt::plat::X11$X11Picture*)s; - - // it's safe to clip manually since we no that no scaling will be done - if (dx1 < clipx) { sx1 += ((clipx - dx1) * (sx2 - sx1)) / (dx2 - dx1); dx1 = clipx; } - if (dy1 < clipy) { sy1 += ((clipy - dy1) * (sy2 - sy1)) / (dy2 - dy1); dy1 = clipy; } - if (dx2 > clipx + clipw) { sx2 -= ((dx2 - clipx - clipw) * (sx2 - sx1)) / (dx2 - dx1); dx2 = clipx + clipw; } - if (dy2 > clipy + cliph) { sy2 -= ((dy2 - clipy - cliph) * (sy2 - sy1)) / (dy2 - dy1); dy2 = clipy + cliph; } - if (dx1 > clipx + clipw) return; - if (dy1 > clipy + cliph) return; - if (dx2 - dx1 <= 0 || dy2 - dy1 <= 0) return; if (source->doublebuf->stipple != NULL) { XSetClipMask(display, (*((GC*)clipped_gc)), *((Pixmap*)source->doublebuf->stipple)); - XSetClipOrigin(display, (*((GC*)clipped_gc)), dx1 - sx1, dy1 - sy1); + XSetClipOrigin(display, (*((GC*)clipped_gc)), cx1 - dx, cy1 - dy); } else { XSetClipMask(display, (*((GC*)clipped_gc)), None); } - XCopyArea(display, *((Pixmap*)source->doublebuf->pm), (*((Pixmap*)pm)), (*((GC*)clipped_gc)), sx1, sy1, sx2 - sx1, sy2 - sy1, dx1, dy1); + XCopyArea(display, + *((Pixmap*)source->doublebuf->pm), (*((Pixmap*)pm)), (*((GC*)clipped_gc)), + cx1 - dx, cy1 - dy, cx2 - cx1, cy2 - cy1, cx1, cy1); } void org::xwt::plat::X11$X11PixelBuffer::slowDrawPicture(org::xwt::Picture* s, - jint dx1, jint dy1, jint dx2, jint dy2, jint sx1, jint sy1, jint sx2, jint sy2, int rgb, int alphaOnly) { + jint dx, jint dy, jint cx1, jint cy1, jint cx2, jint cy2, + jint rgb, jboolean alphaOnly) { org::xwt::plat::X11$X11Picture* source = (org::xwt::plat::X11$X11Picture*)s; XImage* xi; @@ -101,30 +95,29 @@ void org::xwt::plat::X11$X11PixelBuffer::slowDrawPicture(org::xwt::Picture* s, // MEDIUM: write to a shared ximage, then ask the server to do the blit } else if (shm_supported) { - xi = XShmCreateImage(display, visual, colorDepth, ZPixmap, NULL, &shm_info, dx2 - dx1, dy2 - dy1); + xi = XShmCreateImage(display, visual, colorDepth, ZPixmap, NULL, &shm_info, cx2 - cx1, cy2 - cy1); ensureShmSize(xi->bytes_per_line * xi->height); xi->data = shm_info.shmaddr; - XShmGetImage(display, (*((Pixmap*)pm)), xi, dx1, dy1, AllPlanes); + XShmGetImage(display, (*((Pixmap*)pm)), xi, cx1, cy1, AllPlanes); // SLOWEST: write to an ximage, copy it through the TCP connection, ask the server to do the blit } else { - xi = XGetImage(display, (*((Pixmap*)pm)), dx1, dy1, dx2 - dx1, dy2 - dy1, AllPlanes, ZPixmap); + xi = XGetImage(display, (*((Pixmap*)pm)), cx1, cy1, cx2 - cx1, cy2 - cy1, AllPlanes, ZPixmap); } int* sourcedata = (int*)elements(source->data); - for(int y=max(dy1, clipy); ydata + y * xi->bytes_per_line) + - (shared_pixmap ? max(dx1, clipx) * (xi->bits_per_pixel / 8) : - 1 * dy1 * xi->bytes_per_line); + (shared_pixmap ? cx1 * (xi->bits_per_pixel / 8) : - 1 * cy1 * xi->bytes_per_line); - for(int x=max(dx1, clipx); xbits_per_pixel / 8) { - int source_x = ((x - dx1) * (sx2 - sx1)) / (dx2 - dx1) + sx1; - int source_y = ((y - dy1) * (sy2 - sy1)) / (dy2 - dy1) + sy1; - - int sourcepixel = sourcedata[source_x + source_y * source->getWidth()]; - int alpha = (sourcepixel & 0xFF000000) >> 24; + 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; if (alphaOnly) sourcepixel = rgb; int source_red = (sourcepixel & 0x00FF0000) >> 16; int source_green = (sourcepixel & 0x0000FF00) >> 8; @@ -183,11 +176,11 @@ void org::xwt::plat::X11$X11PixelBuffer::slowDrawPicture(org::xwt::Picture* s, // do nothing, we wrote directly to video memory } else if (shm_supported) { - XShmPutImage(display, (*((Pixmap*)pm)), (*((GC*)gc)), xi, 0, 0, dx1, dy1, dx2 - dx1, dy2 - dy1, False); + XShmPutImage(display, (*((Pixmap*)pm)), (*((GC*)gc)), xi, 0, 0, cx1, cy1, cx2 - cx1, cy2 - cy1, False); XDestroyImage(xi); } else { - XPutImage(display, (*((Pixmap*)pm)), (*((GC*)gc)), xi, 0, 0, dx1, dy1, dx2 - dx1, dy2 - dy1); + XPutImage(display, (*((Pixmap*)pm)), (*((GC*)gc)), xi, 0, 0, cx1, cy1, cx2 - cx1, cy2 - cy1); } } @@ -343,7 +336,7 @@ void org::xwt::plat::X11$X11Surface::setLimits(jint minw, jint minh, jint maxw, XSetWMNormalHints(display, (*((Window*)window)), &hints); } -void org::xwt::plat::X11$X11Surface::setSize (jint width, jint height) { +void org::xwt::plat::X11$X11Surface::_setSize (jint width, jint height) { if (width <= 0 || height <= 0) return; XResizeWindow(display, (*((Window*)window)), width, height); XFlush(display); @@ -732,12 +725,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) @@ -755,13 +748,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)); }