/* * To implement "psychedelic mode" we select one of 256 palettes * (actually rotations of the same palette) by using palette_select. * ShiftColors can set it to the default value (0) by passing zero * or simply bump it by one when anything else is passed. */ NaClSrpcError ShiftColors(NaClSrpcChannel *channel, NaClSrpcArg** in_args, NaClSrpcArg** out_args) { struct work_item p; p.kind = WORK_SHIFT_COLOR; p.u.shift_color = in_args[0]->u.ival; work_put(&p); return NACL_SRPC_RESULT_OK; }
/* * Display the pixmap, using the color palette with a possible shift. */ NaClSrpcError MandelDisplay(NaClSrpcChannel *channel, NaClSrpcArg** in_args, NaClSrpcArg** out_args) { struct work_item p; p.kind = WORK_DISPLAY; work_put(&p); return NACL_SRPC_RESULT_OK; }
NaClSrpcError ShutdownSharedMemory(NaClSrpcChannel *channel, NaClSrpcArg **in_args, NaClSrpcArg **out_args) { struct work_item p; p.kind = WORK_SHUTDOWN; work_put(&p); return NACL_SRPC_RESULT_OK; }
NaClSrpcError SetupGlobals(NaClSrpcChannel *channel, NaClSrpcArg **in_args, NaClSrpcArg **out_args) { struct work_item p; p.kind = WORK_SETUP; p.u.setup_canvas_width = in_args[0]->u.dval; work_put(&p); return NACL_SRPC_RESULT_OK; }
/* * To implement "psychedelic mode" we select one of 256 palettes * (actually rotations of the same palette) by using palette_select. * ShiftColors can set it to the default value (0) by passing zero * or simply bump it by one when anything else is passed. */ void ShiftColors(NaClSrpcRpc *rpc, NaClSrpcArg **in_args, NaClSrpcArg **out_args, NaClSrpcClosure *done) { struct work_item p; p.kind = WORK_SHIFT_COLOR; p.u.shift_color = in_args[0]->u.ival; work_put(&p); rpc->result = NACL_SRPC_RESULT_OK; done->Run(done); }
/* * Display the pixmap, using the color palette with a possible shift. */ void MandelDisplay(NaClSrpcRpc *rpc, NaClSrpcArg ** in_args, NaClSrpcArg **out_args, NaClSrpcClosure *done) { struct work_item p; p.kind = WORK_DISPLAY; work_put(&p); rpc->result = NACL_SRPC_RESULT_OK; done->Run(done); }
void ShutdownSharedMemory(NaClSrpcRpc *rpc, NaClSrpcArg **in_args, NaClSrpcArg **out_args, NaClSrpcClosure *done) { struct work_item p; p.kind = WORK_SHUTDOWN; work_put(&p); rpc->result = NACL_SRPC_RESULT_OK; done->Run(done); }
void SetupGlobals(NaClSrpcRpc *rpc, NaClSrpcArg **in_args, NaClSrpcArg **out_args, NaClSrpcClosure *done) { struct work_item p; p.kind = WORK_SETUP; p.u.setup_canvas_width = in_args[0]->u.dval; work_put(&p); rpc->result = NACL_SRPC_RESULT_OK; done->Run(done); }
/* * Select the region of the X-Y plane to be viewed and compute. */ NaClSrpcError SetRegion(NaClSrpcChannel *channel, NaClSrpcArg **in_args, NaClSrpcArg **out_args) { struct work_item p; p.kind = WORK_SET_REGION; p.u.set_region.new_x_left = in_args[0]->u.dval; p.u.set_region.new_y_top = in_args[1]->u.dval; p.u.set_region.new_x_right = in_args[2]->u.dval; p.u.set_region.new_y_bottom = in_args[3]->u.dval; work_put(&p); return NACL_SRPC_RESULT_OK; }
/* * Select the region of the X-Y plane to be viewed and compute. */ void SetRegion(NaClSrpcRpc *rpc, NaClSrpcArg **in_args, NaClSrpcArg **out_args, NaClSrpcClosure *done) { struct work_item p; p.kind = WORK_SET_REGION; p.u.set_region.new_x_left = in_args[0]->u.dval; p.u.set_region.new_y_top = in_args[1]->u.dval; p.u.set_region.new_x_right = in_args[2]->u.dval; p.u.set_region.new_y_bottom = in_args[3]->u.dval; work_put(&p); rpc->result = NACL_SRPC_RESULT_OK; done->Run(done); }
void quick_sort_aux(float *data, int n, int depth, workpile_t wp, int deferrable) { int i,j; /* If array small, use insertion sort */ if (n <= SORT_DIRECT) { for (j = 1; j < n; j++) { /* data[0..j-1] in sort; find a spot for data[j] */ float key = data[j]; for (i = j - 1; i >= 0 && key < data[i]; i--) data[i+1] = data[i]; data[i+1] = key; } return; } /* Defer this work to work queue if policy says so */ if (deferrable && depth <= DEFER_DEPTH) { quick_sort_args *q = (quick_sort_args *) malloc(sizeof (quick_sort_args)); assert(q != NULL); q->data = data; q->n = n; q->depth = depth; q->wp = wp; work_put(wp, (void *)q); return; } /* Otherwise, partition data based on a median estimate */ #define swap(i,j) {float t = data[i]; data[i] = data[j]; data[j] = t;} i = 0; j = n - 1; for (;;) { while (data[i] < data[j]) j--; if (i >= j) break; swap(i, j); i++; while (data[i] < data[j]) i++; if (i >= j) { i = j; break; } swap(i, j); j--; } /* Median value is now at data[i] */ /* Partitioned so that data[0..i-1] <= median <= data[i+1..n-1] */ quick_sort_aux(data, i, depth+1, wp, TRUE); quick_sort_aux(&data[i+1], n-i-1, depth+1, wp, TRUE); }