📄 pe_istreamctrl.cpp
字号:
status = PE_FAILURE;
goto err_out;
}
/* Maybe this should default to black.
* DirectFB defaults to blue for bg, so setting to transparent black.
*/
if ((*disp_layer)->SetBackgroundColor((*disp_layer), 0, 0, 0, 0) != DFB_OK)
{
DbgPrint(("peiStrmConfigGraphics: Failed to set SetBackgroundColor\n"));
status = PE_FAILURE;
goto err_out;
}
/* Apparently the PG composition objects are already alpha premultiplied,
* I would say that this is probably also the case for IG */
/* setup output surface based on resolution */
LayerConfig.flags = (DFBDisplayLayerConfigFlags)(DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT | DLCONF_SURFACE_CAPS);
LayerConfig.width = screen_width;
LayerConfig.height = screen_height;
LayerConfig.pixelformat = DSPF_LUT8;
LayerConfig.surface_caps = DSCAPS_PREMULTIPLIED;
/* setup the graphics plane for 1080i arbg surface */
if ((*disp_layer)->SetConfiguration((*disp_layer), &LayerConfig) != DFB_OK)
{
DbgPrint(("peiStrmConfigGraphics: Failed to SetConfiguration\n"));
status = PE_FAILURE;
goto err_out;
}
/* get the primary surface for this diplay layer */
if ((*disp_layer)->GetSurface((*disp_layer), &sfc) != DFB_OK)
{
DbgPrint(("peiStrmConfigGraphics: Failed to get surface\n"));
status = PE_FAILURE;
goto err_out;
}
/* get the surfaces palette */
if (sfc->GetPalette(sfc, &pal) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmConfigGraphics: Failed to get palette!\n"));
status = PE_FAILURE;
goto err_out;
}
/* set default transparent palette entry */
if (pal->SetEntries(pal, &clr_transp, 1, 0xff) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmConfigGraphics: Failed to set transparent palette entry!\n"));
status = PE_FAILURE;
goto err_out;
}
/* set surface color index to transparent */
if (sfc->SetColorIndex(sfc, 0xff) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmConfigGraphics: Failed to set color index!\n"));
status = PE_FAILURE;
goto err_out;
}
/* clear the surface */
if (sfc->FillRectangle(sfc, 0, 0, screen_width, screen_height) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmConfigGraphics: Failed to clear surface!\n"));
status = PE_FAILURE;
goto err_out;
}
/* flip the surface */
if (sfc->Flip(sfc, NULL, DSFLIP_NONE) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmConfigGraphics: Failed to blit bitmap object!\n"));
status = PE_FAILURE;
goto err_out;
}
err_out:
if (pal)
{
pal->Release(pal);
}
/* release surface */
if (sfc)
{
sfc->Release(sfc);
}
return (status);
}
/**
* Private function to set PG/IG/TextST graphics plane resolution to enable scaling from
* source to output resolution.
*
* @param layer_handle - decode handle for the layer
* @param ulWidth - new width
* @param ulHeight - new height
*
* @return PE_STATUS.
*/
static PE_STATUS peiStrmSetGraphicsSrcResolution(DfbExtHandle *layer_handle, ULONG ulWidth, ULONG ulHeight)
{
IDirectFBSurface *dfbSurface = NULL;
IDirectFBPalette *dfbPalette = NULL;
IDirectFBDisplayLayer *dfbDispLayer = NULL;
DFBDisplayLayerConfig LayerConfig;
DFBDisplayLayerID layer_id;
DfbExtLayerSettingsType settings;
DFBColor ClearColor = {0,0,0,0};
int CurrentLevel = -1;
PE_STATUS status = PE_SUCCESS;
/* disable for now because it is causing the system to hang */
if (layer_handle == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Layer handle is null\n"));
return (PE_NULL_POINTER);
}
/* configure the graphics layer */
if (DfbExtLayerGet(*layer_handle, &settings) != 0)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Failed call to DfbExtLayerGet ig\n"));
return (PE_FAILURE);
}
layer_id = (DFBDisplayLayerID)settings.id;
/* get the directfb display layer for specified graphics layer */
if (pDfb->GetDisplayLayer(pDfb, layer_id, &dfbDispLayer) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Failed to set GetDisplayLayer\n"));
status = PE_FAILURE;
goto err_out;
}
/* set coop level */
if (dfbDispLayer->SetCooperativeLevel(dfbDispLayer, DLSCL_ADMINISTRATIVE) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Failed to set coop level\n"));
status = PE_FAILURE;
goto err_out;
}
/* set the new layer configuration */
if (dfbDispLayer->GetConfiguration(dfbDispLayer, &LayerConfig) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Failed to GetConfiguration\n"));
status = PE_FAILURE;
goto err_out;
}
/* check the layer config */
if ( (LayerConfig.width == (int)ulWidth) && (LayerConfig.height == (int)ulHeight) )
{
/* we don't need to set config, it's already correct so exit and return success */
status = PE_SUCCESS;
goto err_out;
}
/* new layer settings */
LayerConfig.flags = (DFBDisplayLayerConfigFlags)(DLCONF_WIDTH | DLCONF_HEIGHT);
LayerConfig.width = ulWidth;
LayerConfig.height = ulHeight;
/* get the display level so we know what to set it back to */
if (dfbDispLayer->GetLevel(dfbDispLayer, &CurrentLevel) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Failed to get display level\n"));
status = PE_FAILURE;
goto err_out;
}
/* set level to -1 so it's not visible during set config */
if (dfbDispLayer->SetLevel(dfbDispLayer, -1) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Failed to set the level to -1\n"));
status = PE_FAILURE;
goto err_out;
}
/* set the new layer configuration */
if (dfbDispLayer->SetConfiguration(dfbDispLayer, &LayerConfig) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Failed to SetConfiguration\n"));
status = PE_FAILURE;
goto err_out;
}
/* get the primary surface for this diplay layer */
if (dfbDispLayer->GetSurface(dfbDispLayer, &dfbSurface) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Failed to get surface\n"));
status = PE_FAILURE;
goto err_out;
}
if (LayerConfig.pixelformat == DSPF_LUT8)
{
/* get the surfaces palette */
if (dfbSurface->GetPalette(dfbSurface, &dfbPalette) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Failed to get palette!\n"));
status = PE_FAILURE;
goto err_out;
}
/* set default transparent palette entry */
if (dfbPalette->SetEntries(dfbPalette, &ClearColor, 1, 0xff) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Failed to set transparent palette entry!\n"));
status = PE_FAILURE;
goto err_out;
}
/* set surface color index to transparent */
if (dfbSurface->SetColorIndex(dfbSurface, 0xff) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Failed to set color index!\n"));
status = PE_FAILURE;
goto err_out;
}
/* clear the surface */
if (dfbSurface->FillRectangle(dfbSurface, 0, 0, ulWidth, ulHeight) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Failed to FillRectangle!\n"));
status = PE_FAILURE;
goto err_out;
}
/* flip the surface */
if (dfbSurface->Flip(dfbSurface, NULL, DSFLIP_NONE) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Failed to Flip!\n"));
status = PE_FAILURE;
goto err_out;
}
}
else if (LayerConfig.pixelformat == DSPF_ARGB)
{
/* clear the visible surface */
if (dfbSurface->Clear(dfbSurface, 0, 0, 0, 0) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Failed to Clear ARGB!\n"));
status = PE_FAILURE;
goto err_out;
}
/* flip the surface */
if (dfbSurface->Flip(dfbSurface, NULL, DSFLIP_NONE) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: Failed to Flip!\n"));
status = PE_FAILURE;
goto err_out;
}
}
err_out:
if (dfbPalette != NULL)
{
dfbPalette->Release(dfbPalette);
}
if (dfbSurface != NULL)
{
dfbSurface->Release(dfbSurface);
}
if (dfbDispLayer != NULL)
{
/* restore the display layers level */
if (CurrentLevel != -1)
{
if (dfbDispLayer->SetLevel(dfbDispLayer, CurrentLevel) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsSrcResolution: restore level Failed!\n"));
}
}
dfbDispLayer->Release(dfbDispLayer);
}
return (status);
}
/**
* Private function to set the aspect ratio of the graphics plane
*
* @param layer_handle - decode handle for the layer
* @param ulWidth - new width
* @param ulHeight - new height
* @param ScreenAspect - the aspect ratio of the display
* @param SourceAspect - the aspect ratio of the source content
*
* @return PE_STATUS.
*/
static PE_STATUS peiStrmSetGraphicsAspectRatio(DfbExtHandle *layer_handle, PE_ICONFIGURE_VIDEO_FORMAT VideoFormat,
PE_ICONFIGURE_ASPECT_RATIO ScreenAspect, PE_ISTREAMCTRL_SOURCE_ASPECT_RATIO SourceAspect)
{
IDirectFBDisplayLayer *dfbDispLayer = NULL;
IDirectFBSurface *sfc;
DFBDisplayLayerID layer_id;
DfbExtLayerSettingsType settings;
DFBDisplayLayerConfig LayerConfig;
int width, height;
PE_STATUS status = PE_SUCCESS;
/* check the layer_handle */
if (layer_handle == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsAspectRatio: Layer handle is null\n"));
return (PE_NULL_POINTER);
}
/* configure the graphics layer */
if (DfbExtLayerGet(*layer_handle, &settings) != 0)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsAspectRatio: Failed call to DfbExtLayerGet ig\n"));
return (PE_FAILURE);
}
layer_id = (DFBDisplayLayerID)settings.id;
/* get the directfb display layer for specified graphics layer */
if (pDfb->GetDisplayLayer(pDfb, layer_id, &dfbDispLayer) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsAspectRatio: Failed to set GetDisplayLayer\n"));
status = PE_FAILURE;
goto err_out;
}
/* set coop level */
if (dfbDispLayer->SetCooperativeLevel(dfbDispLayer, DLSCL_ADMINISTRATIVE) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsAspectRatio: Failed to set coop level\n"));
status = PE_FAILURE;
goto err_out;
}
/* set the new layer configuration */
if (dfbDispLayer->GetConfiguration(dfbDispLayer, &LayerConfig) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsAspectRatio: Failed to GetConfiguration\n"));
status = PE_FAILURE;
goto err_out;
}
/* set the new layer configuration */
if (dfbDispLayer->GetSurface(dfbDispLayer, &sfc) != DFB_OK)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsAspectRatio: Failed to GetConfiguration\n"));
status = PE_FAILURE;
goto err_out;
}
/* get the surface size */
if (sfc->GetSize(sfc, &width, &height) != DFB_OK)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -