func (w *windowImpl) Upload(dp image.Point, src screen.Buffer, sr image.Rectangle) { completion := make(chan struct{}) // Protect struct contents from being GCed uploadsMu.Lock() uploadID++ id := uploadID uploads[id] = upload{ dp: dp, src: src.(*bufferImpl), sr: sr, completion: completion, } uploadsMu.Unlock() win32.SendMessage(w.hwnd, msgUpload, id, 0) <-completion }
func (w *windowImpl) Fill(dr image.Rectangle, src color.Color, op draw.Op) { rect := _RECT{ Left: int32(dr.Min.X), Top: int32(dr.Min.Y), Right: int32(dr.Max.X), Bottom: int32(dr.Max.Y), } r, g, b, a := src.RGBA() r >>= 8 g >>= 8 b >>= 8 a >>= 8 color := (a << 24) | (r << 16) | (g << 8) | b msg := uint32(msgFillOver) if op == draw.Src { msg = msgFillSrc } // Note: this SendMessage won't return until after the fill // completes, so using &rect is safe. win32.SendMessage(w.hwnd, msg, uintptr(color), uintptr(unsafe.Pointer(&rect))) }