aboutsummaryrefslogtreecommitdiff
path: root/prototypes/xgb-xrender.go
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2018-08-23 04:19:28 +0200
committerPřemysl Janouch <p@janouch.name>2018-09-02 18:25:35 +0200
commit23586eae01b5ff3b187bd3786fe5c55f87f8c001 (patch)
tree0afefeedb36b921673fd1876ffa739c355acae30 /prototypes/xgb-xrender.go
parent9424579c7514aaaebe9d90a354929d52aed57f48 (diff)
downloadhaven-23586eae01b5ff3b187bd3786fe5c55f87f8c001.tar.gz
haven-23586eae01b5ff3b187bd3786fe5c55f87f8c001.tar.xz
haven-23586eae01b5ff3b187bd3786fe5c55f87f8c001.zip
xgb-render: give up on composite alpha
Diffstat (limited to 'prototypes/xgb-xrender.go')
-rw-r--r--prototypes/xgb-xrender.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/prototypes/xgb-xrender.go b/prototypes/xgb-xrender.go
index dba6687..ea20624 100644
--- a/prototypes/xgb-xrender.go
+++ b/prototypes/xgb-xrender.go
@@ -234,13 +234,10 @@ func main() {
bounds := f.Bounds(fixed.Int26_6(opts.Size * float64(opts.DPI) *
(64.0 / 72.0)))
- var rgbFormat render.Pictformat
+ var alphaFormat render.Pictformat
for _, pf := range pformats.Formats {
- // Hopefully. Might want to check ARGB/BGRA.
- if pf.Depth == 32 && pf.Direct.AlphaMask != 0 {
- rgbFormat = pf.Id
- log.Printf("%+v\n", pf)
- break
+ if pf.Depth == 8 && pf.Direct.AlphaMask == 0xff {
+ alphaFormat = pf.Id
}
}
@@ -250,11 +247,12 @@ func main() {
}
// NOTE: A depth of 24 will not work, the server always rejects it.
- _ = render.CreateGlyphSet(X, gsid, rgbFormat)
+ // Composite alpha doesn't make sense since golang/freetype can't use it.
+ _ = render.CreateGlyphSet(X, gsid, alphaFormat)
- // TODO: Seems like we want to use NRGBA. Or RGBA if the A is always 1.
- // Or implement our own image.Image for direct gamma-corrected RGB!
- nrgb := image.NewRGBA(image.Rect(
+ // NOTE: We could do gamma post-correction in higher precision if we
+ // implemented our own clone of the image.Image implementation.
+ nrgb := image.NewGray(image.Rect(
+bounds.Min.X.Floor(),
-bounds.Min.Y.Floor(),
+bounds.Max.X.Ceil(),