/*------------------------------------------------------------------------------

    Function name: af_set_type

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_RET af_set_type(isp_af_context_t *af, IM_UINT32 type)
{ 
 	IM_INFOMSG((IM_STR("%s"), IM_STR(_IM_FUNC_)));
	
	IM_ASSERT(af != IM_NULL);
	IM_ASSERT(af->regVal != IM_NULL);
	IM_ASSERT(af->regOfst != IM_NULL);

	/*check af type*/
	if(type > ISP_AF_TYPE_NINE_WINS)
	{
		IM_ERRMSG((IM_STR("Invalid type: type=%d"), type));
		return IM_RET_INVALID_PARAMETER;
	}

	if(af->type == type)
	{
		IM_INFOMSG((IM_STR("af has already been this type")));
		return IM_RET_OK;	
	}
		
	if(af->enable == IM_TRUE)
	{
		SetIspRegister(af->regVal, ISP_AF_CNTL_TYPE, type);
		IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_CNTL], af->regVal[rISP_AF_CNTL]));
	}

	af->type = type;
	return IM_RET_OK;
	
Fail:
	return IM_RET_FAILED;
}
/*------------------------------------------------------------------------------

    Function name: af_get_result

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_RET af_get_result(isp_af_context_t *af, isp_af_result_t *rsut)
{ 
	IM_UINT32 i;
 	IM_INFOMSG((IM_STR("%s"), IM_STR(_IM_FUNC_)));
	
	IM_ASSERT(af != IM_NULL);
	IM_ASSERT(af->regVal != IM_NULL);
	IM_ASSERT(af->regOfst != IM_NULL);
	IM_ASSERT(rsut != IM_NULL);

	IM_JIF(isppwl_read_reg(af->regOfst[rISP_AF_RSUT], &af->regVal[rISP_AF_RSUT]));
	af->rsut.value = GetIspRegister(af->regVal, ISP_AF_RSUT);
	rsut->value = af->rsut.value;

	for(i=0; i<9; i++)
	{
		IM_JIF(isppwl_read_reg(af->regOfst[rISP_AF_CNT0 + i], &af->regVal[rISP_AF_CNT0 + i]));
		af->rsut.cnt[i] = GetIspRegister(af->regVal, ISP_AF_CNT0+i);
		rsut->cnt[i] = af->rsut.cnt[i];	
	}

	return IM_RET_OK;
	
Fail:
	return IM_RET_FAILED;
}
/*------------------------------------------------------------------------------

    Function name: hist_set_hist_threshold_matrix

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_RET hist_set_hist_threshold_matrix(isp_hist_context_t *hist, isp_hist_thr_matrix *thrMat)
{ 
 	IM_INFOMSG((IM_STR("%s"), IM_STR(_IM_FUNC_)));
	
	IM_ASSERT(hist != IM_NULL);
	IM_ASSERT(hist->regVal != IM_NULL);
	IM_ASSERT(hist->regOfst != IM_NULL);
	IM_ASSERT(thrMat != IM_NULL);

	/*check hist threshold*/
	if((thrMat->th1 < 0) || (thrMat->th1 > 127)
		|| (thrMat->th2 < 0) || (thrMat->th2 > 255))
	{
		IM_ERRMSG((IM_STR("Invalid threshold:  th1=%d, th2=%d"), 
			 thrMat->th1, thrMat->th2));
		return IM_RET_INVALID_PARAMETER;
	}

	if(hist->enable == IM_TRUE)
	{
		/*set hist threshold*/ 
		SetIspRegister(hist->regVal, ISP_HIST_TH_1, thrMat->th1);
		SetIspRegister(hist->regVal, ISP_HIST_TH_2, thrMat->th2);
		 
		IM_JIF(isppwl_write_reg(hist->regOfst[rISP_HIST_TH], hist->regVal[rISP_HIST_TH]));
	}

	isppwl_memcpy((void*)(&hist->thrMat), (void *)(thrMat), sizeof(isp_hist_thr_matrix));	
	return IM_RET_OK;
	
Fail:
	return IM_RET_FAILED;
}
/*------------------------------------------------------------------------------

    Function name: hist_set_enable

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_RET hist_set_enable(isp_hist_context_t *hist)
{ 
 	IM_INFOMSG((IM_STR("%s"), IM_STR(_IM_FUNC_)));
	
	IM_ASSERT(hist != IM_NULL);
	IM_ASSERT(hist->regVal != IM_NULL);
	IM_ASSERT(hist->regOfst != IM_NULL);

	if(hist->enable == IM_TRUE)
	{
		IM_INFOMSG((IM_STR("hist has been enabled")));
		return IM_RET_OK;	
	}
	//enable hist 
	/*set hist and backlit threshold*/
	SetIspRegister(hist->regVal, ISP_BLIT_TH1, hist->blitTh1);
	SetIspRegister(hist->regVal, ISP_HIST_TH_1, hist->thrMat.th1);
	SetIspRegister(hist->regVal, ISP_HIST_TH_2, hist->thrMat.th2);
	/*set hist enable*/
	SetIspRegister(hist->regVal, ISP_GLB_CFG2_HISTBYPASS, 0);

	IM_JIF(isppwl_write_reg(hist->regOfst[rISP_BLIT_TH], hist->regVal[rISP_BLIT_TH]));
	IM_JIF(isppwl_write_reg(hist->regOfst[rISP_HIST_TH], hist->regVal[rISP_HIST_TH]));
	IM_JIF(isppwl_write_reg(hist->regOfst[rISP_GLB_CFG2], hist->regVal[rISP_GLB_CFG2]));

	hist->enable = IM_TRUE;
	return IM_RET_OK;
	
Fail:
	return IM_RET_FAILED;
}
IM_RET dmmupwl_free_linear_page_align_memory(IN IM_Buffer *buffer)
{
	//ptable_mem_t *ptm;
	IM_INFOMSG((IM_STR("%s()"), IM_STR(_IM_FUNC_)));
#if 0
	ptm = (ptable_mem_t *)im_list_begin(gPwl->ptmlist);
	IM_ASSERT(ptm != IM_NULL);
	while(ptm != IM_NULL){
		if(ptm->kVirAddrRemap == buffer->vir_addr){
			break;
		}
		ptm = (ptable_mem_t *)im_list_next(gPwl->ptmlist);
	}
	IM_ASSERT(ptm != IM_NULL);
	IM_ASSERT(ptm->kVirAddrRemap != IM_NULL);
	IM_ASSERT(ptm->kVirAddr != IM_NULL);

	IM_INFOMSG((IM_STR("ptm->kVirAddr=0x%x"), (IM_INT32)ptm->kVirAddr));
	IM_INFOMSG((IM_STR("ptm->kVirAddrRemap=0x%x"), (IM_INT32)ptm->kVirAddrRemap));

	iounmap(ptm->kVirAddrRemap);
	//kfree(ptm->kVirAddr);
	free_page((IM_UINT32)ptm->kVirAddr);
	im_list_erase(gPwl->ptmlist, ptm);

	return IM_RET_OK;
#else	
	IM_INFOMSG((IM_STR("buffer vir_addr=0x%x, phy_addr=0x%x"), (IM_UINT32)buffer->vir_addr, buffer->phy_addr));
	dma_unmap_page(NULL, buffer->phy_addr, PAGE_SIZE, DMA_BIDIRECTIONAL);
	__free_page(virt_to_page(buffer->vir_addr));
	return IM_RET_OK;
#endif	
}
/*------------------------------------------------------------------------------

    Function name: ae_get_result

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_RET ae_get_result(isp_ae_context_t *ae, isp_ae_result_t *rsut)
{ 
	IM_UINT32 i;
 	IM_INFOMSG((IM_STR("%s"), IM_STR(_IM_FUNC_)));
	
	IM_ASSERT(ae != IM_NULL);
	IM_ASSERT(ae->regVal != IM_NULL);
	IM_ASSERT(ae->regOfst != IM_NULL);
	IM_ASSERT(rsut != IM_NULL);

	IM_JIF(isppwl_read_reg(ae->regOfst[rISP_AE_YAVG], &ae->regVal[rISP_AE_YAVG]));
	rsut->avg = GetIspRegister(ae->regVal, ISP_AE_YAVG);
	
	//isppwl_read_regs();
	for(i=0; i<25; i++)
	{
		IM_JIF(isppwl_read_reg(ae->regOfst[rISP_COUNTER00 + i], &ae->regVal[rISP_COUNTER00 + i]));
		rsut->cnt[i] = GetIspRegister(ae->regVal, ISP_COUNTER00+i);
	}
		
	return IM_RET_OK;
	
Fail:
	return IM_RET_FAILED;
}
/*------------------------------------------------------------------------------

    Function name: hist_set_hist_threshold_matrix

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_RET hist_set_backlit_threshold(isp_hist_context_t *hist, IM_UINT32 blitTh1)
{
 	IM_INFOMSG((IM_STR("%s"), IM_STR(_IM_FUNC_)));
	
	IM_ASSERT(hist != IM_NULL);
	IM_ASSERT(hist->regVal != IM_NULL);
	IM_ASSERT(hist->regOfst != IM_NULL);

	/*check hist threshold*/
	if((blitTh1 < 0) || (blitTh1 > 16777215))
	{
		IM_ERRMSG((IM_STR("Invalid backlit threshold: blitTh1=%d"), blitTh1));
		return IM_RET_INVALID_PARAMETER;
	}

	if(hist->enable == IM_TRUE)
	{
		/*set backlit threshold*/
		SetIspRegister(hist->regVal, ISP_BLIT_TH1, blitTh1);
		
		IM_JIF(isppwl_write_reg(hist->regOfst[rISP_BLIT_TH], hist->regVal[rISP_BLIT_TH]));
	}

	hist->blitTh1 = blitTh1;
	return IM_RET_OK;
	
Fail:
	return IM_RET_FAILED;
}
/*------------------------------------------------------------------------------

    Function name: hist_get_result

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_RET hist_get_result(isp_hist_context_t *hist, isp_hist_result_t *rsut)
{ 
	IM_UINT32 i;
 	IM_INFOMSG((IM_STR("%s"), IM_STR(_IM_FUNC_)));
	
	IM_ASSERT(hist != IM_NULL);
	IM_ASSERT(hist->regVal != IM_NULL);
	IM_ASSERT(hist->regOfst != IM_NULL);
	IM_ASSERT(rsut != IM_NULL);

	IM_JIF(isppwl_read_reg(hist->regOfst[rISP_BACK_LIT], &hist->regVal[rISP_BACK_LIT]));
	hist->rsut.bkLit = GetIspRegister(hist->regVal, ISP_BACK_LIT);
	rsut->bkLit = hist->rsut.bkLit;
	
	for(i=0; i<16; i++)
	{
		IM_JIF(isppwl_read_reg(hist->regOfst[rISP_HIST_COUNTER1 + i], &hist->regVal[rISP_HIST_COUNTER1 + i]));
		hist->rsut.hist[i] = GetIspRegister(hist->regVal, ISP_HIST_COUNTER1+i);
		rsut->hist[i] = hist->rsut.hist[i];
	}
		
	return IM_RET_OK;
	
Fail:
	return IM_RET_FAILED;
}
/*------------------------------------------------------------------------------

    Function name: af_set_enable

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_RET af_set_enable(isp_af_context_t *af)
{
	IM_UINT32 i;
 	IM_INFOMSG((IM_STR("%s"), IM_STR(_IM_FUNC_)));
	
	IM_ASSERT(af != IM_NULL);
	IM_ASSERT(af->regVal != IM_NULL);
	IM_ASSERT(af->regOfst != IM_NULL);

	if(af->enable == IM_TRUE)
	{
		IM_INFOMSG((IM_STR("af has been enabled")));
		return IM_RET_OK;	
	}
	
	/*set af type*/
	SetIspRegister(af->regVal, ISP_AF_CNTL_TYPE, af->type);

	/*set af block coordinate*/
	for(i=0; i<9; i++)
	{
		SetIspRegister(af->regVal, ISP_AF_P0ST_X00+4*i, af->coordinate.blokPos[i].x0);
		SetIspRegister(af->regVal, ISP_AF_P0ST_Y00+4*i, af->coordinate.blokPos[i].y0);
		SetIspRegister(af->regVal, ISP_AF_P0ED_X01+4*i, af->coordinate.blokPos[i].x1);
		SetIspRegister(af->regVal, ISP_AF_P0ED_Y01+4*i, af->coordinate.blokPos[i].y1);
	}

	/*set af enable*/
	SetIspRegister(af->regVal, ISP_GLB_CFG2_AFBYPASS, 0);

	//isppwl_write_regs();
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_CNTL], af->regVal[rISP_AF_CNTL]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P0ST], af->regVal[rISP_AF_P0ST]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P0ED], af->regVal[rISP_AF_P0ED]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P1ST], af->regVal[rISP_AF_P1ST]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P1ED], af->regVal[rISP_AF_P1ED]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P2ST], af->regVal[rISP_AF_P2ST]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P2ED], af->regVal[rISP_AF_P2ED]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P3ST], af->regVal[rISP_AF_P3ST]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P3ED], af->regVal[rISP_AF_P3ED]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P4ST], af->regVal[rISP_AF_P4ST]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P4ED], af->regVal[rISP_AF_P4ED]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P5ST], af->regVal[rISP_AF_P5ST]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P5ED], af->regVal[rISP_AF_P5ED]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P6ST], af->regVal[rISP_AF_P6ST]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P6ED], af->regVal[rISP_AF_P6ED]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P7ST], af->regVal[rISP_AF_P7ST]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P7ED], af->regVal[rISP_AF_P7ED]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P8ST], af->regVal[rISP_AF_P8ST]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_AF_P8ED], af->regVal[rISP_AF_P8ED]));
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_GLB_CFG2], af->regVal[rISP_GLB_CFG2]));

	af->enable = IM_TRUE;
	return IM_RET_OK;
	
Fail:
	return IM_RET_FAILED;
}
/*------------------------------------------------------------------------------

    Function name: ae_set_enable

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_RET ae_set_enable(isp_ae_context_t *ae)
{
	IM_UINT32 i;
 	IM_INFOMSG((IM_STR("%s"), IM_STR(_IM_FUNC_)));
	
	IM_ASSERT(ae != IM_NULL);
	IM_ASSERT(ae->regVal != IM_NULL);
	IM_ASSERT(ae->regOfst != IM_NULL);

	if(ae->enable == IM_TRUE)
	{
		IM_INFOMSG((IM_STR("ae has been enabled")));
		return IM_RET_OK;	
	}

	/*set ae block num*/
	if(ae->blokSelect.blokNum == 0)
	{
		SetIspRegister(ae->regVal, ISP_AE_CNTL_NUM_1, (1<<15)/25);
	}
	else
	{
		SetIspRegister(ae->regVal, ISP_AE_CNTL_NUM_1, (1<<15)/(ae->blokSelect.blokNum));
	}
	
	/*set ae block enable*/
	SetIspRegister(ae->regVal, ISP_AE_BEN, ae->blokSelect.blokEn);

	//set log2(block pixnum)
	SetIspRegister(ae->regVal, ISP_AE_CNTL_PNUM_N, ae->coordinate.log2_blokPixNum);
	
	//set block blokPosition
	for(i=0; i<25; i++)
	{
		SetIspRegister(ae->regVal, (ISP_AE_X00_1+i*4), ae->coordinate.blokPos[i].x1);
		SetIspRegister(ae->regVal, (ISP_AE_X00_0+i*4), ae->coordinate.blokPos[i].x0);
		SetIspRegister(ae->regVal, (ISP_AE_Y00_1+i*4), ae->coordinate.blokPos[i].y1);
		SetIspRegister(ae->regVal, (ISP_AE_Y00_0+i*4), ae->coordinate.blokPos[i].y0);

		IM_JIF(isppwl_write_reg(ae->regOfst[rISP_AE_X00+i*2], ae->regVal[rISP_AE_X00+i*2]));
		IM_JIF(isppwl_write_reg(ae->regOfst[rISP_AE_Y00+i*2], ae->regVal[rISP_AE_Y00+i*2]));
	}
	
	/*set ae bypass*/
	SetIspRegister(ae->regVal, ISP_GLB_CFG2_AEBYPASS, 0);

	//isppwl_write_regs();
	IM_JIF(isppwl_write_reg(ae->regOfst[rISP_AE_CNTL], ae->regVal[rISP_AE_CNTL]));
	IM_JIF(isppwl_write_reg(ae->regOfst[rISP_AE_BEN], ae->regVal[rISP_AE_BEN]));		
	IM_JIF(isppwl_write_reg(ae->regOfst[rISP_GLB_CFG2], ae->regVal[rISP_GLB_CFG2]));

	ae->enable = IM_TRUE;
	return IM_RET_OK;
	
Fail:
	return IM_RET_FAILED;
}
/*------------------------------------------------------------------------------

    Function name: ae_set_block_coordinate

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_RET ae_set_block_coordinate(isp_ae_context_t *ae, isp_ae_coordinate_t *coordinate)
{
	IM_UINT32	i;
 	IM_INFOMSG((IM_STR("%s"), IM_STR(_IM_FUNC_)));
	
	IM_ASSERT(ae != IM_NULL);
	IM_ASSERT(ae->regVal != IM_NULL);
	IM_ASSERT(ae->regOfst != IM_NULL);
	IM_ASSERT(coordinate != IM_NULL);

	//check log2(block pixnum)
	if(coordinate->log2_blokPixNum > 31)
	{
		IM_ERRMSG((IM_STR("Invalid log2_blokPixNum=%d"), coordinate->log2_blokPixNum));
		return IM_RET_INVALID_PARAMETER;
	}

	//check block blokPosition
	for(i=0; i<25; i++)
	{
		if((coordinate->blokPos[i].x0 < 0) || (coordinate->blokPos[i].x0 > 4095)
			|| (coordinate->blokPos[i].y0 < 0) || (coordinate->blokPos[i].y0 > 4095)
			|| (coordinate->blokPos[i].x1 < 0) || (coordinate->blokPos[i].x1 > 4095)
			|| (coordinate->blokPos[i].y1 < 0) || (coordinate->blokPos[i].y1 > 4095))
		{
			IM_ERRMSG((IM_STR("Invalid blokPosition[%d]: x0=%d, y0=%d, x1=%d, y1=%d"),
				i, coordinate->blokPos[i].x0, coordinate->blokPos[i].y0, coordinate->blokPos[i].x1, coordinate->blokPos[i].y1));
			return IM_RET_INVALID_PARAMETER;
		}
	}
	
	if(ae->enable == IM_TRUE)
	{	
		//set log2(block pixnum)
		SetIspRegister(ae->regVal, ISP_AE_CNTL_PNUM_N, coordinate->log2_blokPixNum);
		IM_JIF(isppwl_write_reg(ae->regOfst[rISP_AE_CNTL], ae->regVal[rISP_AE_CNTL]));
		
		//set block blokPosition
		for(i=0; i<25; i++)
		{
			SetIspRegister(ae->regVal, (ISP_AE_X00_1+i*4), coordinate->blokPos[i].x1);
			SetIspRegister(ae->regVal, (ISP_AE_X00_0+i*4), coordinate->blokPos[i].x0);
			SetIspRegister(ae->regVal, (ISP_AE_Y00_1+i*4), coordinate->blokPos[i].y1);
			SetIspRegister(ae->regVal, (ISP_AE_Y00_0+i*4), coordinate->blokPos[i].y0);

			IM_JIF(isppwl_write_reg(ae->regOfst[rISP_AE_X00+i*2], ae->regVal[rISP_AE_X00+i*2]));
			IM_JIF(isppwl_write_reg(ae->regOfst[rISP_AE_Y00+i*2], ae->regVal[rISP_AE_Y00+i*2]));
		}
	}
	
	isppwl_memcpy((void*)(&ae->coordinate), (void *)(coordinate), sizeof(isp_ae_coordinate_t));
	return IM_RET_OK;
	
Fail:
	return IM_RET_FAILED;
}
Beispiel #12
0
void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
{
    ImGuiIO& io = ImGui::GetIO();
    IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");

    // Setup display size (every frame to accommodate for window resizing)
    int w, h;
    int display_w, display_h;
    SDL_GetWindowSize(window, &w, &h);
    SDL_GL_GetDrawableSize(window, &display_w, &display_h);
    io.DisplaySize = ImVec2((float)w, (float)h);
    if (w > 0 && h > 0)
        io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);

    // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
    static Uint64 frequency = SDL_GetPerformanceFrequency();
    Uint64 current_time = SDL_GetPerformanceCounter();
    io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
    g_Time = current_time;

    ImGui_ImplSDL2_UpdateMousePosAndButtons();
    ImGui_ImplSDL2_UpdateMouseCursor();

    // Update game controllers (if enabled and available)
    ImGui_ImplSDL2_UpdateGamepads();
}
// Functions
bool    ImGui_ImplOpenGL3_Init(const char* glsl_version)
{
    ImGuiIO& io = ImGui::GetIO();
    io.BackendRendererName = "imgui_impl_opengl3";

    // Store GLSL version string so we can refer to it later in case we recreate shaders. Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure.
#if defined(IMGUI_IMPL_OPENGL_ES2)
    if (glsl_version == NULL)
        glsl_version = "#version 100";
#elif defined(IMGUI_IMPL_OPENGL_ES3)
    if (glsl_version == NULL)
        glsl_version = "#version 300 es";
#else
    if (glsl_version == NULL)
        glsl_version = "#version 130";
#endif
    IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(g_GlslVersionString));
    strcpy(g_GlslVersionString, glsl_version);
    strcat(g_GlslVersionString, "\n");

    // Make a dummy GL call (we don't actually need the result)
    // IF YOU GET A CRASH HERE: it probably means that you haven't initialized the OpenGL function loader used by this code.
    // Desktop OpenGL 3/4 need a function loader. See the IMGUI_IMPL_OPENGL_LOADER_xxx explanation above.
    GLint current_texture;
    glGetIntegerv(GL_TEXTURE_BINDING_2D, &current_texture);

    return true;
}
Beispiel #14
0
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	if (ImGui_ImplDX9_WndProcHandler(hWnd, msg, wParam, lParam))
		return true;

	switch (msg) {
	case WM_SIZE:
		if (g_pd3dDevice != NULL && wParam != SIZE_MINIMIZED) {
			ImGui_ImplDX9_InvalidateDeviceObjects();
			g_d3dpp.BackBufferWidth = LOWORD(lParam);
			g_d3dpp.BackBufferHeight = HIWORD(lParam);
			HRESULT hr = g_pd3dDevice->Reset(&g_d3dpp);
			if (hr == D3DERR_INVALIDCALL)
				IM_ASSERT(0);
			ImGui_ImplDX9_CreateDeviceObjects();
		}
		return 0;
	case WM_SYSCOMMAND:
		if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu
			return 0;
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	return DefWindowProc(hWnd, msg, wParam, lParam);
}
Beispiel #15
0
// OpenGL code based on http://open.gl tutorials
void InitGL()
{
	glfwSetErrorCallback(glfw_error_callback);

    if (!glfwInit())
        exit(1);

	//glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	//glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
	//glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
	//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
	glfwWindowHint(GLFW_REFRESH_RATE, 60);
	glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
	window = glfwCreateWindow(1280, 720, "ImGui OpenGL example", nullptr, nullptr);
	glfwMakeContextCurrent(window);

	glfwSetKeyCallback(window, glfw_key_callback);
	glfwSetScrollCallback(window, glfw_scroll_callback);
	glfwSetCharCallback(window, glfw_char_callback);

	glewExperimental = GL_TRUE;
	glewInit();

	GLenum err = GL_NO_ERROR;
	err = glGetError(); IM_ASSERT(err == GL_NO_ERROR);
}
Beispiel #16
0
bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window)
{
    #if !SDL_HAS_VULKAN
    IM_ASSERT(0 && "Unsupported");
    #endif
    return ImGui_ImplSDL2_Init(window);
}
/*------------------------------------------------------------------------------

    Function name: hist_init

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_RET hist_init(isp_hist_context_t *hist, hist_config_t *cfg)
{ 
 	IM_INFOMSG((IM_STR("%s"), IM_STR(_IM_FUNC_)));
	
	IM_ASSERT(hist != IM_NULL);
	IM_ASSERT(hist->regVal != IM_NULL);
	IM_ASSERT(hist->regOfst != IM_NULL);
	IM_ASSERT(cfg != IM_NULL);
	
	/*check hist and backlit threshold*/
	if((cfg->blitTh1 < 0) || (cfg->blitTh1 > 16777215)
		|| (cfg->thrMat.th1 < 0) || (cfg->thrMat.th1 > 127)
		|| (cfg->thrMat.th2 < 0) || (cfg->thrMat.th2 > 255))
	{
		IM_ERRMSG((IM_STR("Invalid threshold: blitTh1=%d, th1=%d, th2=%d"), 
			cfg->blitTh1, cfg->thrMat.th1, cfg->thrMat.th2));
		return IM_RET_INVALID_PARAMETER;
	}


	if(cfg->enable == IM_TRUE)
	{
		/*set hist and backlit threshold*/
		SetIspRegister(hist->regVal, ISP_BLIT_TH1, cfg->blitTh1);
		SetIspRegister(hist->regVal, ISP_HIST_TH_1, cfg->thrMat.th1);
		SetIspRegister(hist->regVal, ISP_HIST_TH_2, cfg->thrMat.th2);
		/*set hist enable*/
		SetIspRegister(hist->regVal, ISP_GLB_CFG2_HISTBYPASS, 0);
		
		IM_JIF(isppwl_write_reg(hist->regOfst[rISP_BLIT_TH], hist->regVal[rISP_BLIT_TH]));
		IM_JIF(isppwl_write_reg(hist->regOfst[rISP_HIST_TH], hist->regVal[rISP_HIST_TH]));
		IM_JIF(isppwl_write_reg(hist->regOfst[rISP_GLB_CFG2], hist->regVal[rISP_GLB_CFG2]));
	}
	else
	{
		/*set hist bypass*/
		SetIspRegister(hist->regVal, ISP_GLB_CFG2_HISTBYPASS, 1);
		IM_JIF(isppwl_write_reg(hist->regOfst[rISP_GLB_CFG2], hist->regVal[rISP_GLB_CFG2]));
	}
	hist->blitTh1 = cfg->blitTh1;
	isppwl_memcpy((void*)(&hist->thrMat), (void *)(&cfg->thrMat), sizeof(isp_hist_thr_matrix));
	hist->enable = cfg->enable;
	return IM_RET_OK;
	
Fail:
	return IM_RET_FAILED;
}
Beispiel #18
0
void ImGui_ImplGlfw_NewFrame()
{
    ImGuiIO& io = ImGui::GetIO();
    IM_ASSERT(io.Fonts->IsBuilt());     // Font atlas needs to be built, call renderer _NewFrame() function e.g. ImGui_ImplOpenGL3_NewFrame() 

    // Setup display size
    int w, h;
    int display_w, display_h;
    w = Global.iWindowWidth;
    h = Global.iWindowHeight;
    display_w = w;
    display_h = h;
    io.DisplaySize = ImVec2((float)w, (float)h);
    io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);

    // Setup time step
    double current_time = glfwGetTime();
    io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
    g_Time = current_time;

    ImGui_ImplGlfw_UpdateMousePosAndButtons();
    ImGui_ImplGlfw_UpdateMouseCursor();

    // Gamepad navigation mapping [BETA]
    memset(io.NavInputs, 0, sizeof(io.NavInputs));
    if (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad)
    {
        // Update gamepad inputs
        #define MAP_BUTTON(NAV_NO, BUTTON_NO)       { if (buttons_count > BUTTON_NO && buttons[BUTTON_NO] == GLFW_PRESS) io.NavInputs[NAV_NO] = 1.0f; }
        #define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float v = (axes_count > AXIS_NO) ? axes[AXIS_NO] : V0; v = (v - V0) / (V1 - V0); if (v > 1.0f) v = 1.0f; if (io.NavInputs[NAV_NO] < v) io.NavInputs[NAV_NO] = v; }
        int axes_count = 0, buttons_count = 0;
        const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axes_count);
        const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &buttons_count);
        MAP_BUTTON(ImGuiNavInput_Activate,   0);     // Cross / A
        MAP_BUTTON(ImGuiNavInput_Cancel,     1);     // Circle / B
        MAP_BUTTON(ImGuiNavInput_Menu,       2);     // Square / X
        MAP_BUTTON(ImGuiNavInput_Input,      3);     // Triangle / Y
        MAP_BUTTON(ImGuiNavInput_DpadLeft,   13);    // D-Pad Left
        MAP_BUTTON(ImGuiNavInput_DpadRight,  11);    // D-Pad Right
        MAP_BUTTON(ImGuiNavInput_DpadUp,     10);    // D-Pad Up
        MAP_BUTTON(ImGuiNavInput_DpadDown,   12);    // D-Pad Down
        MAP_BUTTON(ImGuiNavInput_FocusPrev,  4);     // L1 / LB
        MAP_BUTTON(ImGuiNavInput_FocusNext,  5);     // R1 / RB
        MAP_BUTTON(ImGuiNavInput_TweakSlow,  4);     // L1 / LB
        MAP_BUTTON(ImGuiNavInput_TweakFast,  5);     // R1 / RB
        MAP_ANALOG(ImGuiNavInput_LStickLeft, 0,  -0.3f,  -0.9f);
        MAP_ANALOG(ImGuiNavInput_LStickRight,0,  +0.3f,  +0.9f);
        MAP_ANALOG(ImGuiNavInput_LStickUp,   1,  +0.3f,  +0.9f);
        MAP_ANALOG(ImGuiNavInput_LStickDown, 1,  -0.3f,  -0.9f);
        #undef MAP_BUTTON
        #undef MAP_ANALOG
        if (axes_count > 0 && buttons_count > 0)
            io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
        else
            io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
    }
}
Beispiel #19
0
bool    ImGui_ImplGlfwGL3_Init(GLFWwindow* window, bool install_callbacks, const char* glsl_version)
{
	// Store GL version string so we can refer to it later in case we recreate shaders.
	if (glsl_version == NULL)
		glsl_version = "#version 150";
	IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(g_GlslVersion));
	strcpy(g_GlslVersion, glsl_version);
	strcat(g_GlslVersion, "\n");
	return true;
}
/*------------------------------------------------------------------------------

    Function name: ae_set_block_select

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_RET ae_set_block_select(isp_ae_context_t *ae, isp_ae_block_select *blokSelect)
{ 
 	IM_INFOMSG((IM_STR("%s"), IM_STR(_IM_FUNC_)));
	
	IM_ASSERT(ae != IM_NULL);
	IM_ASSERT(ae->regVal != IM_NULL);
	IM_ASSERT(ae->regOfst != IM_NULL);
	IM_ASSERT(blokSelect != IM_NULL);

	//check block select params
	if((blokSelect->blokNum > 25) || (blokSelect->blokEn > 0x1ffffff))
	{
		IM_ERRMSG((IM_STR("Invalid blokSelect: blokNum=%d, blokEn=0x%x"),
			blokSelect->blokNum, blokSelect->blokEn));
		return IM_RET_INVALID_PARAMETER;
	}
	
	if(ae->enable == IM_TRUE)
	{
		/*set ae block num*/
		if(blokSelect->blokNum == 0)
		{
			SetIspRegister(ae->regVal, ISP_AE_CNTL_NUM_1, (1<<15)/25);
		}
		else
		{
			SetIspRegister(ae->regVal, ISP_AE_CNTL_NUM_1, (1<<15)/blokSelect->blokNum);
		}
		/*set ae block enable*/
		SetIspRegister(ae->regVal, ISP_AE_BEN, blokSelect->blokEn);
		
		//isppwl_write_regs();
		IM_JIF(isppwl_write_reg(ae->regOfst[rISP_AE_CNTL], ae->regVal[rISP_AE_CNTL]));
		IM_JIF(isppwl_write_reg(ae->regOfst[rISP_AE_BEN], ae->regVal[rISP_AE_BEN]));
	}

	ae->blokSelect.blokNum = blokSelect->blokNum;
	ae->blokSelect.blokEn = blokSelect->blokEn;
	return IM_RET_OK;
	
Fail:
	return IM_RET_FAILED;
}
bool ImGui::InputTextMultiline(const char* label, std::string* str, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
{
    IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0);
    flags |= ImGuiInputTextFlags_CallbackResize;

    InputTextCallback_UserData cb_user_data;
    cb_user_data.Str = str;
    cb_user_data.ChainCallback = callback;
    cb_user_data.ChainCallbackUserData = user_data;
    return InputTextMultiline(label, (char*)str->c_str(), str->capacity() + 1, size, flags, InputTextCallback, &cb_user_data);
}
/*------------------------------------------------------------------------------

    Function name: GetIspRegister

        Functional description: get uint32 value

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_UINT32 GetIspRegister(const IM_UINT32 * regBase, IM_UINT32 id)
{

    IM_UINT32 tmp;

    IM_ASSERT(id <= ISP_LAST_REG_ID);

    tmp = regBase[ispRegSpec[id][0]];
    tmp = tmp >> ispRegSpec[id][2];
    tmp &= regMask[ispRegSpec[id][1]];
    return (tmp);

}
/*------------------------------------------------------------------------------

    Function name: SetIspRegister

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
void SetIspRegister(IM_UINT32 * regBase, IM_UINT32 id, IM_INT32 value)
{

    IM_UINT32 tmp;

    IM_ASSERT(id <= ISP_LAST_REG_ID);

    tmp = regBase[ispRegSpec[id][0]];
    tmp &= ~(regMask[ispRegSpec[id][1]] << ispRegSpec[id][2]);
    tmp |= (value & regMask[ispRegSpec[id][1]]) << ispRegSpec[id][2];
    regBase[ispRegSpec[id][0]] = tmp;

}
/*------------------------------------------------------------------------------

    Function name: hist_set_disable

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_RET hist_set_disable(isp_hist_context_t *hist)
{ 
 	IM_INFOMSG((IM_STR("%s"), IM_STR(_IM_FUNC_)));
	
	IM_ASSERT(hist != IM_NULL);
	IM_ASSERT(hist->regVal != IM_NULL);
	IM_ASSERT(hist->regOfst != IM_NULL);

	if(hist->enable != IM_TRUE)
	{
		IM_INFOMSG((IM_STR("hist has been disabled")));
		return IM_RET_OK;	
	}
	//disable hist
	SetIspRegister(hist->regVal, ISP_GLB_CFG2_HISTBYPASS, 1);
	IM_JIF(isppwl_write_reg(hist->regOfst[rISP_GLB_CFG2], hist->regVal[rISP_GLB_CFG2]));

	hist->enable = IM_FALSE;
	return IM_RET_OK;
	
Fail:
	return IM_RET_FAILED;
}
/*------------------------------------------------------------------------------

    Function name: ae_set_disable

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_RET ae_set_disable(isp_ae_context_t *ae)
{ 
 	IM_INFOMSG((IM_STR("%s"), IM_STR(_IM_FUNC_)));
	
	IM_ASSERT(ae != IM_NULL);
	IM_ASSERT(ae->regVal != IM_NULL);
	IM_ASSERT(ae->regOfst != IM_NULL);

	if(ae->enable != IM_TRUE)
	{
		IM_INFOMSG((IM_STR("ae has been disabled")));
		return IM_RET_OK;	
	}

	/*set ae bypass*/
	SetIspRegister(ae->regVal, ISP_GLB_CFG2_AEBYPASS, 1);
	IM_JIF(isppwl_write_reg(ae->regOfst[rISP_GLB_CFG2], ae->regVal[rISP_GLB_CFG2]));

	ae->enable = IM_FALSE;
	return IM_RET_OK;
	
Fail:
	return IM_RET_FAILED;
}
/*------------------------------------------------------------------------------

    Function name: af_set_disable

        Functional description:

        Inputs:

        Outputs:

        Returns: 

------------------------------------------------------------------------------*/
IM_RET af_set_disable(isp_af_context_t *af)
{ 
 	IM_INFOMSG((IM_STR("%s"), IM_STR(_IM_FUNC_)));
	
	IM_ASSERT(af != IM_NULL);
	IM_ASSERT(af->regVal != IM_NULL);
	IM_ASSERT(af->regOfst != IM_NULL);

	if(af->enable != IM_TRUE)
	{
		IM_INFOMSG((IM_STR("af has been disabled")));
		return IM_RET_OK;	
	}
	//disable af
	
	SetIspRegister(af->regVal, ISP_GLB_CFG2_AFBYPASS, 1);
	IM_JIF(isppwl_write_reg(af->regOfst[rISP_GLB_CFG2], af->regVal[rISP_GLB_CFG2]));

	af->enable = IM_FALSE;
	return IM_RET_OK;
	
Fail:
	return IM_RET_FAILED;
}
Beispiel #27
0
// Functions
bool    ImGui_ImplOpenGL3_Init(const char* glsl_version)
{
    // Store GLSL version string so we can refer to it later in case we recreate shaders. Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure.
#ifdef USE_GL_ES3
    if (glsl_version == NULL)
        glsl_version = "#version 300 es";
#else
    if (glsl_version == NULL)
        glsl_version = "#version 130";
#endif
    IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(g_GlslVersionString));
    strcpy(g_GlslVersionString, glsl_version);
    strcat(g_GlslVersionString, "\n");
    return true;
}
static int InputTextCallback(ImGuiInputTextCallbackData* data)
{
    InputTextCallback_UserData* user_data = (InputTextCallback_UserData*)data->UserData;
    if (data->EventFlag == ImGuiInputTextFlags_CallbackResize)
    {
        // Resize string callback
        // If for some reason we refuse the new length (BufTextLen) and/or capacity (BufSize) we need to set them back to what we want.
        std::string* str = user_data->Str;
        IM_ASSERT(data->Buf == str->c_str());
        str->resize(data->BufTextLen);
        data->Buf = (char*)str->c_str();
    }
    else if (user_data->ChainCallback)
    {
        // Forward to user callback, if any
        data->UserData = user_data->ChainCallbackUserData;
        return user_data->ChainCallback(data);
    }
    return 0;
}
Beispiel #29
0
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
bool ImGui_ImplSDL2_ProcessEvent(SDL_Event* event)
{
    ImGuiIO& io = ImGui::GetIO();
    switch (event->type)
    {
    case SDL_MOUSEWHEEL:
        {
            if (event->wheel.x > 0) io.MouseWheelH += 1;
            if (event->wheel.x < 0) io.MouseWheelH -= 1;
            if (event->wheel.y > 0) io.MouseWheel += 1;
            if (event->wheel.y < 0) io.MouseWheel -= 1;
            return true;
        }
    case SDL_MOUSEBUTTONDOWN:
        {
            if (event->button.button == SDL_BUTTON_LEFT) g_MousePressed[0] = true;
            if (event->button.button == SDL_BUTTON_RIGHT) g_MousePressed[1] = true;
            if (event->button.button == SDL_BUTTON_MIDDLE) g_MousePressed[2] = true;
            return true;
        }
    case SDL_TEXTINPUT:
        {
            io.AddInputCharactersUTF8(event->text.text);
            return true;
        }
    case SDL_KEYDOWN:
    case SDL_KEYUP:
        {
            int key = event->key.keysym.scancode;
            IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown));
            io.KeysDown[key] = (event->type == SDL_KEYDOWN);
            io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0);
            io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0);
            io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0);
            io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0);
            return true;
        }
    }
    return false;
}
Beispiel #30
0
void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
{
    ImGuiIO& io = ImGui::GetIO();
    IM_ASSERT(io.Fonts->IsBuilt());     // Font atlas needs to be built, call renderer _NewFrame() function e.g. ImGui_ImplOpenGL3_NewFrame() 

    // Setup display size (every frame to accommodate for window resizing)
    int w, h;
    int display_w, display_h;
    SDL_GetWindowSize(window, &w, &h);
    SDL_GL_GetDrawableSize(window, &display_w, &display_h);
    io.DisplaySize = ImVec2((float)w, (float)h);
    io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);

    // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution)
    static Uint64 frequency = SDL_GetPerformanceFrequency();
    Uint64 current_time = SDL_GetPerformanceCounter();
    io.DeltaTime = g_Time > 0 ? (float)((double)(current_time - g_Time) / frequency) : (float)(1.0f / 60.0f);
    g_Time = current_time;

    ImGui_ImplSDL2_UpdateMousePosAndButtons();
    ImGui_ImplSDL2_UpdateMouseCursor();
}