summaryrefslogtreecommitdiff
path: root/area.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-04-11 21:30:19 -0400
committerPietro Gagliardi <[email protected]>2014-04-11 21:30:19 -0400
commite3fdc76c5bf6b77ce53c8573f05f2d0ae8e33778 (patch)
tree7c086b63ecfada242152b25e4898ca82c03b76e7 /area.go
parent57088b9787ca7e9e7a6135c0f512c70da91a88f2 (diff)
Rewrote Area code on Windows to use alpha-premultiplied RGB and only use GDI functions to do it... and it doesn't quite work right yet.
Diffstat (limited to 'area.go')
-rw-r--r--area.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/area.go b/area.go
index 579d484..2314837 100644
--- a/area.go
+++ b/area.go
@@ -7,6 +7,7 @@ import (
"sync"
"image"
"unsafe"
+ "reflect"
)
// Area represents a blank canvas upon which programs may draw anything and receive arbitrary events from the user.
@@ -339,10 +340,14 @@ func pixelData(img *image.RGBA) *uint8 {
// some platforms require pixels in ARGB order in their native endianness (because they treat the pixel array as an array of uint32s)
// this does the conversion
-// s stores the slice used to avoid frequent memory allocations
-func toARGB(i *image.RGBA, s *sysData) *byte {
- // TODO actually store realBits in s
- realbits := make([]byte, 4 * i.Rect.Dx() * i.Rect.Dy())
+// you need to convert somewhere; this memory is assumed to have a stride equal to the pixels per scanline (Windows gives us memory to use; other platforms we'll see)
+func toARGB(i *image.RGBA, memory uintptr) {
+ var realbits []byte
+
+ rbs := (*reflect.SliceHeader)(unsafe.Pointer(&realbits))
+ rbs.Data = memory
+ rbs.Len = 4 * i.Rect.Dx() * i.Rect.Dy()
+ rbs.Cap = rbs.Len
p := pixelDataPos(i)
q := 0
for y := i.Rect.Min.Y; y < i.Rect.Max.Y; y++ {
@@ -363,5 +368,4 @@ func toARGB(i *image.RGBA, s *sysData) *byte {
}
p = nextp
}
- return &realbits[0]
}