Exemplo n.º 1
0
static void calc_total_layout(LAYOUT *base)
{
    calc_layout(base->next);
    calc_fills(base->next, 0, 0);
    calc_aligns(base->next);
    calc_offsets(base->next, 0, 0);
    
}
Exemplo n.º 2
0
static void calc_offsets(LAYOUT *layout, int offx, int offy)
{
    do {
        layout->offx = offx;
        layout->offy = offy;    
        if (layout->child) {
            calc_offsets(layout->child, 
                         layout->offx + layout->x, 
                         layout->offy + layout->y);
        }
        layout = layout->next;
    } while (layout);   
}
Exemplo n.º 3
0
Arquivo: dary.c Projeto: tkng/dary
/* This function does no error check. You must check and ensure this function
   must not fail before calling. */
static void
move_conflicts_real(dary *da, const int *conflicts, int move_to)
{
   int i = 0;
   int offsets[257];
   int parent_index = get_parent_index(da, conflicts[0]);

   calc_offsets(conflicts, offsets);

   da->base[parent_index] = move_to - (conflicts[0] - da->base[parent_index]);

   for (i = 0; conflicts[i] != -1; i++) {
      move_node(da, conflicts[i], move_to + offsets[i]);
   }
   //  dary_dump(da);
}
Exemplo n.º 4
0
Arquivo: dary.c Projeto: tkng/dary
static dary_status
find_movable_location(dary *da, const int *conflicts, int *first_loc)
{
   int i = da->free_head;
   int offsets[UCHAR_MAX+1];

   calc_offsets(conflicts, offsets);

   //  dary_dump(da);
   //  validate_array(da);

   dprint("free_head %d", da->free_head);

   if (da->free_head < 0) {
      *first_loc = -1;
      return DARY_STATUS_FAIL;
   }

   while (i != - da->check[i]) {

      assert(i > UCHAR_MAX);
      
      if (is_movable(da, i, offsets)) {
         dprint("movable to %d", i);
         *first_loc = i;
         return DARY_STATUS_SUCCESS;
      }
      i = - da->check[i];
   }

   if (is_movable(da, i, offsets)) {
      dprint("movable to %d", i);
      *first_loc = i;
      return DARY_STATUS_SUCCESS;
   } else {   
      *first_loc = -1;
      return DARY_STATUS_FAIL;
   }
}
Exemplo n.º 5
0
/**
 * Initialize fragment shader input attribute info.
 */
void
lp_build_interp_soa_init(struct lp_build_interp_soa_context *bld,
                         struct gallivm_state *gallivm,
                         unsigned num_inputs,
                         const struct lp_shader_input *inputs,
                         boolean pixel_center_integer,
                         LLVMBuilderRef builder,
                         struct lp_type type,
                         LLVMValueRef a0_ptr,
                         LLVMValueRef dadx_ptr,
                         LLVMValueRef dady_ptr,
                         LLVMValueRef x0,
                         LLVMValueRef y0)
{
   struct lp_type coeff_type;
   struct lp_type setup_type;
   unsigned attrib;
   unsigned chan;

   memset(bld, 0, sizeof *bld);

   memset(&coeff_type, 0, sizeof coeff_type);
   coeff_type.floating = TRUE;
   coeff_type.sign = TRUE;
   coeff_type.width = 32;
   coeff_type.length = type.length;

   memset(&setup_type, 0, sizeof setup_type);
   setup_type.floating = TRUE;
   setup_type.sign = TRUE;
   setup_type.width = 32;
   setup_type.length = TGSI_NUM_CHANNELS;


   /* XXX: we don't support interpolating into any other types */
   assert(memcmp(&coeff_type, &type, sizeof coeff_type) == 0);

   lp_build_context_init(&bld->coeff_bld, gallivm, coeff_type);
   lp_build_context_init(&bld->setup_bld, gallivm, setup_type);

   /* For convenience */
   bld->pos = bld->attribs[0];
   bld->inputs = (const LLVMValueRef (*)[TGSI_NUM_CHANNELS]) bld->attribs[1];

   /* Position */
   bld->mask[0] = TGSI_WRITEMASK_XYZW;
   bld->interp[0] = LP_INTERP_LINEAR;

   /* Inputs */
   for (attrib = 0; attrib < num_inputs; ++attrib) {
      bld->mask[1 + attrib] = inputs[attrib].usage_mask;
      bld->interp[1 + attrib] = inputs[attrib].interp;
   }
   bld->num_attribs = 1 + num_inputs;

   /* Ensure all masked out input channels have a valid value */
   for (attrib = 0; attrib < bld->num_attribs; ++attrib) {
      for (chan = 0; chan < TGSI_NUM_CHANNELS; ++chan) {
         bld->attribs[attrib][chan] = bld->coeff_bld.undef;
      }
   }

   if (pixel_center_integer) {
      bld->pos_offset = 0.0;
   } else {
      bld->pos_offset = 0.5;
   }

   pos_init(bld, x0, y0);

   /*
    * Simple method (single step interpolation) may be slower if vector length
    * is just 4, but the results are different (generally less accurate) with
    * the other method, so always use more accurate version.
    */
   if (1) {
      bld->simple_interp = TRUE;
      {
         /* XXX this should use a global static table */
         unsigned i;
         unsigned num_loops = 16 / type.length;
         LLVMValueRef pixoffx, pixoffy, index;
         LLVMValueRef ptr;

         bld->xoffset_store = lp_build_array_alloca(gallivm,
                                                    lp_build_vec_type(gallivm, type),
                                                    lp_build_const_int32(gallivm, num_loops),
                                                    "");
         bld->yoffset_store = lp_build_array_alloca(gallivm,
                                                    lp_build_vec_type(gallivm, type),
                                                    lp_build_const_int32(gallivm, num_loops),
                                                    "");
         for (i = 0; i < num_loops; i++) {
            index = lp_build_const_int32(gallivm, i);
            calc_offsets(&bld->coeff_bld, i*type.length/4, &pixoffx, &pixoffy);
            ptr = LLVMBuildGEP(builder, bld->xoffset_store, &index, 1, "");
            LLVMBuildStore(builder, pixoffx, ptr);
            ptr = LLVMBuildGEP(builder, bld->yoffset_store, &index, 1, "");
            LLVMBuildStore(builder, pixoffy, ptr);
         }
      }
      coeffs_init_simple(bld, a0_ptr, dadx_ptr, dady_ptr);
   }
   else {
      bld->simple_interp = FALSE;
      coeffs_init(bld, a0_ptr, dadx_ptr, dady_ptr);
   }

}
Exemplo n.º 6
0
Arquivo: dary.c Projeto: tkng/dary
static dary_status
move_conflicts2(dary *da, int n, uchar k)
{
   int conflicts[256+1], move_to; /* MAX conflicts 256, +1 is for termination */
   int retcode;
   int i = 0;

   get_children(da, n, conflicts);

   dprint("da->base[%d] =%d, k = %d", n, da->base[n], k);
  
   // ここはなんとか関数化できないか?
   if (conflicts[0] < da->base[n] + k) {
      while (conflicts[i] != -1) {
         i++;
      }
      dprint("last node is k");
      conflicts[i] = da->base[n] + k;
      conflicts[i+1] = -1;
   } else {
      int len = length(conflicts);
      memmove(&conflicts[1], conflicts, (len + 1) * sizeof(int));
      conflicts[0] = da->base[n] + k;
      dprint("first node is k");
   }
   i = 0;
   while (conflicts[i] != -1) {
      dprint("conflicts[%d] = %d", i, conflicts[i]);
      i++;
   }

   retcode = find_movable_location(da, conflicts, &move_to);

   if (retcode != DARY_STATUS_SUCCESS) {
      dprint("move_conflicts:Could not found movable location. Retrying...\n");
      retcode = extend_array(da, da->length + 256);
      if (retcode != DARY_STATUS_SUCCESS) {
         return retcode;
      }
      /* This find_movable_loc must be success, but ensure return value to make sure. */
      retcode = find_movable_location(da, conflicts, &move_to);
    
      if (retcode != DARY_STATUS_SUCCESS) {
         return retcode;
      }
   }

   i = 0;
   int offsets[257];

   calc_offsets(conflicts, offsets);

   for (i = 0; conflicts[i] != -1; i++) {
      if (conflicts[i] != da->base[n] + k) {
         move_node(da, conflicts[i], move_to + offsets[i]);
      }
   }
   da->base[n] = move_to - (conflicts[0] - da->base[n]);
   dprint("da->base[%d] = da->base[%d] (%d) + move_to %d - %d = %d",
          n, n, da->base[n], move_to, conflicts[0], 
          da->base[n] + (move_to - conflicts[0]));

   return DARY_STATUS_SUCCESS;
}