Esempio n. 1
0
static void imlut_new(DL_STATE *page,
                      float *decode_array, void *decode_for_adjust,
                      int32 ncomps, int32 bpp, Bool expanded,
                      uint8 **lut, imlut_t **new_imlut)
{
  Bool result = FALSE;
  const imlut_t blank = { 0 };
  imlut_t *imlut;

  *new_imlut = NULL;

  imlut = dl_alloc(page->dlpools, sizeof(imlut_t),
                   MM_ALLOC_CLASS_IMAGE_TABLES);
  if ( imlut == NULL )
    return;

  *imlut = blank;
  imlut->bpp = bpp;
  imlut->ncomps = ncomps;
  imlut->decode_for_adjust = decode_for_adjust;
  imlut->expanded = expanded;
  imlut->lut = lut;
#if defined( DEBUG_BUILD )
  imlut->hits = 1;
#endif

#define return DO_NOT_return_goto_cleanup_INSTEAD!

  if ( decode_array ) {
    int32 i;

    imlut->decode_array = dl_alloc(page->dlpools, 2 * ncomps * sizeof(float),
                                   MM_ALLOC_CLASS_IMAGE_TABLES);
    if ( !imlut->decode_array )
      goto cleanup;

    for ( i = 2 * ncomps - 1; i >= 0; --i ) {
      imlut->decode_array[i] = decode_array[i];
    }
  }

  *new_imlut = imlut;

  result = TRUE;

 cleanup:
  if ( !result )
    /* Failure is not an error, just tidy up */
    imlut_free(page, imlut);
#undef return
  return;
}
Esempio n. 2
0
void dl_draw_strip(dl_list_t * dl,
				   const draw_vertex_t v[256],
				   int n,
				   int flags)
{
  struct dl_draw_strip_command * c = dl_alloc(dl,
											  sizeof(*c)
											  - sizeof(c->v)
											  + n * sizeof(c->v[0]));

/*   SDDEBUG("[%s] %d %x\n", __FUNCTION__, n, flags); */

  if (c) {
	int i;
	c->n = n;
	c->flags = flags;
	for (i=0; i<n; ++i) {
	  c->v[i] = v[i];
/* 	  SDDEBUG("%02d %f %f %f %f\n\n", i, v[i].x, v[i].y, v[i].w, v[i].w); */
	}
    dl_insert(dl, c,
			  dl_draw_strip_render_opaque,
			  dl_draw_strip_render_transparent);
  }
}
static void dl_load_txt_build_default_data( dl_ctx_t ctx, dl_txt_read_ctx* read_state, unsigned int member_index )
{
	if( ctx->member_descs[member_index].default_value_offset == 0xFFFFFFFF )
		return;

	// TODO: check that this is not outside the buffers
	dl_type_desc*   def_type   = dl_alloc_type( ctx, dl_internal_hash_string( "a_type_here" ) );
	dl_member_desc* def_member = dl_alloc_member( ctx );

	dl_member_desc* member = &ctx->member_descs[member_index];

	uint32_t def_start = member->default_value_offset;
	uint32_t def_len   = member->default_value_size;

	char def_buffer[2048]; // TODO: no hardcode =/

	// TODO: check that typename do not exist in the ctx!

	size_t name_start = ctx->typedata_strings_size;
	dl_txt_read_substr temp = { "a_type_here", 11 };
	def_type->name = dl_alloc_string( ctx, &temp );
	def_type->size[DL_PTR_SIZE_HOST]      = member->size[DL_PTR_SIZE_HOST];
	def_type->alignment[DL_PTR_SIZE_HOST] = member->alignment[DL_PTR_SIZE_HOST];
	def_type->member_count = 1;

	memcpy( def_member, member, sizeof( dl_member_desc ) );
	def_member->offset[0] = 0;
	def_member->offset[1] = 0;

	dl_internal_str_format( def_buffer, sizeof(def_buffer), "{\"a_type_here\":{\"%s\":%.*s}}", dl_internal_member_name( ctx, member ), (int)def_len, read_state->start + def_start );

	size_t prod_bytes;
	dl_error_t err;
	err = dl_txt_pack( ctx, def_buffer, 0x0, 0, &prod_bytes );
	if( err != DL_ERROR_OK )
		dl_txt_read_failed( ctx, read_state, DL_ERROR_INVALID_DEFAULT_VALUE, "failed to pack default-value for member \"%s\" with error \"%s\"",
															dl_internal_member_name( ctx, member ),
															dl_error_to_string( err ) );

	uint8_t* pack_buffer = (uint8_t*)dl_alloc( &ctx->alloc, prod_bytes );

	dl_txt_pack( ctx, def_buffer, pack_buffer, prod_bytes, 0x0 );

	// TODO: convert packed instance to typelib endian/ptrsize here!

	size_t inst_size = prod_bytes - sizeof( dl_data_header );

	ctx->default_data = (uint8_t*)dl_realloc( &ctx->alloc, ctx->default_data, ctx->default_data_size + inst_size, ctx->default_data_size );
	memcpy( ctx->default_data + ctx->default_data_size, pack_buffer + sizeof( dl_data_header ), inst_size );

	dl_free( &ctx->alloc, pack_buffer );

	member->default_value_offset = (uint32_t)ctx->default_data_size;
	member->default_value_size   = (uint32_t)inst_size;
	ctx->default_data_size += inst_size;

	--ctx->type_count;
	--ctx->member_count;
	ctx->typedata_strings_size = name_start;
}
Esempio n. 4
0
static void scrolltext(dl_list_t * dl, 
		       float x, float y, float z,
		       float a, float r, float g, float b,
		       const char * text,
		       float w, float spd, int pingpong)
{
  struct scrolltext_command * c;
  int len;

  if (!text) {
    return;
  }
  if (len = strlen(text), len < 1) {
    return;
  }
  len += sizeof(*c);
  if (c = dl_alloc(dl, len), c) {
    c->x = x;    c->y = y;    c->z = z;
    c->a = a;    c->r = r;    c->g = g;    c->b = b;
    c->len = len;
    c->window = w > 0 ? w : 640;
    c->spd = (spd != 0) ? spd : 1;
    c->pingpong = pingpong;
    strcpy(c->text, text);
    text_size_str_prop(text, &c->w, &c->h, 0, 16, 1);
    if (pingpong == 2) {
      c->xs = 0;
    } else {
      c->xs = c->spd > 0 ? c->window : -c->w;
    }
    dl_insert(dl, c, 0, scrolltext_render_transparent);
  }
}
Esempio n. 5
0
/**
 * Create a new blist
 *
 * There are three different ways we may want to create a blist
 *   a) block != NULL && abytes == 0
 *      This means create a blist and copy its characteristics from the
 *      specified block
 *   b) block == NULL && abytes != 0
 *      This means create a blist and all zero all its characteristics
 *      except for setting abytes to the given value
 *   c) block == NULL && abytes == 0
 *      This means create the blist and the block in one chunk of memory
 *      and zero all the blist and block characteristics.
 *
 * \param[in]     page        DL on which the image blist is being used.
 * \param[in]     bx          Column index
 * \param[in]     global      Is it a global or local blist ?
 * \param[in,out] block       Image block template
 * \param[in]     abytes      block size
 * \param[in]     cost        MM cost
 * \return                    The created blist, or NULL on error
 */
IM_BLIST *blist_create(IM_SHARED *im_shared, int32 bx, Bool global,
                       IM_BLOCK *block, int32 abytes, mm_cost_t cost)
{
  IM_BLIST *blist;
  size_t size = sizeof(IM_BLIST);

  HQASSERT(block == NULL || abytes == 0,"blist creation specified twice");

  if ( abytes || block ) {
    if ( (blist = dl_alloc(im_shared->page->dlpools, size,
                           MM_ALLOC_CLASS_IMAGE_DATA)) == NULL )
      return NULL;
  } else {
    size += im_blocksizeof();
    if ( (blist = im_dataalloc(im_shared, size, cost)) == NULL )
      return NULL;
    block = (IM_BLOCK *)(blist + 1);
    HqMemZero(block, im_blocksizeof());
  }

  blist->bx         = bx;
  blist->global     = (uint8)global;
  blist->wasGlobal  = (uint8)global;
  blist->next       = NULL;
  blist->prev       = NULL;
  blist->block      = block;
  if ( block )
    im_block2blist(blist, TRUE);
  else {
    blist->wasGlobal = (uint8)(!global); /* Not sure why this is done */
    blist->abytes    = CAST_SIGNED_TO_INT16(abytes);
    blist->data      = NULL;
  }
  return blist;
}
Esempio n. 6
0
static int gc_any(lua_State * L, dl_list_t * dl,  dl_command_func_t render)
{
  struct gc_com * c;
  
  if(c = dl_alloc(dl, sizeof(*c)), !c) {
    return DL_COMID_ERROR;
  }
  c->flags = strtoflags(lua_tostring(L, 2), GC_RESTORE_ALL);
  return dl_insert(dl, c, push_render, push_render);
}
Esempio n. 7
0
static void setcolor1(dl_list_t * dl, const draw_color_t * color)
{
  struct color1_com * c;

  if(c = dl_alloc(dl, sizeof(*c)), !c) {
	return;
  }
  c->color[0] = color[0];
  dl_insert(dl, c, dl_color1_render, dl_color1_render);
}
Esempio n. 8
0
static void properties(dl_list_t * dl,
		       fontid_t fontid, const float size, const float aspect,
		       int filter)
{
  struct textprop_command * c;

  if (fontid < 0 || size <= 0) {
    return;
  }
  if (c = dl_alloc(dl, sizeof(*c)), c) {
    c->font = fontid;
    c->size = size;
    c->aspect = aspect;
    c->filter = filter;
    dl_insert(dl, c, 0, properties_render_transparent);
  }
}
Esempio n. 9
0
void glNewList(GLuint list, GLenum mode) {
    FORWARD_IF_REMOTE(glNewList);
    // TODO: make sure this doesn't break anything
    if (list == 0) {
        ERROR(GL_INVALID_VALUE);
    }
    if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) {
        ERROR(GL_INVALID_ENUM);
    }
    if (state.block.active || state.list.active) {
        ERROR(GL_INVALID_OPERATION);
    }
    displaylist_t *dl = dl_alloc();
    if (dl == NULL) {
        ERROR(GL_OUT_OF_MEMORY);
    }
    state.list.name = list;
    state.list.mode = mode;
    state.list.active = dl;
}
Esempio n. 10
0
dl_error_t dl_context_create( dl_ctx_t* dl_ctx, dl_create_params_t* create_params )
{
	dl_allocator alloc;
	dl_allocator_initialize( &alloc, create_params->alloc_func, create_params->realloc_func, create_params->free_func, create_params->alloc_ctx );

	dl_context* ctx = (dl_context*)dl_alloc( &alloc, sizeof( dl_context ) );

	if(ctx == 0x0)
		return DL_ERROR_OUT_OF_LIBRARY_MEMORY;

	memset(ctx, 0x0, sizeof(dl_context));
	memcpy(&ctx->alloc, &alloc, sizeof( dl_allocator ) );

	ctx->error_msg_func = create_params->error_msg_func;
	ctx->error_msg_ctx  = create_params->error_msg_ctx;

	*dl_ctx = ctx;

	return DL_ERROR_OK;
}
Esempio n. 11
0
static void text(dl_list_t * dl, 
		 float x, float y, float z,
		 float a, float r, float g, float b,
		 const char * text)
{
  struct text_command * c;
  int len;

  if (!text) {
    return;
  }
  if (len = strlen(text), len < 1) {
    return;
  }
  len += sizeof(*c);
  if (c = dl_alloc(dl, len), c) {
    c->x = x;    c->y = y;    c->z = z;
    c->a = a;    c->r = r;    c->g = g;    c->b = b;
    strcpy(c->text, text);
    /* 	SDDEBUG("[dltext: [%s]]\n",c->text); */
    dl_insert(dl, c, 0, text_render_transparent);
  }
}
Esempio n. 12
0
/**
 * Start the image blist module for this page.
 */
Bool im_blist_start(IM_SHARED *im_shared)
{
  BLIST_CTX *ctx;
  size_t i, nthreads = NUM_THREADS();

  HQASSERT(im_shared->blist_ctx == NULL, "blist_ctx already exists");

  ctx = dl_alloc(im_shared->page->dlpools,
                 sizeof(BLIST_CTX) + sizeof(blist_wide_band) * (nthreads-1),
                 MM_ALLOC_CLASS_IMAGE);
  if ( ctx == NULL )
    return error_handler(VMERROR);

  ctx->im_blistc = 0;
  ctx->nthreads = nthreads;
  for ( i = 0 ; i < nthreads ; ++i ) {
    ctx->wide_bands[i].width = 0;
    ctx->wide_bands[i].bandno = 0;
  }

  im_shared->blist_ctx = ctx;
  return TRUE;
}