feat/data-dnd e05cb15

pq.go RawHistoryFolder

1package vulkan
2
3import "math"
4
5var srgbTable = func() (table [256]float64) {
6	for i := range table {
7		table[i] = srgbToLinear(float64(i) / 255)
8	}
9	return
10}()
11
12// srgbToLinear decodes a unit-range sRGB component.
13func srgbToLinear(v float64) float64 {
14	if v <= 0.04045 {
15		return v / 12.92
16	}
17	return math.Pow((v+0.055)/1.055, 2.4)
18}
19
20// linearToSRGB encodes a unit-range linear component; the inverse of
21// srgbToLinear.
22func linearToSRGB(v float64) float64 {
23	if v <= 0.04045/12.92 {
24		return v * 12.92
25	}
26	return 1.055*math.Pow(v, 1/2.4) - 0.055
27}
28
29// pqEncode encodes absolute luminance in nits using SMPTE ST 2084.
30func pqEncode(nits float64) float64 {
31	if nits <= 0 {
32		return 0
33	}
34	x := math.Pow(min(nits, 10000)/10000, 2610.0/16384)
35	return math.Pow((3424.0/4096+2413.0/128*x)/(1+2392.0/128*x), 2523.0/32)
36}
37
38// hdrPixel transforms an unassociated sRGB triplet into BT.2020 PQ.
39func hdrPixel(red, green, blue, nits float64) (float64, float64, float64) {
40	r, g, b := srgbToLinear(red), srgbToLinear(green), srgbToLinear(blue)
41	return pqEncode((0.627404*r + 0.329283*g + 0.043313*b) * nits),
42		pqEncode((0.069097*r + 0.919540*g + 0.011362*b) * nits),
43		pqEncode((0.016391*r + 0.088013*g + 0.895595*b) * nits)
44}
45
46// hdrCursorPixel converts premultiplied BGRA bytes, preserving alpha.
47// The source is quantized to its 8-bit unassociated sRGB value for the LUT.
48func hdrCursorPixel(p []byte, nits float64) {
49	a := float64(p[3]) / 255
50	if a == 0 {
51		clear(p[:3])
52		return
53	}
54	index := func(v byte) int { return min(255, int(math.Round(float64(v)/a))) }
55	r, g, b := srgbTable[index(p[2])], srgbTable[index(p[1])], srgbTable[index(p[0])]
56	r, g, b = pqEncode((0.627404*r+0.329283*g+0.043313*b)*nits), pqEncode((0.069097*r+0.919540*g+0.011362*b)*nits), pqEncode((0.016391*r+0.088013*g+0.895595*b)*nits)
57	p[0], p[1], p[2] = byte(math.Round(b*a*255)), byte(math.Round(g*a*255)), byte(math.Round(r*a*255))
58}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 25

Tags 10

↑↓ moveenter openesc close