darling-cocotron/CoreGraphics/CGGradient.m
Christopher Lloyd 00dea648f8 - attempt at fixing flickering NSOpenGLView on Windows 7
- added opengl32 as a direct dependency
- added CGGradient skeleton
- reorganized some private CA, FreeBSD CGL fixes
2010-05-21 16:44:50 -04:00

49 lines
1.5 KiB
Objective-C

#import <CoreGraphics/CGGradient.h>
#import <CoreGraphics/CGColor.h>
#import <Foundation/NSString.h>
CGGradientRef CGGradientCreateWithColorComponents(CGColorSpaceRef colorSpace,const CGFloat components[],const CGFloat locations[],size_t count) {
return NULL;
}
CGGradientRef CGGradientCreateWithColors(CGColorSpaceRef colorSpace,CFArrayRef colors,const CGFloat locations[]) {
CFIndex i,count=CFArrayGetCount(colors);
size_t numberOfComponents=CGColorSpaceGetNumberOfComponents(colorSpace)+1;
CGFloat components[count*numberOfComponents];
for(i=0;i<count;i++){
CGColorRef color=(CGColorRef)CFArrayGetValueAtIndex(colors,i);
size_t checkNumberOfComponents=CGColorGetNumberOfComponents(color);
size_t j;
if(checkNumberOfComponents==numberOfComponents){
const CGFloat *copy=CGColorGetComponents(color);
for(j=0;j<numberOfComponents;j++)
components[i*numberOfComponents+j]=components[j];
}
else {
NSLog(@"CGGradientCreateWithColors, color spaces don't match, conversion not implemented");
for(j=0;j<numberOfComponents;j++)
components[i*numberOfComponents+j]=0;
}
}
return CGGradientCreateWithColorComponents(colorSpace,components,locations,count);
}
void CGGradientRelease(CGGradientRef self) {
if(self==NULL)
return;
CFRelease(self);
}
CGGradientRef CGGradientRetain(CGGradientRef self) {
if(self==NULL)
return NULL;
return (CGGradientRef)CFRetain(self);
}