void CEGLNativeTypeBoxee::Initialize() { gdl_init(); int enable = 1; gdl_rectangle_t srcRect, dstRect; gdl_display_info_t display_info; gdl_get_display_info(GDL_DISPLAY_ID_0, &display_info); dstRect.origin.x = 0; dstRect.origin.y = 0; dstRect.width = display_info.tvmode.width; dstRect.height = display_info.tvmode.height; srcRect.origin.x = 0; srcRect.origin.y = 0; srcRect.width = display_info.tvmode.width; srcRect.height = display_info.tvmode.height; gdl_port_set_attr(GDL_PD_ID_HDMI, GDL_PD_ATTR_ID_POWER, &enable); gdl_plane_reset(GDL_GRAPHICS_PLANE); gdl_plane_config_begin(GDL_GRAPHICS_PLANE); gdl_plane_set_uint(GDL_PLANE_SRC_COLOR_SPACE, GDL_COLOR_SPACE_RGB); gdl_plane_set_uint(GDL_PLANE_PIXEL_FORMAT, GDL_PF_ARGB_32); gdl_plane_set_rect(GDL_PLANE_DST_RECT, &dstRect); gdl_plane_set_rect(GDL_PLANE_SRC_RECT, &srcRect); gdl_plane_config_end(GDL_FALSE); return; }
// Initializes a plane for the graphics to be rendered to static gdl_ret_t setup_plane(gdl_plane_id_t plane) { gdl_pixel_format_t pixelFormat = GDL_PF_ARGB_32; gdl_color_space_t colorSpace = GDL_COLOR_SPACE_RGB; gdl_rectangle_t srcRect; gdl_rectangle_t dstRect; gdl_ret_t rc = GDL_SUCCESS; dstRect.origin.x = ORIGIN_X; dstRect.origin.y = ORIGIN_Y; dstRect.width = WIDTH; dstRect.height = HEIGHT; srcRect.origin.x = 0; srcRect.origin.y = 0; srcRect.width = WIDTH; srcRect.height = HEIGHT; rc = gdl_plane_reset(plane); if (GDL_SUCCESS == rc) { rc = gdl_plane_config_begin(plane); } if (GDL_SUCCESS == rc) { rc = gdl_plane_set_attr(GDL_PLANE_SRC_COLOR_SPACE, &colorSpace); } if (GDL_SUCCESS == rc) { rc = gdl_plane_set_attr(GDL_PLANE_PIXEL_FORMAT, &pixelFormat); } if (GDL_SUCCESS == rc) { rc = gdl_plane_set_attr(GDL_PLANE_DST_RECT, &dstRect); } if (GDL_SUCCESS == rc) { rc = gdl_plane_set_attr(GDL_PLANE_SRC_RECT, &srcRect); } if (GDL_SUCCESS == rc) { rc = gdl_plane_config_end(GDL_FALSE); } else { gdl_plane_config_end(GDL_TRUE); } if (GDL_SUCCESS != rc) { fprintf(stderr, "GDL configuration failed! GDL error code is 0x%x\n", rc); } return rc; }
static CoglBool gdl_plane_init (CoglDisplay *display, CoglError **error) { CoglBool ret = TRUE; gdl_color_space_t colorSpace = GDL_COLOR_SPACE_RGB; gdl_pixel_format_t pixfmt = GDL_PF_ARGB_32; gdl_rectangle_t dstRect; gdl_display_info_t display_info; gdl_ret_t rc = GDL_SUCCESS; if (!display->gdl_plane) { _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT, "No GDL plane specified with " "cogl_gdl_display_set_plane"); return FALSE; } rc = gdl_init (NULL); if (rc != GDL_SUCCESS) { _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT, "GDL initialize failed. %s", gdl_get_error_string (rc)); return FALSE; } rc = gdl_get_display_info (GDL_DISPLAY_ID_0, &display_info); if (rc != GDL_SUCCESS) { _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT, "GDL failed to get display infomation: %s", gdl_get_error_string (rc)); gdl_close (); return FALSE; } dstRect.origin.x = 0; dstRect.origin.y = 0; dstRect.width = display_info.tvmode.width; dstRect.height = display_info.tvmode.height; /* Configure the plane attribute. */ rc = gdl_plane_reset (display->gdl_plane); if (rc == GDL_SUCCESS) rc = gdl_plane_config_begin (display->gdl_plane); if (rc == GDL_SUCCESS) rc = gdl_plane_set_attr (GDL_PLANE_SRC_COLOR_SPACE, &colorSpace); if (rc == GDL_SUCCESS) rc = gdl_plane_set_attr (GDL_PLANE_PIXEL_FORMAT, &pixfmt); if (rc == GDL_SUCCESS) rc = gdl_plane_set_attr (GDL_PLANE_DST_RECT, &dstRect); if (rc == GDL_SUCCESS) rc = gdl_plane_set_uint (GDL_PLANE_NUM_GFX_SURFACES, 3); if (rc == GDL_SUCCESS) rc = gdl_plane_config_end (GDL_FALSE); else gdl_plane_config_end (GDL_TRUE); if (rc != GDL_SUCCESS) { _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT, "GDL configuration failed: %s.", gdl_get_error_string (rc)); ret = FALSE; } gdl_close (); return ret; }
bool CEGLNativeTypeBoxee::SetNativeResolution(const RESOLUTION_INFO &res) { CLog::Log(LOGNOTICE,"Setting resolution: %s\n",res.strMode.c_str()); gdl_pixel_format_t pixelFormat = GDL_PF_ARGB_32; gdl_color_space_t colorSpace = GDL_COLOR_SPACE_RGB; gdl_rectangle_t srcRect; gdl_rectangle_t dstRect; gdl_ret_t rc = GDL_SUCCESS; gdl_boolean_t hdmiEnabled = GDL_FALSE; gdl_plane_id_t m_gdlPlane = GDL_GRAPHICS_PLANE; gdl_display_info_t display_info; memset(&display_info, 0, sizeof(display_info)); RESOLUTION_INFO_to_tvmode(res, &display_info.tvmode); display_info.id = GDL_DISPLAY_ID_0; display_info.flags = 0; display_info.bg_color = 0; display_info.color_space = GDL_COLOR_SPACE_RGB; display_info.gamma = GDL_GAMMA_LINEAR; rc = gdl_set_display_info(&display_info); if ( rc != GDL_SUCCESS) { CLog::Log(LOGERROR, "Could not set display mode for display 0"); return false; } // Setup composite output to NTSC. In order to support PAL we need to use 720x576i50. display_info.id = GDL_DISPLAY_ID_1; display_info.flags = 0; display_info.bg_color = 0; display_info.color_space = GDL_COLOR_SPACE_RGB; display_info.gamma = GDL_GAMMA_LINEAR; display_info.tvmode.width = 720; display_info.tvmode.height = 480; display_info.tvmode.refresh = GDL_REFRESH_59_94; display_info.tvmode.interlaced = GDL_TRUE; rc = gdl_set_display_info(&display_info); dstRect.origin.x = 0; dstRect.origin.y = 0; dstRect.width = res.iWidth; dstRect.height = res.iHeight; srcRect.origin.x = 0; srcRect.origin.y = 0; srcRect.width = res.iWidth; srcRect.height = res.iHeight; if (gdl_port_set_attr(GDL_PD_ID_HDMI, GDL_PD_ATTR_ID_HDCP, &hdmiEnabled) != GDL_SUCCESS) { CLog::Log(LOGWARNING, "Could not disable HDCP"); } if (GDL_SUCCESS == rc) { rc = gdl_plane_config_begin(m_gdlPlane); } rc = gdl_plane_reset(m_gdlPlane); if (GDL_SUCCESS == rc) { rc = gdl_plane_config_begin(m_gdlPlane); } if (GDL_SUCCESS == rc) { rc = gdl_plane_set_attr(GDL_PLANE_SRC_COLOR_SPACE, &colorSpace); } if (GDL_SUCCESS == rc) { rc = gdl_plane_set_attr(GDL_PLANE_PIXEL_FORMAT, &pixelFormat); } if (GDL_SUCCESS == rc) { rc = gdl_plane_set_attr(GDL_PLANE_DST_RECT, &dstRect); } if (GDL_SUCCESS == rc) { rc = gdl_plane_set_attr(GDL_PLANE_SRC_RECT, &srcRect); } if(GDL_SUCCESS == rc) { gdl_boolean_t scalineEnabled = GDL_FALSE; rc = gdl_plane_set_attr(GDL_PLANE_UPSCALE, &scalineEnabled); } if (GDL_SUCCESS == rc) { rc = gdl_plane_config_end(GDL_FALSE); } else { gdl_plane_config_end(GDL_TRUE); } if (GDL_SUCCESS != rc) { CLog::Log(LOGERROR, "GDL configuration failed! GDL error code is 0x%x\n", rc); return false; } CLog::Log(LOGINFO, "GDL plane setup complete"); return true; }
// Initializes a plane for the graphics to be rendered to static gdl_ret_t setup_plane(gdl_plane_id_t plane) { gdl_pixel_format_t pixelFormat = GDL_PF_ARGB_8; gdl_color_space_t colorSpace = GDL_COLOR_SPACE_RGB; gdl_color_t gdl_color; gdl_palette_t pal; gdl_rectangle_t srcRect; gdl_rectangle_t dstRect; gdl_ret_t rc = GDL_SUCCESS; dstRect.origin.x = 0; dstRect.origin.y = 0; dstRect.width = GDL_CURSOR_WIDTH; dstRect.height = GDL_CURSOR_HEIGHT; srcRect.origin.x = 0; srcRect.origin.y = 0; srcRect.width = GDL_CURSOR_WIDTH; srcRect.height = GDL_CURSOR_HEIGHT; rc = gdl_plane_reset(plane); if (GDL_SUCCESS == rc) { rc = gdl_plane_config_begin(plane); } if (GDL_SUCCESS == rc) { rc = gdl_plane_set_attr(GDL_PLANE_SRC_COLOR_SPACE, &colorSpace); } if (GDL_SUCCESS == rc) { rc = gdl_plane_set_attr(GDL_PLANE_PIXEL_FORMAT, &pixelFormat); } if (GDL_SUCCESS == rc) { rc = gdl_plane_set_attr(GDL_PLANE_DST_RECT, &dstRect); } if (GDL_SUCCESS == rc) { rc = gdl_plane_set_attr(GDL_PLANE_SRC_RECT, &srcRect); } if (GDL_SUCCESS == rc) { rc = gdl_plane_config_end(GDL_FALSE); } else { gdl_plane_config_end(GDL_TRUE); } if (GDL_SUCCESS != rc) { qCritical("GDL configuration failed! GDL error code is 0x%x\n", rc); } rc = gdl_alloc_surface(GDL_PF_ARGB_8, GDL_CURSOR_WIDTH, GDL_CURSOR_HEIGHT, 0, &destination_surface_info); CHECK_GDL_RC(rc, "Failed "); // Black pal.data[0].a = 0xff; pal.data[0].r_y = 0x00; pal.data[0].g_u = 0x00; pal.data[0].b_v = 0x00; // White pal.data[1].a = 0xff; pal.data[1].r_y = 0xff; pal.data[1].g_u = 0xff; pal.data[1].b_v = 0xff; // Transparent background pal.data[2].a = 0x00; pal.data[2].r_y = 0x00; pal.data[2].g_u = 0x00; pal.data[2].b_v = 0x00; pal.length = 3; rc = gdl_set_palette(destination_surface_info.id, &pal); CHECK_GDL_RC(rc, "Failed "); rc = gdl_map_surface(destination_surface_info.id, &cursorPlaneBuffer, &cursorPlanePitch); CHECK_GDL_RC(rc, "Failed "); /* The CLUT index */ gdl_color.alpha_index = 0; rc = gdl_clear_surface(destination_surface_info.id, &gdl_color); CHECK_GDL_RC(rc,"Failed "); rc = gdl_flip(plane,destination_surface_info.id, GDL_FLIP_ASYNC); CHECK_GDL_RC(rc,"Failed "); return rc; }