21 #include "../../SDL_internal.h"
23 #if SDL_VIDEO_DRIVER_HAIKU
26 #include <InterfaceKit.h>
34 #include "../../main/haiku/SDL_BApp.h"
63 return (display_mode*)(
mode->driverdata);
68 static float get_refresh_rate(display_mode &
mode) {
69 return float(
mode.timing.pixel_clock * 1000)
70 / float(
mode.timing.h_total *
mode.timing.v_total);
78 void _SpoutModeData(display_mode *bmode) {
80 printf(
"\tw,h = (%i,%i)\n", bmode->virtual_width, bmode->virtual_height);
81 printf(
"\th,v = (%i,%i)\n", bmode->h_display_start,
82 bmode->v_display_start);
85 if(bmode->flags & B_SCROLL) {
86 printf(
"\t\tB_SCROLL\n");
88 if(bmode->flags & B_8_BIT_DAC) {
89 printf(
"\t\tB_8_BIT_DAC\n");
91 if(bmode->flags & B_HARDWARE_CURSOR) {
92 printf(
"\t\tB_HARDWARE_CURSOR\n");
94 if(bmode->flags & B_PARALLEL_ACCESS) {
95 printf(
"\t\tB_PARALLEL_ACCESS\n");
97 if(bmode->flags & B_DPMS) {
98 printf(
"\t\tB_DPMS\n");
100 if(bmode->flags & B_IO_FB_NA) {
101 printf(
"\t\tB_IO_FB_NA\n");
104 printf(
"\tTiming:\n");
105 printf(
"\t\tpx clock: %i\n", bmode->timing.pixel_clock);
106 printf(
"\t\th - display: %i sync start: %i sync end: %i total: %i\n",
107 bmode->timing.h_display, bmode->timing.h_sync_start,
108 bmode->timing.h_sync_end, bmode->timing.h_total);
109 printf(
"\t\tv - display: %i sync start: %i sync end: %i total: %i\n",
110 bmode->timing.v_display, bmode->timing.v_sync_start,
111 bmode->timing.v_sync_end, bmode->timing.v_total);
112 if(bmode->timing.flags) {
113 printf(
"\t\tFlags:\n");
114 if(bmode->timing.flags & B_BLANK_PEDESTAL) {
115 printf(
"\t\t\tB_BLANK_PEDESTAL\n");
117 if(bmode->timing.flags & B_TIMING_INTERLACED) {
118 printf(
"\t\t\tB_TIMING_INTERLACED\n");
120 if(bmode->timing.flags & B_POSITIVE_HSYNC) {
121 printf(
"\t\t\tB_POSITIVE_HSYNC\n");
123 if(bmode->timing.flags & B_POSITIVE_VSYNC) {
124 printf(
"\t\t\tB_POSITIVE_VSYNC\n");
126 if(bmode->timing.flags & B_SYNC_ON_GREEN) {
127 printf(
"\t\t\tB_SYNC_ON_GREEN\n");
140 switch (colorspace) {
163 return(bitsperpixel);
194 static void _BDisplayModeToSdlDisplayMode(display_mode *bmode,
196 mode->w = bmode->virtual_width;
197 mode->h = bmode->virtual_height;
198 mode->refresh_rate = (int)get_refresh_rate(*bmode);
209 mode->driverdata = bmode;
218 static void _AddDisplay(BScreen *
screen) {
222 display_mode *bmode = (display_mode*)
SDL_calloc(1,
sizeof(display_mode));
225 _BDisplayModeToSdlDisplayMode(bmode,
mode);
255 BRect rc = bscreen.Frame();
256 rect->
x = (int)rc.left;
257 rect->
y = (
int)rc.top;
258 rect->
w = (int)rc.Width() + 1;
259 rect->
h = (int)rc.Height() + 1;
269 display_mode this_bmode;
270 display_mode *bmodes;
274 bscreen.GetModeList(&bmodes, &
count);
275 bscreen.GetMode(&this_bmode);
279 if (bmodes[
i].space == this_bmode.space) {
280 _BDisplayModeToSdlDisplayMode(&bmodes[
i], &
mode);
291 if(!bscreen.IsValid()) {
292 printf(__FILE__
": %d - ERROR: BAD SCREEN\n", __LINE__);
296 display_mode *bmode = _ExtractBMode(
mode);
301 display_mode *bmode_list;
302 bscreen.GetModeList(&bmode_list, &
c);
303 for(
i = 0;
i <
c; ++
i) {
304 if( bmode_list[
i].space == bmode->space &&
305 bmode_list[
i].virtual_width == bmode->virtual_width &&
306 bmode_list[
i].virtual_height == bmode->virtual_height ) {
307 bmode = &bmode_list[
i];
312 if(bscreen.SetMode(bmode) != B_OK) {