summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Muizelaar <jmuizelaar@mozilla.com>2009-06-02 11:35:33 -0400
committerJeff Muizelaar <jmuizelaar@mozilla.com>2009-06-02 11:35:33 -0400
commit77d7e58b324a5929891e329da31fccfaa81b5464 (patch)
tree0ff23b7737c0e39b95f498db6cb06110d0a2048e
parent5d3758e57994a350e780ed8279e256b2c570d0d6 (diff)
Add ColorSync performance test
-rw-r--r--util/Makefile3
-rw-r--r--util/colorsync-perf.c47
2 files changed, 50 insertions, 0 deletions
diff --git a/util/Makefile b/util/Makefile
new file mode 100644
index 0000000..5adee94
--- /dev/null
+++ b/util/Makefile
@@ -0,0 +1,3 @@
+LDFLAGS= -Wl,-framework,ApplicationServices
+CFLAGS=-g
+all: colorsync-perf
diff --git a/util/colorsync-perf.c b/util/colorsync-perf.c
new file mode 100644
index 0000000..2878c0e
--- /dev/null
+++ b/util/colorsync-perf.c
@@ -0,0 +1,47 @@
+#include <ApplicationServices/ApplicationServices.h>
+#include <dlfcn.h>
+#include <stdio.h>
+
+#define BITMAP_INFO (kCGBitmapByteOrder32Big | kCGImageAlphaNoneSkipLast)
+
+
+int main() {
+ int width = 256;
+ int height = 256*256;
+
+ CGDataProviderRef input_file = CGDataProviderCreateWithFilename("input.icc");
+ CGDataProviderRef output_file = CGDataProviderCreateWithFilename("output.icc");
+ float range[] = {0, 1., 0, 1., 0, 1.};
+ CGColorSpaceRef output_profile = CGColorSpaceCreateICCBased(3, range, output_file, NULL);
+ CGColorSpaceRef input_profile = CGColorSpaceCreateICCBased(3, range, input_file, NULL);
+ CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
+
+ CGContextRef cin = CGBitmapContextCreate(NULL, width, height,
+ 8, 4*width, input_profile, BITMAP_INFO);
+ CGContextRef cout = CGBitmapContextCreate(NULL, width, height,
+ 8, 4*width, output_profile, BITMAP_INFO);
+
+ CGRect rect = {{0,0},{width, height}};
+ CGImageRef copy = CGBitmapContextCreateImage(cin);
+#define LENGTH 256*256*256
+ static unsigned char src[LENGTH*3];
+ static unsigned char qoutput[LENGTH*3];
+ static unsigned char loutput[LENGTH*3];
+ int i,j,k,l=0;
+ for (i=0; i<256; i++) {
+ for (j=0; j<256; j++) {
+ for (k=0; k<256; k++) {
+ src[l++] = i;
+ src[l++] = j;
+ src[l++] = k;
+ }
+ }
+ }
+
+ CGDataProviderRef dp = CGDataProviderCreateWithData(NULL, src, height * width * 3, NULL);
+ CGImageRef ref = CGImageCreate(width, height, 8, 24, width * 3, input_profile, BITMAP_INFO, dp, NULL, 1, kCGRenderingIntentDefault);
+ clock_t qcms_start = clock();
+ CGContextDrawImage(cout, rect, ref);
+ clock_t qcms_time = clock() - qcms_start;
+ printf("ColorSync: %ld\n", qcms_time);
+}