• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revisionf883662f88f8850b210e47ce6acb5e2579348069 (tree)
Zeit2016-11-07 01:00:19
AutorDeskull <desull@user...>
CommiterDeskull

Log Message

GDI+のための描画処理を整理。 / Rearrange drawing process for GDI+.

Ändern Zusammenfassung

Diff

--- a/src/main-win.c
+++ b/src/main-win.c
@@ -374,6 +374,7 @@ struct _term_data
374374 cptr s;
375375
376376 HWND w;
377+ Gdiplus::Graphics *graphics;
377378
378379 DWORD dwStyle;
379380 DWORD dwExStyle;
@@ -505,6 +506,8 @@ static int use_new_gmode = 0;
505506 /* GDI+ image */
506507 static Image* gdi_images[100];
507508 static Image* background_image;
509+static int bg_width = 0;
510+static int bg_height = 0;
508511
509512 #ifdef USE_SAVER
510513
@@ -798,12 +801,13 @@ static int init_bg(void)
798801 if(background_image) delete(background_image);
799802 return 0;
800803 }
801-
804+ bg_width = background_image->GetWidth();
805+ bg_height = background_image->GetHeight();
802806 use_bg = 1;
803807 return 1;
804808 }
805809
806-static void DrawBG(HDC hdc, RECT *r)
810+static void DrawBG(term_data *td, RECT *r)
807811 {
808812 HDC hdcSrc;
809813 HBITMAP hOld;
@@ -813,14 +817,11 @@ static void DrawBG(HDC hdc, RECT *r)
813817 if(!background_image) return;
814818
815819 nx = x; ny = y;
816- swid = background_image->GetWidth(); shgt = background_image->GetHeight();
820+ swid = bg_width; shgt = bg_height;
817821 if(swid == 0 || shgt == 0)
818822 {
819823 return;
820824 }
821- Graphics graphics(hdc);
822- hdcSrc = CreateCompatibleDC(hdc);
823- hOld = (HBITMAP)SelectObject(hdcSrc, hBG);
824825 Unit srcunit = UnitPixel;
825826 do {
826827 sx = nx % swid;
@@ -828,18 +829,14 @@ static void DrawBG(HDC hdc, RECT *r)
828829 do {
829830 sy = ny % shgt;
830831 chgt = MIN(shgt - sy, r->bottom - ny);
831-
832832 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);
835834 ny += chgt;
836835 } while (ny < r->bottom);
837836 ny = y;
838837 nx += cwid;
839838 } while (nx < r->right);
840839
841- SelectObject(hdcSrc, hOld);
842- DeleteDC(hdcSrc);
843840 }
844841
845842
@@ -2366,7 +2363,7 @@ static errr Term_xtra_win_clear(void)
23662363 if (use_bg)
23672364 {
23682365 rc.left = 0; rc.top = 0;
2369- DrawBG(hdc, &rc);
2366+ DrawBG(td, &rc);
23702367 }
23712368 ReleaseDC(td->w, hdc);
23722369
@@ -2765,7 +2762,7 @@ static errr Term_wipe_win(int x, int y, int n)
27652762 /* bg */
27662763 if (use_bg)
27672764 {
2768- DrawBG(hdc, &rc);
2765+ DrawBG(td, &rc);
27692766 }
27702767 else
27712768 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)
28512848 /* bg */
28522849 if (use_bg)
28532850 {
2854- DrawBG(hdc, &rc);
2851+ DrawBG(td, &rc);
28552852 }
28562853
28572854 /* New rectangle */
@@ -3396,6 +3393,14 @@ static void init_windows(void)
33963393 my_td = NULL;
33973394 if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
33983395
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+
33993404 if (td->visible)
34003405 {
34013406 td->size_hack = TRUE;
@@ -3436,6 +3441,12 @@ static void init_windows(void)
34363441 my_td = NULL;
34373442 if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
34383443
3444+ if(td->graphics)
3445+ {
3446+ delete td->graphics;
3447+ td->graphics = NULL;
3448+ }
3449+ td->graphics = new Gdiplus::Graphics(GetDC(td->w));
34393450 term_data_link(td);
34403451 angband_term[0] = &td->t;
34413452 normsize.x = td->cols;