diff options
author | Scott Kovatch <skovatch> | 2010-11-05 21:08:15 +0000 |
---|---|---|
committer | Scott Kovatch <skovatch> | 2010-11-05 21:08:15 +0000 |
commit | 856b7bca73d8f00eddc1ee12b39576510291716a (patch) | |
tree | 9fea8d802dfd61a4ba2f99082be7c672fda122f6 | |
parent | 95bda0dfcfe322a7e1139fde5ddda6f0e1e756fd (diff) | |
download | eclipse.platform.swt-856b7bca73d8f00eddc1ee12b39576510291716a.tar.gz eclipse.platform.swt-856b7bca73d8f00eddc1ee12b39576510291716a.tar.xz eclipse.platform.swt-856b7bca73d8f00eddc1ee12b39576510291716a.zip |
329569 - conditional code for colors obtained from color spaces
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java | 47 | ||||
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java | 12 |
2 files changed, 47 insertions, 12 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java index 50dc8d92e7..e756c45311 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java @@ -288,7 +288,11 @@ NSAutoreleasePool checkGC (int mask) { } else { float /*double*/ [] color = data.foreground; if (data.fg != null) data.fg.release(); - NSColor fg = data.fg = NSColor.colorWithCalibratedRed(color[0], color[1], color[2], data.alpha / 255f); + NSColor fg; + if (OS.VERSION < 0x1060) + fg = data.fg = NSColor.colorWithDeviceRed(color[0], color[1], color[2], data.alpha / 255f); + else + fg = data.fg = NSColor.colorWithCalibratedRed(color[0], color[1], color[2], data.alpha / 255f); fg.retain(); fg.setStroke(); } @@ -300,7 +304,11 @@ NSAutoreleasePool checkGC (int mask) { } else { float /*double*/ [] color = data.foreground; if (data.fg != null) data.fg.release(); - NSColor fg = data.fg = NSColor.colorWithCalibratedRed(color[0], color[1], color[2], data.alpha / 255f); + NSColor fg; + if (OS.VERSION < 0x1060) + fg = data.fg = NSColor.colorWithDeviceRed(color[0], color[1], color[2], data.alpha / 255f); + else + fg = data.fg = NSColor.colorWithCalibratedRed(color[0], color[1], color[2], data.alpha / 255f); fg.retain(); fg.setFill(); } @@ -313,7 +321,11 @@ NSAutoreleasePool checkGC (int mask) { } else { float /*double*/ [] color = data.background; if (data.bg != null) data.bg.release(); - NSColor bg = data.bg = NSColor.colorWithCalibratedRed(color[0], color[1], color[2], data.alpha / 255f); + NSColor bg; + if (OS.VERSION < 0x1060) + bg = data.bg = NSColor.colorWithDeviceRed(color[0], color[1], color[2], data.alpha / 255f); + else + bg = data.bg = NSColor.colorWithCalibratedRed(color[0], color[1], color[2], data.alpha / 255f); bg.retain(); bg.setFill(); } @@ -772,7 +784,12 @@ NSAttributedString createString(String string, int flags, boolean draw) { NSColor fg = data.fg; if (fg == null) { float /*double*/ [] color = data.foreground; - fg = data.fg = NSColor.colorWithCalibratedRed(color[0], color[1], color[2], data.alpha / 255f); + + if (OS.VERSION < 0x1060) + fg = data.fg = NSColor.colorWithDeviceRed(color[0], color[1], color[2], data.alpha / 255f); + else + fg = data.fg = NSColor.colorWithCalibratedRed(color[0], color[1], color[2], data.alpha / 255f); + fg.retain(); } dict.setObject(fg, OS.NSForegroundColorAttributeName); @@ -1680,7 +1697,10 @@ public void drawText (String string, int x, int y, int flags) { NSColor bg = data.bg; if (bg == null) { float /*double*/ [] color = data.background; - bg = data.bg = NSColor.colorWithCalibratedRed(color[0], color[1], color[2], data.alpha / 255f); + if (OS.VERSION < 0x1060) + bg = data.bg = NSColor.colorWithDeviceRed(color[0], color[1], color[2], data.alpha / 255f); + else + bg = data.bg = NSColor.colorWithCalibratedRed(color[0], color[1], color[2], data.alpha / 255f); bg.retain(); } bg.setFill(); @@ -1830,8 +1850,14 @@ public void fillGradientRectangle(int x, int y, int width, int height, boolean v if (fromRGB.equals(toRGB)) { fillRectangle(x, y, width, height); } else { - NSColor startingColor = NSColor.colorWithCalibratedRed(fromRGB.red / 255f, fromRGB.green / 255f, fromRGB.blue / 255f, data.alpha / 255f); - NSColor endingColor = NSColor.colorWithCalibratedRed(toRGB.red / 255f, toRGB.green / 255f, toRGB.blue / 255f, data.alpha / 255f); + NSColor startingColor, endingColor; + if (OS.VERSION < 0x1060) { + startingColor = NSColor.colorWithDeviceRed(fromRGB.red / 255f, fromRGB.green / 255f, fromRGB.blue / 255f, data.alpha / 255f); + endingColor = NSColor.colorWithDeviceRed(toRGB.red / 255f, toRGB.green / 255f, toRGB.blue / 255f, data.alpha / 255f); + } else { + startingColor = NSColor.colorWithCalibratedRed(fromRGB.red / 255f, fromRGB.green / 255f, fromRGB.blue / 255f, data.alpha / 255f); + endingColor = NSColor.colorWithCalibratedRed(toRGB.red / 255f, toRGB.green / 255f, toRGB.blue / 255f, data.alpha / 255f); + } NSGradient gradient = ((NSGradient)new NSGradient().alloc()).initWithStartingColor(startingColor, endingColor); NSRect rect = new NSRect(); rect.x = x; @@ -1907,7 +1933,12 @@ void fillPattern(NSBezierPath path, Pattern pattern) { float /*double*/ dify = end.y - start.y; if (difx == 0 && dify == 0) { float /*double*/ [] color = pattern.color1; - NSColor.colorWithCalibratedRed(color[0], color[1], color[2], data.alpha / 255f).setFill(); + + if (OS.VERSION < 0x1060) + NSColor.colorWithCalibratedRed(color[0], color[1], color[2], data.alpha / 255f).setFill(); + else + NSColor.colorWithDeviceRed(color[0], color[1], color[2], data.alpha / 255f).setFill(); + path.fill(); handle.restoreGraphicsState(); return; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java index 2ccfd06cae..f06d8a8f61 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java @@ -248,7 +248,8 @@ public Image(Device device, Image srcImage, int flag) { handle = (NSImage)new NSImage().alloc(); handle = handle.initWithSize(size); NSBitmapImageRep rep = (NSBitmapImageRep)new NSBitmapImageRep().alloc(); - rep = rep.initWithBitmapDataPlanes(0, width, height, srcRep.bitsPerSample(), srcRep.samplesPerPixel(), srcRep.hasAlpha(), srcRep.isPlanar(), OS.NSCalibratedRGBColorSpace, format, srcRep.bytesPerRow(), bpp); + NSString colorspace = (OS.VERSION < 0x1060) ? OS.NSCalibratedRGBColorSpace : OS.NSDeviceRGBColorSpace; + rep = rep.initWithBitmapDataPlanes(0, width, height, srcRep.bitsPerSample(), srcRep.samplesPerPixel(), srcRep.hasAlpha(), srcRep.isPlanar(), colorspace, format, srcRep.bytesPerRow(), bpp); handle.addRepresentation(rep); rep.release(); handle.setCacheMode(OS.NSImageCacheNever); @@ -844,7 +845,8 @@ void init(int width, int height) { size.height = height; handle = handle.initWithSize(size); NSBitmapImageRep rep = (NSBitmapImageRep)new NSBitmapImageRep().alloc(); - rep = rep.initWithBitmapDataPlanes(0, width, height, 8, 3, false, false, OS.NSCalibratedRGBColorSpace, OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, width * 4, 32); + NSString colorspace = (OS.VERSION < 0x1060) ? OS.NSCalibratedRGBColorSpace : OS.NSDeviceRGBColorSpace; + rep = rep.initWithBitmapDataPlanes(0, width, height, 8, 3, false, false, colorspace, OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, width * 4, 32); OS.memset(rep.bitmapData(), 0xFF, width * height * 4); handle.addRepresentation(rep); rep.release(); @@ -958,7 +960,8 @@ void init(ImageData image) { size.height = height; handle = handle.initWithSize(size); NSBitmapImageRep rep = (NSBitmapImageRep)new NSBitmapImageRep().alloc(); - rep = rep.initWithBitmapDataPlanes(0, width, height, 8, hasAlpha ? 4 : 3, hasAlpha, false, OS.NSCalibratedRGBColorSpace, OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, bpr, 32); + NSString colorspace = (OS.VERSION < 0x1060) ? OS.NSCalibratedRGBColorSpace : OS.NSDeviceRGBColorSpace; + rep = rep.initWithBitmapDataPlanes(0, width, height, 8, hasAlpha ? 4 : 3, hasAlpha, false, colorspace, OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, bpr, 32); OS.memmove(rep.bitmapData(), buffer, dataSize); handle.addRepresentation(rep); rep.release(); @@ -1000,7 +1003,8 @@ void initNative(String filename) { size.height = height; handle = handle.initWithSize(size); NSBitmapImageRep rep = (NSBitmapImageRep)new NSBitmapImageRep().alloc(); - rep = rep.initWithBitmapDataPlanes(0, width, height, 8, hasAlpha ? 4 : 3, hasAlpha, false, OS.NSCalibratedRGBColorSpace, OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, bpr, 32); + NSString nscolorspace = (OS.VERSION < 0x1060) ? OS.NSCalibratedRGBColorSpace : OS.NSDeviceRGBColorSpace; + rep = rep.initWithBitmapDataPlanes(0, width, height, 8, hasAlpha ? 4 : 3, hasAlpha, false, nscolorspace, OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, bpr, 32); handle.addRepresentation(rep); rep.release(); handle.setCacheMode(OS.NSImageCacheNever); |