1
0
Fork 0

- optimized 'draw-all' made clearing window optional and draw only full visible window.

This commit is contained in:
cage 2022-03-11 16:00:00 +01:00
parent 8eafdb4201
commit 594ff4054e
3 changed files with 68 additions and 20 deletions

View File

@ -16,38 +16,84 @@
(in-package :2d-utils) (in-package :2d-utils)
(eval-when (:compile-toplevel :load-toplevel :execute)
(deftype ivec4-type ()
'(signed-byte 32))
(deftype ivec4 ()
"A 4d vector of unsigned integer."
`(simple-array ivec4-type (4)))
(defun ivec4p (a)
(typep a 'ivec4))
(defun ivec4= (a b)
(every #'= a b)))
(defun ivec4 (x y z &optional (w 0))
(let ((res (misc:make-array-frame 4 0 'ivec4-type t)))
(setf (elt res 0) x
(elt res 1) y
(elt res 2) z
(elt res 3) w)
res))
(defun copy-ivec4 (old)
(let ((res (misc:make-array-frame 4 0 'ivec4-type t)))
(declare (ivec4 res))
(setf (elt res 0) (elt old 0)
(elt res 1) (elt old 1)
(elt res 2) (elt old 2)
(elt res 3) (elt old 3))
res))
(defun make-fresh-ivec4 ()
(misc:make-array-frame 4 0 'ivec4-type t))
(defun iaabb2-min-x (aabb) (defun iaabb2-min-x (aabb)
(declare (ivec4 aabb))
(declare (optimize (speed 3) (debug 0)))
(elt aabb 0)) (elt aabb 0))
(defun iaabb2-max-x (aabb) (defun iaabb2-max-x (aabb)
(declare (ivec4 aabb))
(declare (optimize (speed 3) (debug 0)))
(elt aabb 2)) (elt aabb 2))
(defun iaabb2-min-y (aabb) (defun iaabb2-min-y (aabb)
(declare (ivec4 aabb))
(declare (optimize (speed 3) (debug 0)))
(elt aabb 1)) (elt aabb 1))
(defun iaabb2-max-y (aabb) (defun iaabb2-max-y (aabb)
(declare (ivec4 aabb))
(declare (optimize (speed 3) (debug 0)))
(elt aabb 3)) (elt aabb 3))
(defun make-iaabb2 (min-x min-y max-x max-y) (defun make-iaabb2 (min-x min-y max-x max-y)
(list min-x min-y max-x max-y)) (declare (optimize (speed 3) (debug 0)))
(ivec4 min-x min-y max-x max-y))
(defun iaabb2~ (a b) (defun iaabb2~ (a b)
(and (declare (ivec4 a b))
(= (elt a 0) (elt b 0)) (declare (optimize (speed 3) (debug 0)))
(= (elt a 1) (elt b 1)) (and (= (elt a 0) (elt b 0))
(= (elt a 2) (elt b 2)) (= (elt a 1) (elt b 1))
(= (elt a 3) (elt b 3)))) (= (elt a 2) (elt b 2))
(= (elt a 3) (elt b 3))))
(defun valid-iaabb2 (aabb) (defun valid-iaabb2 (aabb)
(declare (ivec4 aabb))
(declare (optimize (speed 3) (debug 0)))
(and (>= (elt aabb 0) 0) (and (>= (elt aabb 0) 0)
(>= (elt aabb 1) 0) (>= (elt aabb 1) 0)
(>= (elt aabb 2) 0) (>= (elt aabb 2) 0)
(>= (elt aabb 3) 0) (>= (elt aabb 3) 0)
(> (elt aabb 2) (elt aabb 0)) (> (elt aabb 2) (elt aabb 0))
(> (elt aabb 3) (elt aabb 1)))) (> (elt aabb 3) (elt aabb 1))))
(defun expand-iaabb2 (aabb coord) (defun expand-iaabb2 (aabb coord)
(let ((cp (copy-list aabb))) (let ((cp (copy-ivec4 aabb)))
(when (< (elt coord 0) (elt aabb 0)) (when (< (elt coord 0) (elt aabb 0))
(setf (elt cp 0) (elt coord 0))) (setf (elt cp 0) (elt coord 0)))
(when (> (elt coord 0) (elt aabb 2)) (when (> (elt coord 0) (elt aabb 2))
@ -59,7 +105,7 @@
cp)) cp))
(defun union-iaabb2 (aabb aabb2) (defun union-iaabb2 (aabb aabb2)
(let ((cp (copy-list aabb))) (let ((cp (copy-ivec4 aabb)))
(setf cp (expand-iaabb2 cp (subseq aabb2 0 2))) (setf cp (expand-iaabb2 cp (subseq aabb2 0 2)))
(setf cp (expand-iaabb2 cp (list (elt aabb2 2) (elt aabb2 1)))) (setf cp (expand-iaabb2 cp (list (elt aabb2 2) (elt aabb2 1))))
(setf cp (expand-iaabb2 cp (list (elt aabb2 2) (elt aabb2 3)))) (setf cp (expand-iaabb2 cp (list (elt aabb2 2) (elt aabb2 3))))
@ -73,16 +119,16 @@
(y1 (elt coords 1)) (y1 (elt coords 1))
(x2 (elt coords 2)) (x2 (elt coords 2))
(y2 (elt coords 3))) (y2 (elt coords 3)))
(list x1 y1 (- x2 x1) (- y2 y1)))) (ivec4 x1 y1 (- x2 x1) (- y2 y1))))
(defun irect2->iaabb2 (coords) (defun irect2->iaabb2 (coords)
"(upper-left-x upper-left-y w h) to "(upper-left-x upper-left-y w h) to
(upper-left-x upper-left-y bottom-right-x bottom-right-y)" (upper-left-x upper-left-y bottom-right-x bottom-right-y)"
(let ((x1 (elt coords 0)) (let ((x1 (elt coords 0))
(y1 (elt coords 1)) (y1 (elt coords 1))
(w (elt coords 2)) (w (elt coords 2))
(h (elt coords 3))) (h (elt coords 3)))
(list x1 y1 (+ x1 w) (+ y1 h)))) (ivec4 x1 y1 (+ x1 w) (+ y1 h))))
(defun irect2->iaabb2* (&rest coords) (defun irect2->iaabb2* (&rest coords)
(irect2->iaabb2 coords)) (irect2->iaabb2 coords))

View File

@ -429,7 +429,7 @@ Metadata includes:
win) win)
(remove-focus-to-all-windows) (remove-focus-to-all-windows)
(setf (windows:in-focus win) t) (setf (windows:in-focus win) t)
(windows:draw-all) (windows:draw-all :clear nil)
(when info-change-focus-message (when info-change-focus-message
(info-message info-change-focus-message +maximum-event-priority+)) (info-message info-change-focus-message +maximum-event-priority+))
win) win)

View File

@ -379,11 +379,13 @@ height, position and so on)"
(calculate window dt)) (calculate window dt))
(refresh-marked)) (refresh-marked))
(defun draw-all () (defun draw-all (&key (clear t))
(do-stack-element (window *window-stack*) (let ((to-be-drawn (remove-intersecting-window)))
(when (win-visible-p window) (loop for window in to-be-drawn do
(win-clear window) (when (win-visible-p window)
(draw window)))) (when clear
(win-clear window))
(draw window)))))
(defun refresh-config-all () (defun refresh-config-all ()
(if command-line:*gemini-full-screen-mode* (if command-line:*gemini-full-screen-mode*