mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 00:45:35 +00:00
internal/byteslice: rename package unsafe
All functions left in the old package unsafe were provided byte slice views of other types. Rename the package accordingly and avoid a name clash with the standard library package unsafe. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
package unsafe
|
||||
// Package byteslice provides byte slice views of other Go values such as
|
||||
// slices and structs.
|
||||
package byteslice
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// StructView returns a byte slice view of a struct.
|
||||
func StructView(s interface{}) []byte {
|
||||
// Struct returns a byte slice view of a struct.
|
||||
func Struct(s interface{}) []byte {
|
||||
v := reflect.ValueOf(s).Elem()
|
||||
sz := int(v.Type().Size())
|
||||
var res []byte
|
||||
@@ -19,8 +21,8 @@ func StructView(s interface{}) []byte {
|
||||
return res
|
||||
}
|
||||
|
||||
// BytesView returns a byte slice view of a slice.
|
||||
func BytesView(s interface{}) []byte {
|
||||
// Slice returns a byte slice view of a slice.
|
||||
func Slice(s interface{}) []byte {
|
||||
v := reflect.ValueOf(s)
|
||||
first := v.Index(0)
|
||||
sz := int(first.Type().Size())
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"gioui.org/internal/byteslice"
|
||||
"gioui.org/internal/gl"
|
||||
"gioui.org/internal/unsafe"
|
||||
)
|
||||
|
||||
// FBO implements an intermediate sRGB FBO
|
||||
@@ -71,7 +71,7 @@ func (s *FBO) Blit() {
|
||||
s.c.Uniform1i(s.c.GetUniformLocation(prog, "tex"), 0)
|
||||
s.quad = s.c.CreateBuffer()
|
||||
s.c.BindBuffer(gl.ARRAY_BUFFER, s.quad)
|
||||
coords := unsafe.BytesView([]float32{
|
||||
coords := byteslice.Slice([]float32{
|
||||
-1, +1, 0, 1,
|
||||
+1, +1, 1, 1,
|
||||
-1, -1, 0, 0,
|
||||
|
||||
Reference in New Issue
Block a user