# HG changeset patch # User Mikhail Kryshen <mikhail@kryshen.net> # Date 1293084024 -10800 # Node ID 017f5f14b8769e66d4eb2d121ed2dad06e59bf36 # Parent bf4a46f80851369d5d6586e53cbf9669f2b70f45 Async layer: use compatible BufferedImage. diff -r bf4a46f80851 -r 017f5f14b876 src/net/kryshen/indyvon/async.clj --- 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))