|
|
| version 1.1, 2004/07/14 16:01:40 | version 1.4, 2005/03/12 12:36:57 |
|---|---|
| Line 12 | Line 12 |
| * 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright |
| * notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the |
| * documentation and/or other materials provided with the distribution. | * documentation and/or other materials provided with the distribution. |
| * 3. The name of the author may not be used to endorse or promote products | |
| * derived from this software without specific prior written permission. | |
| * | * |
| * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| Line 40 | Line 38 |
| typedef struct { | typedef struct { |
| BYTE scrnmode; | UINT8 scrnmode; |
| BYTE drawing; | UINT8 drawing; |
| int width; | int width; |
| int height; | int height; |
| int extend; | int extend; |
| Line 72 typedef struct { | Line 70 typedef struct { |
| typedef struct { | typedef struct { |
| SCRNSURF ss; | SCRNSURF ss; |
| BYTE renewal[SURFACE_HEIGHT]; | UINT8 renewal[SURFACE_HEIGHT]; |
| } X11SCRNSURF; | } X11SCRNSURF; |
| static SCRNMNG scrnmng; | static SCRNMNG scrnmng; |
| Line 250 scrnmng_initialize(void) | Line 248 scrnmng_initialize(void) |
| } | } |
| BOOL | BOOL |
| scrnmng_create(BYTE mode) | scrnmng_create(UINT8 mode) |
| { | { |
| GdkVisual *visual; | GdkVisual *visual; |
| RECT_T rect; | RECT_T rect; |
| int height; | int height; |
| int bitcolor; | |
| UINT lpitch; | UINT lpitch; |
| BYTE bytes_per_pixel; | UINT8 bytes_per_pixel; |
| pixmap_format_t fmt; | |
| int padding; | |
| while (drawmng.drawing) | while (drawmng.drawing) |
| gtk_main_iteration_do(FALSE); | gtk_main_iteration_do(FALSE); |
| Line 274 scrnmng_create(BYTE mode) | Line 273 scrnmng_create(BYTE mode) |
| scrnmng.flag = SCRNFLAG_HAVEEXTEND; | scrnmng.flag = SCRNFLAG_HAVEEXTEND; |
| visual = gtk_widget_get_visual(drawarea); | visual = gtk_widget_get_visual(drawarea); |
| bitcolor = gtkdrawmng_getbpp(drawarea, main_window); | if (!gtkdrawmng_getformat(drawarea, main_window, &fmt)) |
| if (bitcolor == 0) { | |
| return FAILURE; | return FAILURE; |
| } else if (bitcolor == 16) { | |
| switch (fmt.bits_per_pixel) { | |
| case 16: | |
| drawmng_make16mask(&drawmng.pal16mask, visual->blue_mask, visual->red_mask, visual->green_mask); | drawmng_make16mask(&drawmng.pal16mask, visual->blue_mask, visual->red_mask, visual->green_mask); |
| } else if (bitcolor == 8) { | break; |
| case 8: | |
| palette_init(); | palette_init(); |
| break; | |
| } | } |
| drawmng.extend = 1; | drawmng.extend = 1; |
| bytes_per_pixel = bitcolor >> 3; | bytes_per_pixel = (UINT8)(fmt.bits_per_pixel / 8); |
| if (!(mode & SCRNMODE_ROTATE)) { | if (!(mode & SCRNMODE_ROTATE)) { |
| rect.right = 641; | rect.right = 641; |
| rect.bottom = 480; | rect.bottom = 480; |
| lpitch = rect.right * bytes_per_pixel; | |
| if (lpitch % 4) { | |
| rect.right += (lpitch % 4) / bytes_per_pixel; | |
| lpitch = rect.right * bytes_per_pixel; | |
| } | |
| } else { | } else { |
| rect.right = 480; | rect.right = 480; |
| rect.bottom = 641; | rect.bottom = 641; |
| } | |
| lpitch = rect.right * bytes_per_pixel; | |
| padding = lpitch % (fmt.scanline_pad / 8); | |
| if (padding > 0) { | |
| rect.right += padding / bytes_per_pixel; | |
| lpitch = rect.right * bytes_per_pixel; | lpitch = rect.right * bytes_per_pixel; |
| } | } |
| height = 480; | height = 480; |
| Line 316 scrnmng_create(BYTE mode) | Line 319 scrnmng_create(BYTE mode) |
| gdk_draw_rectangle(drawmng.backsurf, drawarea->style->black_gc, | gdk_draw_rectangle(drawmng.backsurf, drawarea->style->black_gc, |
| TRUE, 0, 0, rect.right, rect.bottom); | TRUE, 0, 0, rect.right, rect.bottom); |
| } | } |
| scrnmng.bpp = (BYTE)bitcolor; | scrnmng.bpp = (UINT8)fmt.bits_per_pixel; |
| drawmng.lpitch = lpitch; | drawmng.lpitch = lpitch; |
| scrnsurf.ss.bpp = bitcolor; | scrnsurf.ss.bpp = fmt.bits_per_pixel; |
| drawmng.scrnmode = mode; | drawmng.scrnmode = mode; |
| drawmng.width = 640; | drawmng.width = 640; |
| drawmng.height = height; | drawmng.height = height; |
| Line 389 scrnmng_surflock(void) | Line 392 scrnmng_surflock(void) |
| memcpy(scrnsurf.renewal, renewal_line, sizeof(scrnsurf.renewal)); | memcpy(scrnsurf.renewal, renewal_line, sizeof(scrnsurf.renewal)); |
| #endif | #endif |
| scrnsurf.ss.ptr = (BYTE *)drawmng.surface->mem; | scrnsurf.ss.ptr = (UINT8 *)drawmng.surface->mem; |
| if (!(drawmng.scrnmode & SCRNMODE_ROTATE)) { | if (!(drawmng.scrnmode & SCRNMODE_ROTATE)) { |
| scrnsurf.ss.xalign = bytes_per_pixel; | scrnsurf.ss.xalign = bytes_per_pixel; |
| scrnsurf.ss.yalign = lpitch; | scrnsurf.ss.yalign = lpitch; |
| Line 413 scrnmng_surfunlock(const SCRNSURF *surf) | Line 416 scrnmng_surfunlock(const SCRNSURF *surf) |
| GdkDrawable *d = drawarea->window; | GdkDrawable *d = drawarea->window; |
| GdkGC *gc = drawarea->style->fg_gc[GTK_WIDGET_STATE(drawarea)]; | GdkGC *gc = drawarea->style->fg_gc[GTK_WIDGET_STATE(drawarea)]; |
| X11SCRNSURF *ss = (X11SCRNSURF *)surf; | X11SCRNSURF *ss = (X11SCRNSURF *)surf; |
| BYTE *delta = ss->renewal; | UINT8 *delta = ss->renewal; |
| RECT_T r; | RECT_T r; |
| gint h, s; | gint h, s; |