]> gitweb.factorcode.org Git - factor.git/commitdiff
win32 offscreen refinements
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 10 Dec 2008 14:49:50 +0000 (08:49 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 10 Dec 2008 14:49:50 +0000 (08:49 -0600)
basis/ui/backend/backend.factor [changed mode: 0644->0755]
basis/ui/cocoa/cocoa.factor
basis/ui/windows/windows.factor
extra/ui/offscreen/offscreen.factor

old mode 100644 (file)
new mode 100755 (executable)
index 7b808bb..aa84419
@@ -27,7 +27,7 @@ GENERIC: select-gl-context ( handle -- )
 
 GENERIC: flush-gl-context ( handle -- )
 
-GENERIC: offscreen-pixels ( handle -- alien )
+HOOK: offscreen-pixels ui-backend ( world -- alien w h )
 
 HOOK: beep ui-backend ( -- )
 
index 1338983164a4e74d241b09efcd345870874c02b3..b4025b72b2642c9de97d1838b2e604d16e06d91b 100755 (executable)
@@ -123,8 +123,8 @@ M: handle select-gl-context ( handle -- )
 M: handle flush-gl-context ( handle -- )
     (gl-context) -> flushBuffer ;
 
-M: offscreen-handle offscreen-pixels ( handle -- alien )
-    buffer>> ;
+M: cocoa-ui-backend offscreen-pixels ( world -- alien w h )
+    [ handle>> buffer>> ] [ dim>> first2 neg ] ;
 
 M: cocoa-ui-backend beep ( -- )
     NSBeep ;
index ca5d77e9f945e722f4f23087f8d39f6c0d945f98..8e60ad1bc583f9aed52a78c7a4660816d12d96cc 100755 (executable)
@@ -6,7 +6,7 @@ ui.gadgets ui.backend ui.clipboards ui.gadgets.worlds
 ui.gestures io kernel math math.vectors namespaces make
 sequences strings vectors words windows.kernel32 windows.gdi32
 windows.user32 windows.opengl32 windows.messages windows.types
-windows.nt windows threads libc combinators
+windows.nt windows threads libc combinators fry
 combinators.short-circuit continuations command-line shuffle
 opengl ui.render ascii math.bitwise locals symbols accessors
 math.geometry.rect math.order ascii calendar
@@ -544,8 +544,20 @@ M: windows-ui-backend (close-offscreen-buffer) ( handle -- )
     [ hDC>> DeleteDC drop ]
     [ hBitmap>> DeleteObject drop ] bi ;
 
-M: win-offscreen offscreen-pixels ( handle -- alien )
-    bits>> ;
+! Windows 32-bit bitmaps don't actually use the alpha byte of
+! each pixel; it's left as zero
+
+: (make-opaque) ( byte-array -- byte-array' )
+    [ length 4 / ]
+    [ '[ 255 swap 4 * 3 + _ set-nth ] each ]
+    [ ] tri ;
+
+: (opaque-pixels) ( world -- pixels )
+    [ handle>> bits>> ] [ dim>> first2 * 4 * ] bi
+    memory>byte-array (make-opaque) ;
+
+M: windows-ui-backend offscreen-pixels ( world -- alien w h )
+    [ (opaque-pixels) ] [ dim>> first2 ] bi ;
 
 M: windows-ui-backend raise-window* ( world -- )
     handle>> [
index 779ecc0c31ae040a245088e4b4c1197f2e44644b..33d4a92f376448a04d82444cb4fb783b12003c24 100755 (executable)
@@ -23,9 +23,11 @@ M: offscreen-world ungraft*
     ungraft notify-queued ;
 
 : offscreen-world>bitmap ( world -- bitmap )
-    [ handle>> offscreen-pixels ] [ dim>> first2 neg ] bi
-    bgra>bitmap ;
+    offscreen-pixels bgra>bitmap ;
 
 : do-offscreen ( gadget quot: ( offscreen-world -- ) -- )
     [ open-offscreen ] dip
-    over [ slip ] [ close-offscreen ] [ ] cleanup ;
+    over [ slip ] [ close-offscreen ] [ ] cleanup ; inline
+
+: gadget>bitmap ( gadget -- bitmap )
+    [ offscreen-world>bitmap ] do-offscreen ;