mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 01:45:36 +00:00
io/profile: [API] delete package
It was a design mistake to make profiling data available to programs. Rather, profiling should either be a user-configurable debug overlay, reported through runtime/trace, or both. This change drops the io/profile package because we're about to overhaul event routing. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
// Package profiles provides access to rendering
|
||||
// profiles.
|
||||
package profile
|
||||
|
||||
import (
|
||||
"gioui.org/internal/ops"
|
||||
"gioui.org/io/event"
|
||||
"gioui.org/op"
|
||||
)
|
||||
|
||||
// Op registers a handler for receiving
|
||||
// Events.
|
||||
type Op struct {
|
||||
Tag event.Tag
|
||||
}
|
||||
|
||||
// Event contains profile data from a single
|
||||
// rendered frame.
|
||||
type Event struct {
|
||||
// Timings. Very likely to change.
|
||||
Timings string
|
||||
}
|
||||
|
||||
func (p Op) Add(o *op.Ops) {
|
||||
data := ops.Write1(&o.Internal, ops.TypeProfileLen, p.Tag)
|
||||
data[0] = byte(ops.TypeProfile)
|
||||
}
|
||||
|
||||
func (p Event) ImplementsEvent() {}
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
"gioui.org/io/event"
|
||||
"gioui.org/io/key"
|
||||
"gioui.org/io/pointer"
|
||||
"gioui.org/io/profile"
|
||||
"gioui.org/io/semantic"
|
||||
"gioui.org/io/system"
|
||||
"gioui.org/io/transfer"
|
||||
@@ -54,10 +53,6 @@ type Router struct {
|
||||
// InvalidateOp summary.
|
||||
wakeup bool
|
||||
wakeupTime time.Time
|
||||
|
||||
// ProfileOp summary.
|
||||
profHandlers map[event.Tag]struct{}
|
||||
profile profile.Event
|
||||
}
|
||||
|
||||
// SemanticNode represents a node in the tree describing the components
|
||||
@@ -103,10 +98,6 @@ type handlerEvents struct {
|
||||
// Events returns the available events for the handler key.
|
||||
func (q *Router) Events(k event.Tag) []event.Event {
|
||||
events := q.handlers.Events(k)
|
||||
if _, isprof := q.profHandlers[k]; isprof {
|
||||
delete(q.profHandlers, k)
|
||||
events = append(events, q.profile)
|
||||
}
|
||||
return events
|
||||
}
|
||||
|
||||
@@ -116,9 +107,6 @@ func (q *Router) Events(k event.Tag) []event.Event {
|
||||
func (q *Router) Frame(frame *op.Ops) {
|
||||
q.handlers.Clear()
|
||||
q.wakeup = false
|
||||
for k := range q.profHandlers {
|
||||
delete(q.profHandlers, k)
|
||||
}
|
||||
var ops *ops.Ops
|
||||
if frame != nil {
|
||||
ops = &frame.Internal
|
||||
@@ -157,8 +145,6 @@ func (q *Router) QueueTopmost(events ...key.Event) bool {
|
||||
func (q *Router) Queue(events ...event.Event) bool {
|
||||
for _, e := range events {
|
||||
switch e := e.(type) {
|
||||
case profile.Event:
|
||||
q.profile = e
|
||||
case pointer.Event:
|
||||
q.pointer.queue.Push(e, &q.handlers)
|
||||
case key.Event:
|
||||
@@ -388,12 +374,6 @@ func (q *Router) collect() {
|
||||
q.wakeup = true
|
||||
q.wakeupTime = op.At
|
||||
}
|
||||
case ops.TypeProfile:
|
||||
op := decodeProfileOp(encOp.Data, encOp.Refs)
|
||||
if q.profHandlers == nil {
|
||||
q.profHandlers = make(map[event.Tag]struct{})
|
||||
}
|
||||
q.profHandlers[op.Tag] = struct{}{}
|
||||
case ops.TypeClipboardRead:
|
||||
q.cqueue.ProcessReadClipboard(encOp.Refs)
|
||||
case ops.TypeClipboardWrite:
|
||||
@@ -556,12 +536,6 @@ func (q *Router) collect() {
|
||||
}
|
||||
}
|
||||
|
||||
// Profiling reports whether there was profile handlers in the
|
||||
// most recent Frame call.
|
||||
func (q *Router) Profiling() bool {
|
||||
return len(q.profHandlers) > 0
|
||||
}
|
||||
|
||||
// WakeupTime returns the most recent time for doing another frame,
|
||||
// as determined from the last call to Frame.
|
||||
func (q *Router) WakeupTime() (time.Time, bool) {
|
||||
@@ -604,15 +578,6 @@ func (h *handlerEvents) Clear() {
|
||||
}
|
||||
}
|
||||
|
||||
func decodeProfileOp(d []byte, refs []interface{}) profile.Op {
|
||||
if ops.OpType(d[0]) != ops.TypeProfile {
|
||||
panic("invalid op")
|
||||
}
|
||||
return profile.Op{
|
||||
Tag: refs[0].(event.Tag),
|
||||
}
|
||||
}
|
||||
|
||||
func decodeInvalidateOp(d []byte) op.InvalidateOp {
|
||||
bo := binary.LittleEndian
|
||||
if ops.OpType(d[0]) != ops.TypeInvalidate {
|
||||
|
||||
Reference in New Issue
Block a user