9fans.net/go@v0.0.5/draw/memdraw/lhide.go (about) 1 // #include <u.h> 2 // #include <libc.h> 3 // #include <draw.h> 4 // #include <memdraw.h> 5 // #include <memlayer.h> 6 7 /* 8 * Hide puts that portion of screenr now on the screen into the window's save area. 9 * Expose puts that portion of screenr now in the save area onto the screen. 10 * 11 * Hide and Expose both require that the layer structures in the screen 12 * match the geometry they are being asked to update, that is, they update the 13 * save area (hide) or screen (expose) based on what those structures tell them. 14 * This means they must be called at the correct time during window shuffles. 15 */ 16 17 package memdraw 18 19 import ( 20 "9fans.net/go/draw" 21 ) 22 23 func lhideop(src *Image, screenr draw.Rectangle, clipr draw.Rectangle, etc interface{}, insave int) { 24 l := etc.(*Layer) 25 if src != l.save { /* do nothing if src is already in save area */ 26 r := screenr.Sub(l.Delta) 27 Draw(l.save, r, src, screenr.Min, nil, screenr.Min, draw.S) 28 } 29 } 30 31 func memlhide(i *Image, screenr draw.Rectangle) { 32 if i.Layer.save == nil { 33 return 34 } 35 if !draw.RectClip(&screenr, i.Layer.Screen.Image.R) { 36 return 37 } 38 _memlayerop(lhideop, i, screenr, screenr, i.Layer) 39 } 40 41 func lexposeop(dst *Image, screenr draw.Rectangle, clipr draw.Rectangle, etc interface{}, insave int) { 42 if insave != 0 { /* if dst is save area, don't bother */ 43 return 44 } 45 l := etc.(*Layer) 46 r := screenr.Sub(l.Delta) 47 if l.save != nil { 48 Draw(dst, screenr, l.save, r.Min, nil, r.Min, draw.S) 49 } else { 50 l.Refreshfn(dst, r, l.Refreshptr) 51 } 52 } 53 54 func memlexpose(i *Image, screenr draw.Rectangle) { 55 if !draw.RectClip(&screenr, i.Layer.Screen.Image.R) { 56 return 57 } 58 _memlayerop(lexposeop, i, screenr, screenr, i.Layer) 59 }