/*
 * Class:     org_libharu_PdfPage
 * Method:    closePath
 * Signature: ()V
 */
JNIEXPORT void JNICALL
Java_org_libharu_PdfPage_closePath(JNIEnv *env, jobject obj) {
    jint page;
    /* Get mHPDFPagePointer */
    page = (*env)->GetIntField(env, obj, mHPDFPagePointer);
    HPDF_Page_ClosePath((HPDF_Page) page);
}
Ejemplo n.º 2
0
bool pdf_plot_path(const float *p, unsigned int n, colour fill, float width,
		colour c, const float transform[6])
{
	unsigned int i;
	bool empty_path;

#ifdef PDF_DEBUG
	NSLOG(netsurf, INFO, ".");
#endif

	if (n == 0)
		return true;

	if (c == NS_TRANSPARENT && fill == NS_TRANSPARENT)
		return true;

	if (p[0] != PLOTTER_PATH_MOVE)
		return false;

	apply_clip_and_mode(false, fill, c, width, DashPattern_eNone);

	empty_path = true;
	for (i = 0 ; i < n ; ) {
		if (p[i] == PLOTTER_PATH_MOVE) {
			HPDF_Page_MoveTo(pdf_page,
					transform_x(transform, p[i+1], p[i+2]),
					transform_y(transform, p[i+1], p[i+2]));
			i+= 3;
		} else if (p[i] == PLOTTER_PATH_CLOSE) {
			if (!empty_path)
				HPDF_Page_ClosePath(pdf_page);
			i++;
		} else if (p[i] == PLOTTER_PATH_LINE) {
			HPDF_Page_LineTo(pdf_page,
					transform_x(transform, p[i+1], p[i+2]),
					transform_y(transform, p[i+1], p[i+2]));
			i+=3;
			empty_path = false;
		} else if (p[i] == PLOTTER_PATH_BEZIER) {
			HPDF_Page_CurveTo(pdf_page,
					transform_x(transform, p[i+1], p[i+2]),
					transform_y(transform, p[i+1], p[i+2]),
					transform_x(transform, p[i+3], p[i+4]),
					transform_y(transform, p[i+3], p[i+4]),
					transform_x(transform, p[i+5], p[i+6]),
					transform_y(transform, p[i+5], p[i+6]));
			i += 7;
			empty_path = false;
		} else {
			NSLOG(netsurf, INFO, "bad path command %f", p[i]);
			return false;
		}
	}

	if (empty_path) {
		HPDF_Page_EndPath(pdf_page);
		return true;
	}

	if (fill != NS_TRANSPARENT) {
		if (c != NS_TRANSPARENT)
			HPDF_Page_FillStroke(pdf_page);
		else
			HPDF_Page_Fill(pdf_page);
	}
	else
		HPDF_Page_Stroke(pdf_page);

	return true;
}