Mercurial > hg > indyvon
changeset 93:017f5f14b876
Async layer: use compatible BufferedImage.
author | Mikhail Kryshen <mikhail@kryshen.net> |
---|---|
date | Thu, 23 Dec 2010 09:00:24 +0300 |
parents | bf4a46f80851 |
children | 649d12b6c9ec |
files | src/net/kryshen/indyvon/async.clj |
diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/net/kryshen/indyvon/async.clj Wed Dec 08 23:40:41 2010 +0300 +++ b/src/net/kryshen/indyvon/async.clj Thu Dec 23 09:00:24 2010 +0300 @@ -23,7 +23,7 @@ net.kryshen.indyvon.core) (:import (net.kryshen.indyvon.core Size Location) - (java.awt Image AlphaComposite) + (java.awt Image AlphaComposite Transparency) (java.awt.image BufferedImage) (java.util.concurrent ThreadFactory ThreadPoolExecutor ThreadPoolExecutor$DiscardOldestPolicy @@ -42,8 +42,9 @@ (defn- create-image [async-layer] ;; TODO: support different image types. - (BufferedImage. (:width async-layer) (:height async-layer) - BufferedImage/TYPE_INT_ARGB_PRE)) + (.. *graphics* (getDeviceConfiguration) + (createCompatibleImage (:width async-layer) (:height async-layer) + Transparency/TRANSLUCENT))) (defn- create-buffer [async-layer] (Buffer. (Object.) (create-image async-layer) 0 :free)) @@ -135,7 +136,8 @@ (add-context-observer content (fn [_ _] (draw-offscreen-async layer))) (when-not @buffers ;; TODO: dynamic size, recreate buffers when size increases. - (let [new-buffers (repeatedly 2 (partial create-buffer layer))] + (let [cb (bound-fn [] (create-buffer layer)) + new-buffers (repeatedly 2 cb)] (dosync (ref-set buffers new-buffers))) (draw-offscreen-async layer))