@gjsify/webgl 0.64.53 → 0.64.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -324,6 +324,19 @@ Reporting the allocation as `canvas.width` — as this bridge did until 2026-08
324
324
 
325
325
  `@gjsify/dom-elements`' register seeds `devicePixelRatio: 1` as the widget-less default only.
326
326
 
327
+ ### Fractional scales (125 %, 150 %)
328
+
329
+ `get_scale_factor()` is `ceil(scale)`, and GTK sizes the GLArea framebuffer with it, so at 125 % GTK hands GL a 2x buffer while the display shows 1.25x. Showing that buffer scaled down resamples it and blurs 1-device-pixel detail. The bridge instead uses the surface's REAL scale (`Gdk.Surface.get_scale()`, via `deviceScale()`):
330
+
331
+ - `devicePixelRatio` is 1.25 / 1.5, and `canvas.width` / `drawingBufferWidth` is `round(allocation x scale)`, the real device size.
332
+ - The viewport is narrowed to that region at the start of every frame (GTK binds the larger ceil-sized one). The region is the bottom-left corner of GTK's FBO.
333
+ - `vfunc_snapshot` scales GTK's own texture draw by `ceil/scale` about the bottom-left corner and clips to the widget, so one texel lands on exactly one device pixel. No extra FBO, no copy, no per-frame allocation.
334
+ - A `notify::scale` on the surface re-fires the resize consumers, because a monitor switch can change the fractional scale while `ceil(scale)` and the allocation stay put and GTK emits no `resize`.
335
+
336
+ Integer scales take the untouched parent path. Measured buffers for a 400x300 widget: 400x300 at 1, 500x375 at 1.25, 600x450 at 1.5, 800x600 at 2. A 1-device-pixel checkerboard screenshot at each scale has no grey pixel and no equal neighbours.
337
+
338
+ CI cannot run this leg: Xvfb has no fractional scaling, and `GDK_SCALE` is integer-only. Run `test:hidpi` under `scripts/headless-run --scale 1.25` (mutter headless) in the werkstatt workspace to exercise it. The stub spec pins the arithmetic in CI.
339
+
327
340
  Two specs hold it, because each answers a question the other cannot:
328
341
 
329
342
  - `html-canvas-element.spec.ts` varies the scale factor through a stub, so the arithmetic is pinned at 0, 1, 2 and 3 on any host.
@@ -1 +1 @@
1
- import{__name as e}from"./_virtual/_rolldown/runtime.js";import{describe as t,expect as n,it as r,on as i}from"@gjsify/unit";import{WebGLBridge as a}from"@gjsify/webgl";import o from"@girs/glib-2.0";import s from"@girs/gtk-4.0";function nativeGl(e){return e._native}function spinUntil(e,t=1e4){let n=o.MainContext.default(),r=o.get_monotonic_time()+t*1e3,i=o.timeout_add(o.PRIORITY_DEFAULT,50,()=>o.SOURCE_CONTINUE);for(;!e()&&o.get_monotonic_time()<r;)n.iteration(!0);return o.source_remove(i),e()}var c=e(async()=>{await i(`Gl`,async()=>{s.init();let e=new s.Window({default_width:320,default_height:240}),i=new a;i.set_hexpand(!0),i.set_vexpand(!0),i.installGlobals();let c=[];i.connect(`resize`,(e,t,n)=>{c.push([t,n])});let l=null,u=null;i.onReady((e,t)=>{l=e,u=t}),e.set_child(i),e.present(),spinUntil(()=>u!==null);let captureFrame=()=>{let e=null;return i.requestAnimationFrame(()=>{let t=u,n=l,r=Array.from(nativeGl(t).getParameteriv(2978,4)),a=t.drawingBufferWidth,o=t.drawingBufferHeight;t.enable(t.SCISSOR_TEST),t.scissor(0,0,a,o),t.clearColor(1,0,0,1),t.clear(t.COLOR_BUFFER_BIT),t.scissor(a-1,o-1,1,1),t.clearColor(0,1,0,1),t.clear(t.COLOR_BUFFER_BIT),t.disable(t.SCISSOR_TEST);let s=new Uint8Array(4);t.readPixels(a-1,o-1,1,1,t.RGBA,t.UNSIGNED_BYTE,s),e={allocW:i.get_allocated_width(),allocH:i.get_allocated_height(),scale:i.get_scale_factor(),dpr:globalThis.devicePixelRatio,canvasW:n.width,canvasH:n.height,clientW:n.clientWidth,clientH:n.clientHeight,bufferW:a,bufferH:o,gtkViewport:r,farCorner:Array.from(s)}}),spinUntil(()=>e!==null),e},assertFrame=async(e,i)=>{await t(`WebGLBridge HiDPI on a real GLArea — ${e}`,async()=>{await r(`renders a frame`,async()=>{n(i()).not.toBeNull()}),await r(`devicePixelRatio is the widget scale factor`,async()=>{let e=i();n(e.scale).toBeGreaterThan(0),n(e.dpr).toBe(e.scale)}),await r(`drawing buffer = CSS size × devicePixelRatio`,async()=>{let e=i();n(e.clientW).toBe(e.allocW),n(e.clientH).toBe(e.allocH),n(e.canvasW).toBe(e.clientW*e.dpr),n(e.canvasH).toBe(e.clientH*e.dpr),n(e.bufferW).toBe(e.canvasW),n(e.bufferH).toBe(e.canvasH)}),await r(`matches the size GTK's resize signal gave in device pixels`,async()=>{let e=i(),t=c[c.length-1];n(t).toBeDefined(),n(t[0]).toBe(e.bufferW),n(t[1]).toBe(e.bufferH)}),await r(`matches the viewport GTK bound for the render`,async()=>{let e=i();n(e.gtkViewport.join(`,`)).toBe(`0,0,${e.bufferW},${e.bufferH}`)}),await r(`reaches the top-right device pixel of the framebuffer`,async()=>{n(i().farCorner.join(`,`)).toBe(`0,255,0,255`)})})};n(u).not.toBeNull();let d=captureFrame();await assertFrame(`initial size`,()=>d);let f=o.getenv(`GJSIFY_TEST_EXPECT_SCALE`);f&&await t(`WebGLBridge HiDPI — requested scale took effect`,async()=>{await r(`runs at scale ${f}`,async()=>{n(d?.scale).toBe(Number(f))})});let p=c.length,m=(d?.allocW??320)+160,h=(d?.allocH??240)+120;i.set_size_request(m,h),spinUntil(()=>c.length>p&&i.get_allocated_width()>=m);let g=captureFrame();await assertFrame(`after resize`,()=>g),await t(`WebGLBridge HiDPI — resize`,async()=>{await r(`the drawing buffer followed the new allocation`,async()=>{n(g.allocW).toBeGreaterThan(d.allocW),n(g.bufferW).toBe(g.allocW*g.scale),n(g.bufferH).toBe(g.allocH*g.scale)})}),e.destroy()})},`default`);export{c as default};
1
+ import{__name as e}from"./_virtual/_rolldown/runtime.js";import{describe as t,expect as n,it as r,on as i}from"@gjsify/unit";import{WebGLBridge as a}from"@gjsify/webgl";import o from"@girs/glib-2.0";import s from"@girs/gtk-4.0";function nativeGl(e){return e._native}function spinUntil(e,t=1e4){let n=o.MainContext.default(),r=o.get_monotonic_time()+t*1e3,i=o.timeout_add(o.PRIORITY_DEFAULT,50,()=>o.SOURCE_CONTINUE);for(;!e()&&o.get_monotonic_time()<r;)n.iteration(!0);return o.source_remove(i),e()}var c=e(async()=>{await i(`Gl`,async()=>{s.init();let e=new s.Window({default_width:320,default_height:240}),i=new a;i.set_hexpand(!0),i.set_vexpand(!0),i.installGlobals();let c=[];i.connect(`resize`,(e,t,n)=>{c.push([t,n])});let l=null,u=null;i.onReady((e,t)=>{l=e,u=t}),e.set_child(i),e.present(),spinUntil(()=>u!==null);let captureFrame=()=>{let e=null;return i.requestAnimationFrame(()=>{let t=u,n=l,r=Array.from(nativeGl(t).getParameteriv(2978,4)),a=t.drawingBufferWidth,o=t.drawingBufferHeight;t.enable(t.SCISSOR_TEST),t.scissor(0,0,a,o),t.clearColor(1,0,0,1),t.clear(t.COLOR_BUFFER_BIT),t.scissor(a-1,o-1,1,1),t.clearColor(0,1,0,1),t.clear(t.COLOR_BUFFER_BIT),t.disable(t.SCISSOR_TEST);let s=new Uint8Array(4);t.readPixels(a-1,o-1,1,1,t.RGBA,t.UNSIGNED_BYTE,s),e={allocW:i.get_allocated_width(),allocH:i.get_allocated_height(),scale:i.get_native()?.get_surface()?.get_scale()??i.get_scale_factor(),fboScale:i.get_scale_factor(),dpr:globalThis.devicePixelRatio,canvasW:n.width,canvasH:n.height,clientW:n.clientWidth,clientH:n.clientHeight,bufferW:a,bufferH:o,gtkViewport:r,farCorner:Array.from(s)}}),spinUntil(()=>e!==null),e},assertFrame=async(e,i)=>{await t(`WebGLBridge HiDPI on a real GLArea — ${e}`,async()=>{await r(`renders a frame`,async()=>{n(i()).not.toBeNull()}),await r(`devicePixelRatio is the widget scale factor`,async()=>{let e=i();n(e.scale).toBeGreaterThan(0),n(e.dpr).toBe(e.scale)}),await r(`drawing buffer = CSS size × devicePixelRatio`,async()=>{let e=i();n(e.clientW).toBe(e.allocW),n(e.clientH).toBe(e.allocH),n(e.canvasW).toBe(Math.round(e.clientW*e.dpr)),n(e.canvasH).toBe(Math.round(e.clientH*e.dpr)),n(e.bufferW).toBe(e.canvasW),n(e.bufferH).toBe(e.canvasH)}),await r(`fits inside the framebuffer GTK's resize signal sized (alloc × ceil(scale))`,async()=>{let e=i(),t=c[c.length-1];n(t).toBeDefined(),n(t[0]).toBe(e.allocW*e.fboScale),n(t[1]).toBe(e.allocH*e.fboScale),n(e.bufferW).toBeLessThan(t[0]+1),n(e.bufferH).toBeLessThan(t[1]+1),n(e.bufferW).toBe(Math.round(e.allocW*e.scale)),n(e.bufferH).toBe(Math.round(e.allocH*e.scale))}),await r(`starts the frame with a viewport of the drawing buffer`,async()=>{let e=i();n(e.gtkViewport.join(`,`)).toBe(`0,0,${e.bufferW},${e.bufferH}`)}),await r(`reaches the top-right device pixel of the framebuffer`,async()=>{n(i().farCorner.join(`,`)).toBe(`0,255,0,255`)})})};n(u).not.toBeNull();let d=captureFrame();await assertFrame(`initial size`,()=>d);let f=o.getenv(`GJSIFY_TEST_EXPECT_SCALE`);f&&await t(`WebGLBridge HiDPI — requested scale took effect`,async()=>{await r(`runs at scale ${f}`,async()=>{n(d?.scale).toBe(Number(f))})});let p=c.length,m=(d?.allocW??320)+160,h=(d?.allocH??240)+120;i.set_size_request(m,h),spinUntil(()=>c.length>p&&i.get_allocated_width()>=m);let g=captureFrame();await assertFrame(`after resize`,()=>g),await t(`WebGLBridge HiDPI — resize`,async()=>{await r(`the drawing buffer followed the new allocation`,async()=>{n(g.allocW).toBeGreaterThan(d.allocW),n(g.bufferW).toBe(Math.round(g.allocW*g.scale)),n(g.bufferH).toBe(Math.round(g.allocH*g.scale))})}),e.destroy()})},`default`);export{c as default};
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{WebGLRenderingContext as e}from"./webgl-rendering-context.js";import{WebGL2RenderingContext as t}from"./webgl2-rendering-context.js";import{HTMLCanvasElement as n}from"@gjsify/dom-elements";var HTMLCanvasElement=class extends n{constructor(e){super(),this.gtkGlArea=e}get width(){return this.gtkGlArea.get_allocated_width()*this.scaleFactor}set width(e){}get height(){return this.gtkGlArea.get_allocated_height()*this.scaleFactor}set height(e){}get scaleFactor(){return this.gtkGlArea.get_scale_factor()||1}get clientWidth(){return this.gtkGlArea.get_allocated_width()}get clientHeight(){return this.gtkGlArea.get_allocated_height()}get offsetWidth(){return this.clientWidth}get offsetHeight(){return this.clientHeight}getGlArea(){return this.gtkGlArea}_createCloneTarget(){let e=new n;return e.width=this.width,e.height=this.height,e}getContext(n,r){return n===`webgl`||n===`experimental-webgl`?(this._webgl||=(this.gtkGlArea.make_current(),new e(this,r)),this._webgl):n===`webgl2`?(this._webgl2||=(this.gtkGlArea.make_current(),new t(this,r)),this._webgl2):super.getContext(n,r)}};export{HTMLCanvasElement};
1
+ import"./_virtual/_rolldown/runtime.js";import{WebGLRenderingContext as e}from"./webgl-rendering-context.js";import{WebGL2RenderingContext as t}from"./webgl2-rendering-context.js";import{HTMLCanvasElement as n}from"@gjsify/dom-elements";function deviceScale(e){let t=e.get_native?.()?.get_surface?.()?.get_scale?.();return typeof t==`number`&&t>0?t:e.get_scale_factor()||1}var HTMLCanvasElement=class extends n{constructor(e){super(),this.gtkGlArea=e}get width(){return Math.round(this.gtkGlArea.get_allocated_width()*this.scaleFactor)}set width(e){}get height(){return Math.round(this.gtkGlArea.get_allocated_height()*this.scaleFactor)}set height(e){}get scaleFactor(){return deviceScale(this.gtkGlArea)}get clientWidth(){return this.gtkGlArea.get_allocated_width()}get clientHeight(){return this.gtkGlArea.get_allocated_height()}get offsetWidth(){return this.clientWidth}get offsetHeight(){return this.clientHeight}getGlArea(){return this.gtkGlArea}_createCloneTarget(){let e=new n;return e.width=this.width,e.height=this.height,e}getContext(n,r){return n===`webgl`||n===`experimental-webgl`?(this._webgl||=(this.gtkGlArea.make_current(),new e(this,r)),this._webgl):n===`webgl2`?(this._webgl2||=(this.gtkGlArea.make_current(),new t(this,r)),this._webgl2):super.getContext(n,r)}};export{HTMLCanvasElement,deviceScale};
@@ -1 +1 @@
1
- import{__name as e}from"./_virtual/_rolldown/runtime.js";import{HTMLCanvasElement as t}from"./html-canvas-element.js";import{describe as n,expect as r,it as i}from"@gjsify/unit";function stubGlArea(e,t,n){return{get_allocated_width:()=>e,get_allocated_height:()=>t,get_scale_factor:()=>n}}var a=e(async()=>{await n(`HTMLCanvasElement (GLArea) — cloneNode`,async()=>{await i(`clones to a plain canvas instead of throwing`,async()=>{let e=new t(stubGlArea(640,480,1)).cloneNode(!1);r(e.width).toBe(640),r(e.height).toBe(480)}),await i(`gives the clone a writable size — no widget owns it`,async()=>{let e=new t(stubGlArea(640,480,1)).cloneNode(!1);e.width=800,e.height=600,r(e.width).toBe(800),r(e.height).toBe(600)}),await i(`leaves the original bound to its widget`,async()=>{let e=new t(stubGlArea(640,480,2));e.cloneNode(!1),r(e.width).toBe(1280)})}),await n(`HTMLCanvasElement (GLArea) — drawing buffer vs CSS size`,async()=>{await i(`reports the drawing buffer in DEVICE pixels on a HiDPI surface`,async()=>{let e=new t(stubGlArea(360,655,3));r(e.width).toBe(1080),r(e.height).toBe(1965)}),await i(`keeps the CSS layout size LOGICAL on the same surface`,async()=>{let e=new t(stubGlArea(360,655,3));r(e.clientWidth).toBe(360),r(e.clientHeight).toBe(655),r(e.offsetWidth).toBe(360),r(e.offsetHeight).toBe(655)}),await i(`CSS size × devicePixelRatio equals the drawing buffer`,async()=>{let e=new t(stubGlArea(800,600,2));r(e.clientWidth*e.scaleFactor).toBe(e.width),r(e.clientHeight*e.scaleFactor).toBe(e.height)}),await i(`is a no-op change at scale-factor 1 (every pre-HiDPI host)`,async()=>{let e=new t(stubGlArea(1024,768,1));r(e.width).toBe(1024),r(e.height).toBe(768),r(e.clientWidth).toBe(1024),r(e.clientHeight).toBe(768)}),await i(`treats an unrealized widget (scale 0) as scale 1, not as a 0×0 buffer`,async()=>{let e=new t(stubGlArea(640,480,0));r(e.scaleFactor).toBe(1),r(e.width).toBe(640),r(e.height).toBe(480)}),await i(`ignores width/height writes — GTK owns the allocation`,async()=>{let e=new t(stubGlArea(360,655,3));e.width=42,e.height=42,r(e.width).toBe(1080),r(e.height).toBe(1965)})})},`default`);export{a as default};
1
+ import{__name as e}from"./_virtual/_rolldown/runtime.js";import{HTMLCanvasElement as t}from"./html-canvas-element.js";import{describe as n,expect as r,it as i}from"@gjsify/unit";function stubGlArea(e,t,n,r){return{get_native:()=>r===void 0?null:{get_surface:()=>({get_scale:()=>r})},get_allocated_width:()=>e,get_allocated_height:()=>t,get_scale_factor:()=>n}}var a=e(async()=>{await n(`HTMLCanvasElement (GLArea) — cloneNode`,async()=>{await i(`clones to a plain canvas instead of throwing`,async()=>{let e=new t(stubGlArea(640,480,1)).cloneNode(!1);r(e.width).toBe(640),r(e.height).toBe(480)}),await i(`gives the clone a writable size — no widget owns it`,async()=>{let e=new t(stubGlArea(640,480,1)).cloneNode(!1);e.width=800,e.height=600,r(e.width).toBe(800),r(e.height).toBe(600)}),await i(`leaves the original bound to its widget`,async()=>{let e=new t(stubGlArea(640,480,2));e.cloneNode(!1),r(e.width).toBe(1280)})}),await n(`HTMLCanvasElement (GLArea) — drawing buffer vs CSS size`,async()=>{await i(`reports the drawing buffer in DEVICE pixels on a HiDPI surface`,async()=>{let e=new t(stubGlArea(360,655,3));r(e.width).toBe(1080),r(e.height).toBe(1965)}),await i(`keeps the CSS layout size LOGICAL on the same surface`,async()=>{let e=new t(stubGlArea(360,655,3));r(e.clientWidth).toBe(360),r(e.clientHeight).toBe(655),r(e.offsetWidth).toBe(360),r(e.offsetHeight).toBe(655)}),await i(`CSS size × devicePixelRatio equals the drawing buffer`,async()=>{let e=new t(stubGlArea(800,600,2));r(e.clientWidth*e.scaleFactor).toBe(e.width),r(e.clientHeight*e.scaleFactor).toBe(e.height)}),await i(`is a no-op change at scale-factor 1 (every pre-HiDPI host)`,async()=>{let e=new t(stubGlArea(1024,768,1));r(e.width).toBe(1024),r(e.height).toBe(768),r(e.clientWidth).toBe(1024),r(e.clientHeight).toBe(768)}),await i(`treats an unrealized widget (scale 0) as scale 1, not as a 0×0 buffer`,async()=>{let e=new t(stubGlArea(640,480,0));r(e.scaleFactor).toBe(1),r(e.width).toBe(640),r(e.height).toBe(480)}),await i(`ignores width/height writes — GTK owns the allocation`,async()=>{let e=new t(stubGlArea(360,655,3));e.width=42,e.height=42,r(e.width).toBe(1080),r(e.height).toBe(1965)})}),await n(`HTMLCanvasElement (GLArea) — fractional scale`,async()=>{await i(`reports the REAL device size at 125 %`,async()=>{let e=new t(stubGlArea(400,300,2,1.25));r(e.scaleFactor).toBe(1.25),r(e.width).toBe(500),r(e.height).toBe(375)}),await i(`reports the REAL device size at 150 %`,async()=>{let e=new t(stubGlArea(400,300,2,1.5));r(e.width).toBe(600),r(e.height).toBe(450)}),await i(`rounds a non-integer device size to whole pixels`,async()=>{let e=new t(stubGlArea(401,301,2,1.25));r(e.width).toBe(501),r(e.height).toBe(376)}),await i(`never exceeds the ceil-sized GTK framebuffer`,async()=>{let e=new t(stubGlArea(333,777,2,1.25));r(e.width).toBeLessThan(667),r(e.height).toBeLessThan(1555)}),await i(`falls back to the integer factor when no surface scale exists`,async()=>{let e=new t(stubGlArea(400,300,2));r(e.scaleFactor).toBe(2),r(e.width).toBe(800)}),await i(`integer surface scale is unchanged`,async()=>{r(new t(stubGlArea(400,300,2,2)).width).toBe(800)})})},`default`);export{a as default};
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{WebGLBuffer as e}from"./webgl-buffer.js";import{WebGLUniformLocation as t}from"./webgl-uniform-location.js";import{WebGLDrawingBufferWrapper as n}from"./webgl-drawing-buffer-wrapper.js";import{WebGLFramebuffer as r}from"./webgl-framebuffer.js";import{WebGLRenderbuffer as i}from"./webgl-renderbuffer.js";import{WebGLTexture as a}from"./webgl-texture.js";import{WebGLProgram as o}from"./webgl-program.js";import{WebGLShader as s}from"./webgl-shader.js";import{WebGLShaderPrecisionFormat as c}from"./webgl-shader-precision-format.js";import{WebGLActiveInfo as l}from"./webgl-active-info.js";import{EXTBlendMinMax as u,getEXTBlendMinMax as d}from"./extensions/ext-blend-minmax.js";import{EXTColorBufferFloat as f,getEXTColorBufferFloat as p}from"./extensions/ext-color-buffer-float.js";import{EXTColorBufferHalfFloat as m,getEXTColorBufferHalfFloat as h}from"./extensions/ext-color-buffer-half-float.js";import{EXTTextureFilterAnisotropic as g,getEXTTextureFilterAnisotropic as _}from"./extensions/ext-texture-filter-anisotropic.js";import{OESElementIndexUint as v,getOESElementIndexUint as y}from"./extensions/oes-element-index-unit.js";import{OESStandardDerivatives as b,getOESStandardDerivatives as x}from"./extensions/oes-standard-derivatives.js";import{OESTextureFloatLinear as S,getOESTextureFloatLinear as C}from"./extensions/oes-texture-float-linear.js";import{OESTextureFloat as w,getOESTextureFloat as T}from"./extensions/oes-texture-float.js";import{OESTextureHalfFloat as E,getOESTextureHalfFloat as D}from"./extensions/oes-texture-half-float.js";import{STACKGLDestroyContext as O,getSTACKGLDestroyContext as k}from"./extensions/stackgl-destroy-context.js";import{STACKGLResizeDrawingBuffer as A,getSTACKGLResizeDrawingBuffer as j}from"./extensions/stackgl-resize-drawing-buffer.js";import{WEBGLDebugRendererInfo as M,getWEBGLDebugRendererInfo as N}from"./extensions/webgl-debug-renderer-info.js";import{WebGLContextAttributes as P}from"./webgl-context-attributes.js";import{WebGLTextureUnit as F}from"./webgl-texture-unit.js";import{WebGLVertexArrayGlobalAttribute as I,WebGLVertexArrayGlobalState as L,WebGLVertexArrayObjectAttribute as R,WebGLVertexArrayObjectState as z}from"./webgl-vertex-attribute.js";import{WebGLContextBase as B}from"./webgl-context-base.js";import{WebGLRenderingContext as V}from"./webgl-rendering-context.js";import{WebGLQuery as H}from"./webgl-query.js";import{WebGLSampler as U}from"./webgl-sampler.js";import{WebGLSync as W}from"./webgl-sync.js";import{WebGLTransformFeedback as G}from"./webgl-transform-feedback.js";import{WebGLVertexArrayObject as K}from"./webgl-vertex-array-object.js";import{WebGL2RenderingContext as q}from"./webgl2-rendering-context.js";import{HTMLCanvasElement as J}from"./html-canvas-element.js";import{isSoftwareRenderer as Y}from"./software-renderer.js";import{WebGLBridge as X}from"./webgl-bridge.js";import"@girs/gtk-4.0";import"@girs/gjs";import"@girs/gio-2.0";export{u as EXTBlendMinMax,f as EXTColorBufferFloat,m as EXTColorBufferHalfFloat,g as EXTTextureFilterAnisotropic,J as HTMLCanvasElement,v as OESElementIndexUint,b as OESStandardDerivatives,w as OESTextureFloat,S as OESTextureFloatLinear,E as OESTextureHalfFloat,O as STACKGLDestroyContext,A as STACKGLResizeDrawingBuffer,M as WEBGLDebugRendererInfo,q as WebGL2RenderingContext,l as WebGLActiveInfo,X as WebGLBridge,e as WebGLBuffer,P as WebGLContextAttributes,B as WebGLContextBase,n as WebGLDrawingBufferWrapper,r as WebGLFramebuffer,o as WebGLProgram,H as WebGLQuery,i as WebGLRenderbuffer,V as WebGLRenderingContext,U as WebGLSampler,s as WebGLShader,c as WebGLShaderPrecisionFormat,W as WebGLSync,a as WebGLTexture,F as WebGLTextureUnit,G as WebGLTransformFeedback,t as WebGLUniformLocation,I as WebGLVertexArrayGlobalAttribute,L as WebGLVertexArrayGlobalState,K as WebGLVertexArrayObject,R as WebGLVertexArrayObjectAttribute,z as WebGLVertexArrayObjectState,d as getEXTBlendMinMax,p as getEXTColorBufferFloat,h as getEXTColorBufferHalfFloat,_ as getEXTTextureFilterAnisotropic,y as getOESElementIndexUint,x as getOESStandardDerivatives,T as getOESTextureFloat,C as getOESTextureFloatLinear,D as getOESTextureHalfFloat,k as getSTACKGLDestroyContext,j as getSTACKGLResizeDrawingBuffer,N as getWEBGLDebugRendererInfo,Y as isSoftwareRenderer};
1
+ import{WebGLBuffer as e}from"./webgl-buffer.js";import{WebGLUniformLocation as t}from"./webgl-uniform-location.js";import{WebGLDrawingBufferWrapper as n}from"./webgl-drawing-buffer-wrapper.js";import{WebGLFramebuffer as r}from"./webgl-framebuffer.js";import{WebGLRenderbuffer as i}from"./webgl-renderbuffer.js";import{WebGLTexture as a}from"./webgl-texture.js";import{WebGLProgram as o}from"./webgl-program.js";import{WebGLShader as s}from"./webgl-shader.js";import{WebGLShaderPrecisionFormat as c}from"./webgl-shader-precision-format.js";import{WebGLActiveInfo as l}from"./webgl-active-info.js";import{EXTBlendMinMax as u,getEXTBlendMinMax as d}from"./extensions/ext-blend-minmax.js";import{EXTColorBufferFloat as f,getEXTColorBufferFloat as p}from"./extensions/ext-color-buffer-float.js";import{EXTColorBufferHalfFloat as m,getEXTColorBufferHalfFloat as h}from"./extensions/ext-color-buffer-half-float.js";import{EXTTextureFilterAnisotropic as g,getEXTTextureFilterAnisotropic as _}from"./extensions/ext-texture-filter-anisotropic.js";import{OESElementIndexUint as v,getOESElementIndexUint as y}from"./extensions/oes-element-index-unit.js";import{OESStandardDerivatives as b,getOESStandardDerivatives as x}from"./extensions/oes-standard-derivatives.js";import{OESTextureFloatLinear as S,getOESTextureFloatLinear as C}from"./extensions/oes-texture-float-linear.js";import{OESTextureFloat as w,getOESTextureFloat as T}from"./extensions/oes-texture-float.js";import{OESTextureHalfFloat as E,getOESTextureHalfFloat as D}from"./extensions/oes-texture-half-float.js";import{STACKGLDestroyContext as O,getSTACKGLDestroyContext as k}from"./extensions/stackgl-destroy-context.js";import{STACKGLResizeDrawingBuffer as A,getSTACKGLResizeDrawingBuffer as j}from"./extensions/stackgl-resize-drawing-buffer.js";import{WEBGLDebugRendererInfo as M,getWEBGLDebugRendererInfo as N}from"./extensions/webgl-debug-renderer-info.js";import{WebGLContextAttributes as P}from"./webgl-context-attributes.js";import{WebGLTextureUnit as F}from"./webgl-texture-unit.js";import{WebGLVertexArrayGlobalAttribute as I,WebGLVertexArrayGlobalState as L,WebGLVertexArrayObjectAttribute as R,WebGLVertexArrayObjectState as z}from"./webgl-vertex-attribute.js";import{WebGLContextBase as B}from"./webgl-context-base.js";import{WebGLRenderingContext as V}from"./webgl-rendering-context.js";import{WebGLQuery as H}from"./webgl-query.js";import{WebGLSampler as U}from"./webgl-sampler.js";import{WebGLSync as W}from"./webgl-sync.js";import{WebGLTransformFeedback as G}from"./webgl-transform-feedback.js";import{WebGLVertexArrayObject as K}from"./webgl-vertex-array-object.js";import{WebGL2RenderingContext as q}from"./webgl2-rendering-context.js";import{HTMLCanvasElement as J,deviceScale as Y}from"./html-canvas-element.js";import{isSoftwareRenderer as X}from"./software-renderer.js";import{WebGLBridge as Z}from"./webgl-bridge.js";import"@girs/gtk-4.0";import"@girs/gjs";import"@girs/gio-2.0";export{u as EXTBlendMinMax,f as EXTColorBufferFloat,m as EXTColorBufferHalfFloat,g as EXTTextureFilterAnisotropic,J as HTMLCanvasElement,v as OESElementIndexUint,b as OESStandardDerivatives,w as OESTextureFloat,S as OESTextureFloatLinear,E as OESTextureHalfFloat,O as STACKGLDestroyContext,A as STACKGLResizeDrawingBuffer,M as WEBGLDebugRendererInfo,q as WebGL2RenderingContext,l as WebGLActiveInfo,Z as WebGLBridge,e as WebGLBuffer,P as WebGLContextAttributes,B as WebGLContextBase,n as WebGLDrawingBufferWrapper,r as WebGLFramebuffer,o as WebGLProgram,H as WebGLQuery,i as WebGLRenderbuffer,V as WebGLRenderingContext,U as WebGLSampler,s as WebGLShader,c as WebGLShaderPrecisionFormat,W as WebGLSync,a as WebGLTexture,F as WebGLTextureUnit,G as WebGLTransformFeedback,t as WebGLUniformLocation,I as WebGLVertexArrayGlobalAttribute,L as WebGLVertexArrayGlobalState,K as WebGLVertexArrayObject,R as WebGLVertexArrayObjectAttribute,z as WebGLVertexArrayObjectState,Y as deviceScale,d as getEXTBlendMinMax,p as getEXTColorBufferFloat,h as getEXTColorBufferHalfFloat,_ as getEXTTextureFilterAnisotropic,y as getOESElementIndexUint,x as getOESStandardDerivatives,T as getOESTextureFloat,C as getOESTextureFloatLinear,D as getOESTextureHalfFloat,k as getSTACKGLDestroyContext,j as getSTACKGLResizeDrawingBuffer,N as getWEBGLDebugRendererInfo,X as isSoftwareRenderer};
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{WebGLRenderingContext as e}from"./webgl-rendering-context.js";import{WebGL2RenderingContext as t}from"./webgl2-rendering-context.js";import{HTMLCanvasElement as n}from"./html-canvas-element.js";import{isSoftwareRenderer as r}from"./software-renderer.js";import{notifyElementResize as i}from"@gjsify/dom-elements";import a from"gi://GObject?version=2.0";import o from"gi://Gdk?version=4.0";import s from"gi://GLib?version=2.0";import c from"gi://Gtk?version=4.0";import{attachEventControllers as l}from"@gjsify/event-bridge";import{Event as u}from"@gjsify/dom-events";const d=a.registerClass({GTypeName:`GjsifyWebGLBridge`},class WebGLBridge extends c.GLArea{constructor(e){super(e),this._canvas=null,this._readyCallbacks=[],this._resizeCallbacks=[],this._renderTag=null,this._tickCallbackId=null,this._frameCallback=null,this._lastFrameCallback=null,this._lastFrameTime=0,this._replaying=!1,this._frameCallbackId=0,this._nextFrameId=1,this._timeOrigin=s.get_monotonic_time(),this._rendererInfo=null,this.set_allowed_apis(o.GLAPI.GL|o.GLAPI.GLES),this.set_required_version(3,2),this.set_has_depth_buffer(!0),this.set_has_stencil_buffer(!0),l(this,()=>this._canvas,{captureKeys:!0}),this._tickCallbackId=this.add_tick_callback((e,t)=>(this._frameCallback!==null&&this.queue_render(),s.SOURCE_CONTINUE));let t=this.connect(`render`,()=>{this.disconnect(t),this.make_current(),this._canvas=new n(this);{let e=globalThis;e.document?.body&&e.document.body.appendChild(this._canvas)}this._canvas.getContext(`webgl2`);let e=this._canvas.getContext(`webgl`);if(e){this._reportRenderer(e);for(let t of this._readyCallbacks)t(this._canvas,e);this._readyCallbacks=[]}return this._renderTag=this.connect(`render`,e=>{let t=(s.get_monotonic_time()-this._timeOrigin)/1e3;if(this._frameCallback!==null){globalThis.__GJSIFY_DEBUG_RAF===!0&&console.log(`[rAF] frame callback fires t=${t.toFixed(1)}`);let e=this._frameCallback;this._frameCallback=null,this._frameCallbackId=0,this._lastFrameCallback=e,this._lastFrameTime=t,e(t)}else if(this._lastFrameCallback!==null){this._replaying=!0;try{this._lastFrameCallback(this._lastFrameTime)}finally{this._replaying=!1}}return!0}),!0});this.connect(`resize`,()=>{let e=this.get_allocated_width(),t=this.get_allocated_height();this._canvas&&(this._canvas.dispatchEvent(new u(`resize`)),i(this._canvas,e,t));for(let n of this._resizeCallbacks)n(e,t);this._frameCallback&&this.requestAnimationFrame(this._frameCallback)}),this.connect(`unrealize`,()=>{this._renderTag!==null&&(this.disconnect(this._renderTag),this._renderTag=null),this._tickCallbackId!==null&&(this.remove_tick_callback(this._tickCallbackId),this._tickCallbackId=null),this._frameCallback=null,this._lastFrameCallback=null,this._lastFrameTime=0,this._replaying=!1,this._canvas=null})}get canvas(){return this._canvas}get rendererInfo(){return this._rendererInfo}onReady(e){if(this._canvas){let t=this._canvas.getContext(`webgl`);if(t){e(this._canvas,t);return}}this._readyCallbacks.push(e)}onWebGLReady(e){this.onReady(e)}_reportRenderer(e){let t=e.getExtension(`WEBGL_debug_renderer_info`),n=String(e.getParameter(t.UNMASKED_VENDOR_WEBGL)??``),i=String(e.getParameter(t.UNMASKED_RENDERER_WEBGL)??``);this._rendererInfo={vendor:n,renderer:i},r(i)&&console.warn(`[@gjsify/webgl] GL is rasterised on the CPU by "${i}" (${n}) — this host exposes no usable GPU. Every draw call still works; fill-heavy or continuously animating content will be orders of magnitude slower than on hardware, which can look like a frozen window rather than a slow one. Read it yourself via WebGLBridge.rendererInfo or the WEBGL_debug_renderer_info extension.`)}onResize(e){this._resizeCallbacks.push(e)}requestAnimationFrame(e){let t=this._nextFrameId++;return this._replaying?t:(this._frameCallback=e,this._frameCallbackId=t,this.queue_render(),t)}cancelAnimationFrame(e){e!==0&&e===this._frameCallbackId&&(this._frameCallback=null,this._frameCallbackId=0,this._lastFrameCallback=null,this._lastFrameTime=0)}installGlobals(){let n=globalThis;n.requestAnimationFrame=e=>this.requestAnimationFrame(e),n.cancelAnimationFrame=e=>this.cancelAnimationFrame(e),n.WebGLRenderingContext=e,n.WebGL2RenderingContext=t,Object.defineProperty(globalThis,"devicePixelRatio",{get:()=>this.get_scale_factor()||1,configurable:!0});let r=this._timeOrigin;n.performance={now:()=>(s.get_monotonic_time()-r)/1e3,timeOrigin:Date.now()}}});export{d as WebGLBridge};
1
+ import"./_virtual/_rolldown/runtime.js";import{WebGLRenderingContext as e}from"./webgl-rendering-context.js";import{WebGL2RenderingContext as t}from"./webgl2-rendering-context.js";import{HTMLCanvasElement as n,deviceScale as r}from"./html-canvas-element.js";import{isSoftwareRenderer as i}from"./software-renderer.js";import{notifyElementResize as a}from"@gjsify/dom-elements";import o from"gi://GObject?version=2.0";import s from"gi://Gdk?version=4.0";import c from"gi://GLib?version=2.0";import l from"gi://Gtk?version=4.0";import u from"gi://Graphene?version=1.0";import{attachEventControllers as d}from"@gjsify/event-bridge";import{Event as f}from"@gjsify/dom-events";const p=o.registerClass({GTypeName:`GjsifyWebGLBridge`},class WebGLBridge extends l.GLArea{constructor(e){super(e),this._canvas=null,this._readyCallbacks=[],this._resizeCallbacks=[],this._renderTag=null,this._tickCallbackId=null,this._frameCallback=null,this._lastFrameCallback=null,this._lastFrameTime=0,this._replaying=!1,this._frameCallbackId=0,this._nextFrameId=1,this._timeOrigin=c.get_monotonic_time(),this._rendererInfo=null,this._scaleSurface=null,this._scaleNotifyId=null,this.set_allowed_apis(s.GLAPI.GL|s.GLAPI.GLES),this.set_required_version(3,2),this.set_has_depth_buffer(!0),this.set_has_stencil_buffer(!0),d(this,()=>this._canvas,{captureKeys:!0}),this._tickCallbackId=this.add_tick_callback((e,t)=>(this._frameCallback!==null&&this.queue_render(),c.SOURCE_CONTINUE));let t=this.connect(`render`,()=>{this.disconnect(t),this.make_current(),this._canvas=new n(this);{let e=globalThis;e.document?.body&&e.document.body.appendChild(this._canvas)}this._canvas.getContext(`webgl2`);let e=this._canvas.getContext(`webgl`);if(e){this._reportRenderer(e);for(let t of this._readyCallbacks)t(this._canvas,e);this._readyCallbacks=[]}return this._renderTag=this.connect(`render`,t=>{this._fitViewportToDeviceSize(e);let n=(c.get_monotonic_time()-this._timeOrigin)/1e3;if(this._frameCallback!==null){globalThis.__GJSIFY_DEBUG_RAF===!0&&console.log(`[rAF] frame callback fires t=${n.toFixed(1)}`);let e=this._frameCallback;this._frameCallback=null,this._frameCallbackId=0,this._lastFrameCallback=e,this._lastFrameTime=n,e(n)}else if(this._lastFrameCallback!==null){this._replaying=!0;try{this._lastFrameCallback(this._lastFrameTime)}finally{this._replaying=!1}}return!0}),!0});this.connect(`resize`,()=>this._notifyResize()),this.connect(`realize`,()=>{let e=this.get_native()?.get_surface();e&&this._scaleNotifyId===null&&(this._scaleSurface=e,this._scaleNotifyId=e.connect(`notify::scale`,()=>{this._notifyResize(),this.queue_render()}))}),this.connect(`unrealize`,()=>{this._scaleSurface&&this._scaleNotifyId!==null&&this._scaleSurface.disconnect(this._scaleNotifyId),this._scaleSurface=null,this._scaleNotifyId=null,this._renderTag!==null&&(this.disconnect(this._renderTag),this._renderTag=null),this._tickCallbackId!==null&&(this.remove_tick_callback(this._tickCallbackId),this._tickCallbackId=null),this._frameCallback=null,this._lastFrameCallback=null,this._lastFrameTime=0,this._replaying=!1,this._canvas=null})}_notifyResize(){let e=this.get_allocated_width(),t=this.get_allocated_height();this._canvas&&(this._canvas.dispatchEvent(new f(`resize`)),a(this._canvas,e,t));for(let n of this._resizeCallbacks)n(e,t);this._frameCallback&&this.requestAnimationFrame(this._frameCallback)}_fitViewportToDeviceSize(e){let t=this._canvas;if(!e||!t)return;let n=this.get_scale_factor()||1;r(this)!==n&&e.viewport(0,0,t.width,t.height)}vfunc_snapshot(e){let t=r(this),n=this.get_scale_factor()||1;if(t===n){super.vfunc_snapshot(e);return}let i=n/t;e.save(),e.push_clip(new u.Rect().init(0,0,this.get_width(),this.get_height()));let a=this.get_height();e.translate(new u.Point().init(0,a)),e.scale(i,i),e.translate(new u.Point().init(0,-a)),super.vfunc_snapshot(e),e.pop(),e.restore()}get canvas(){return this._canvas}get rendererInfo(){return this._rendererInfo}onReady(e){if(this._canvas){let t=this._canvas.getContext(`webgl`);if(t){e(this._canvas,t);return}}this._readyCallbacks.push(e)}onWebGLReady(e){this.onReady(e)}_reportRenderer(e){let t=e.getExtension(`WEBGL_debug_renderer_info`),n=String(e.getParameter(t.UNMASKED_VENDOR_WEBGL)??``),r=String(e.getParameter(t.UNMASKED_RENDERER_WEBGL)??``);this._rendererInfo={vendor:n,renderer:r},i(r)&&console.warn(`[@gjsify/webgl] GL is rasterised on the CPU by "${r}" (${n}) — this host exposes no usable GPU. Every draw call still works; fill-heavy or continuously animating content will be orders of magnitude slower than on hardware, which can look like a frozen window rather than a slow one. Read it yourself via WebGLBridge.rendererInfo or the WEBGL_debug_renderer_info extension.`)}onResize(e){this._resizeCallbacks.push(e)}requestAnimationFrame(e){let t=this._nextFrameId++;return this._replaying?t:(this._frameCallback=e,this._frameCallbackId=t,this.queue_render(),t)}cancelAnimationFrame(e){e!==0&&e===this._frameCallbackId&&(this._frameCallback=null,this._frameCallbackId=0,this._lastFrameCallback=null,this._lastFrameTime=0)}installGlobals(){let n=globalThis;n.requestAnimationFrame=e=>this.requestAnimationFrame(e),n.cancelAnimationFrame=e=>this.cancelAnimationFrame(e),n.WebGLRenderingContext=e,n.WebGL2RenderingContext=t,Object.defineProperty(globalThis,"devicePixelRatio",{get:()=>r(this),configurable:!0});let i=this._timeOrigin;n.performance={now:()=>(c.get_monotonic_time()-i)/1e3,timeOrigin:Date.now()}}});export{p as WebGLBridge};
@@ -2,6 +2,14 @@ import { HTMLCanvasElement as BaseHTMLCanvasElement } from '@gjsify/dom-elements
2
2
  import type Gtk from 'gi://Gtk?version=4.0';
3
3
  import { WebGLRenderingContext as OurWebGLRenderingContext } from './webgl-rendering-context.js';
4
4
  import { WebGL2RenderingContext as OurWebGL2RenderingContext } from './webgl2-rendering-context.js';
5
+ /**
6
+ * The REAL device-pixels-per-logical-pixel of a widget: the surface's fractional scale
7
+ * (1.25, 1.5) where GTK reports one, else the integer `get_scale_factor()`.
8
+ *
9
+ * `get_scale_factor()` is `ceil(scale)` — GTK sizes the GLArea framebuffer with it, so
10
+ * at 125 % it is 2 while the display shows 1.25. `0` / missing means no surface yet.
11
+ */
12
+ export declare function deviceScale(widget: Gtk.Widget): number;
5
13
  export declare class HTMLCanvasElement extends BaseHTMLCanvasElement {
6
14
  readonly gtkGlArea: Gtk.GLArea;
7
15
  _webgl?: OurWebGLRenderingContext;
@@ -2,6 +2,7 @@ import GObject from 'gi://GObject?version=2.0';
2
2
  import Gdk from 'gi://Gdk?version=4.0';
3
3
  import GLib from 'gi://GLib?version=2.0';
4
4
  import Gtk from 'gi://Gtk?version=4.0';
5
+ import Graphene from 'gi://Graphene?version=1.0';
5
6
  import { HTMLCanvasElement as OurHTMLCanvasElement } from './html-canvas-element.js';
6
7
  import { WebGLRenderingContext as OurWebGLRenderingContext } from './webgl-rendering-context.js';
7
8
  type WebGLReadyCallback = (canvas: globalThis.HTMLCanvasElement, gl: globalThis.WebGLRenderingContext) => void;
@@ -36,6 +37,26 @@ export declare const WebGLBridge: {
36
37
  vendor: string;
37
38
  renderer: string;
38
39
  } | null;
40
+ _scaleSurface: Gdk.Surface | null;
41
+ _scaleNotifyId: number | null;
42
+ /** Fires every resize consumer: DOM event, ResizeObserver, `onResize`, rAF re-arm. */
43
+ _notifyResize(): void;
44
+ /**
45
+ * Fractional scale only: GTK binds a viewport of the whole framebuffer
46
+ * (`alloc × ceil(scale)`), but the drawing buffer is the smaller
47
+ * `round(alloc × scale)` region in its bottom-left corner. Start each frame with
48
+ * the viewport a fresh browser canvas has.
49
+ */
50
+ _fitViewportToDeviceSize(gl: OurWebGLRenderingContext | null): void;
51
+ /**
52
+ * Presents the real-size region 1:1. GtkGLArea draws its whole framebuffer
53
+ * (`alloc × ceil(scale)` texels) into the logical allocation, i.e. one texel per
54
+ * `1/ceil(scale)` logical px; the content sits in the bottom-left of the widget
55
+ * (GL origin). Scaling the parent draw by `ceil/scale` from the
56
+ * widget origin makes one texel exactly one device pixel; the clip drops the
57
+ * unused remainder. Integer scales take the untouched parent path.
58
+ */
59
+ vfunc_snapshot(snapshot: Gtk.Snapshot): void;
39
60
  /** The HTMLCanvasElement wrapping this GLArea. Available after the first render. */
40
61
  get canvas(): globalThis.HTMLCanvasElement | null;
41
62
  /**
@@ -313,7 +334,6 @@ export declare const WebGLBridge: {
313
334
  vfunc_set_focus_child(child: Gtk.Widget | null): void;
314
335
  vfunc_show(): void;
315
336
  vfunc_size_allocate(width: number, height: number, baseline: number): void;
316
- vfunc_snapshot(snapshot: Gtk.Snapshot): void;
317
337
  vfunc_state_flags_changed(previous_state_flags: Gtk.StateFlags): void;
318
338
  vfunc_system_setting_changed(settings: Gtk.SystemSetting): void;
319
339
  vfunc_unmap(): void;
@@ -329,10 +349,10 @@ export declare const WebGLBridge: {
329
349
  add_tick_callback(callback: Gtk.TickCallback): number;
330
350
  allocate(width: number, height: number, baseline: number, transform: import("@girs/gsk-4.0").default.Transform | null): void;
331
351
  child_focus(direction: Gtk.DirectionType): boolean;
332
- compute_bounds(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Rect];
352
+ compute_bounds(target: Gtk.Widget): [boolean, Graphene.Rect];
333
353
  compute_expand(orientation: Gtk.Orientation): boolean;
334
- compute_point(target: Gtk.Widget, point: import("@girs/graphene-1.0").default.Point): [boolean, import("@girs/graphene-1.0").default.Point];
335
- compute_transform(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Matrix];
354
+ compute_point(target: Gtk.Widget, point: Graphene.Point): [boolean, Graphene.Point];
355
+ compute_transform(target: Gtk.Widget): [boolean, Graphene.Matrix];
336
356
  contains(x: number, y: number): boolean;
337
357
  create_pango_context(): import("@girs/pango-1.0").default.Context;
338
358
  create_pango_layout(text: string | null): import("@girs/pango-1.0").default.Layout;
@@ -537,6 +557,26 @@ export declare const WebGLBridge: {
537
557
  vendor: string;
538
558
  renderer: string;
539
559
  } | null;
560
+ _scaleSurface: Gdk.Surface | null;
561
+ _scaleNotifyId: number | null;
562
+ /** Fires every resize consumer: DOM event, ResizeObserver, `onResize`, rAF re-arm. */
563
+ _notifyResize(): void;
564
+ /**
565
+ * Fractional scale only: GTK binds a viewport of the whole framebuffer
566
+ * (`alloc × ceil(scale)`), but the drawing buffer is the smaller
567
+ * `round(alloc × scale)` region in its bottom-left corner. Start each frame with
568
+ * the viewport a fresh browser canvas has.
569
+ */
570
+ _fitViewportToDeviceSize(gl: OurWebGLRenderingContext | null): void;
571
+ /**
572
+ * Presents the real-size region 1:1. GtkGLArea draws its whole framebuffer
573
+ * (`alloc × ceil(scale)` texels) into the logical allocation, i.e. one texel per
574
+ * `1/ceil(scale)` logical px; the content sits in the bottom-left of the widget
575
+ * (GL origin). Scaling the parent draw by `ceil/scale` from the
576
+ * widget origin makes one texel exactly one device pixel; the clip drops the
577
+ * unused remainder. Integer scales take the untouched parent path.
578
+ */
579
+ vfunc_snapshot(snapshot: Gtk.Snapshot): void;
540
580
  /** The HTMLCanvasElement wrapping this GLArea. Available after the first render. */
541
581
  get canvas(): globalThis.HTMLCanvasElement | null;
542
582
  /**
@@ -814,7 +854,6 @@ export declare const WebGLBridge: {
814
854
  vfunc_set_focus_child(child: Gtk.Widget | null): void;
815
855
  vfunc_show(): void;
816
856
  vfunc_size_allocate(width: number, height: number, baseline: number): void;
817
- vfunc_snapshot(snapshot: Gtk.Snapshot): void;
818
857
  vfunc_state_flags_changed(previous_state_flags: Gtk.StateFlags): void;
819
858
  vfunc_system_setting_changed(settings: Gtk.SystemSetting): void;
820
859
  vfunc_unmap(): void;
@@ -830,10 +869,10 @@ export declare const WebGLBridge: {
830
869
  add_tick_callback(callback: Gtk.TickCallback): number;
831
870
  allocate(width: number, height: number, baseline: number, transform: import("@girs/gsk-4.0").default.Transform | null): void;
832
871
  child_focus(direction: Gtk.DirectionType): boolean;
833
- compute_bounds(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Rect];
872
+ compute_bounds(target: Gtk.Widget): [boolean, Graphene.Rect];
834
873
  compute_expand(orientation: Gtk.Orientation): boolean;
835
- compute_point(target: Gtk.Widget, point: import("@girs/graphene-1.0").default.Point): [boolean, import("@girs/graphene-1.0").default.Point];
836
- compute_transform(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Matrix];
874
+ compute_point(target: Gtk.Widget, point: Graphene.Point): [boolean, Graphene.Point];
875
+ compute_transform(target: Gtk.Widget): [boolean, Graphene.Matrix];
837
876
  contains(x: number, y: number): boolean;
838
877
  create_pango_context(): import("@girs/pango-1.0").default.Context;
839
878
  create_pango_layout(text: string | null): import("@girs/pango-1.0").default.Layout;
@@ -1038,6 +1077,26 @@ export declare const WebGLBridge: {
1038
1077
  vendor: string;
1039
1078
  renderer: string;
1040
1079
  } | null;
1080
+ _scaleSurface: Gdk.Surface | null;
1081
+ _scaleNotifyId: number | null;
1082
+ /** Fires every resize consumer: DOM event, ResizeObserver, `onResize`, rAF re-arm. */
1083
+ _notifyResize(): void;
1084
+ /**
1085
+ * Fractional scale only: GTK binds a viewport of the whole framebuffer
1086
+ * (`alloc × ceil(scale)`), but the drawing buffer is the smaller
1087
+ * `round(alloc × scale)` region in its bottom-left corner. Start each frame with
1088
+ * the viewport a fresh browser canvas has.
1089
+ */
1090
+ _fitViewportToDeviceSize(gl: OurWebGLRenderingContext | null): void;
1091
+ /**
1092
+ * Presents the real-size region 1:1. GtkGLArea draws its whole framebuffer
1093
+ * (`alloc × ceil(scale)` texels) into the logical allocation, i.e. one texel per
1094
+ * `1/ceil(scale)` logical px; the content sits in the bottom-left of the widget
1095
+ * (GL origin). Scaling the parent draw by `ceil/scale` from the
1096
+ * widget origin makes one texel exactly one device pixel; the clip drops the
1097
+ * unused remainder. Integer scales take the untouched parent path.
1098
+ */
1099
+ vfunc_snapshot(snapshot: Gtk.Snapshot): void;
1041
1100
  /** The HTMLCanvasElement wrapping this GLArea. Available after the first render. */
1042
1101
  get canvas(): globalThis.HTMLCanvasElement | null;
1043
1102
  /**
@@ -1315,7 +1374,6 @@ export declare const WebGLBridge: {
1315
1374
  vfunc_set_focus_child(child: Gtk.Widget | null): void;
1316
1375
  vfunc_show(): void;
1317
1376
  vfunc_size_allocate(width: number, height: number, baseline: number): void;
1318
- vfunc_snapshot(snapshot: Gtk.Snapshot): void;
1319
1377
  vfunc_state_flags_changed(previous_state_flags: Gtk.StateFlags): void;
1320
1378
  vfunc_system_setting_changed(settings: Gtk.SystemSetting): void;
1321
1379
  vfunc_unmap(): void;
@@ -1331,10 +1389,10 @@ export declare const WebGLBridge: {
1331
1389
  add_tick_callback(callback: Gtk.TickCallback): number;
1332
1390
  allocate(width: number, height: number, baseline: number, transform: import("@girs/gsk-4.0").default.Transform | null): void;
1333
1391
  child_focus(direction: Gtk.DirectionType): boolean;
1334
- compute_bounds(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Rect];
1392
+ compute_bounds(target: Gtk.Widget): [boolean, Graphene.Rect];
1335
1393
  compute_expand(orientation: Gtk.Orientation): boolean;
1336
- compute_point(target: Gtk.Widget, point: import("@girs/graphene-1.0").default.Point): [boolean, import("@girs/graphene-1.0").default.Point];
1337
- compute_transform(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Matrix];
1394
+ compute_point(target: Gtk.Widget, point: Graphene.Point): [boolean, Graphene.Point];
1395
+ compute_transform(target: Gtk.Widget): [boolean, Graphene.Matrix];
1338
1396
  contains(x: number, y: number): boolean;
1339
1397
  create_pango_context(): import("@girs/pango-1.0").default.Context;
1340
1398
  create_pango_layout(text: string | null): import("@girs/pango-1.0").default.Layout;
@@ -1539,6 +1597,26 @@ export declare const WebGLBridge: {
1539
1597
  vendor: string;
1540
1598
  renderer: string;
1541
1599
  } | null;
1600
+ _scaleSurface: Gdk.Surface | null;
1601
+ _scaleNotifyId: number | null;
1602
+ /** Fires every resize consumer: DOM event, ResizeObserver, `onResize`, rAF re-arm. */
1603
+ _notifyResize(): void;
1604
+ /**
1605
+ * Fractional scale only: GTK binds a viewport of the whole framebuffer
1606
+ * (`alloc × ceil(scale)`), but the drawing buffer is the smaller
1607
+ * `round(alloc × scale)` region in its bottom-left corner. Start each frame with
1608
+ * the viewport a fresh browser canvas has.
1609
+ */
1610
+ _fitViewportToDeviceSize(gl: OurWebGLRenderingContext | null): void;
1611
+ /**
1612
+ * Presents the real-size region 1:1. GtkGLArea draws its whole framebuffer
1613
+ * (`alloc × ceil(scale)` texels) into the logical allocation, i.e. one texel per
1614
+ * `1/ceil(scale)` logical px; the content sits in the bottom-left of the widget
1615
+ * (GL origin). Scaling the parent draw by `ceil/scale` from the
1616
+ * widget origin makes one texel exactly one device pixel; the clip drops the
1617
+ * unused remainder. Integer scales take the untouched parent path.
1618
+ */
1619
+ vfunc_snapshot(snapshot: Gtk.Snapshot): void;
1542
1620
  /** The HTMLCanvasElement wrapping this GLArea. Available after the first render. */
1543
1621
  get canvas(): globalThis.HTMLCanvasElement | null;
1544
1622
  /**
@@ -1816,7 +1894,6 @@ export declare const WebGLBridge: {
1816
1894
  vfunc_set_focus_child(child: Gtk.Widget | null): void;
1817
1895
  vfunc_show(): void;
1818
1896
  vfunc_size_allocate(width: number, height: number, baseline: number): void;
1819
- vfunc_snapshot(snapshot: Gtk.Snapshot): void;
1820
1897
  vfunc_state_flags_changed(previous_state_flags: Gtk.StateFlags): void;
1821
1898
  vfunc_system_setting_changed(settings: Gtk.SystemSetting): void;
1822
1899
  vfunc_unmap(): void;
@@ -1832,10 +1909,10 @@ export declare const WebGLBridge: {
1832
1909
  add_tick_callback(callback: Gtk.TickCallback): number;
1833
1910
  allocate(width: number, height: number, baseline: number, transform: import("@girs/gsk-4.0").default.Transform | null): void;
1834
1911
  child_focus(direction: Gtk.DirectionType): boolean;
1835
- compute_bounds(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Rect];
1912
+ compute_bounds(target: Gtk.Widget): [boolean, Graphene.Rect];
1836
1913
  compute_expand(orientation: Gtk.Orientation): boolean;
1837
- compute_point(target: Gtk.Widget, point: import("@girs/graphene-1.0").default.Point): [boolean, import("@girs/graphene-1.0").default.Point];
1838
- compute_transform(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Matrix];
1914
+ compute_point(target: Gtk.Widget, point: Graphene.Point): [boolean, Graphene.Point];
1915
+ compute_transform(target: Gtk.Widget): [boolean, Graphene.Matrix];
1839
1916
  contains(x: number, y: number): boolean;
1840
1917
  create_pango_context(): import("@girs/pango-1.0").default.Context;
1841
1918
  create_pango_layout(text: string | null): import("@girs/pango-1.0").default.Layout;
@@ -2040,6 +2117,26 @@ export declare const WebGLBridge: {
2040
2117
  vendor: string;
2041
2118
  renderer: string;
2042
2119
  } | null;
2120
+ _scaleSurface: Gdk.Surface | null;
2121
+ _scaleNotifyId: number | null;
2122
+ /** Fires every resize consumer: DOM event, ResizeObserver, `onResize`, rAF re-arm. */
2123
+ _notifyResize(): void;
2124
+ /**
2125
+ * Fractional scale only: GTK binds a viewport of the whole framebuffer
2126
+ * (`alloc × ceil(scale)`), but the drawing buffer is the smaller
2127
+ * `round(alloc × scale)` region in its bottom-left corner. Start each frame with
2128
+ * the viewport a fresh browser canvas has.
2129
+ */
2130
+ _fitViewportToDeviceSize(gl: OurWebGLRenderingContext | null): void;
2131
+ /**
2132
+ * Presents the real-size region 1:1. GtkGLArea draws its whole framebuffer
2133
+ * (`alloc × ceil(scale)` texels) into the logical allocation, i.e. one texel per
2134
+ * `1/ceil(scale)` logical px; the content sits in the bottom-left of the widget
2135
+ * (GL origin). Scaling the parent draw by `ceil/scale` from the
2136
+ * widget origin makes one texel exactly one device pixel; the clip drops the
2137
+ * unused remainder. Integer scales take the untouched parent path.
2138
+ */
2139
+ vfunc_snapshot(snapshot: Gtk.Snapshot): void;
2043
2140
  /** The HTMLCanvasElement wrapping this GLArea. Available after the first render. */
2044
2141
  get canvas(): globalThis.HTMLCanvasElement | null;
2045
2142
  /**
@@ -2317,7 +2414,6 @@ export declare const WebGLBridge: {
2317
2414
  vfunc_set_focus_child(child: Gtk.Widget | null): void;
2318
2415
  vfunc_show(): void;
2319
2416
  vfunc_size_allocate(width: number, height: number, baseline: number): void;
2320
- vfunc_snapshot(snapshot: Gtk.Snapshot): void;
2321
2417
  vfunc_state_flags_changed(previous_state_flags: Gtk.StateFlags): void;
2322
2418
  vfunc_system_setting_changed(settings: Gtk.SystemSetting): void;
2323
2419
  vfunc_unmap(): void;
@@ -2333,10 +2429,10 @@ export declare const WebGLBridge: {
2333
2429
  add_tick_callback(callback: Gtk.TickCallback): number;
2334
2430
  allocate(width: number, height: number, baseline: number, transform: import("@girs/gsk-4.0").default.Transform | null): void;
2335
2431
  child_focus(direction: Gtk.DirectionType): boolean;
2336
- compute_bounds(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Rect];
2432
+ compute_bounds(target: Gtk.Widget): [boolean, Graphene.Rect];
2337
2433
  compute_expand(orientation: Gtk.Orientation): boolean;
2338
- compute_point(target: Gtk.Widget, point: import("@girs/graphene-1.0").default.Point): [boolean, import("@girs/graphene-1.0").default.Point];
2339
- compute_transform(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Matrix];
2434
+ compute_point(target: Gtk.Widget, point: Graphene.Point): [boolean, Graphene.Point];
2435
+ compute_transform(target: Gtk.Widget): [boolean, Graphene.Matrix];
2340
2436
  contains(x: number, y: number): boolean;
2341
2437
  create_pango_context(): import("@girs/pango-1.0").default.Context;
2342
2438
  create_pango_layout(text: string | null): import("@girs/pango-1.0").default.Layout;
@@ -2541,6 +2637,26 @@ export declare const WebGLBridge: {
2541
2637
  vendor: string;
2542
2638
  renderer: string;
2543
2639
  } | null;
2640
+ _scaleSurface: Gdk.Surface | null;
2641
+ _scaleNotifyId: number | null;
2642
+ /** Fires every resize consumer: DOM event, ResizeObserver, `onResize`, rAF re-arm. */
2643
+ _notifyResize(): void;
2644
+ /**
2645
+ * Fractional scale only: GTK binds a viewport of the whole framebuffer
2646
+ * (`alloc × ceil(scale)`), but the drawing buffer is the smaller
2647
+ * `round(alloc × scale)` region in its bottom-left corner. Start each frame with
2648
+ * the viewport a fresh browser canvas has.
2649
+ */
2650
+ _fitViewportToDeviceSize(gl: OurWebGLRenderingContext | null): void;
2651
+ /**
2652
+ * Presents the real-size region 1:1. GtkGLArea draws its whole framebuffer
2653
+ * (`alloc × ceil(scale)` texels) into the logical allocation, i.e. one texel per
2654
+ * `1/ceil(scale)` logical px; the content sits in the bottom-left of the widget
2655
+ * (GL origin). Scaling the parent draw by `ceil/scale` from the
2656
+ * widget origin makes one texel exactly one device pixel; the clip drops the
2657
+ * unused remainder. Integer scales take the untouched parent path.
2658
+ */
2659
+ vfunc_snapshot(snapshot: Gtk.Snapshot): void;
2544
2660
  /** The HTMLCanvasElement wrapping this GLArea. Available after the first render. */
2545
2661
  get canvas(): globalThis.HTMLCanvasElement | null;
2546
2662
  /**
@@ -2818,7 +2934,6 @@ export declare const WebGLBridge: {
2818
2934
  vfunc_set_focus_child(child: Gtk.Widget | null): void;
2819
2935
  vfunc_show(): void;
2820
2936
  vfunc_size_allocate(width: number, height: number, baseline: number): void;
2821
- vfunc_snapshot(snapshot: Gtk.Snapshot): void;
2822
2937
  vfunc_state_flags_changed(previous_state_flags: Gtk.StateFlags): void;
2823
2938
  vfunc_system_setting_changed(settings: Gtk.SystemSetting): void;
2824
2939
  vfunc_unmap(): void;
@@ -2834,10 +2949,10 @@ export declare const WebGLBridge: {
2834
2949
  add_tick_callback(callback: Gtk.TickCallback): number;
2835
2950
  allocate(width: number, height: number, baseline: number, transform: import("@girs/gsk-4.0").default.Transform | null): void;
2836
2951
  child_focus(direction: Gtk.DirectionType): boolean;
2837
- compute_bounds(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Rect];
2952
+ compute_bounds(target: Gtk.Widget): [boolean, Graphene.Rect];
2838
2953
  compute_expand(orientation: Gtk.Orientation): boolean;
2839
- compute_point(target: Gtk.Widget, point: import("@girs/graphene-1.0").default.Point): [boolean, import("@girs/graphene-1.0").default.Point];
2840
- compute_transform(target: Gtk.Widget): [boolean, import("@girs/graphene-1.0").default.Matrix];
2954
+ compute_point(target: Gtk.Widget, point: Graphene.Point): [boolean, Graphene.Point];
2955
+ compute_transform(target: Gtk.Widget): [boolean, Graphene.Matrix];
2841
2956
  contains(x: number, y: number): boolean;
2842
2957
  create_pango_context(): import("@girs/pango-1.0").default.Context;
2843
2958
  create_pango_layout(text: string | null): import("@girs/pango-1.0").default.Layout;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/webgl",
3
- "version": "0.64.53",
3
+ "version": "0.64.54",
4
4
  "description": "WebGL module for Gjs",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -64,8 +64,8 @@
64
64
  "WebGL"
65
65
  ],
66
66
  "devDependencies": {
67
- "@gjsify/cli": "0.64.53",
68
- "@gjsify/unit": "0.64.53",
67
+ "@gjsify/cli": "0.64.54",
68
+ "@gjsify/unit": "0.64.54",
69
69
  "@types/bit-twiddle": "^1.0.3",
70
70
  "@types/node": "^25.9.2",
71
71
  "typescript": "^6.0.3"
@@ -75,10 +75,10 @@
75
75
  "@girs/gjs": "5.4.0",
76
76
  "@girs/gtk-4.0": "5.4.0",
77
77
  "@girs/gwebgl-0.1": "0.1.0-4.0.0-rc.5",
78
- "@gjsify/dom-elements": "0.64.53",
79
- "@gjsify/dom-events": "0.64.53",
80
- "@gjsify/event-bridge": "0.64.53",
81
- "@gjsify/utils": "0.64.53",
78
+ "@gjsify/dom-elements": "0.64.54",
79
+ "@gjsify/dom-events": "0.64.54",
80
+ "@gjsify/event-bridge": "0.64.54",
81
+ "@gjsify/utils": "0.64.54",
82
82
  "bit-twiddle": "^1.0.2",
83
83
  "glsl-tokenizer": "^2.1.5"
84
84
  },
@@ -93,13 +93,13 @@
93
93
  },
94
94
  "homepage": "https://github.com/gjsify/gjsify/tree/main/packages/framework/webgl#readme",
95
95
  "optionalDependencies": {
96
- "@gjsify/webgl-darwin-arm64": "0.64.53",
97
- "@gjsify/webgl-darwin-x64": "0.64.53",
98
- "@gjsify/webgl-linux-arm64": "0.64.53",
99
- "@gjsify/webgl-linux-ppc64": "0.64.53",
100
- "@gjsify/webgl-linux-riscv64": "0.64.53",
101
- "@gjsify/webgl-linux-s390x": "0.64.53",
102
- "@gjsify/webgl-linux-x64": "0.64.53",
103
- "@gjsify/webgl-win32-x64": "0.64.53"
96
+ "@gjsify/webgl-darwin-arm64": "0.64.54",
97
+ "@gjsify/webgl-darwin-x64": "0.64.54",
98
+ "@gjsify/webgl-linux-arm64": "0.64.54",
99
+ "@gjsify/webgl-linux-ppc64": "0.64.54",
100
+ "@gjsify/webgl-linux-riscv64": "0.64.54",
101
+ "@gjsify/webgl-linux-s390x": "0.64.54",
102
+ "@gjsify/webgl-linux-x64": "0.64.54",
103
+ "@gjsify/webgl-win32-x64": "0.64.54"
104
104
  }
105
105
  }