-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsurface_control.go
More file actions
66 lines (54 loc) · 1.91 KB
/
surface_control.go
File metadata and controls
66 lines (54 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Code generated by idiomgen. DO NOT EDIT.
package surfacecontrol
import (
"unsafe"
capi "github.com/AndroidGoLab/ndk/capi/surfacecontrol"
)
// SurfaceControl wraps the NDK ASurfaceControl handle.
type SurfaceControl struct {
ptr *capi.ASurfaceControl
}
// cptr returns the underlying C pointer, or nil if h is nil.
// This allows passing optional (nullable) handle parameters to capi functions.
func (h *SurfaceControl) cptr() *capi.ASurfaceControl {
if h == nil {
return nil
}
return h.ptr
}
// Close releases the underlying NDK handle.
func (h *SurfaceControl) Close() error {
if h.ptr == nil {
return nil
}
capi.ASurfaceControl_release(h.ptr)
h.ptr = nil
return nil
}
// NewSurfaceControlFromPointer wraps a raw ASurfaceControl pointer.
func NewSurfaceControlFromPointer(ptr unsafe.Pointer) *SurfaceControl {
return &SurfaceControl{ptr: (*capi.ASurfaceControl)(ptr)}
}
// Pointer returns the underlying pointer as unsafe.Pointer.
func (h *SurfaceControl) Pointer() unsafe.Pointer {
return unsafe.Pointer(h.ptr)
}
// UintPtr returns the underlying pointer as a uintptr.
// This is useful for interop with gomobile bind, golang.org/x/mobile,
// gioui.org, and other packages that represent native handles as uintptr.
func (h *SurfaceControl) UintPtr() uintptr {
return uintptr(unsafe.Pointer(h.ptr))
}
// NewSurfaceControlFromUintPtr wraps a uintptr as a SurfaceControl.
// The caller must ensure ptr points to a valid ASurfaceControl.
func NewSurfaceControlFromUintPtr(ptr uintptr) *SurfaceControl {
return &SurfaceControl{ptr: (*capi.ASurfaceControl)(unsafe.Pointer(ptr))}
}
// Acquire calls the underlying NDK function.
func (h *SurfaceControl) Acquire() {
capi.ASurfaceControl_acquire(h.ptr)
}
// CreateChild creates a new SurfaceControl from this SurfaceControl.
func (h *SurfaceControl) CreateChild(debug_name string) *SurfaceControl {
return &SurfaceControl{ptr: capi.ASurfaceControl_create(h.ptr, debug_name)}
}