[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18597] branches/blender2.5/blender/source /blender: 2.5: WIP commit for WM compositing.

Brecht Van Lommel brecht at blender.org
Tue Jan 20 22:55:50 CET 2009


Revision: 18597
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18597
Author:   blendix
Date:     2009-01-20 22:55:48 +0100 (Tue, 20 Jan 2009)

Log Message:
-----------
2.5: WIP commit for WM compositing.

* Drawing code from wm_event_system.c split into separate wm_draw.c file.

Now there's 3 different draw methods implemented, not sure what survives
or will be added but is useful for debugging.

* Draw All: redraws everything each time, for reference.
* Draw Overlap All: what the code did before this commit, only draw
  regions marked for redraw, and anything that overlaps them.
* Triple Buffer: copies/retores all area regions into a texture, and
  blits that before drawing. Menus, brushes, gestures, etc are redrawn
  always on top of that.

Currently "Draw Overlap All" is set hardcoded to be used still. Triple
Buffer code is not complete, it doesn't handle window resize yet. Cards
that don't support non power of two textures can need quite large
textures as well, this could be split into multiple smaller ones.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/include/ED_screen.h
    branches/blender2.5/blender/source/blender/editors/screen/area.c
    branches/blender2.5/blender/source/blender/editors/screen/screen_edit.c
    branches/blender2.5/blender/source/blender/gpu/GPU_extensions.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_windowmanager_types.h
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_event_system.c

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_draw.c

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-01-20 20:44:36 UTC (rev 18596)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-01-20 21:55:48 UTC (rev 18597)
@@ -3999,6 +3999,9 @@
 		win->queue.first= win->queue.last= NULL;
 		win->handlers.first= win->handlers.last= NULL;
 		win->subwindows.first= win->subwindows.last= NULL;
+
+		win->drawtex= 0;
+		win->drawmethod= 0;
 	}
 	
 	wm->operators.first= wm->operators.last= NULL;
@@ -4448,6 +4451,7 @@
 	ar->headerstr= NULL;
 	ar->swinid= 0;
 	ar->type= NULL;
+	ar->swap= 0;
 }
 
 /* for the saved 2.50 files without regiondata */

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_screen.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_screen.h	2009-01-20 20:44:36 UTC (rev 18596)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_screen.h	2009-01-20 21:55:48 UTC (rev 18597)
@@ -55,7 +55,7 @@
 void	ED_spacetypes_keymap(struct wmWindowManager *wm);
 int		ED_area_header_standardbuttons(const struct bContext *C, struct uiBlock *block, int yco);
 void	ED_area_overdraw(struct bContext *C);
-void	ED_area_overdraw_flush(struct bContext *C);
+void	ED_area_overdraw_flush(struct bContext *C, struct ScrArea *sa, struct ARegion *ar);
 
 
 /* areas */

Modified: branches/blender2.5/blender/source/blender/editors/screen/area.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/area.c	2009-01-20 20:44:36 UTC (rev 18596)
+++ branches/blender2.5/blender/source/blender/editors/screen/area.c	2009-01-20 21:55:48 UTC (rev 18597)
@@ -143,28 +143,18 @@
 
 /* based on screen region draw tags, set draw tags in azones, and future region tabs etc */
 /* only exported for WM */
-void ED_area_overdraw_flush(bContext *C)
+void ED_area_overdraw_flush(bContext *C, ScrArea *sa, ARegion *ar)
 {
-	ScrArea *sa;
+	AZone *az;
 	
-	for(sa= CTX_wm_screen(C)->areabase.first; sa; sa= sa->next) {
-		ARegion *ar;
-		
-		for(ar= sa->regionbase.first; ar; ar= ar->next) {
-			if(ar->do_draw) {
-				AZone *az;
-				
-				for(az= sa->actionzones.first; az; az= az->next) {
-					int xs= (az->x1+az->x2)/2, ys= (az->y1+az->y2)/2;
-		
-					/* test if inside */
-					if(BLI_in_rcti(&ar->winrct, xs, ys)) {
-						az->do_draw= 1;
-					}
-				}
-			}
+	for(az= sa->actionzones.first; az; az= az->next) {
+		int xs= (az->x1+az->x2)/2, ys= (az->y1+az->y2)/2;
+
+		/* test if inside */
+		if(BLI_in_rcti(&ar->winrct, xs, ys)) {
+			az->do_draw= 1;
 		}
-	}	
+	}
 }
 
 /* only exported for WM */
@@ -233,7 +223,6 @@
 	ED_region_pixelspace(ar);
 	
 	ar->do_draw= 0;
-	ar->swap= WIN_BACK_OK;
 }
 
 /* **********************************

Modified: branches/blender2.5/blender/source/blender/editors/screen/screen_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/screen_edit.c	2009-01-20 20:44:36 UTC (rev 18596)
+++ branches/blender2.5/blender/source/blender/editors/screen/screen_edit.c	2009-01-20 21:55:48 UTC (rev 18597)
@@ -990,7 +990,6 @@
 	
 	if(G.f & G_DEBUG) printf("draw screen\n");
 	win->screen->do_draw= 0;
-	win->screen->swap= WIN_BACK_OK;
 }
 
 /* make this screen usable */

Modified: branches/blender2.5/blender/source/blender/gpu/GPU_extensions.h
===================================================================
--- branches/blender2.5/blender/source/blender/gpu/GPU_extensions.h	2009-01-20 20:44:36 UTC (rev 18596)
+++ branches/blender2.5/blender/source/blender/gpu/GPU_extensions.h	2009-01-20 21:55:48 UTC (rev 18597)
@@ -62,8 +62,8 @@
    - if texture with non square dimensions is created, depending on the
      graphics card capabilities the texture may actually be stored in a
 	 larger texture with power of two dimensions. the actual dimensions
-	 may be querd with GPU_texture_opengl_width/height. GPU_texture_coord_2f
-	 calls glTexCoord2f with the coordinates adjust for this.
+	 may be queried with GPU_texture_opengl_width/height. GPU_texture_coord_2f
+	 calls glTexCoord2f with the coordinates adjusted for this.
    - can use reference counting:
        - reference counter after GPU_texture_create is 1
        - GPU_texture_ref increases by one

Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_windowmanager_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesdna/DNA_windowmanager_types.h	2009-01-20 20:44:36 UTC (rev 18596)
+++ branches/blender2.5/blender/source/blender/makesdna/DNA_windowmanager_types.h	2009-01-20 21:55:48 UTC (rev 18597)
@@ -96,6 +96,10 @@
 	struct wmEvent *eventstate;	/* storage for event system */
 	
 	struct wmSubWindow *curswin;	/* internal for wm_subwindow.c only */
+
+	unsigned int drawtex;		/* internal for wm_draw.c only */
+	int drawtexw, drawtexh;		/* internal for wm_draw.c only */
+	int drawmethod;				/* internal for wm_draw.c only */
 	
 	ListBase timers;
 	

Added: branches/blender2.5/blender/source/blender/windowmanager/intern/wm_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/windowmanager/intern/wm_draw.c	                        (rev 0)
+++ branches/blender2.5/blender/source/blender/windowmanager/intern/wm_draw.c	2009-01-20 21:55:48 UTC (rev 18597)
@@ -0,0 +1,515 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. 
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2007 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <GL/glew.h>
+
+#include "DNA_listBase.h"
+#include "DNA_screen_types.h"
+#include "DNA_windowmanager_types.h"
+#include "DNA_userdef_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+
+#include "BKE_context.h"
+#include "BKE_global.h"
+
+#include "ED_screen.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+#include "wm.h"
+#include "wm_window.h"
+#include "wm_event_system.h"
+
+/* swap */
+#define WIN_NONE_OK		0
+#define WIN_BACK_OK     1
+#define WIN_FRONT_OK    2
+#define WIN_BOTH_OK		3
+
+/* draw method */
+#define USER_DRAW_ALL			0
+#define USER_DRAW_OVERLAP_ALL	1
+#define USER_DRAW_OVERLAP		2
+#define USER_DRAW_TRIPLE		3
+
+/* ********************* drawing, swap ****************** */
+
+static void wm_paintcursor_draw(bContext *C)
+{
+	wmWindowManager *wm= CTX_wm_manager(C);
+	
+	if(wm->paintcursors.first) {
+		wmWindow *win= CTX_wm_window(C);
+		wmPaintCursor *pc;
+		
+		for(pc= wm->paintcursors.first; pc; pc= pc->next) {
+			if(pc->poll(C)) {
+				ARegion *ar= CTX_wm_region(C);
+				pc->draw(C, win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin);
+			}
+		}
+	}
+}
+
+/********************** draw all **************************/
+/* - reference method, draw all each time                 */
+
+static void wm_method_draw_all(bContext *C, wmWindow *win)
+{
+	bScreen *screen= win->screen;
+	ScrArea *sa;
+	ARegion *ar;
+
+	/* draw area regions */
+	for(sa= screen->areabase.first; sa; sa= sa->next) {
+		CTX_wm_area_set(C, sa);
+
+		for(ar=sa->regionbase.first; ar; ar= ar->next) {
+			if(ar->swinid) {
+				CTX_wm_region_set(C, ar);
+				ED_region_do_draw(C, ar);
+				if(screen->subwinactive==ar->swinid)
+					wm_paintcursor_draw(C);
+				ED_area_overdraw_flush(C, sa, ar);
+				CTX_wm_region_set(C, NULL);
+			}
+		}
+		
+		CTX_wm_area_set(C, NULL);
+	}
+
+	ED_screen_draw(win);
+	ED_area_overdraw(C);
+
+	/* draw overlapping regions */
+	for(ar=screen->regionbase.first; ar; ar= ar->next) {
+		if(ar->swinid) {
+			CTX_wm_region_set(C, ar);
+			ED_region_do_draw(C, ar);
+			CTX_wm_region_set(C, NULL);
+		}
+	}
+
+	if(screen->do_gesture)
+		wm_gesture_draw(win);
+}
+
+/****************** draw overlap all **********************/
+/* - redraw marked areas, and anything that overlaps it   */
+/* - it also handles swap exchange optionally, assuming   */
+/*   that on swap no clearing happens and we get back the */
+/*   same buffer as we swapped to the front               */
+/* - TODO for swap exchange in full screen mode, and then */
+/*   switching to another window seems to invalidate the  */
+/*   swap flags, probably best to clear then?             */
+
+/* mark area-regions to redraw if overlapped with rect */
+static void wm_overlap_regions_down(bScreen *screen, rcti *dirty)
+{
+	ScrArea *sa;
+	ARegion *ar;
+
+	for(sa= screen->areabase.first; sa; sa= sa->next) {
+		for(ar= sa->regionbase.first; ar; ar= ar->next) {
+			if(BLI_isect_rcti(dirty, &ar->winrct, NULL)) {
+				ar->do_draw= 1;
+				ar->swap= WIN_NONE_OK;
+			}
+		}
+	}
+}
+
+/* mark menu-regions to redraw if overlapped with rect */
+static void wm_overlap_regions_up(bScreen *screen, rcti *dirty)
+{
+	ARegion *ar;
+	
+	for(ar= screen->regionbase.first; ar; ar= ar->next) {
+		if(BLI_isect_rcti(dirty, &ar->winrct, NULL)) {
+			ar->do_draw= 1;
+			ar->swap= WIN_NONE_OK;
+		}
+	}
+}
+
+static void wm_method_draw_overlap_all(bContext *C, wmWindow *win)
+{
+	bScreen *screen= win->screen;
+	ScrArea *sa;
+	ARegion *ar;
+	int exchange= (G.f & G_SWAP_EXCHANGE);
+
+	/* flush overlapping regions */
+	if(screen->regionbase.first) {
+		/* flush redraws of area regions up to overlapping regions */
+		for(sa= screen->areabase.first; sa; sa= sa->next)
+			for(ar= sa->regionbase.first; ar; ar= ar->next)
+				if(ar->swinid && ar->do_draw)
+					wm_overlap_regions_up(screen, &ar->winrct);
+		

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list