Documentation
¶
Overview ¶
Package darwin holds what macOS and iOS share (SPEC §29.2): the loader of the system frameworks (dl), the Objective-C helpers (objcx), Core Foundation (cf), and the layout test helper for the Go mirrors of C structures (layouttest). Its sub-packages are called through purego, with no cgo. Only the engine and the platform backends import them, never a public package (SPEC §6.3 rule 1).
Flutter: no counterpart.
Index ¶
Constants ¶
const TagIOSurfacePoolExhausted = "IOSurfacePoolExhausted"
TagIOSurfacePoolExhausted is the tag of the error of a pool whose surfaces are all in use.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// Pix is the pixels: rows of Stride bytes, the top row first.
Pix []byte
// Stride is the length of a row in bytes.
Stride int
// Width and Height are the size in pixels.
Width, Height int
// Age is as in gpu.PixelBuffer: 0 for undefined content, n for the frame of n presentations ago.
Age int
// Surface is the surface behind the buffer, for the layer that shows it.
Surface Surface
}
Buffer is a surface of the pool that is locked for writing.
Flutter: no counterpart
type CGFloat ¶
type CGFloat = float64
CGFloat is Core Graphics' floating point type on a 64-bit target.
Flutter: no counterpart
type CGRect ¶
CGRect is the rectangle of Core Graphics (CGRect); AppKit's NSRect is the same type.
Flutter: no counterpart
type CVSMPTETime ¶
type CVSMPTETime struct {
Subframes int16 `c:"subframes"`
SubframeDivisor int16 `c:"subframeDivisor"`
Counter uint32 `c:"counter"`
Type uint32 `c:"type"`
Flags uint32 `c:"flags"`
Hours int16 `c:"hours"`
Minutes int16 `c:"minutes"`
Seconds int16 `c:"seconds"`
Frames int16 `c:"frames"`
}
CVSMPTETime is Core Video's CVSMPTETime, the time code inside a CVTimeStamp.
Flutter: no counterpart
type CVTimeStamp ¶
type CVTimeStamp struct {
Version uint32 `c:"version"`
VideoTimeScale int32 `c:"videoTimeScale"`
VideoTime int64 `c:"videoTime"`
HostTime uint64 `c:"hostTime"`
RateScalar float64 `c:"rateScalar"`
VideoRefreshPeriod int64 `c:"videoRefreshPeriod"`
SMPTETime CVSMPTETime `c:"smpteTime"`
Flags uint64 `c:"flags"`
Reserved uint64 `c:"reserved"`
}
CVTimeStamp is Core Video's CVTimeStamp, which a display link gives the callback of the frame.
Flutter: no counterpart
type NSEdgeInsets ¶
type NSEdgeInsets struct {
Top CGFloat `c:"top"`
Left CGFloat `c:"left"`
Bottom CGFloat `c:"bottom"`
Right CGFloat `c:"right"`
}
NSEdgeInsets is AppKit's NSEdgeInsets, the insets that the safe area of a window is told with.
Flutter: no counterpart
type NSRange ¶
NSRange is Foundation's NSRange: a location and a length in UTF-16 units, which the text input client of a view is told with.
Flutter: no counterpart
type Surface ¶
type Surface interface {
// Size is the size of the surface in pixels.
Size() (width, height int)
// Stride is the length of a row in bytes.
Stride() int
// Lock makes the memory writable by the CPU and returns it (stride x height bytes). It stays valid
// until Unlock.
Lock() ([]byte, error)
// Unlock ends the CPU access.
Unlock()
// InUse says whether somebody else (the window server) still reads the surface.
InUse() bool
// Release gives the surface up. The window server keeps what it shows until it is done with it.
Release()
}
Surface is memory that a window shows and the window server reads: an IOSurface (SPEC §29.5). The pool works over this interface, so that its rules (the age of a buffer, the buffers in use, a new size) are tested on every host with a fake.
Flutter: no counterpart
type SurfacePool ¶
type SurfacePool struct {
// contains filtered or unexported fields
}
SurfacePool is the set of surfaces that one window draws into (SPEC §29.5, §9.6): at most Max, handed out so that a surface that the window shows, or that the window server still reads, is never written to. Each buffer has an age, the number of presentations since it was shown, so that the renderer redraws only what the last frames changed. It belongs to the UI thread.
Flutter: shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.mm FlutterSurfaceManager (its back and front buffers; here a pool of up to eight)
func NewSurfacePool ¶
func NewSurfacePool(max int, makeSurface func(width, height int) (Surface, error)) *SurfacePool
NewSurfacePool makes a pool of at most max surfaces, made by the function (an IOSurface in the app).
Flutter: no counterpart
func (*SurfacePool) Acquire ¶
func (p *SurfacePool) Acquire(width, height int) (Buffer, error)
Acquire gives a locked buffer of the size that nothing reads now. The buffer that was acquired and not presented is given up first (its content is not a frame any more). A new size releases every surface of the old size. Among the free surfaces it picks the one shown last, which has the smallest age, so that the least has to be redrawn; with none free it makes a new surface up to Max and then fails with IOSurfacePoolExhausted.
Flutter: no counterpart
func (*SurfacePool) Close ¶
func (p *SurfacePool) Close()
Close releases every surface.
Flutter: no counterpart
func (*SurfacePool) Current ¶
func (p *SurfacePool) Current() Surface
Current is the surface that the window shows now, or nil.
func (*SurfacePool) Len ¶
func (p *SurfacePool) Len() int
Len is the number of surfaces that the pool holds.
func (*SurfacePool) Present ¶
func (p *SurfacePool) Present() (shown Surface, ok bool)
Present unlocks the buffer that Acquire gave out and makes it the shown one. It returns its surface, which the caller puts into the layer, and ok false when nothing was acquired (the window shows what it showed).
Flutter: shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.mm FlutterSurfaceManager present
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cf is the part of Core Foundation that the macOS and iOS backends use (SPEC §29.2, §29.3): strings, dictionaries, the run loop, and the version-0 run loop sources and the timers that carry Post and the timer heap of the UI thread.
|
Package cf is the part of Core Foundation that the macOS and iOS backends use (SPEC §29.2, §29.3): strings, dictionaries, the run loop, and the version-0 run loop sources and the timers that carry Post and the timer heap of the UI thread. |
|
Package coreaudio is the audio backend of macOS and iOS (SPEC §29.11, §30.10): Core Audio's AudioQueue for playback and capture, with the list of devices and its changes from the property listeners of the system object.
|
Package coreaudio is the audio backend of macOS and iOS (SPEC §29.11, §30.10): Core Audio's AudioQueue for playback and capture, with the list of devices and its changes from the property listeners of the system object. |
|
Package dl is the one safe way to load the system frameworks of macOS and iOS and to call into them without cgo: it wraps purego's Dlopen, Dlsym and callbacks, tags every failure, and offers the libc helpers (malloc, free, C strings) that the backends share.
|
Package dl is the one safe way to load the system frameworks of macOS and iOS and to call into them without cgo: it wraps purego's Dlopen, Dlsym and callbacks, tags every failure, and offers the libc helpers (malloc, free, C strings) that the backends share. |
|
Package layouttest checks the Go mirrors of C and Objective-C structures that the macOS and iOS backends pass to and get from the system (NSRect, CGPoint, CVTimeStamp, AudioStreamBasicDescription, ...) against the headers of the SDK (SPEC §29.2, §8.1 rule 3).
|
Package layouttest checks the Go mirrors of C and Objective-C structures that the macOS and iOS backends pass to and get from the system (NSRect, CGPoint, CVTimeStamp, AudioStreamBasicDescription, ...) against the headers of the SDK (SPEC §29.2, §8.1 rule 3). |
|
Package mainthread runs the tests of a macOS program on the main thread: AppKit works only there (SPEC §29.3), and the Go test runner runs every test on a goroutine of its own.
|
Package mainthread runs the tests of a macOS program on the main thread: AppKit works only there (SPEC §29.3), and the Go test runner runs every test on a goroutine of its own. |
|
Package objcx is Glutter's thin layer over purego's objc package (SPEC §29.2): selectors made once, Foundation values (NSString, NSNumber, NSArray, NSURL, NSError) to and from Go, autorelease pools, blocks, and the registry of the Objective-C classes that Go implements (the app delegate, the view, the accessibility elements), whose instances find their Go object by a handle.
|
Package objcx is Glutter's thin layer over purego's objc package (SPEC §29.2): selectors made once, Foundation values (NSString, NSNumber, NSArray, NSURL, NSError) to and from Go, autorelease pools, blocks, and the registry of the Objective-C classes that Go implements (the app delegate, the view, the accessibility elements), whose instances find their Go object by a handle. |