46 CGContextRef context = job->
context;
50 size_t context_datalen;
60 context_data = CGBitmapContextGetData(context);
61 context_datalen = CGBitmapContextGetBytesPerRow(context) * CGBitmapContextGetHeight(context);
70 CGPDFContextClose(context);
75 *((CGImageRef *) job->
window) = CGBitmapContextCreateImage(context);
81 CGDataConsumerRef data_consumer =
82 CGDataConsumerCreate(job,
84 CGImageDestinationRef image_destination =
85 CGImageDestinationCreateWithDataConsumer(data_consumer,
89 CGImageRef
image = CGBitmapContextCreateImage(context);
90 CGImageDestinationAddImage(image_destination,
image,
NULL);
91 CGImageDestinationFinalize(image_destination);
94 if (image_destination)
95 CFRelease(image_destination);
96 CGImageRelease(
image);
97 CGDataConsumerRelease(data_consumer);
102 CGContextRelease(context);
105 if (context_data && context_datalen)
106 munmap(context_data, context_datalen);
112 CGRect bounds = CGRectMake(0.0, 0.0, job->
width, job->
height);
121 const void *auxiliaryKeys[] = {
122 kCGPDFContextCreator,
125 const void *auxiliaryValues[] = {
126 CFStringCreateWithFormat(
NULL,
NULL,
132 CFStringCreateWithCStringNoCopy(
NULL,
134 kCFStringEncodingUTF8,
138 CFDictionaryRef auxiliaryInfo =
139 CFDictionaryCreate(
NULL,
142 sizeof(auxiliaryValues) /
143 sizeof(auxiliaryValues[0]),
144 &kCFTypeDictionaryKeyCallBacks,
145 &kCFTypeDictionaryValueCallBacks);
148 CGDataConsumerRef data_consumer =
149 CGDataConsumerCreate(job,
152 CGPDFContextCreate(data_consumer, &bounds,
156 CGDataConsumerRelease(data_consumer);
157 CFRelease(auxiliaryInfo);
158 for (
size_t i = 0; i <
sizeof(auxiliaryValues) /
sizeof(auxiliaryValues[0]);
160 CFRelease(auxiliaryValues[i]);
168 if (bytes_per_row % 16 != 0) {
169 bytes_per_row += 16 - (bytes_per_row % 16);
177 size_t buffer_size = job->
height * bytes_per_row;
178 mach_msg_type_number_t vm_info_size = HOST_VM_INFO_COUNT;
179 vm_statistics_data_t vm_info;
182 (mach_host_self(), HOST_VM_INFO,
183 (host_info_t) & vm_info,
184 &vm_info_size) != KERN_SUCCESS
186 vm_info.free_count * vm_page_size) {
187 FILE *temp_file = tmpfile();
189 int temp_file_descriptor = fileno(temp_file);
190 if (temp_file_descriptor >= 0
191 && ftruncate(temp_file_descriptor,
193 buffer = mmap(
NULL, buffer_size, PROT_READ | PROT_WRITE,
194 MAP_FILE | MAP_PRIVATE, temp_file_descriptor, 0);
195 if (buffer == MAP_FAILED)
201 if (buffer ==
NULL) {
202 buffer = mmap(
NULL, buffer_size, PROT_READ | PROT_WRITE,
203 MAP_ANON | MAP_PRIVATE, -1, 0);
204 if (buffer == MAP_FAILED) {
211 CGColorSpaceRef color_space =
212 CGColorSpaceCreateDeviceRGB();
213 job->
context = CGBitmapContextCreate(buffer,
219 kCGImageAlphaPremultipliedFirst
224 CGColorSpaceRelease(color_space);
232 CGContextRef context = job->
context;
233 CGContextBeginPage(context, &bounds);
234 CGContextSaveGState(context);
240 CGContextRotateCTM(context, job->
rotation *
M_PI / 180.0);
298 CGContextRef context = job->
context;
312 const CGFloat *segments;
313 size_t segment_count;
317 segment_count =
sizeof(
dashed) /
sizeof(CGFloat);
321 segment_count =
sizeof(
dotted) /
sizeof(CGFloat);
328 CGContextSetLineDash(context, 0.0, segments, segment_count);
331 CGContextSetLineWidth(context, job->
obj->
penwidth);
334 CGContextDrawPath(context, filled ? kCGPathFillStroke : kCGPathStroke);
double yoffset_centerline
void(* free_layout)(void *layout)