Beispiel #1
0
void tmulti_page::remove_page(const unsigned page, unsigned count)
{
	assert(generator_);

	if(page >= get_page_count()) {
		return;
	}

	if(!count || count > get_page_count()) {
		count = get_page_count();
	}

	for(; count; --count) {
		generator_->delete_item(page);
	}
}
static enum PVRSRV_ERROR UnwrapExtMemoryCallBack(void *pvParam, u32 ui32Param)
{
	enum PVRSRV_ERROR eError = PVRSRV_OK;
	struct PVRSRV_KERNEL_MEM_INFO *psMemInfo = pvParam;
	void *hOSWrapMem;

	PVR_UNREFERENCED_PARAMETER(ui32Param);

	hOSWrapMem = psMemInfo->sMemBlk.hOSWrapMem;

	if (psMemInfo->psKernelSyncInfo)
		put_syncinfo(psMemInfo->psKernelSyncInfo);

	if (psMemInfo->sMemBlk.psIntSysPAddr) {
		int page_count;

		page_count = get_page_count((u32)psMemInfo->pvLinAddrKM,
				psMemInfo->ui32AllocSize);

		OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
			  page_count * sizeof(struct IMG_SYS_PHYADDR),
			  psMemInfo->sMemBlk.psIntSysPAddr, NULL);
	}

	if (eError == PVRSRV_OK) {
		psMemInfo->ui32RefCount--;
		eError = FreeDeviceMem(psMemInfo);
	}

	if (hOSWrapMem)
		OSReleasePhysPageAddr(hOSWrapMem);

	return eError;
}
static enum PVRSRV_ERROR UnmapDeviceMemoryCallBack(void *pvParam, u32 ui32Param)
{
	enum PVRSRV_ERROR eError;
	struct RESMAN_MAP_DEVICE_MEM_DATA *psMapData = pvParam;
	int page_count;

	PVR_UNREFERENCED_PARAMETER(ui32Param);

	page_count = get_page_count((u32)psMapData->psMemInfo->pvLinAddrKM,
				psMapData->psMemInfo->ui32AllocSize);

	if (psMapData->psMemInfo->sMemBlk.psIntSysPAddr)
		OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
			  page_count * sizeof(struct IMG_SYS_PHYADDR),
			  psMapData->psMemInfo->sMemBlk.psIntSysPAddr, NULL);

	eError = FreeDeviceMem(psMapData->psMemInfo);
	if (eError != PVRSRV_OK) {
		PVR_DPF(PVR_DBG_ERROR, "UnmapDeviceMemoryCallBack: "
				"Failed to free DST meminfo");
		return eError;
	}

	psMapData->psSrcMemInfo->ui32RefCount--;

	PVR_ASSERT(psMapData->psSrcMemInfo->ui32RefCount != (u32) (-1));
/*
 * Don't free the source MemInfo as we didn't allocate it
 * and it's not our job as the process the allocated
 * should also free it when it's finished
 */
	OSFreeMem(PVRSRV_OS_PAGEABLE_HEAP,
		  sizeof(struct RESMAN_MAP_DEVICE_MEM_DATA), psMapData, NULL);

	return eError;
}
Beispiel #4
0
static void begin_print(GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data)
{
	DocInfo *dinfo = user_data;
	PangoFontDescription *desc;
	gint i;
	gint style_max;

	if (dinfo == NULL)
		return;

	gtk_widget_show(main_widgets.progressbar);

	desc = pango_font_description_from_string(interface_prefs.editor_font);

	/* init dinfo fields */
	dinfo->lines = sci_get_line_count(dinfo->doc->editor->sci);
	dinfo->lines_per_page = 0;
	dinfo->cur_line = 0;
	dinfo->cur_pos = 0;
	dinfo->long_line = FALSE;
	dinfo->print_time = time(NULL);
	dinfo->max_line_number_margin = get_line_numbers_arity(dinfo->lines) + 1;
	/* increase font width by 1 (looks better) */
	dinfo->font_width = get_font_width(context, desc) + 1;
	/* create a PangoLayout to be commonly used in get_page_count and draw_page */
	dinfo->layout = setup_pango_layout(context, desc);
	/* this is necessary because of possible line breaks on the printed page and then
	 * lines_per_page differs from document line count */
	dinfo->n_pages = get_page_count(context, dinfo);

	/* read all styles from Scintilla */
	style_max = pow(2, scintilla_send_message(dinfo->doc->editor->sci, SCI_GETSTYLEBITS, 0, 0));
	/* if the lexer uses only the first 32 styles(style bits = 5),
	 * we need to add the pre-defined styles */
	if (style_max == 32)
		style_max = STYLE_LASTPREDEFINED;
	for (i = 0; i < style_max; i++)
	{
		dinfo->styles[i][FORE] = ROTATE_RGB(scintilla_send_message(
			dinfo->doc->editor->sci, SCI_STYLEGETFORE, i, 0));
		if (i == STYLE_LINENUMBER)
		{	/* ignore background colour for line number margin to avoid trouble with wrapped lines */
			dinfo->styles[STYLE_LINENUMBER][BACK] = ROTATE_RGB(scintilla_send_message(
				dinfo->doc->editor->sci, SCI_STYLEGETBACK, STYLE_DEFAULT, 0));
		}
		else
		{
			dinfo->styles[i][BACK] = ROTATE_RGB(scintilla_send_message(
				dinfo->doc->editor->sci, SCI_STYLEGETBACK, i, 0));
		}
		/* use white background color unless foreground is white to save ink */
		if (dinfo->styles[i][FORE] != 0xffffff)
			dinfo->styles[i][BACK] = 0xffffff;
		dinfo->styles[i][BOLD] =
			scintilla_send_message(dinfo->doc->editor->sci, SCI_STYLEGETBOLD, i, 0);
		dinfo->styles[i][ITALIC] =
			scintilla_send_message(dinfo->doc->editor->sci, SCI_STYLEGETITALIC, i, 0);
	}

	if (dinfo->n_pages >= 0)
		gtk_print_operation_set_n_pages(operation, dinfo->n_pages);

	pango_font_description_free(desc);
}