コード例 #1
0
static void
_cleanup(doeE env, doeObject o)
{
    dcPathFiller	pf = (dcPathFiller)o;
    dcPathFillerData*	p  = (dcPathFillerData*)o;
    doeObject		po;

    (*pf)->reset(env, pf);

    po = (doeObject)(p->runsBuilder);
    if (po != NULL) {
	(*po)->_cleanup(env, po);
	doeMem_free(env, po);
    }

    po = (doeObject)(p->fastOutputPC);
    if (po != NULL) {
	(*po)->_cleanup(env, po);
	doeMem_free(env, po);
    }

    dcPool_destroy(env, p->poolRun);
    dcPool_destroy(env, p->poolLeftSide);

    if (p->xt != NULL)	doeMem_free(env, p->xt);
    if (p->yt != NULL)	doeMem_free(env, p->yt);

    BASE__cleanup(env, o);
}
コード例 #2
0
/*
 * Disposer Method Called by Disposer thread
 * All the native memory associated with stroker is  cleaned here.
 */
void PathStroker_DisposeOps(JNIEnv *env, jlong ops)
{
    doeObject	cobj;
    PathStroker	cdata	= (PathStroker)jlong_to_ptr(ops);
    doeE	cenv;

    /* protect against getting called twice */
    if (cdata == NULL) {
        return;
    }

    cenv	= cdata->env;
    doeE_setPCtxt(cenv, env);
    doeError_reset(cenv);

    cobj = (doeObject)(cdata->stroker);
    (*cobj)->_cleanup(cenv, cobj);
    doeMem_free(cenv, cobj);

    cobj = (doeObject)(cdata->cjout);
    (*cobj)->_cleanup(cenv, cobj);
    doeMem_free(cenv, cobj);

    doeMem_free(cenv, cdata);

    doeE_destroy(cenv);
}
コード例 #3
0
static void
dcPool_cleanup(doeE env, dcPool pool)
{
    doeMem_free(env, pool->poolName);
    while (pool->freeItems != NULL) {
	dcPoolItem item = pool->freeItems;
	pool->freeItems = item->next;
#ifdef DEBUG_MEMSTATS
	pool->totalMem_free++;
#endif
	doeMem_free(env, item);
    }
}
コード例 #4
0
static void
reset(doeE env, dcPathFiller pf)
{
    dcPathFillerData*	p  = (dcPathFillerData*)pf;
    dcPathStore		ps = (dcPathStore) pf;
    i32			tilex, tiley;

    if (p->redundantReset)	return;
    p->redundantReset = TRUE;

    (*ps)->reset(env, ps);	/* reset the PathStore */
    stateResetAll(p);
    LeftSide_releaseList(env, p->lsEffects);
    p->lsEffects = NULL;
    if (p->tileRuns != NULL) {
	for (tiley = 0; tiley < p->outHTi; tiley++) {
	    for (tilex = 0; tilex <= p->outWTi; tilex++) {
		Run_releaseList(env, p->tileRuns[tilex][tiley]);
	    }
	}
	doeMem_free(env, p->tileRuns);
	p->tileRuns = NULL;
    }

    dcPool_endCycle(env, p->poolRun);
    dcPool_endCycle(env, p->poolLeftSide);
}
コード例 #5
0
/*
 * Class:     sun_dc_pr_PathDasher
 * Method:    dispose
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_sun_dc_pr_PathDasher_dispose
  (JNIEnv *env, jobject obj)
{
    PathDasher	cdata	= (PathDasher)jlong_to_ptr(((*env)->GetLongField(env, obj, fidCData)));
    doeObject	cobj;

    doeE	cenv	= cdata->env;
    doeE_setPCtxt(cenv, env);
    doeError_reset(cenv);

    cobj = (doeObject)(cdata->dasher);
    (*cobj)->_cleanup(cenv, cobj);
    doeMem_free(cenv, cobj);

    cobj = (doeObject)(cdata->cjout);
    (*cobj)->_cleanup(cenv, cobj);
    doeMem_free(cenv, cobj);

    doeMem_free(cenv, cdata);

    doeE_destroy(cenv);
}
コード例 #6
0
dcPool
dcPool_create(doeE env, char* poolname, ixx itembytes, ixx initialitems, f32 xsigma)
{
    dcPool	pool = doeMem_malloc(env, sizeof(dcPoolData));
    if (pool == NULL) {
	doeError_setNoMemory(env);
	return NULL;
    }
    dcPool_init(env, pool, poolname, itembytes, initialitems, xsigma);
    if (doeError_occurred(env)) {
	dcPool_cleanup(env, pool);
	doeMem_free(env, pool);
	return NULL;
    }

    return pool;
}
コード例 #7
0
static dcPathConsumer
RunsBuilder_create(doeE env, dcPathFillerData* pfp)
{
    dcPathConsumer	p = doeMem_malloc(env, (i32)sizeof(RunsBuilderData));

    if (p == NULL) {
	doeError_setNoMemory(env);
	return NULL;
    }

    RunsBuilder_init(env, p, pfp);
    if (doeError_occurred(env)) {
	doeMem_free(env, p);
	p = NULL;
    }

    return p;
}
コード例 #8
0
static dcPathConsumer
FastOutputPC_create(doeE env)
{
    dcPathConsumer	p = doeMem_malloc(env, (i32)sizeof(FastOutputPCData));

    if (p == NULL) {
	doeError_setNoMemory(env);
	return NULL;
    }

    FastOutputPC_init(env, p);
    if (doeError_occurred(env)) {
	doeMem_free(env, p);
	p = NULL;
    }

    return p;
}
コード例 #9
0
void
dcPool_destroy(doeE env, dcPool pool)
{
    if (pool == NULL) return;
#ifdef DEBUG_MEMSTATS
  if (memstat_verbose) {
    printf("\n%20s 999999 averages/cycle: pool=%5.1f, used=%5.1f, malloc=%5.1f, free=%5.1f; %5dcycles\n",
	pool->poolName,
	(f32)(pool->totalPool)		/pool->totalCycles,
	(f32)(pool->totalUsed)		/pool->totalCycles,
	(f32)(pool->totalMem_malloc)	/pool->totalCycles,
	(f32)(pool->totalMem_free)	/pool->totalCycles,
	pool->totalCycles);
  }
#endif
    dcPool_cleanup(env, pool);
    doeMem_free(env, pool);
}
コード例 #10
0
dcPathFiller
dcPathFiller_create(doeE env)
{
    dcPathFiller p = (dcPathFiller)doeMem_malloc(env, (i32)sizeof(dcPathFillerData));

    if (p == NULL) {
	doeError_setNoMemory(env);
	return NULL;
    }

    dcPathFiller_init(env, p);
    if (doeError_occurred(env)) {
	_cleanup(env, (doeObject)p);
	doeMem_free(env, p);
	p = NULL;
    }

    return p;
}
コード例 #11
0
CJPathConsumer
CJPathConsumer_create(doeE env, jobject obj)
{
    CJPCData*	p;
    JNIEnv*	jenv = doeE_getPCtxt(env);

    p = (CJPCData*)doeMem_malloc(env, sizeof(CJPCData));
    if (p == NULL) {
	doeError_setNoMemory(env);
	return NULL;
    }
    CJPathConsumer_init(env, (CJPathConsumer)p);
    if (doeError_occurred(env)) {
	doeMem_free(env, p);
	return NULL;
    }

    /* _________________________________
     * the Java PathConsumer counterpart
     */
    p->jpc = (*jenv)->NewGlobalRef(jenv, obj);

    return (CJPathConsumer)p;
}
コード例 #12
0
static void
setOutputArea(doeE env, dcPathFiller pf, f32 outlox, f32 outloy, i32 w, i32 h)
{
    dcPathFillerData*	p = (dcPathFillerData*)pf;
    dcFastPathProducer	fpp = p->thisFPP;
    i32			xi, yi;

    /* check state, parameters */
    if (!((dcPathStoreData*)p)->pathDefined) {
	doeError_set(env, dcPRError, dcPRError_UNEX_setOutputArea);
	return;
    }
    if (w <= 0 || h <= 0) {
	doeError_set(env, dcPRError, dcPRError_BAD_outputarea);
	return;
    }
    if (!(	dcPathFiller_validLoCoord(outlox)	&&
		dcPathFiller_validLoCoord(outloy)	&&
		dcPathFiller_validHiCoord(outlox + w)	&&
		dcPathFiller_validHiCoord(outloy + h))) {
	doeError_set(env, dcPRException, dcPRException_BAD_COORD_setOutputArea);
	return;
    }

    stateSet(p, setOutputAreaDone);

    p->outLoX = outlox;
    p->outLoY = outloy;
    p->outW   = w;
    p->outH   = h;
    p->outWTiF = w / dcPathFiller_tileSizeF;
    p->outHTiF = h / dcPathFiller_tileSizeF;

    if (p->tileRuns != NULL)
	doeMem_free(env, p->tileRuns);

    p->fastOutput =	w <= dcPathFiller_tileSize	&&
			h <= dcPathFiller_tileSize	&&
			p->pathBox[0] >= outlox		&&
			p->pathBox[1] >= outloy		&&
			p->pathBox[2] <= outlox + w	&&
			p->pathBox[3] <= outloy + h;

    if (p->fastOutput)
	return;

    /* allocate [tileRuns], indexed [xindex][yindex];
       (here we reuse [w] and [h] as width and height in tiles) */
    p->outWTi = w = (p->outW + dcPathFiller_tileSize - 1) >> dcPathFiller_tileSizeL2S;
    p->outHTi = h = (p->outH + dcPathFiller_tileSize - 1) >> dcPathFiller_tileSizeL2S;
    
    p->tileRuns = doeMem_malloc(env, 
			  sizeof(Run*)*(w + 1)	/* array  of (Run*), indexed by X */
			+ sizeof(Run )*(w + 1)*h/* arrays of (Run),  indexed by Y */
		  );
    if (p->tileRuns == NULL) {
	doeError_setNoMemory(env);
	return;
    }
    for (xi = 0; xi <= w; xi++) {
	p->tileRuns[xi] = (Run*)(p->tileRuns + w + 1) + xi * h;
    }
    for (yi = 0; yi < h; yi++) {
	for (xi = 0; xi <= w; xi++) {
	    p->tileRuns[xi][yi] = NULL;
	}
    }

    (*fpp)->sendTo(env, fpp, p->runsBuilder);
    if (doeError_occurred(env)) {
	doeError_setNoMemory(env);
	return;
    }

    /* set things so [nextTile] will advance to the 1st tile */
    p->tileXI = w;
    p->tileYI = -1;
    (*pf)->nextTile(env, pf);
}
コード例 #13
0
void
dcPool_endCycle(doeE env, dcPool pool)
{
	dcPoolItem	item;
	ixx		ui = pool->ui;
	i32		u  = pool->U[ui];
	f32		sigma;
	f32		umean;
	ixx		bestpoolsize;
	ixx		poolsize;

	pool->sumU  -= u;
	pool->sumUU -= u*u;
	pool->U[ui] = u = pool->itemsMaxInUse;
	pool->itemsMaxInUse = 0;
	pool->sumU  += u;
	pool->sumUU += u*u;
	ui++;
	if (ui >= dcPool_samples) ui = 0;
	pool->ui = ui;

	umean = (f32)(pool->sumU) / dcPool_samples;
	sigma  = pool->sumUU + dcPool_samples*umean*umean - 2.0F*umean*pool->sumU;
	sigma /= (dcPool_samples - 1);
	sigma  = sqrt(sigma);
	bestpoolsize = ceil(umean + pool->xSigma * sigma);
	if (bestpoolsize < pool->itemMinInPool)
	    bestpoolsize = pool->itemMinInPool;

	poolsize = pool->itemsInPool;
#ifdef DEBUG_MEMSTATS
	pool->totalCycles++;
	pool->totalPool += poolsize;
	pool->totalUsed += u;
/*
      if (memstat_verbose) {
	printf("%20s: Uin=%3d   Umean=%6.2f sigma=%6.2f  allocation: curr=%3d, best=%3d",
		pool->poolName, u, umean, sigma, poolsize, bestpoolsize);
	if (poolsize > bestpoolsize)	printf(" excess freed");
	printf("\n");
      }
*/
#ifdef DEBUG_MEMSTATS_PER_CYCLE
	{
	    ixx i;
	    for (i = 0; i <= 100; i++) {
		if (i == u)	pool->aux[i] = 'U';
	    }
	}
      if (memstat_verbose) {
	printf("%20s %6d %s\n", pool->poolName, pool->totalCycles, pool->aux);
      }
#endif
#endif
	while (poolsize > bestpoolsize) {
	    poolsize--;
	    item = pool->freeItems;
	    pool->freeItems = item->next;
	    doeMem_free(env, item);
#ifdef DEBUG_MEMSTATS
	    pool->totalMem_free++;
#endif
	}
	pool->itemsInPool = poolsize;
#ifdef DEBUG_MEMSTATS_PER_CYCLE
	{
	    ixx i;
	    ixx min = floor(umean - pool->xSigma * sigma);
	    ixx max = ceil (umean + pool->xSigma * sigma);
	    ixx ave = floor(umean + 0.5);
	    for (i = 0; i <= 100; i++) {
		pool->aux[i] = ' ';
		if (i >= min && i <= max)	pool->aux[i] = '-';
		if (0 == i % 10)		pool->aux[i] = '|';
		if (i == ave)			pool->aux[i] = 'o';
		if (i == poolsize)		pool->aux[i] = 'A';
	    }
	}
#endif
}