Documentation
¶
Overview ¶
Package cef2gtk provides a GTK4 widget bridge for purego-cef accelerated off-screen rendering.
The project is Wayland-only and GPU-first. It is intended to use CEF accelerated OSR shared textures/DMABUFs; software OnPaint rendering is a diagnostic/error path, not a product renderer.
Index ¶
- Variables
- func ConfigureCommandLine(commandLine cef.CommandLine, _ CommandLineOptions)
- func ConfigureWindowInfo(info *cef.WindowInfo, opts WindowInfoOptions)
- type Backend
- type CommandLineOptions
- type DiagnosticEvent
- type Diagnostics
- type DurationStats
- type GCStats
- type Hooks
- type InputOptions
- type Options
- type ProfileOptions
- type ProfileSnapshot
- type RenderingMode
- type View
- func (v *View) AddSizeObserver(fn func(width, height int32)) func()
- func (v *View) AttachInput(host cef.BrowserHost, opts InputOptions) error
- func (v *View) Backend() Backend
- func (v *View) ConfigureProfiling(opts ProfileOptions) error
- func (v *View) Destroy() error
- func (v *View) DetachInput() error
- func (v *View) DeviceScaleFactor() float32
- func (v *View) Diagnostics() Diagnostics
- func (v *View) GLArea() *gtk.GLArea
- func (v *View) HasFocus() bool
- func (v *View) PrepareOnGTKThread() error
- func (v *View) RenderHandler(hooks Hooks) cef.RenderHandler
- func (v *View) SetCursorFromName(name string)
- func (v *View) SetInputHost(host cef.BrowserHost) error
- func (v *View) Size() (int32, int32)
- func (v *View) Widget() *gtk.Widget
- type ViewOptions
- type WindowInfoOptions
Constants ¶
This section is empty.
Variables ¶
var ErrInputNotAttached = errors.New("input bridge is not attached")
var ErrNilView = errors.New("nil View")
var ErrViewNotInitialized = errors.New("view not initialized")
Functions ¶
func ConfigureCommandLine ¶
func ConfigureCommandLine(commandLine cef.CommandLine, _ CommandLineOptions)
ConfigureCommandLine configures the CEF command line for Wayland accelerated rendering. It is intended to be called from App.OnBeforeCommandLineProcessing.
func ConfigureWindowInfo ¶
func ConfigureWindowInfo(info *cef.WindowInfo, opts WindowInfoOptions)
ConfigureWindowInfo configures CEF window info for accelerated windowless rendering with shared textures.
Types ¶
type Backend ¶
type Backend string
Backend selects the GTK presentation backend used by a View.
const ( // BackendAuto tries the GDK DMABUF backend first and falls back to GLArea // when GDK DMABUF construction is unavailable. BackendAuto Backend = "auto" // BackendGDKDMABUF presents CEF DMABUF frames as GDK textures. BackendGDKDMABUF Backend = "gdk-dmabuf" // BackendGLArea presents CEF DMABUF frames through GtkGLArea/EGL/OpenGL. BackendGLArea Backend = "glarea" )
type CommandLineOptions ¶
type CommandLineOptions struct{}
CommandLineOptions configures CEF command-line setup for the GTK bridge.
type DiagnosticEvent ¶
DiagnosticEvent records notable rendering-path events and failures.
type Diagnostics ¶
type Diagnostics struct {
Backend string
AcceleratedPaints int
AcceleratedPaintErrors int
UnsupportedPaints int
ImportFailures int
RenderFailures int
TexturesBuilt int
TextureBuildFailures int
FDDupFailures int
UnsupportedFormats int
PaintableSwaps int
PendingFrame bool
PendingScheduled bool
PendingAge time.Duration
PendingSourceID uint
PendingReschedules int
PendingScheduleFailures int
PendingIdleCallbacks int
Events []DiagnosticEvent
}
Diagnostics is a snapshot of View rendering diagnostics. Events contains the most recent diagnostic events, capped to avoid unbounded growth.
type DurationStats ¶
type DurationStats = internalprofile.DurationStats
DurationStats aggregates duration samples for one profiling window.
type GCStats ¶
type GCStats = internalprofile.GCStats
GCStats summarizes Go runtime GC state for one profiling window.
type Hooks ¶
type Hooks struct {
OnUnsupportedPaint func()
OnError func(error)
OnTextSelectionChanged func(selectedText string, selectedRange *cef.Range)
}
Hooks contains optional callbacks invoked by the public CEF render adapter.
type InputOptions ¶
type InputOptions struct {
// Scale is the HiDPI scale factor applied to pointer coordinates. Values <= 0 use 1.
Scale int32
// OnMiddleClick is invoked when GTK receives a middle-button press. Returning
// true consumes the event before it is forwarded to CEF.
OnMiddleClick func(x, y float64) bool
// SelectionText returns the current browser selection for explicit clipboard
// shortcuts. When set with OnClipboardShortcut, Ctrl+C/Ctrl+X can be mirrored
// to application-level clipboard orchestration before forwarding to CEF.
SelectionText func() string
// OnClipboardShortcut is invoked for explicit Ctrl+C/Ctrl+X shortcuts when
// SelectionText returns non-empty text. action is "copy" or "cut".
OnClipboardShortcut func(action, text string)
}
InputOptions configures GTK-to-CEF input forwarding.
type Options ¶
type Options struct {
// RenderingMode must be RenderingModeAcceleratedDMABUF. It defaults to that
// mode when left empty.
RenderingMode RenderingMode
}
Options configures a View.
type ProfileOptions ¶
type ProfileOptions struct {
Enabled bool
Interval time.Duration
OnSnapshot func(ProfileSnapshot)
Writer io.Writer
}
ProfileOptions configures development-only render profiling for a View.
type ProfileSnapshot ¶
type ProfileSnapshot = internalprofile.Snapshot
ProfileSnapshot contains one profiling window of render-pipeline metrics.
type RenderingMode ¶
type RenderingMode string
RenderingMode selects the rendering pipeline used by the GTK bridge.
const ( // RenderingModeAcceleratedDMABUF uses CEF accelerated OSR shared textures // imported through Wayland DMABUF/EGL and rendered by GtkGLArea. RenderingModeAcceleratedDMABUF RenderingMode = "accelerated-dmabuf" )
type View ¶
type View struct {
// contains filtered or unexported fields
}
View is a GTK-backed CEF OSR view.
func NewView ¶
func NewView() *View
NewView creates an accelerated CEF view using BackendAuto or the PUREGO_CEF2GTK_BACKEND override when it is set.
func NewViewWithOptions ¶
func NewViewWithOptions(opts ViewOptions) *View
NewViewWithOptions creates an accelerated CEF view with explicit options. When PUREGO_CEF2GTK_BACKEND is set, it intentionally overrides opts.Backend for diagnostics and deployment-level backend selection.
func (*View) AddSizeObserver ¶
AddSizeObserver registers a callback invoked on the GTK thread when the view observes a positive size change. It returns a function that unregisters the observer. If a real positive size has already been observed, the callback is invoked immediately with that size; the synthetic Size() fallback is not emitted as an observer event. Register and unregister from the GTK thread.
func (*View) AttachInput ¶
func (v *View) AttachInput(host cef.BrowserHost, opts InputOptions) error
AttachInput attaches GTK event controllers to the view and forwards input to host. Call from the GTK/main thread; GTK controller attachment is not goroutine-safe.
func (*View) ConfigureProfiling ¶
func (v *View) ConfigureProfiling(opts ProfileOptions) error
ConfigureProfiling enables or disables development-only render profiling. When enabled, snapshots are emitted at opts.Interval through opts.OnSnapshot and/or opts.Writer. Rendering continues if snapshot writing fails.
func (*View) Destroy ¶
Destroy releases GL resources owned by the view. Call on the GTK main thread; it disconnects GTK signal handlers and is not safe for concurrent use.
func (*View) DetachInput ¶
DetachInput removes input controllers attached by AttachInput.
func (*View) DeviceScaleFactor ¶
DeviceScaleFactor returns the last GTK scale factor observed for the view. Values <= 0 are normalized to 1.
func (*View) Diagnostics ¶
func (v *View) Diagnostics() Diagnostics
Diagnostics returns a point-in-time diagnostics snapshot.
func (*View) HasFocus ¶
HasFocus reports whether the underlying GTK widget currently has focus. Call on the GTK main thread.
func (*View) PrepareOnGTKThread ¶
PrepareOnGTKThread initializes renderer resources. Call on GTK main thread.
func (*View) RenderHandler ¶
func (v *View) RenderHandler(hooks Hooks) cef.RenderHandler
RenderHandler returns a CEF render handler adapter for this view.
func (*View) SetCursorFromName ¶
SetCursorFromName applies a named cursor to the underlying GTK widget. Call on the GTK main thread.
func (*View) SetInputHost ¶
func (v *View) SetInputHost(host cef.BrowserHost) error
SetInputHost updates the CEF browser host used by the attached input bridge. Must be called on the GTK/main thread. Returns ErrInputNotAttached when v.input is nil. Callers must call AttachInput first.
type ViewOptions ¶
type ViewOptions struct {
// Backend selects the renderer backend. Empty defaults to BackendAuto.
Backend Backend
// Profile optionally enables development render profiling during construction.
Profile ProfileOptions
}
ViewOptions configures NewViewWithOptions.
func (ViewOptions) Validate ¶
func (o ViewOptions) Validate() error
Validate verifies that the requested backend is supported by the option schema.
type WindowInfoOptions ¶
type WindowInfoOptions struct {
// Parent is the native parent window handle passed to CEF.
Parent uintptr
}
WindowInfoOptions configures CEF window-info setup for the GTK bridge.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
probe-gtk-egl
command
|
|
|
probe-import-copy
command
|
|
|
examples
|
|
|
simple-browser
command
|
|
|
internal
|
|
|
cefadapter
Package cefadapter converts purego-cef callback data into internal models.
|
Package cefadapter converts purego-cef callback data into internal models. |
|
dmabuf
Package dmabuf models borrowed Linux DMABUF frames received from CEF.
|
Package dmabuf models borrowed Linux DMABUF frames received from CEF. |
|
egl
Package egl contains small EGL helpers shared by GTK/GL probing and rendering.
|
Package egl contains small EGL helpers shared by GTK/GL probing and rendering. |
|
gl
Package gl contains purego OpenGL helpers used by the accelerated renderer.
|
Package gl contains purego OpenGL helpers used by the accelerated renderer. |
|
gtkgdk
Package gtkgdk renders CEF accelerated-paint DMABUF frames through GDK textures.
|
Package gtkgdk renders CEF accelerated-paint DMABUF frames through GDK textures. |
|
gtkgl
Package gtkgl contains GtkGLArea context probing helpers shared by probes and renderers.
|
Package gtkgl contains GtkGLArea context probing helpers shared by probes and renderers. |