diff options
author | Silenio Quarti <silenio> | 2005-09-01 18:15:44 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2005-09-01 18:15:44 +0000 |
commit | 600117323003db9ea522ed0baf12ee909172c3dc (patch) | |
tree | d7398c07911305263692a79f67fd00421f0178e9 /bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java | |
parent | 1acd89a2d1e085725362a748b0102b8318356ef1 (diff) | |
download | eclipse.platform.swt-600117323003db9ea522ed0baf12ee909172c3dc.tar.gz eclipse.platform.swt-600117323003db9ea522ed0baf12ee909172c3dc.tar.xz eclipse.platform.swt-600117323003db9ea522ed0baf12ee909172c3dc.zip |
106981
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java')
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java | 159 |
1 files changed, 110 insertions, 49 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java index 74bcf2bd20..3a57b2b818 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java @@ -517,6 +517,10 @@ void drawImageAlpha(Image srcImage, int srcX, int srcY, int srcWidth, int srcHei drawImage(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight, depth); return; } + if (device.useXRender) { + drawImageXRender(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight, srcImage.mask, OS.PictStandardA8); + return; + } /* Check the clipping */ Rectangle rect = getClipping(); @@ -628,65 +632,117 @@ void drawImageMask(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeig int xDrawable = data.drawable; /* Generate the mask if necessary. */ if (srcImage.transparentPixel != -1) srcImage.createMask(); - int colorPixmap = 0, maskPixmap = 0; - int foreground = 0x00000000; - if (simple || (srcWidth == destWidth && srcHeight == destHeight)) { - colorPixmap = srcImage.pixmap; - maskPixmap = srcImage.mask; - } else { - /* Stretch the color and mask*/ - int xImagePtr = scalePixmap(xDisplay, srcImage.pixmap, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false, false); - if (xImagePtr != 0) { - int xMaskPtr = scalePixmap(xDisplay, srcImage.mask, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false, false); - if (xMaskPtr != 0) { - /* Create color scaled pixmaps */ - colorPixmap = OS.XCreatePixmap(xDisplay, xDrawable, destWidth, destHeight, depth); - int tempGC = OS.XCreateGC(xDisplay, colorPixmap, 0, null); - OS.XPutImage(xDisplay, colorPixmap, tempGC, xImagePtr, 0, 0, 0, 0, destWidth, destHeight); - OS.XFreeGC(xDisplay, tempGC); - - /* Create mask scaled pixmaps */ - maskPixmap = OS.XCreatePixmap(xDisplay, xDrawable, destWidth, destHeight, 1); - tempGC = OS.XCreateGC(xDisplay, maskPixmap, 0, null); - OS.XPutImage(xDisplay, maskPixmap, tempGC, xMaskPtr, 0, 0, 0, 0, destWidth, destHeight); - OS.XFreeGC(xDisplay, tempGC); - OS.XDestroyImage(xMaskPtr); + if (device.useXRender) { + drawImageXRender(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight, srcImage.mask, OS.PictStandardA1); + } else { + int colorPixmap = 0, maskPixmap = 0; + int foreground = 0x00000000; + if (simple || (srcWidth == destWidth && srcHeight == destHeight)) { + colorPixmap = srcImage.pixmap; + maskPixmap = srcImage.mask; + } else { + /* Stretch the color and mask*/ + int xImagePtr = scalePixmap(xDisplay, srcImage.pixmap, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false, false); + if (xImagePtr != 0) { + int xMaskPtr = scalePixmap(xDisplay, srcImage.mask, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false, false); + if (xMaskPtr != 0) { + /* Create color scaled pixmaps */ + colorPixmap = OS.XCreatePixmap(xDisplay, xDrawable, destWidth, destHeight, depth); + int tempGC = OS.XCreateGC(xDisplay, colorPixmap, 0, null); + OS.XPutImage(xDisplay, colorPixmap, tempGC, xImagePtr, 0, 0, 0, 0, destWidth, destHeight); + OS.XFreeGC(xDisplay, tempGC); + + /* Create mask scaled pixmaps */ + maskPixmap = OS.XCreatePixmap(xDisplay, xDrawable, destWidth, destHeight, 1); + tempGC = OS.XCreateGC(xDisplay, maskPixmap, 0, null); + OS.XPutImage(xDisplay, maskPixmap, tempGC, xMaskPtr, 0, 0, 0, 0, destWidth, destHeight); + OS.XFreeGC(xDisplay, tempGC); + + OS.XDestroyImage(xMaskPtr); + } + OS.XDestroyImage(xImagePtr); } - OS.XDestroyImage(xImagePtr); + + /* Change the source rectangle */ + srcX = srcY = 0; + srcWidth = destWidth; + srcHeight = destHeight; + + foreground = ~foreground; } - /* Change the source rectangle */ - srcX = srcY = 0; - srcWidth = destWidth; - srcHeight = destHeight; + /* Do the blts */ + if (colorPixmap != 0 && maskPixmap != 0) { + XGCValues values = new XGCValues(); + OS.XGetGCValues(xDisplay, handle, OS.GCForeground | OS. GCBackground | OS.GCFunction, values); + OS.XSetFunction(xDisplay, handle, OS.GXxor); + OS.XCopyArea(xDisplay, colorPixmap, xDrawable, handle, srcX, srcY, srcWidth, srcHeight, destX, destY); + OS.XSetForeground(xDisplay, handle, foreground); + OS.XSetBackground(xDisplay, handle, ~foreground); + OS.XSetFunction(xDisplay, handle, OS.GXand); + OS.XCopyPlane(xDisplay, maskPixmap, xDrawable, handle, srcX, srcY, srcWidth, srcHeight, destX, destY, 1); + OS.XSetFunction(xDisplay, handle, OS.GXxor); + OS.XCopyArea(xDisplay, colorPixmap, xDrawable, handle, srcX, srcY, srcWidth, srcHeight, destX, destY); + OS.XSetForeground(xDisplay, handle, values.foreground); + OS.XSetBackground(xDisplay, handle, values.background); + OS.XSetFunction(xDisplay, handle, values.function); + } - foreground = ~foreground; - } - - /* Do the blts */ - if (colorPixmap != 0 && maskPixmap != 0) { - XGCValues values = new XGCValues(); - OS.XGetGCValues(xDisplay, handle, OS.GCForeground | OS. GCBackground | OS.GCFunction, values); - OS.XSetFunction(xDisplay, handle, OS.GXxor); - OS.XCopyArea(xDisplay, colorPixmap, xDrawable, handle, srcX, srcY, srcWidth, srcHeight, destX, destY); - OS.XSetForeground(xDisplay, handle, foreground); - OS.XSetBackground(xDisplay, handle, ~foreground); - OS.XSetFunction(xDisplay, handle, OS.GXand); - OS.XCopyPlane(xDisplay, maskPixmap, xDrawable, handle, srcX, srcY, srcWidth, srcHeight, destX, destY, 1); - OS.XSetFunction(xDisplay, handle, OS.GXxor); - OS.XCopyArea(xDisplay, colorPixmap, xDrawable, handle, srcX, srcY, srcWidth, srcHeight, destX, destY); - OS.XSetForeground(xDisplay, handle, values.foreground); - OS.XSetBackground(xDisplay, handle, values.background); - OS.XSetFunction(xDisplay, handle, values.function); + /* Destroy scaled pixmaps */ + if (colorPixmap != 0 && srcImage.pixmap != colorPixmap) OS.XFreePixmap(xDisplay, colorPixmap); + if (maskPixmap != 0 && srcImage.mask != maskPixmap) OS.XFreePixmap(xDisplay, maskPixmap); } - /* Destroy scaled pixmaps */ - if (colorPixmap != 0 && srcImage.pixmap != colorPixmap) OS.XFreePixmap(xDisplay, colorPixmap); - if (maskPixmap != 0 && srcImage.mask != maskPixmap) OS.XFreePixmap(xDisplay, maskPixmap); /* Destroy the image mask if the there is a GC created on the image */ if (srcImage.transparentPixel != -1 && srcImage.memGC != null) srcImage.destroyMask(); } +void drawImageXRender(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, int imgWidth, int imgHeight, int maskPixmap, int maskType) { + int drawable = data.drawable; + int xDisplay = data.display; + int maskPict = 0; + if (maskPixmap != 0) { + int attribCount = 0; + XRenderPictureAttributes attrib = null; + if (srcImage.alpha != -1) { + attribCount = 1; + attrib = new XRenderPictureAttributes(); + attrib.repeat = true; + } + maskPict = OS.XRenderCreatePicture(xDisplay, maskPixmap, OS.XRenderFindStandardFormat(xDisplay, maskType), attribCount, attrib); + if (maskPict == 0) SWT.error(SWT.ERROR_NO_HANDLES); + } + int format = OS.XRenderFindVisualFormat(xDisplay, OS.XDefaultVisual(xDisplay, OS.XDefaultScreen(xDisplay))); + int destPict = OS.XRenderCreatePicture(xDisplay, drawable, format, 0, null); + if (destPict == 0) SWT.error(SWT.ERROR_NO_HANDLES); + int srcPict = OS.XRenderCreatePicture(xDisplay, srcImage.pixmap, format, 0, null); + if (srcPict == 0) SWT.error(SWT.ERROR_NO_HANDLES); + if (srcWidth != destWidth || srcHeight != destHeight) { + int[] transform = new int[]{(int)(((float)srcWidth / destWidth) * 65536), 0, 0, 0, (int)(((float)srcHeight / destHeight) * 65536), 0, 0, 0, 65536}; + OS.XRenderSetPictureTransform(xDisplay, srcPict, transform); + if (maskPict != 0) OS.XRenderSetPictureTransform(xDisplay, maskPict, transform); + } + int clipping = data.clipRgn; + if (data.damageRgn != 0) { + if (clipping == 0) { + clipping = data.damageRgn; + } else { + clipping = OS.XCreateRegion (); + OS.XUnionRegion(clipping, data.clipRgn, clipping); + OS.XIntersectRegion(clipping, data.damageRgn, clipping); + } + } + if (clipping != 0) { + OS.XRenderSetPictureClipRegion(xDisplay, destPict, clipping); + if (clipping != data.clipRgn && clipping != data.damageRgn) { + OS.XDestroyRegion(clipping); + } + } + OS.XRenderComposite(xDisplay, maskPict != 0 ? OS.PictOpOver : OS.PictOpSrc, srcPict, maskPict, destPict, srcX, srcY, srcX, srcY, destX, destY, destWidth, destHeight); + OS.XRenderFreePicture(xDisplay, destPict); + OS.XRenderFreePicture(xDisplay, srcPict); + if (maskPict != 0) OS.XRenderFreePicture(xDisplay, maskPict); +} void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, int imgWidth, int imgHeight, int depth) { int xDisplay = data.display; int xDrawable = data.drawable; @@ -695,6 +751,10 @@ void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, OS.XCopyArea(xDisplay, srcImage.pixmap, xDrawable, handle, srcX, srcY, srcWidth, srcHeight, destX, destY); return; } + if (device.useXRender) { + drawImageXRender(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight, 0, -1); + return; + } /* Streching case */ int xImagePtr = scalePixmap(xDisplay, srcImage.pixmap, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false, false); @@ -3218,6 +3278,7 @@ public static GC motif_new(Drawable drawable, GCData data) { */ public static GC motif_new(int xGC, GCData data) { GC gc = new GC(); + gc.device = data.device; gc.init(null, data, xGC); return gc; } |