Esempio n. 1
0
/*
 * 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;
}
Esempio n. 2
0
/*
 * 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;
}
Esempio n. 3
0
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;
}
Esempio n. 4
0
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;
}
Esempio n. 5
0
/*
 * 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);
}
Esempio n. 6
0
/*
 * 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);
}
Esempio n. 7
0
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);
}
Esempio n. 8
0
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);
}
Esempio n. 9
0
/*
 * 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;
}
Esempio n. 10
0
/*
 * 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);
}
Esempio n. 11
0
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);
}