1// Package gdk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gdk
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/gio"
12 "github.com/bnema/puregotk/v4/glib"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type GLTextureClass struct {
17 _ structs.HostLayout
18}
19
20func (x *GLTextureClass) GoPointer() uintptr {
21 return uintptr(unsafe.Pointer(x))
22}
23
24// A `GdkTexture` representing a GL texture object.
25type GLTexture struct {
26 Texture
27}
28
29var xGLTextureGLibType func() types.GType
30
31func GLTextureGLibType() types.GType {
32 return xGLTextureGLibType()
33}
34
35func GLTextureNewFromInternalPtr(ptr uintptr) *GLTexture {
36 cls := &GLTexture{}
37 cls.Ptr = ptr
38 return cls
39}
40
41var xNewGLTexture func(uintptr, uint, int, int, uintptr, uintptr) uintptr
42
43// Creates a new texture for an existing GL texture.
44//
45// Note that the GL texture must not be modified until @destroy is called,
46// which will happen when the GdkTexture object is finalized, or due to
47// an explicit call of [method@Gdk.GLTexture.release].
48func NewGLTexture(ContextVar *GLContext, IdVar uint, WidthVar int, HeightVar int, DestroyVar *glib.DestroyNotify, DataVar uintptr) *GLTexture {
49 var cls *GLTexture
50
51 var DestroyVarRef uintptr
52 if DestroyVar != nil {
53 DestroyVarPtr := uintptr(unsafe.Pointer(DestroyVar))
54 if cbRefPtr, ok := glib.GetCallback(DestroyVarPtr); ok {
55 DestroyVarRef = cbRefPtr
56 } else {
57 fcb := func(arg0 uintptr) {
58 cbFn := *DestroyVar
59 cbFn(arg0)
60 }
61 DestroyVarRef = purego.NewCallback(fcb)
62 glib.SaveCallbackWithClosure(DestroyVarPtr, DestroyVarRef, DestroyVar)
63 }
64 }
65
66 cret := xNewGLTexture(ContextVar.GoPointer(), IdVar, WidthVar, HeightVar, DestroyVarRef, DataVar)
67
68 if cret == 0 {
69 return nil
70 }
71 cls = &GLTexture{}
72 cls.Ptr = cret
73 return cls
74}
75
76var xGLTextureRelease func(uintptr)
77
78// Releases the GL resources held by a `GdkGLTexture`.
79//
80// The texture contents are still available via the
81// [method@Gdk.Texture.download] function, after this
82// function has been called.
83func (x *GLTexture) Release() {
84
85 xGLTextureRelease(x.GoPointer())
86
87}
88
89func (c *GLTexture) GoPointer() uintptr {
90 if c == nil {
91 return 0
92 }
93 return c.Ptr
94}
95
96func (c *GLTexture) SetGoPointer(ptr uintptr) {
97 c.Ptr = ptr
98}
99
100// Compute a concrete size for the `GdkPaintable`.
101//
102// Applies the sizing algorithm outlined in the
103// [CSS Image spec](https://drafts.csswg.org/css-images-3/#default-sizing)
104// to the given @paintable. See that link for more details.
105//
106// It is not necessary to call this function when both @specified_width
107// and @specified_height are known, but it is useful to call this
108// function in GtkWidget:measure implementations to compute the
109// other dimension when only one dimension is given.
110func (x *GLTexture) ComputeConcreteSize(SpecifiedWidthVar float64, SpecifiedHeightVar float64, DefaultWidthVar float64, DefaultHeightVar float64, ConcreteWidthVar *float64, ConcreteHeightVar *float64) {
111
112 XGdkPaintableComputeConcreteSize(x.GoPointer(), SpecifiedWidthVar, SpecifiedHeightVar, DefaultWidthVar, DefaultHeightVar, ConcreteWidthVar, ConcreteHeightVar)
113
114}
115
116// Gets an immutable paintable for the current contents displayed by @paintable.
117//
118// This is useful when you want to retain the current state of an animation,
119// for example to take a screenshot of a running animation.
120//
121// If the @paintable is already immutable, it will return itself.
122func (x *GLTexture) GetCurrentImage() *PaintableBase {
123 var cls *PaintableBase
124
125 cret := XGdkPaintableGetCurrentImage(x.GoPointer())
126
127 if cret == 0 {
128 return nil
129 }
130 cls = &PaintableBase{}
131 cls.Ptr = cret
132 return cls
133}
134
135// Get flags for the paintable.
136//
137// This is oftentimes useful for optimizations.
138//
139// See [flags@Gdk.PaintableFlags] for the flags and what they mean.
140func (x *GLTexture) GetFlags() PaintableFlags {
141
142 cret := XGdkPaintableGetFlags(x.GoPointer())
143 return cret
144}
145
146// Gets the preferred aspect ratio the @paintable would like to be displayed at.
147//
148// The aspect ratio is the width divided by the height, so a value of 0.5
149// means that the @paintable prefers to be displayed twice as high as it
150// is wide. Consumers of this interface can use this to preserve aspect
151// ratio when displaying the paintable.
152//
153// This is a purely informational value and does not in any way limit the
154// values that may be passed to [method@Gdk.Paintable.snapshot].
155//
156// Usually when a @paintable returns nonzero values from
157// [method@Gdk.Paintable.get_intrinsic_width] and
158// [method@Gdk.Paintable.get_intrinsic_height] the aspect ratio
159// should conform to those values, though that is not required.
160//
161// If the @paintable does not have a preferred aspect ratio,
162// it returns 0. Negative values are never returned.
163func (x *GLTexture) GetIntrinsicAspectRatio() float64 {
164
165 cret := XGdkPaintableGetIntrinsicAspectRatio(x.GoPointer())
166 return cret
167}
168
169// Gets the preferred height the @paintable would like to be displayed at.
170//
171// Consumers of this interface can use this to reserve enough space to draw
172// the paintable.
173//
174// This is a purely informational value and does not in any way limit the
175// values that may be passed to [method@Gdk.Paintable.snapshot].
176//
177// If the @paintable does not have a preferred height, it returns 0.
178// Negative values are never returned.
179func (x *GLTexture) GetIntrinsicHeight() int {
180
181 cret := XGdkPaintableGetIntrinsicHeight(x.GoPointer())
182 return cret
183}
184
185// Gets the preferred width the @paintable would like to be displayed at.
186//
187// Consumers of this interface can use this to reserve enough space to draw
188// the paintable.
189//
190// This is a purely informational value and does not in any way limit the
191// values that may be passed to [method@Gdk.Paintable.snapshot].
192//
193// If the @paintable does not have a preferred width, it returns 0.
194// Negative values are never returned.
195func (x *GLTexture) GetIntrinsicWidth() int {
196
197 cret := XGdkPaintableGetIntrinsicWidth(x.GoPointer())
198 return cret
199}
200
201// Called by implementations of `GdkPaintable` to invalidate their contents.
202//
203// Unless the contents are invalidated, implementations must guarantee that
204// multiple calls of [method@Gdk.Paintable.snapshot] produce the same output.
205//
206// This function will emit the [signal@Gdk.Paintable::invalidate-contents]
207// signal.
208//
209// If a @paintable reports the %GDK_PAINTABLE_STATIC_CONTENTS flag,
210// it must not call this function.
211func (x *GLTexture) InvalidateContents() {
212
213 XGdkPaintableInvalidateContents(x.GoPointer())
214
215}
216
217// Called by implementations of `GdkPaintable` to invalidate their size.
218//
219// As long as the size is not invalidated, @paintable must return the same
220// values for its intrinsic width, height and aspect ratio.
221//
222// This function will emit the [signal@Gdk.Paintable::invalidate-size]
223// signal.
224//
225// If a @paintable reports the %GDK_PAINTABLE_STATIC_SIZE flag,
226// it must not call this function.
227func (x *GLTexture) InvalidateSize() {
228
229 XGdkPaintableInvalidateSize(x.GoPointer())
230
231}
232
233// Snapshots the given paintable with the given @width and @height.
234//
235// The paintable is drawn at the current (0,0) offset of the @snapshot.
236// If @width and @height are not larger than zero, this function will
237// do nothing.
238func (x *GLTexture) Snapshot(SnapshotVar *Snapshot, WidthVar float64, HeightVar float64) {
239
240 XGdkPaintableSnapshot(x.GoPointer(), SnapshotVar.GoPointer(), WidthVar, HeightVar)
241
242}
243
244// Checks if two icons are equal.
245func (x *GLTexture) Equal(Icon2Var gio.Icon) bool {
246
247 cret := gio.XGIconEqual(x.GoPointer(), Icon2Var.GoPointer())
248 return cret
249}
250
251// Gets a hash for an icon.
252func (x *GLTexture) Hash() uint {
253
254 cret := gio.XGIconHash(x.GoPointer())
255 return cret
256}
257
258// Serializes a #GIcon into a #GVariant. An equivalent #GIcon can be retrieved
259// back by calling g_icon_deserialize() on the returned value.
260// As serialization will avoid using raw icon data when possible, it only
261// makes sense to transfer the #GVariant between processes on the same machine,
262// (as opposed to over the network), and within the same file system namespace.
263func (x *GLTexture) Serialize() *glib.Variant {
264
265 cret := gio.XGIconSerialize(x.GoPointer())
266 return cret
267}
268
269// Generates a textual representation of @icon that can be used for
270// serialization such as when passing @icon to a different process or
271// saving it to persistent storage. Use g_icon_new_for_string() to
272// get @icon back from the returned string.
273//
274// The encoding of the returned string is proprietary to #GIcon except
275// in the following two cases
276//
277// - If @icon is a #GFileIcon, the returned string is a native path
278// (such as `/path/to/my icon.png`) without escaping
279// if the #GFile for @icon is a native file. If the file is not
280// native, the returned string is the result of g_file_get_uri()
281// (such as `sftp://path/to/my%20icon.png`).
282//
283// - If @icon is a #GThemedIcon with exactly one name and no fallbacks,
284// the encoding is simply the name (such as `network-server`).
285func (x *GLTexture) ToString() string {
286
287 cret := gio.XGIconToString(x.GoPointer())
288 return cret
289}
290
291// Loads a loadable icon. For the asynchronous version of this function,
292// see g_loadable_icon_load_async().
293func (x *GLTexture) Load(SizeVar int, TypeVar *string, CancellableVar *gio.Cancellable) (*gio.InputStream, error) {
294 var cls *gio.InputStream
295 var cerr *glib.Error
296
297 cret := gio.XGLoadableIconLoad(x.GoPointer(), SizeVar, TypeVar, CancellableVar.GoPointer(), &cerr)
298
299 if cret == 0 {
300 return nil, cerr
301 }
302 cls = &gio.InputStream{}
303 cls.Ptr = cret
304 if cerr == nil {
305 return cls, nil
306 }
307 return cls, cerr
308
309}
310
311// Loads an icon asynchronously. To finish this function, see
312// g_loadable_icon_load_finish(). For the synchronous, blocking
313// version of this function, see g_loadable_icon_load().
314func (x *GLTexture) LoadAsync(SizeVar int, CancellableVar *gio.Cancellable, CallbackVar *gio.AsyncReadyCallback, UserDataVar uintptr) {
315
316 gio.XGLoadableIconLoadAsync(x.GoPointer(), SizeVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
317
318}
319
320// Finishes an asynchronous icon load started in g_loadable_icon_load_async().
321func (x *GLTexture) LoadFinish(ResVar gio.AsyncResult, TypeVar *string) (*gio.InputStream, error) {
322 var cls *gio.InputStream
323 var cerr *glib.Error
324
325 cret := gio.XGLoadableIconLoadFinish(x.GoPointer(), ResVar.GoPointer(), TypeVar, &cerr)
326
327 if cret == 0 {
328 return nil, cerr
329 }
330 cls = &gio.InputStream{}
331 cls.Ptr = cret
332 if cerr == nil {
333 return cls, nil
334 }
335 return cls, cerr
336
337}
338
339func init() {
340 core.SetPackageName("GDK", "gtk4")
341 core.SetSharedLibraries("GDK", []string{"libgtk-4.so.1"})
342 var libs []uintptr
343 for _, libPath := range core.GetPaths("GDK") {
344 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
345 if err != nil {
346 panic(err)
347 }
348 libs = append(libs, lib)
349 }
350
351 core.PuregoSafeRegister(&xGLTextureGLibType, libs, "gdk_gl_texture_get_type")
352
353 core.PuregoSafeRegister(&xNewGLTexture, libs, "gdk_gl_texture_new")
354
355 core.PuregoSafeRegister(&xGLTextureRelease, libs, "gdk_gl_texture_release")
356
357}