예제 #1
0
/*
 * Class:     sun_dc_pr_PathDasher
 * Method:    cClassInitialize
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_sun_dc_pr_PathDasher_cClassInitialize
  (JNIEnv *env, jclass cls)
{
    doeE	cenv	= doeE_make();
    doeE_setPCtxt(cenv, env);

    CJPathConsumer_staticInitialize(cenv);
    if (doeError_occurred(cenv)) {
	CJError_throw(cenv);
	return;
    }

    dcPathDasher_staticInitialize(cenv);
    if (doeError_occurred(cenv)) {
	CJError_throw(cenv);
	return;
    }

    doeE_destroy(cenv);

    /*
     * Cacheing the class specific data
     */
    clsDasher	= (*env)->NewGlobalRef(env, cls);
    fidCData	= (*env)->GetFieldID(env, cls, "cData", "J");
}
예제 #2
0
static void
useProxy(doeE env, dcPathConsumer pc, dcFastPathProducer proxy)
{
    dcPathFillerData*	p = (dcPathFillerData*)pc;
    dcFastPathProducer	fpp = p->thisFPP;

    ((dcPathConsumerFace*)&dcPathStoreClass)->useProxy(env, pc, proxy);
    if (doeError_occurred(env))	return;

    (*proxy)->getBox(env, proxy, p->pathBox);
    if (doeError_occurred(env))	return;

#ifdef DEBUG
   /*
    * Set the exception to indicate that some segments of the path have
    * way too large coordinates. The exception will be eaten at java level.
    * See 4485298 for more info.
    */
    if (!(	dcPathFiller_validLoCoord(p->pathBox[0])	&&
		dcPathFiller_validLoCoord(p->pathBox[1])	&&
		dcPathFiller_validHiCoord(p->pathBox[2])	&&
		dcPathFiller_validHiCoord(p->pathBox[3]))) {
	doeError_set(env, dcPathException, dcPathException_BAD_PATH_useProxy);
    }
#endif

 }
예제 #3
0
/*
 * Class:     sun_dc_pr_PathStroker
 * Method:    cInitialize
 * Signature: (Lsun/dc/path/PathConsumer;)V
 */
JNIEXPORT void JNICALL Java_sun_dc_pr_PathStroker_cInitialize
  (JNIEnv *env, jobject obj, jobject out)
{
    jclass	cls;
    jfieldID	fid;
    jmethodID	mid;

    PathStroker	cdata;

    doeE	cenv	= doeE_make();
    doeE_setPCtxt(cenv, env);

    cdata = (PathStroker)doeMem_malloc(cenv, sizeof(PathStrokerData));
    if (doeError_occurred(cenv)) {
	CJError_throw(cenv);
	return;
    }
    (*env)->SetLongField(env, obj, fidCData, ptr_to_jlong(cdata));

    /* __________________________
     * the c environment variable
     */
    cdata->env = cenv;

    /* Register the data for disposal */
    Disposer_AddRecord(env, obj, PathStroker_DisposeOps, ptr_to_jlong(cdata));

    /* __________________________________
     * the corresponding CJ path consumer
     * (always created so as to be able to deal with any type of
     *  incoming out path consumers)
     */
    cdata->cjout = CJPathConsumer_create(cenv, out);
    if (doeError_occurred(cenv)) {
	CJError_throw(cenv);
	return;
    }

    /* ________________________________________________
     * determines if "out" has a native implementation.
     */
    cls = (*env)->GetObjectClass(env, out);
    mid = (*env)->GetMethodID(env, cls, "getCPathConsumer", "()J");
    cdata->cout = (dcPathConsumer)
	jlong_to_ptr((*env)->CallLongMethod(env, out, mid));

    /* ________________________
     * the actual c PathStroker
     */
    if (cdata->cout) {
	cdata->stroker = dcPathStroker_create(cenv, cdata->cout);
    } else {
	cdata->stroker = dcPathStroker_create(cenv, (dcPathConsumer)cdata->cjout);
    }
    if (doeError_occurred(cenv)) {
	CJError_throw(cenv);
	return;
    }
}
예제 #4
0
/*
 * Class:     sun_dc_pr_PathDasher
 * Method:    setOutputT6
 * Signature: ([F)V
 */
JNIEXPORT void JNICALL Java_sun_dc_pr_PathDasher_setOutputT6
  (JNIEnv *env, jobject obj, jfloatArray t6)
{
    PathDasher	cdata	= (PathDasher)jlong_to_ptr(((*env)->GetLongField(env, obj, fidCData)));

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

    if (t6 == NULL) {
	(*cdata->dasher)->setOutputT6(cenv, cdata->dasher, NULL);
    } else {
	jfloat*	ct6;
	if (((*env)->GetArrayLength(env, t6)) < 6) {
	    doeError_set(cenv, dcPRError, dcPRError_BAD_outputt6);
	    CJError_throw(cenv);
	    return;
	}
	ct6 = (*env)->GetPrimitiveArrayCritical(env, t6, NULL);
	(*cdata->dasher)->setOutputT6(cenv, cdata->dasher, (f32*)ct6);
	(*env)->ReleasePrimitiveArrayCritical(env, t6, ct6, JNI_ABORT);
    }
    if (doeError_occurred(cenv))
	CJError_throw(cenv);
}
예제 #5
0
/*
 * Class:     sun_dc_pr_PathStroker
 * Method:    setPenT4
 * Signature: ([F)V
 */
JNIEXPORT void JNICALL Java_sun_dc_pr_PathStroker_setPenT4
  (JNIEnv *env, jobject obj, jfloatArray t4)
{
    PathStroker	cdata	= (PathStroker)jlong_to_ptr(((*env)->GetLongField(env, obj, fidCData)));

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

    if (t4 == NULL) {
	(*cdata->stroker)->setPenT4(cenv, cdata->stroker, NULL);
    } else {
	jfloat* ct4;
	if (((*env)->GetArrayLength(env, t4)) < 4) {
	    doeError_set(cenv, dcPRError, dcPRError_BAD_pent4);
	    CJError_throw(cenv);
	    return;
	}
	ct4 = (*env)->GetPrimitiveArrayCritical(env, t4, NULL);
	(*cdata->stroker)->setPenT4(cenv, cdata->stroker, (f32*)ct4);
	(*env)->ReleasePrimitiveArrayCritical(env, t4, ct4, JNI_ABORT);
    }
    if (doeError_occurred(cenv))
	CJError_throw(cenv);
}
예제 #6
0
/*
 * Class:     sun_dc_pr_PathStroker
 * Method:    cClassFinalize
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_sun_dc_pr_PathStroker_cClassFinalize
  (JNIEnv *env, jclass cls)
{
    doeE	cenv	= doeE_make();
    doeE_setPCtxt(cenv, env);

    CJPathConsumer_staticFinalize(cenv);
    if (doeError_occurred(cenv)) {
	CJError_throw(cenv);
	return;
    }
    dcPathStroker_staticFinalize(cenv);
    if (doeError_occurred(cenv)) {
	CJError_throw(cenv);
	return;
    }
    doeE_destroy(cenv);

    (*env)->DeleteGlobalRef(env, clsStroker);
}
예제 #7
0
/*
 * Class:     sun_dc_pr_PathStroker
 * Method:    cClassInitialize
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_sun_dc_pr_PathStroker_cClassInitialize
  (JNIEnv *env, jclass cls)
{
    jfieldID	fid;

    doeE	cenv	= doeE_make();
    doeE_setPCtxt(cenv, env);

    CJPathConsumer_staticInitialize(cenv);
    if (doeError_occurred(cenv)) {
	CJError_throw(cenv);
	return;
    }
    dcPathStroker_staticInitialize(cenv);
    if (doeError_occurred(cenv)) {
	CJError_throw(cenv);
	return;
    }
    doeE_destroy(cenv);

    /* ________________________________
     * Cacheing the class specific data
     */
    clsStroker	= (*env)->NewGlobalRef(env, cls);
    fidCData	= (*env)->GetFieldID(env, cls, "cData", "J");

    fid	    = (*env)->GetStaticFieldID (env, cls, "ROUND", "I");
    jround  = (*env)->GetStaticIntField(env, cls, fid);

    fid	    = (*env)->GetStaticFieldID (env, cls, "SQUARE", "I");
    jsquare = (*env)->GetStaticIntField(env, cls, fid);

    fid	    = (*env)->GetStaticFieldID (env, cls, "BUTT", "I");
    jbutt   = (*env)->GetStaticIntField(env, cls, fid);

    fid	    = (*env)->GetStaticFieldID (env, cls, "MITER", "I");
    jmiter  = (*env)->GetStaticIntField(env, cls, fid);

    fid	    = (*env)->GetStaticFieldID (env, cls, "BEVEL", "I");
    jbevel  = (*env)->GetStaticIntField(env, cls, fid);
}
예제 #8
0
/*
 * Class:     sun_dc_pr_PathStroker
 * Method:    reset
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_sun_dc_pr_PathStroker_reset
  (JNIEnv *env, jobject obj)
{
    PathStroker	cdata	= (PathStroker)jlong_to_ptr(((*env)->GetLongField(env, obj, fidCData)));

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

    (*cdata->stroker)->reset(cenv, cdata->stroker);
    if (doeError_occurred(cenv))
	CJError_throw(cenv);
}
예제 #9
0
static void
FastOutputPC_init(doeE env, dcPathConsumer target)
{
    FastOutputPCData*	p = (FastOutputPCData*)target;

    BASE_init(env, target);
    if (doeError_occurred(env)) {
	BASE__cleanup(env, target);
	return;
    }

    *target = (dcPathConsumerFace*)&FastOutputPCClass;
}
예제 #10
0
/*
 * Class:     sun_dc_pr_PathStroker
 * Method:    setOutputConsumer
 * Signature: (Lsun/dc/path/PathConsumer;)V
 */
JNIEXPORT void JNICALL Java_sun_dc_pr_PathStroker_setOutputConsumer
  (JNIEnv *env, jobject obj, jobject out)
{
    jclass	cls;
    jmethodID	mid;

    PathStroker	cdata	= (PathStroker)jlong_to_ptr(((*env)->GetLongField(env, obj, fidCData)));

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

    /* ________________________________________________
     * determines if "out" has a native implementation.
     */
    cls = (*env)->GetObjectClass(env, out);
    mid = (*env)->GetMethodID(env, cls, "getCPathConsumer", "()J");
    cdata->cout = (dcPathConsumer)
	jlong_to_ptr((*env)->CallLongMethod(env, out, mid));

    if (cdata->cout) {
	(*cdata->stroker)->setOutputConsumer(cenv, cdata->stroker, cdata->cout);
    } else {
	/*
	 * update CJ stub to use new java path consumer
	 */
	(*cdata->cjout)->setJPathConsumer(cenv, cdata->cjout, out);
	if (doeError_occurred(cenv)) {
	    CJError_throw(cenv);
	    return;
	}
	(*cdata->stroker)->setOutputConsumer(cenv, cdata->stroker,
					 (dcPathConsumer)cdata->cjout);
    }
    if (doeError_occurred(cenv))
	CJError_throw(cenv);
}
예제 #11
0
/*
 * Class:     sun_dc_pr_PathStroker
 * Method:    appendQuadratic
 * Signature: (FFFF)V
 */
JNIEXPORT void JNICALL Java_sun_dc_pr_PathStroker_appendQuadratic
  (JNIEnv *env, jobject obj, jfloat xm, jfloat ym, jfloat x1, jfloat y1)
{
    PathStroker	cdata	= (PathStroker)jlong_to_ptr(((*env)->GetLongField(env, obj, fidCData)));
    dcPathConsumer
		cstroker= (dcPathConsumer)(cdata->stroker);

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

    (*cstroker)->appendQuadratic(cenv, cstroker, xm, ym, x1, y1);
    if (doeError_occurred(cenv))
	CJError_throw(cenv);
}
예제 #12
0
/*
 * Class:     sun_dc_pr_PathStroker
 * Method:    beginSubpath
 * Signature: (FF)V
 */
JNIEXPORT void JNICALL Java_sun_dc_pr_PathStroker_beginSubpath
  (JNIEnv *env, jobject obj, jfloat x0, jfloat y0)
{
    PathStroker	cdata	= (PathStroker)jlong_to_ptr(((*env)->GetLongField(env, obj, fidCData)));
    dcPathConsumer
		cstroker= (dcPathConsumer)(cdata->stroker);

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

    (*cstroker)->beginSubpath(cenv, cstroker, x0, y0);
    if (doeError_occurred(cenv))
	CJError_throw(cenv);
}
예제 #13
0
static void
RunsBuilder_init(doeE env, dcPathConsumer target, dcPathFillerData* pfp)
{
    RunsBuilderData*	p = (RunsBuilderData*)target;

    BASE_init(env, target);
    if (doeError_occurred(env)) {
	BASE__cleanup(env, target);
	return;
    }

    *target = &RunsBuilderClass;

    p->pfp = pfp;
}
예제 #14
0
/*
 * Class:     sun_dc_pr_PathDasher
 * Method:    closedSubpath
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_sun_dc_pr_PathDasher_closedSubpath
  (JNIEnv *env, jobject obj)
{
    PathDasher	cdata	= (PathDasher)jlong_to_ptr(((*env)->GetLongField(env, obj, fidCData)));
    dcPathConsumer
		cdasher	= (dcPathConsumer)(cdata->dasher);

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

    (*cdasher)->closedSubpath(cenv, cdasher);
    if (doeError_occurred(cenv))
	CJError_throw(cenv);
}
예제 #15
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;
}
예제 #16
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;
}
예제 #17
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;
}
예제 #18
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;
}
예제 #19
0
/*
 * Class:     sun_dc_pr_PathDasher
 * Method:    setDash
 * Signature: ([FF)V
 */
JNIEXPORT void JNICALL Java_sun_dc_pr_PathDasher_setDash
  (JNIEnv *env, jobject obj, jfloatArray dash, jfloat offset)
{
    PathDasher	cdata	= (PathDasher)jlong_to_ptr(((*env)->GetLongField(env, obj, fidCData)));

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

    if (dash == NULL) {
	(*cdata->dasher)->setDash(cenv, cdata->dasher, NULL, 0, offset);
    } else {
	jint	len	= (*env)->GetArrayLength(env, dash);
	jfloat*	cdash	= (*env)->GetPrimitiveArrayCritical(env, dash, NULL);  

	(*cdata->dasher)->setDash(cenv, cdata->dasher, cdash, len, offset);
	(*env)->ReleasePrimitiveArrayCritical(env, dash, cdash, JNI_ABORT);
    }
    if (doeError_occurred(cenv))
	CJError_throw(cenv);
}
예제 #20
0
static void
writeAlpha16(	doeE env, dcPathFiller pf,
		u16* alpha, i32 xstride, i32 ystride, i32 pix0offset)
{
    dcPathFillerData*	p = (dcPathFillerData*)pf;
    dcLLFiller		ll;

    if (!stateCheck(p, setOutputAreaDone)) {
	doeError_set(env, dcPRError, dcPRError_UNEX_writeAlpha);
	return;
    }
    if (alpha == NULL || xstride <= 0 || ystride <= 0 || pix0offset < 0) {
	doeError_set(env, dcPRError, dcPRError_BAD_alphadest);
	return;
    }

    ll = dcLLFiller_get(env);
    if (doeError_occurred(env))
	return;

    if (p->fastOutput) {
	FastOutputPC		fopc = p->fastOutputPC;
	dcFastPathProducer	fpp  = p->thisFPP;

	(*ll)->setParams(env, ll, p->fillmode, p->outW, p->outH);
	(*fopc)->setUpAlpha16(	env, fopc, ll,
				-p->outLoX, -p->outLoY,
				alpha, xstride, ystride, pix0offset);
	(*fpp)->sendTo(env, fpp, (dcPathConsumer)fopc);
    } else {
	i32 tilew = MIN(p->outW -  ((p->tileXI - 1) << dcPathFiller_tileSizeL2S),
			dcPathFiller_tileSize);
	(*ll)->setParams(env, ll, p->fillmode, tilew, p->rowH);
	sendTileToLLFiller(env, pf, ll);
	(*ll)->writeAlpha16(env, ll, alpha, xstride, ystride, pix0offset);
    }
    dcLLFiller_release(env, ll);

    nextTile(env,pf);
}
예제 #21
0
/*
 * Class:     sun_dc_pr_PathStroker
 * Method:    setCorners
 * Signature: (IF)V
 */
JNIEXPORT void JNICALL Java_sun_dc_pr_PathStroker_setCorners
  (JNIEnv *env, jobject obj, jint corners, jfloat miterlimit)
{
    PathStroker	cdata	= (PathStroker)jlong_to_ptr(((*env)->GetLongField(env, obj, fidCData)));

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

    if (corners == jround)
	corners = dcPathStroker_ROUND;
    else
	if (corners == jmiter)
	    corners = dcPathStroker_MITER;
	else
	    if (corners == jbevel)
		corners = dcPathStroker_BEVEL;

    (*cdata->stroker)->setCorners(cenv, cdata->stroker, corners, miterlimit);
    if (doeError_occurred(cenv))
	CJError_throw(cenv);
}
예제 #22
0
/*
 * Class:     sun_dc_pr_PathStroker
 * Method:    setCaps
 * Signature: (I)V
 */
JNIEXPORT void JNICALL Java_sun_dc_pr_PathStroker_setCaps
  (JNIEnv *env, jobject obj, jint caps)
{
    PathStroker	cdata	= (PathStroker)jlong_to_ptr(((*env)->GetLongField(env, obj, fidCData)));

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

    if (caps == jround)
	caps = dcPathStroker_ROUND;
    else
	if (caps == jsquare)
	    caps = dcPathStroker_SQUARE;
	else
	    if (caps == jbutt)
		caps = dcPathStroker_BUTT;

    (*cdata->stroker)->setCaps(cenv, cdata->stroker, caps);
    if (doeError_occurred(cenv))
	CJError_throw(cenv);
}
예제 #23
0
void
dcPathFiller_staticInitialize(doeE env)
{
    if (clients++ > 0) return;

    dcPool_staticInitialize(env);
    dcPathStore_staticInitialize(env);
    dcLLFiller_staticInitialize(env);
    FastOutputPC_staticInitialize(env);

    if (doeError_occurred(env)) {
	doeError_setNoMemory(env);
	return;
    }

    dcPathFiller_tileSizeL2S = dcLLFiller_tileSizeL2S;
    dcPathFiller_tileSize    = 1 << dcPathFiller_tileSizeL2S;
    dcPathFiller_tileSizeF   = (f32)dcPathFiller_tileSize;

    runCheckCost =	 77.0F;

    KArc2 =		158.0F;
    LArc2 =		runCheckCost + 46.0F;
    MArc2 =		(f32)dcLLFiller_ticsSetupArc2;
    NArc2 =		(f32)dcLLFiller_ticsStepArc2;
    DIV2Arc2 =		2.00 *	(2 * KArc2 + LArc2 + MArc2) /
				(2 * NArc2 * dcPathFiller_tileSizeF);
    DIV4Arc2 =		0.67 *	(2 * KArc2 + .5F * LArc2 + .5F * MArc2) /
				(2 * NArc2 * dcPathFiller_tileSizeF);

    KArc3 =		206.0F;
    LArc3 =		runCheckCost + 67.0F;
    MArc3 =		(f32)dcLLFiller_ticsSetupArc3;
    NArc3 =		(f32)dcLLFiller_ticsStepArc3;
    DIV2Arc3 =		2.00 *	(2 * KArc3 + LArc3 + MArc3) /
				(2 * NArc3 * dcPathFiller_tileSizeF);
    DIV4Arc3 =		0.67 *	(2 * KArc3 + .5F * LArc3 + .5F * MArc3) /
				(2 * NArc3 * dcPathFiller_tileSizeF);
  }
예제 #24
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;
}
예제 #25
0
void
dcPathFiller_init(doeE env, dcPathFiller pf)
{
    dcPathFillerData*	p  = (dcPathFillerData*)pf;
    dcPathStore		ps = (dcPathStore) pf;

    p->redundantReset = FALSE;

    p->tileRuns = NULL;
    p->lsEffects = NULL;
    p->runsBuilder = NULL;
    p->fastOutputPC = NULL;

    BASE_init(env, pf);

    *pf = &dcPathFillerClass;

    p->poolRun =	dcPool_create(env,	"Run's pool",
						sizeof(RunData),	0, 1.0);
    p->poolLeftSide =	dcPool_create(env,	"LeftSide's pool",
						sizeof(LeftSideData),	0, 1.0);
    p->xtsize = 40;
    p->xt = doeMem_malloc(env, sizeof(f32)*p->xtsize);
    p->ytsize = 40;
    p->yt = doeMem_malloc(env, sizeof(f32)*p->ytsize);
    if (p->xt == NULL || p->yt == NULL) {
	doeError_setNoMemory(env);
    }
    p->thisFPP = (*ps)->getFastPathProducer(env, ps);
    p->runsBuilder = RunsBuilder_create(env, p);
    p->fastOutputPC = (FastOutputPC)FastOutputPC_create(env);

    if (doeError_occurred(env))	return;

    reset(env, pf);
}
예제 #26
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);
}