From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Anders Waldenborg Newsgroups: gmane.emacs.bugs Subject: bug#6230: 23.2; Pixmaps kept in X11 after (svg?) images no longer are used Date: Fri, 21 May 2010 08:37:58 +0200 Message-ID: <4BF62A46.10200@0x63.nu> References: <4BF557EE.4050400@0x63.nu> <87r5l6v6hg.fsf@stupidchicken.com> <4BF59689.7020003@0x63.nu> <87k4qyuxf1.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090403080700030203000601" X-Trace: dough.gmane.org 1274442861 30763 80.91.229.12 (21 May 2010 11:54:21 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 21 May 2010 11:54:21 +0000 (UTC) Cc: 6230@debbugs.gnu.org To: Chong Yidong Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri May 21 13:54:19 2010 connect(): No such file or directory Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OFQny-0004Fz-6s for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 May 2010 13:54:18 +0200 Original-Received: from localhost ([127.0.0.1]:48631 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OFQnx-0006nz-7l for geb-bug-gnu-emacs@m.gmane.org; Fri, 21 May 2010 07:54:17 -0400 Original-Received: from [140.186.70.92] (port=47266 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OFQno-0006nr-Et for bug-gnu-emacs@gnu.org; Fri, 21 May 2010 07:54:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OFQnh-0004ff-07 for bug-gnu-emacs@gnu.org; Fri, 21 May 2010 07:54:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60590) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OFMAI-0002yf-1K for bug-gnu-emacs@gnu.org; Fri, 21 May 2010 02:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OFLss-0005OY-M5; Fri, 21 May 2010 02:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Anders Waldenborg Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 May 2010 06:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6230 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 6230-submit@debbugs.gnu.org id=B6230.127442389320720 (code B ref 6230); Fri, 21 May 2010 06:39:02 +0000 Original-Received: (at 6230) by debbugs.gnu.org; 21 May 2010 06:38:13 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OFLs4-0005O9-Cf for submit@debbugs.gnu.org; Fri, 21 May 2010 02:38:13 -0400 Original-Received: from phlox.netintact.se ([217.73.97.18]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OFLs0-0005O3-S9 for 6230@debbugs.gnu.org; Fri, 21 May 2010 02:38:10 -0400 Original-Received: from hoth.proceranetworks.com (hoth.proceranetworks.com [194.153.91.41]) by phlox.netintact.se (Postfix) with ESMTP id 00A063E8001; Fri, 21 May 2010 08:38:05 +0200 (CEST) Original-Received: from hidden.prnw.net (hidden.prnw.net [127.0.0.1]) by hoth.proceranetworks.com (Postfix) with ESMTP id D965C45F0002; Fri, 21 May 2010 08:38:04 +0200 (CEST) Original-Received: from hoth.proceranetworks.com ([127.0.0.1]) by localhost (hoth.proceranetworks.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ArTxVRqgWe17; Fri, 21 May 2010 08:37:59 +0200 (CEST) Original-Received: from hidden.prnw.net (hidden.prnw.net [127.0.0.1]) by hoth.proceranetworks.com (Postfix) with ESMTP id A87B545F0001; Fri, 21 May 2010 08:37:59 +0200 (CEST) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100515 Icedove/3.0.4 In-Reply-To: <87k4qyuxf1.fsf@stupidchicken.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 21 May 2010 02:39:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:37143 Archived-At: This is a multi-part message in MIME format. --------------090403080700030203000601 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 05/20/2010 10:32 PM, Chong Yidong wrote: > Oh, yes, I forgot. There is image-cache-eviction-delay as well. If you > set this to a sufficiently small number, the test frees the pixmaps as > required. Yes, that works, thanks. > Is there a specific reason you are interested in this problem? It's > possible that we need to improve the conditions under which the image > cache is freed, but it's hard to tell unless we have a use-case in mind. > (Obviously, the current system assumes that the rate at which images are > created is much lower than the "usual editing speed".) Well, I'm toying with a little vector graphics API built on top of emacs' svg support. And my first real example is a clock. By leaving it running for a few minutes easily makes my X server go out of memory. You can find the library (vrend.el) and the example implementing a clock (vrend-example-clock.el) attached. Not sure this clock is a real use-case. But I have a few other ideas in mind on how to use it, which all have substantially lower requirements on refresh rate, but probably large enough to create lots of pixmaps in 30 minutes (which seems to be default value for image-cache-eviction-delay) anders --------------090403080700030203000601 Content-Type: text/plain; name="vrend.el" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="vrend.el" ;;; Beta quality code - use at own risk ;;; Copyright (C) 2010 Anders Waldenborg ;;; I'll add a GPL header or something like that here later... ; We handle the tranformation matrix (but let svg do the actual projection). ; So we need some stuff to handle matrices... (defconst vrend-2pi (* 8.0 (atan 1.0))) (defun vrend--mtx-col (mtx col) "Get column col in matrix mtx" (mapcar '(lambda (v) (aref v col)) mtx)) (defun vrend--mtx-row (mtx row) "Get row row in matrix mtx" (mapcar 'identity (aref mtx row))) (defun vrend--mtx-ref (i j) (aref (aref vrend--curr-mtx i) j)) (defun vrend--dotprod (l r) "dot product of l and r" (if (or l r) (+ (* (car l) (car r)) (vrend--dotprod (cdr l) (cdr r))) 0)) (defun vrend--mtx-mul3x3 (l r) `[[,(vrend--dotprod (vrend--mtx-row l 0) (vrend--mtx-col r 0)) ,(vrend--dotprod (vrend--mtx-row l 0) (vrend--mtx-col r 1)) ,(vrend--dotprod (vrend--mtx-row l 0) (vrend--mtx-col r 2))] [,(vrend--dotprod (vrend--mtx-row l 1) (vrend--mtx-col r 0)) ,(vrend--dotprod (vrend--mtx-row l 1) (vrend--mtx-col r 1)) ,(vrend--dotprod (vrend--mtx-row l 1) (vrend--mtx-col r 2))] [,(vrend--dotprod (vrend--mtx-row l 2) (vrend--mtx-col r 0)) ,(vrend--dotprod (vrend--mtx-row l 2) (vrend--mtx-col r 1)) ,(vrend--dotprod (vrend--mtx-row l 2) (vrend--mtx-col r 2))]]) (defun vrend--mtx-translate (dx dy) "translationmatrix for dx dy" `[[1.0 0.0 ,dx] [0.0 1.0 ,dy] [0.0 0.0 1.0]]) (defun vrend--mtx-rotate (rot) "" `[[,(cos rot) ,(- (sin rot)) 0.0] [,(sin rot) ,(cos rot) 0.0] [ 0.0 0.0 1.0]]) (defun vrend--mtx-scale (sx sy) "" `[[,sx 0.0 0.0] [0.0 ,sy 0.0] [0.0 0.0 1.0]]) (defun vrend--mtx-ident () "" [[1.0 0.0 0.0] [0.0 1.0 0.0] [0.0 0.0 1.0]]) (defun vrend-path-start (x y) (setq vrend--curr-path nil) (vrend-path-moveto x y)) (defun vrend-path-moveto (x y) (add-to-list 'vrend--curr-path (list ?M x y))) (defun vrend-path-lineto (x y) (add-to-list 'vrend--curr-path (list ?L x y))) (defun vrend-path-close () (add-to-list 'vrend--curr-path (list ?Z))) (defun vrend-rotate (deg) (setq vrend--curr-mtx (vrend--mtx-mul3x3 vrend--curr-mtx (vrend--mtx-rotate deg)))) (defun vrend-scale (sx sy) (setq vrend--curr-mtx (vrend--mtx-mul3x3 vrend--curr-mtx (vrend--mtx-scale (float sx) (float sy))))) (defun vrend-translate (dx dy) (setq vrend--curr-mtx (vrend--mtx-mul3x3 vrend--curr-mtx (vrend--mtx-translate (float dx) (float dy))))) (defun vrend--render-path-element (e) (format "%c %s" (car e) (mapconcat '(lambda (x) (format "%f" x)) (cdr e) " "))) (defun vrend--render-path () (insert " d=\"" (mapconcat 'vrend--render-path-element (reverse vrend--curr-path) " ") "\"")) (defun vrend--render-transform () (insert (format " transform=\"matrix(%f %f %f %f %f %f)\"" (vrend--mtx-ref 0 0) (vrend--mtx-ref 1 0) (vrend--mtx-ref 0 1) (vrend--mtx-ref 1 1) (vrend--mtx-ref 0 2) (vrend--mtx-ref 1 2)))) (defun vrend-path-stroke () (insert " \n")) (defmacro vrend-with-saved-matrix (&rest body) (declare (indent 0) (debug t)) `(let ((vrend-with-saved-matrix-saved-matrix vrend--curr-mtx)) (progn ,@body (setq vrend--curr-mtx vrend-with-saved-matrix-saved-matrix)))) (defmacro vrend (width height coordinatetype &rest body) (declare (indent 3) (debug t)) (let ((width (eval width)) (height (eval height))) `(with-temp-buffer (set (make-local-variable 'vrend--curr-mtx) (vrend--mtx-ident)) (set (make-local-variable 'vrend--curr-path) nil) (set (make-local-variable 'vrend--curr-strokestyle) '("black" :width 1)) (set (make-local-variable 'vrend--curr-fillstyle) nil) (insert "\n" "\n" (format "\n") (when ,coordinatetype (vrend-translate ,(/ width 2) ,(/ height 2)) (when (eq ,coordinatetype '1x1fit) (let ((smalldir ,(min width height))) (vrend-scale (/ smalldir 2.0) (/ smalldir 2.0)))) (when (eq ,coordinatetype '1x1square) (vrend-scale ,(/ width 2.0) ,(/ height 2.0))) (vrend-scale -1.0 -1.0)) (progn ,@body) (insert "\n") (create-image (buffer-string) nil t) ))) (provide 'vrend) --------------090403080700030203000601 Content-Type: text/plain; name="vrend-example-clock.el" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="vrend-example-clock.el" ;;; Beta quality code - use at own risk ;;; Copyright (C) 2010 Anders Waldenborg ;;; I'll add a GPL header or something like that here later... ;;; Small example on how to use vrend. ;;; Defines the command vrend-clock which creates a new buffer, ;;; Make sure you resize the window/frame and stuff like that. (require 'cl) (require 'vrend) (defun vrend-clock-update-buffer (buf) (let ((win (get-buffer-window buf t))) (when win (let* ((X (window-inside-pixel-edges win)) (w (- (car (cddr X)) (car X))) (h (- (cadr (cddr X)) (cadr X)))) (with-current-buffer buf (erase-buffer) (insert-image (vrend w h '1x1fit ;; Make hour markers... (vrend-path-start 0.0 0.8) (vrend-path-lineto 0.0 0.9) (vrend-path-close) ;; ...12 of them (loop for D from 0 to 11 by 1 do (vrend-with-saved-matrix (vrend-rotate (* D (/ vrend-2pi 12))) (vrend-path-stroke))) ;; and arrows (let* ((ct (current-time)) (T (decode-time ct)) (h (nth 2 T)) (m (nth 1 T)) (s (nth 0 T)) (ms (/ (nth 2 ct) 1000)) (seconds-since-midnight (+ (* (+ (* h 60) m) 60) s)) (seconds-since-hour (+ (* m 60) s)) (ms-since-minute (+ ms (* s 1000)))) (vrend-with-saved-matrix (vrend-path-start 0.0 0.0) (vrend-path-lineto -0.05 0.4) (vrend-path-lineto 0.0 0.6) (vrend-path-lineto 0.05 0.4) (vrend-path-close) (vrend-rotate (* seconds-since-midnight (/ vrend-2pi (* 60 60 12)))) (vrend-path-stroke)) (vrend-with-saved-matrix (vrend-path-start 0.0 0.0) (vrend-path-lineto -0.05 0.3) (vrend-path-lineto 0.0 0.90) (vrend-path-lineto 0.05 0.3) (vrend-path-close) (vrend-rotate (* seconds-since-hour (/ vrend-2pi (* 60 60)))) (vrend-path-stroke)) (vrend-with-saved-matrix (vrend-path-start 0.0 0.0) (vrend-path-lineto 0.0 0.90) (vrend-path-close) (vrend-rotate (* ms-since-minute (/ vrend-2pi 60000.0))) (vrend-path-stroke)))))))))) (defun vrend-kill-buffer-hook () (cancel-timer vrend-clock-timer)) (defun vrend-clock () (interactive) (with-current-buffer (generate-new-buffer "*aw-clock*") (set-window-buffer nil (current-buffer)) (make-local-variable 'vrend-clock-timer) (add-hook 'kill-buffer-hook 'vrend-kill-buffer-hook nil t) (setq vrend-clock-timer (run-at-time nil 0.1 'vrend-clock-update-buffer (current-buffer))))) --------------090403080700030203000601--