Code cleanup: simplify subwindow code.

This commit is contained in:
Brecht Van Lommel 2018-02-14 03:08:58 +01:00
parent 88bd994a37
commit 3851033a06
7 changed files with 9 additions and 49 deletions

View File

@ -6494,7 +6494,6 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
win->ghostwin = NULL;
win->eventstate = NULL;
win->curswin = NULL;
win->tweak = NULL;
#ifdef WIN32
win->ime_data = NULL;

View File

@ -66,7 +66,6 @@ void ED_region_do_listen(
void ED_region_do_draw(struct bContext *C, struct ARegion *ar);
void ED_region_exit(struct bContext *C, struct ARegion *ar);
void ED_region_pixelspace(struct ARegion *ar);
void ED_region_set(const struct bContext *C, struct ARegion *ar);
void ED_region_update_rect(struct bContext *C, struct ARegion *ar);
void ED_region_init(struct bContext *C, struct ARegion *ar);
void ED_region_tag_redraw(struct ARegion *ar);

View File

@ -495,23 +495,6 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar)
glDisable(GL_BLEND);
}
/* only exported for WM */
/* makes region ready for drawing, sets pixelspace */
void ED_region_set(const bContext *C, ARegion *ar)
{
wmWindow *win = CTX_wm_window(C);
ScrArea *sa = CTX_wm_area(C);
ar->drawrct = ar->winrct;
/* note; this sets state, so we can use wmOrtho and friends */
wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct, true);
UI_SetTheme(sa ? sa->spacetype : 0, ar->type ? ar->type->regionid : 0);
ED_region_pixelspace(ar);
}
/* Follow wmMsgNotifyFn spec */
void ED_region_do_msg_notify_tag_redraw(
bContext *UNUSED(C), wmMsgSubscribeKey *UNUSED(msg_key), wmMsgSubscribeValue *msg_val)

View File

@ -208,8 +208,6 @@ typedef struct wmWindow {
struct wmEvent *eventstate; /* storage for event system */
struct wmSubWindow *curswin; /* internal for wm_subwindow.c only */
struct wmGesture *tweak; /* internal for wm_operators.c */
/* Input Method Editor data - complex character input (esp. for asian character input)

View File

@ -616,7 +616,7 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win)
CTX_wm_region_set(C, ar);
/* make region ready for draw, scissor, pixelspace */
ED_region_set(C, ar);
wmSubWindowScissorSet(win, ar->swinid, &ar->winrct, true);
wm_paintcursor_draw(C, ar);
CTX_wm_region_set(C, NULL);
@ -791,7 +791,7 @@ static void wm_method_draw_triple_multiview(bContext *C, wmWindow *win, eStereoV
CTX_wm_region_set(C, ar);
/* make region ready for draw, scissor, pixelspace */
ED_region_set(C, ar);
wmSubWindowScissorSet(win, ar->swinid, &ar->winrct, true);
wm_paintcursor_draw(C, ar);
CTX_wm_region_set(C, NULL);

View File

@ -91,13 +91,6 @@ void wm_subwindows_free(wmWindow *win)
}
int wm_subwindow_get_id(wmWindow *win)
{
if (win->curswin)
return win->curswin->swinid;
return 0;
}
static wmSubWindow *swin_from_swinid(wmWindow *win, int swinid)
{
wmSubWindow *swin;
@ -204,7 +197,7 @@ int wm_subwindow_open(wmWindow *win, const rcti *winrct, bool activate)
if (freewinid <= swin->swinid)
freewinid = swin->swinid + 1;
win->curswin = swin = MEM_callocN(sizeof(wmSubWindow), "swinopen");
swin = MEM_callocN(sizeof(wmSubWindow), "swinopen");
BLI_addtail(&win->subwindows, swin);
swin->swinid = freewinid;
@ -228,8 +221,6 @@ void wm_subwindow_close(wmWindow *win, int swinid)
wmSubWindow *swin = swin_from_swinid(win, swinid);
if (swin) {
if (swin == win->curswin)
win->curswin = NULL;
wm_subwindow_free(swin);
BLI_remlink(&win->subwindows, swin);
MEM_freeN(swin);
@ -285,26 +276,19 @@ void wm_subwindow_position(wmWindow *win, int swinid, const rcti *winrct, bool a
/* ---------------- WM versions of OpenGL style API calls ------------------------ */
/* ----------------- exported in WM_api.h ------------------------------------------------------ */
/* internal state, no threaded opengl! XXX */
static wmWindow *_curwindow = NULL;
static wmSubWindow *_curswin = NULL;
void wmSubWindowScissorSet(wmWindow *win, int swinid, const rcti *srct, bool srct_pad)
{
int width, height;
_curswin = swin_from_swinid(win, swinid);
wmSubWindow *swin = swin_from_swinid(win, swinid);
if (_curswin == NULL) {
if (swin == NULL) {
printf("%s %d: doesn't exist\n", __func__, swinid);
return;
}
win->curswin = _curswin;
_curwindow = win;
width = BLI_rcti_size_x(&_curswin->winrct) + 1;
height = BLI_rcti_size_y(&_curswin->winrct) + 1;
glViewport(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
width = BLI_rcti_size_x(&swin->winrct) + 1;
height = BLI_rcti_size_y(&swin->winrct) + 1;
glViewport(swin->winrct.xmin, swin->winrct.ymin, width, height);
if (srct) {
int scissor_width = BLI_rcti_size_x(srct);
@ -320,12 +304,10 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, const rcti *srct, bool src
glScissor(srct->xmin, srct->ymin, scissor_width, scissor_height);
}
else
glScissor(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
glScissor(swin->winrct.xmin, swin->winrct.ymin, width, height);
wmOrtho2_pixelspace(width, height);
gpuLoadIdentity();
glFlush();
}
/* enable the WM versions of opengl calls */

View File

@ -38,7 +38,6 @@ void wm_subwindows_free(wmWindow *win);
int wm_subwindow_open(wmWindow *win, const rcti *winrct, bool activate);
void wm_subwindow_close(wmWindow *win, int swinid);
int wm_subwindow_get_id(wmWindow *win); /* returns id */
void wm_subwindow_position(wmWindow *win, int swinid, const rcti *winrct, bool activate);