[Bf-blender-cvs] [3851033a06b] blender2.8: Code cleanup: simplify subwindow code.

Brecht Van Lommel noreply at git.blender.org
Wed Feb 14 12:48:01 CET 2018


Commit: 3851033a06b34abb7492fe5953249e9ff18efca4
Author: Brecht Van Lommel
Date:   Wed Feb 14 03:08:58 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB3851033a06b34abb7492fe5953249e9ff18efca4

Code cleanup: simplify subwindow code.

===================================================================

M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/include/ED_screen.h
M	source/blender/editors/screen/area.c
M	source/blender/makesdna/DNA_windowmanager_types.h
M	source/blender/windowmanager/intern/wm_draw.c
M	source/blender/windowmanager/intern/wm_subwindow.c
M	source/blender/windowmanager/wm_subwindow.h

===================================================================

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index a5370313a93..c70c4830971 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -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;
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 8fa043499f8..01c1e308fb0 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -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);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 274dbcc73cb..57278307d0b 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -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)
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 9ec34ac3823..698d7dfd621 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -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)
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index d103f2291bf..eaee2dae3ac 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -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);
diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c
index 1a8f71891c0..17d69a13aff 100644
--- a/source/blender/windowmanager/intern/wm_subwindow.c
+++ b/source/blender/windowmanager/intern/wm_subwindow.c
@@ -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 */
diff --git a/source/blender/windowmanager/wm_subwindow.h b/source/blender/windowmanager/wm_subwindow.h
index cc9abf87514..77c44d763f7 100644
--- a/source/blender/windowmanager/wm_subwindow.h
+++ b/source/blender/windowmanager/wm_subwindow.h
@@ -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);



More information about the Bf-blender-cvs mailing list