変愚蛮怒のメインリポジトリです
Revision | f883662f88f8850b210e47ce6acb5e2579348069 (tree) |
---|---|
Zeit | 2016-11-07 01:00:19 |
Autor | Deskull <desull@user...> |
Commiter | Deskull |
GDI+のための描画処理を整理。 / Rearrange drawing process for GDI+.
@@ -374,6 +374,7 @@ struct _term_data | ||
374 | 374 | cptr s; |
375 | 375 | |
376 | 376 | HWND w; |
377 | + Gdiplus::Graphics *graphics; | |
377 | 378 | |
378 | 379 | DWORD dwStyle; |
379 | 380 | DWORD dwExStyle; |
@@ -505,6 +506,8 @@ static int use_new_gmode = 0; | ||
505 | 506 | /* GDI+ image */ |
506 | 507 | static Image* gdi_images[100]; |
507 | 508 | static Image* background_image; |
509 | +static int bg_width = 0; | |
510 | +static int bg_height = 0; | |
508 | 511 | |
509 | 512 | #ifdef USE_SAVER |
510 | 513 |
@@ -798,12 +801,13 @@ static int init_bg(void) | ||
798 | 801 | if(background_image) delete(background_image); |
799 | 802 | return 0; |
800 | 803 | } |
801 | - | |
804 | + bg_width = background_image->GetWidth(); | |
805 | + bg_height = background_image->GetHeight(); | |
802 | 806 | use_bg = 1; |
803 | 807 | return 1; |
804 | 808 | } |
805 | 809 | |
806 | -static void DrawBG(HDC hdc, RECT *r) | |
810 | +static void DrawBG(term_data *td, RECT *r) | |
807 | 811 | { |
808 | 812 | HDC hdcSrc; |
809 | 813 | HBITMAP hOld; |
@@ -813,14 +817,11 @@ static void DrawBG(HDC hdc, RECT *r) | ||
813 | 817 | if(!background_image) return; |
814 | 818 | |
815 | 819 | nx = x; ny = y; |
816 | - swid = background_image->GetWidth(); shgt = background_image->GetHeight(); | |
820 | + swid = bg_width; shgt = bg_height; | |
817 | 821 | if(swid == 0 || shgt == 0) |
818 | 822 | { |
819 | 823 | return; |
820 | 824 | } |
821 | - Graphics graphics(hdc); | |
822 | - hdcSrc = CreateCompatibleDC(hdc); | |
823 | - hOld = (HBITMAP)SelectObject(hdcSrc, hBG); | |
824 | 825 | Unit srcunit = UnitPixel; |
825 | 826 | do { |
826 | 827 | sx = nx % swid; |
@@ -828,18 +829,14 @@ static void DrawBG(HDC hdc, RECT *r) | ||
828 | 829 | do { |
829 | 830 | sy = ny % shgt; |
830 | 831 | chgt = MIN(shgt - sy, r->bottom - ny); |
831 | - | |
832 | 832 | rec = Gdiplus::Rect(sx, sy, cwid, chgt); |
833 | - graphics.DrawImage(background_image, rec, nx, ny, cwid, chgt, srcunit); | |
834 | -// graphics.DrawImage(background_image, nx, ny, sx, sy, swid, shgt, srcunit); | |
833 | + td->graphics->DrawImage(background_image, rec, nx, ny, cwid, chgt, srcunit); | |
835 | 834 | ny += chgt; |
836 | 835 | } while (ny < r->bottom); |
837 | 836 | ny = y; |
838 | 837 | nx += cwid; |
839 | 838 | } while (nx < r->right); |
840 | 839 | |
841 | - SelectObject(hdcSrc, hOld); | |
842 | - DeleteDC(hdcSrc); | |
843 | 840 | } |
844 | 841 | |
845 | 842 |
@@ -2366,7 +2363,7 @@ static errr Term_xtra_win_clear(void) | ||
2366 | 2363 | if (use_bg) |
2367 | 2364 | { |
2368 | 2365 | rc.left = 0; rc.top = 0; |
2369 | - DrawBG(hdc, &rc); | |
2366 | + DrawBG(td, &rc); | |
2370 | 2367 | } |
2371 | 2368 | ReleaseDC(td->w, hdc); |
2372 | 2369 |
@@ -2765,7 +2762,7 @@ static errr Term_wipe_win(int x, int y, int n) | ||
2765 | 2762 | /* bg */ |
2766 | 2763 | if (use_bg) |
2767 | 2764 | { |
2768 | - DrawBG(hdc, &rc); | |
2765 | + DrawBG(td, &rc); | |
2769 | 2766 | } |
2770 | 2767 | else |
2771 | 2768 | ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, NULL); |
@@ -2851,7 +2848,7 @@ static errr Term_text_win(int x, int y, int n, byte a, const char *s) | ||
2851 | 2848 | /* bg */ |
2852 | 2849 | if (use_bg) |
2853 | 2850 | { |
2854 | - DrawBG(hdc, &rc); | |
2851 | + DrawBG(td, &rc); | |
2855 | 2852 | } |
2856 | 2853 | |
2857 | 2854 | /* New rectangle */ |
@@ -3396,6 +3393,14 @@ static void init_windows(void) | ||
3396 | 3393 | my_td = NULL; |
3397 | 3394 | if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window")); |
3398 | 3395 | |
3396 | + if(td->graphics) | |
3397 | + { | |
3398 | + delete td->graphics; | |
3399 | + td->graphics = NULL; | |
3400 | + } | |
3401 | + td->graphics = new Gdiplus::Graphics(GetDC(td->w)); | |
3402 | + | |
3403 | + | |
3399 | 3404 | if (td->visible) |
3400 | 3405 | { |
3401 | 3406 | td->size_hack = TRUE; |
@@ -3436,6 +3441,12 @@ static void init_windows(void) | ||
3436 | 3441 | my_td = NULL; |
3437 | 3442 | if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window")); |
3438 | 3443 | |
3444 | + if(td->graphics) | |
3445 | + { | |
3446 | + delete td->graphics; | |
3447 | + td->graphics = NULL; | |
3448 | + } | |
3449 | + td->graphics = new Gdiplus::Graphics(GetDC(td->w)); | |
3439 | 3450 | term_data_link(td); |
3440 | 3451 | angband_term[0] = &td->t; |
3441 | 3452 | normsize.x = td->cols; |