@gjsify/webgl 0.64.55 → 0.64.56
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.
|
@@ -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";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
|
+
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}function snapToDevicePixel(e,t){if(!(t>0))return 0;let n=e*t;return(Math.round(n)-n)/t}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,snapToDevicePixel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__name as e}from"./_virtual/_rolldown/runtime.js";import{HTMLCanvasElement as t}from"./html-canvas-element.js";import{describe as
|
|
1
|
+
import{__name as e}from"./_virtual/_rolldown/runtime.js";import{HTMLCanvasElement as t,snapToDevicePixel as n}from"./html-canvas-element.js";import{describe as r,expect as i,it as a}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 o=e(async()=>{await r(`snapToDevicePixel`,async()=>{let landed=(e,t)=>(e+n(e,t))*t;await a(`leaves a device-aligned edge alone`,async()=>{i(n(0,1.25)).toBe(0),i(n(4,1.25)).toBe(0),i(n(42,1)).toBe(0),i(n(21,2)).toBe(0)}),await a(`lands every fractional edge on a whole device pixel`,async()=>{for(let e of[1.25,1.5,1.75,2.5])for(let t=0;t<200;t++){let n=landed(t,e);i(Math.abs(n-Math.round(n))<1e-9).toBe(!0)}}),await a(`moves by less than half a device pixel`,async()=>{for(let e=0;e<200;e++)i(Math.abs(n(e,1.25))*1.25<=.500000001).toBe(!0)}),await a(`ignores a missing scale`,async()=>{i(n(7,0)).toBe(0)})}),await r(`HTMLCanvasElement (GLArea) — cloneNode`,async()=>{await a(`clones to a plain canvas instead of throwing`,async()=>{let e=new t(stubGlArea(640,480,1)).cloneNode(!1);i(e.width).toBe(640),i(e.height).toBe(480)}),await a(`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,i(e.width).toBe(800),i(e.height).toBe(600)}),await a(`leaves the original bound to its widget`,async()=>{let e=new t(stubGlArea(640,480,2));e.cloneNode(!1),i(e.width).toBe(1280)})}),await r(`HTMLCanvasElement (GLArea) — drawing buffer vs CSS size`,async()=>{await a(`reports the drawing buffer in DEVICE pixels on a HiDPI surface`,async()=>{let e=new t(stubGlArea(360,655,3));i(e.width).toBe(1080),i(e.height).toBe(1965)}),await a(`keeps the CSS layout size LOGICAL on the same surface`,async()=>{let e=new t(stubGlArea(360,655,3));i(e.clientWidth).toBe(360),i(e.clientHeight).toBe(655),i(e.offsetWidth).toBe(360),i(e.offsetHeight).toBe(655)}),await a(`CSS size × devicePixelRatio equals the drawing buffer`,async()=>{let e=new t(stubGlArea(800,600,2));i(e.clientWidth*e.scaleFactor).toBe(e.width),i(e.clientHeight*e.scaleFactor).toBe(e.height)}),await a(`is a no-op change at scale-factor 1 (every pre-HiDPI host)`,async()=>{let e=new t(stubGlArea(1024,768,1));i(e.width).toBe(1024),i(e.height).toBe(768),i(e.clientWidth).toBe(1024),i(e.clientHeight).toBe(768)}),await a(`treats an unrealized widget (scale 0) as scale 1, not as a 0×0 buffer`,async()=>{let e=new t(stubGlArea(640,480,0));i(e.scaleFactor).toBe(1),i(e.width).toBe(640),i(e.height).toBe(480)}),await a(`ignores width/height writes — GTK owns the allocation`,async()=>{let e=new t(stubGlArea(360,655,3));e.width=42,e.height=42,i(e.width).toBe(1080),i(e.height).toBe(1965)})}),await r(`HTMLCanvasElement (GLArea) — fractional scale`,async()=>{await a(`reports the REAL device size at 125 %`,async()=>{let e=new t(stubGlArea(400,300,2,1.25));i(e.scaleFactor).toBe(1.25),i(e.width).toBe(500),i(e.height).toBe(375)}),await a(`reports the REAL device size at 150 %`,async()=>{let e=new t(stubGlArea(400,300,2,1.5));i(e.width).toBe(600),i(e.height).toBe(450)}),await a(`rounds a non-integer device size to whole pixels`,async()=>{let e=new t(stubGlArea(401,301,2,1.25));i(e.width).toBe(501),i(e.height).toBe(376)}),await a(`never exceeds the ceil-sized GTK framebuffer`,async()=>{let e=new t(stubGlArea(333,777,2,1.25));i(e.width).toBeLessThan(667),i(e.height).toBeLessThan(1555)}),await a(`falls back to the integer factor when no surface scale exists`,async()=>{let e=new t(stubGlArea(400,300,2));i(e.scaleFactor).toBe(2),i(e.width).toBe(800)}),await a(`integer surface scale is unchanged`,async()=>{i(new t(stubGlArea(400,300,2,2)).width).toBe(800)})})},`default`);export{o 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,deviceScale as Y}from"./html-canvas-element.js";import{isSoftwareRenderer as
|
|
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,snapToDevicePixel as X}from"./html-canvas-element.js";import{isSoftwareRenderer as Z}from"./software-renderer.js";import{WebGLBridge as Q}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,Q 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,Z as isSoftwareRenderer,X as snapToDevicePixel};
|
package/lib/esm/webgl-bridge.js
CHANGED
|
@@ -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,deviceScale as r}from"./html-canvas-element.js";import{isSoftwareRenderer as
|
|
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,snapToDevicePixel as i}from"./html-canvas-element.js";import{isSoftwareRenderer as a}from"./software-renderer.js";import{notifyElementResize as o}from"@gjsify/dom-elements";import s from"gi://GObject?version=2.0";import c from"gi://Gdk?version=4.0";import l from"gi://GLib?version=2.0";import u from"gi://Gtk?version=4.0";import d from"gi://Graphene?version=1.0";import{attachEventControllers as f}from"@gjsify/event-bridge";import{Event as p}from"@gjsify/dom-events";const m=s.registerClass({GTypeName:`GjsifyWebGLBridge`},class WebGLBridge extends u.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=l.get_monotonic_time(),this._rendererInfo=null,this._scaleSurface=null,this._scaleNotifyId=null,this.set_allowed_apis(c.GLAPI.GL|c.GLAPI.GLES),this.set_required_version(3,2),this.set_has_depth_buffer(!0),this.set_has_stencil_buffer(!0),f(this,()=>this._canvas,{captureKeys:!0}),this._tickCallbackId=this.add_tick_callback((e,t)=>(this._frameCallback!==null&&this.queue_render(),l.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=(l.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 p(`resize`)),o(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)}_deviceGridShift(e,t){let n=this.get_native();if(!n)return[0,0];let[r,a]=this.compute_point(n,new d.Point().init(0,e));if(!r)return[0,0];let[o,s]=n.get_surface_transform();return[i(a.x+o,t),i(a.y+s,t)]}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 d.Rect().init(0,0,this.get_width(),this.get_height()));let a=this.get_height(),[o,s]=this._deviceGridShift(a,t);e.translate(new d.Point().init(o,s)),e.translate(new d.Point().init(0,a)),e.scale(i,i),e.translate(new d.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},a(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:()=>(l.get_monotonic_time()-i)/1e3,timeOrigin:Date.now()}}});export{m as WebGLBridge};
|
|
@@ -10,6 +10,17 @@ import { WebGL2RenderingContext as OurWebGL2RenderingContext } from './webgl2-re
|
|
|
10
10
|
* at 125 % it is 2 while the display shows 1.25. `0` / missing means no surface yet.
|
|
11
11
|
*/
|
|
12
12
|
export declare function deviceScale(widget: Gtk.Widget): number;
|
|
13
|
+
/**
|
|
14
|
+
* Logical shift that lands a device-space coordinate on a whole device pixel.
|
|
15
|
+
*
|
|
16
|
+
* `position` is where an edge sits in the surface in LOGICAL px. A widget's logical
|
|
17
|
+
* origin is an integer, but its device origin is `origin × scale`, which is fractional at
|
|
18
|
+
* 125 % and 150 % (a 3 px margin is 4.5 device px at 1.5). GSK draws the GL texture at
|
|
19
|
+
* that fractional spot with a linear filter, so every texel edge is blended with its
|
|
20
|
+
* neighbour: a 1-texel checkerboard comes out grey, and pixel art loses its edges.
|
|
21
|
+
* Shifting the draw by this amount puts the texel grid back on the device grid.
|
|
22
|
+
*/
|
|
23
|
+
export declare function snapToDevicePixel(position: number, scale: number): number;
|
|
13
24
|
export declare class HTMLCanvasElement extends BaseHTMLCanvasElement {
|
|
14
25
|
readonly gtkGlArea: Gtk.GLArea;
|
|
15
26
|
_webgl?: OurWebGLRenderingContext;
|
|
@@ -48,6 +48,12 @@ export declare const WebGLBridge: {
|
|
|
48
48
|
* the viewport a fresh browser canvas has.
|
|
49
49
|
*/
|
|
50
50
|
_fitViewportToDeviceSize(gl: OurWebGLRenderingContext | null): void;
|
|
51
|
+
/**
|
|
52
|
+
* Shift, in widget coordinates, that puts the widget's bottom-left corner on a
|
|
53
|
+
* whole device pixel of its surface. `[0, 0]` where the position cannot be
|
|
54
|
+
* known (not rooted, or a transformed ancestor).
|
|
55
|
+
*/
|
|
56
|
+
_deviceGridShift(height: number, scale: number): [number, number];
|
|
51
57
|
/**
|
|
52
58
|
* Presents the real-size region 1:1. GtkGLArea draws its whole framebuffer
|
|
53
59
|
* (`alloc × ceil(scale)` texels) into the logical allocation, i.e. one texel per
|
|
@@ -568,6 +574,12 @@ export declare const WebGLBridge: {
|
|
|
568
574
|
* the viewport a fresh browser canvas has.
|
|
569
575
|
*/
|
|
570
576
|
_fitViewportToDeviceSize(gl: OurWebGLRenderingContext | null): void;
|
|
577
|
+
/**
|
|
578
|
+
* Shift, in widget coordinates, that puts the widget's bottom-left corner on a
|
|
579
|
+
* whole device pixel of its surface. `[0, 0]` where the position cannot be
|
|
580
|
+
* known (not rooted, or a transformed ancestor).
|
|
581
|
+
*/
|
|
582
|
+
_deviceGridShift(height: number, scale: number): [number, number];
|
|
571
583
|
/**
|
|
572
584
|
* Presents the real-size region 1:1. GtkGLArea draws its whole framebuffer
|
|
573
585
|
* (`alloc × ceil(scale)` texels) into the logical allocation, i.e. one texel per
|
|
@@ -1088,6 +1100,12 @@ export declare const WebGLBridge: {
|
|
|
1088
1100
|
* the viewport a fresh browser canvas has.
|
|
1089
1101
|
*/
|
|
1090
1102
|
_fitViewportToDeviceSize(gl: OurWebGLRenderingContext | null): void;
|
|
1103
|
+
/**
|
|
1104
|
+
* Shift, in widget coordinates, that puts the widget's bottom-left corner on a
|
|
1105
|
+
* whole device pixel of its surface. `[0, 0]` where the position cannot be
|
|
1106
|
+
* known (not rooted, or a transformed ancestor).
|
|
1107
|
+
*/
|
|
1108
|
+
_deviceGridShift(height: number, scale: number): [number, number];
|
|
1091
1109
|
/**
|
|
1092
1110
|
* Presents the real-size region 1:1. GtkGLArea draws its whole framebuffer
|
|
1093
1111
|
* (`alloc × ceil(scale)` texels) into the logical allocation, i.e. one texel per
|
|
@@ -1608,6 +1626,12 @@ export declare const WebGLBridge: {
|
|
|
1608
1626
|
* the viewport a fresh browser canvas has.
|
|
1609
1627
|
*/
|
|
1610
1628
|
_fitViewportToDeviceSize(gl: OurWebGLRenderingContext | null): void;
|
|
1629
|
+
/**
|
|
1630
|
+
* Shift, in widget coordinates, that puts the widget's bottom-left corner on a
|
|
1631
|
+
* whole device pixel of its surface. `[0, 0]` where the position cannot be
|
|
1632
|
+
* known (not rooted, or a transformed ancestor).
|
|
1633
|
+
*/
|
|
1634
|
+
_deviceGridShift(height: number, scale: number): [number, number];
|
|
1611
1635
|
/**
|
|
1612
1636
|
* Presents the real-size region 1:1. GtkGLArea draws its whole framebuffer
|
|
1613
1637
|
* (`alloc × ceil(scale)` texels) into the logical allocation, i.e. one texel per
|
|
@@ -2128,6 +2152,12 @@ export declare const WebGLBridge: {
|
|
|
2128
2152
|
* the viewport a fresh browser canvas has.
|
|
2129
2153
|
*/
|
|
2130
2154
|
_fitViewportToDeviceSize(gl: OurWebGLRenderingContext | null): void;
|
|
2155
|
+
/**
|
|
2156
|
+
* Shift, in widget coordinates, that puts the widget's bottom-left corner on a
|
|
2157
|
+
* whole device pixel of its surface. `[0, 0]` where the position cannot be
|
|
2158
|
+
* known (not rooted, or a transformed ancestor).
|
|
2159
|
+
*/
|
|
2160
|
+
_deviceGridShift(height: number, scale: number): [number, number];
|
|
2131
2161
|
/**
|
|
2132
2162
|
* Presents the real-size region 1:1. GtkGLArea draws its whole framebuffer
|
|
2133
2163
|
* (`alloc × ceil(scale)` texels) into the logical allocation, i.e. one texel per
|
|
@@ -2648,6 +2678,12 @@ export declare const WebGLBridge: {
|
|
|
2648
2678
|
* the viewport a fresh browser canvas has.
|
|
2649
2679
|
*/
|
|
2650
2680
|
_fitViewportToDeviceSize(gl: OurWebGLRenderingContext | null): void;
|
|
2681
|
+
/**
|
|
2682
|
+
* Shift, in widget coordinates, that puts the widget's bottom-left corner on a
|
|
2683
|
+
* whole device pixel of its surface. `[0, 0]` where the position cannot be
|
|
2684
|
+
* known (not rooted, or a transformed ancestor).
|
|
2685
|
+
*/
|
|
2686
|
+
_deviceGridShift(height: number, scale: number): [number, number];
|
|
2651
2687
|
/**
|
|
2652
2688
|
* Presents the real-size region 1:1. GtkGLArea draws its whole framebuffer
|
|
2653
2689
|
* (`alloc × ceil(scale)` texels) into the logical allocation, i.e. one texel per
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/webgl",
|
|
3
|
-
"version": "0.64.
|
|
3
|
+
"version": "0.64.56",
|
|
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.
|
|
68
|
-
"@gjsify/unit": "0.64.
|
|
67
|
+
"@gjsify/cli": "0.64.56",
|
|
68
|
+
"@gjsify/unit": "0.64.56",
|
|
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.
|
|
79
|
-
"@gjsify/dom-events": "0.64.
|
|
80
|
-
"@gjsify/event-bridge": "0.64.
|
|
81
|
-
"@gjsify/utils": "0.64.
|
|
78
|
+
"@gjsify/dom-elements": "0.64.56",
|
|
79
|
+
"@gjsify/dom-events": "0.64.56",
|
|
80
|
+
"@gjsify/event-bridge": "0.64.56",
|
|
81
|
+
"@gjsify/utils": "0.64.56",
|
|
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.
|
|
97
|
-
"@gjsify/webgl-darwin-x64": "0.64.
|
|
98
|
-
"@gjsify/webgl-linux-arm64": "0.64.
|
|
99
|
-
"@gjsify/webgl-linux-ppc64": "0.64.
|
|
100
|
-
"@gjsify/webgl-linux-riscv64": "0.64.
|
|
101
|
-
"@gjsify/webgl-linux-s390x": "0.64.
|
|
102
|
-
"@gjsify/webgl-linux-x64": "0.64.
|
|
103
|
-
"@gjsify/webgl-win32-x64": "0.64.
|
|
96
|
+
"@gjsify/webgl-darwin-arm64": "0.64.56",
|
|
97
|
+
"@gjsify/webgl-darwin-x64": "0.64.56",
|
|
98
|
+
"@gjsify/webgl-linux-arm64": "0.64.56",
|
|
99
|
+
"@gjsify/webgl-linux-ppc64": "0.64.56",
|
|
100
|
+
"@gjsify/webgl-linux-riscv64": "0.64.56",
|
|
101
|
+
"@gjsify/webgl-linux-s390x": "0.64.56",
|
|
102
|
+
"@gjsify/webgl-linux-x64": "0.64.56",
|
|
103
|
+
"@gjsify/webgl-win32-x64": "0.64.56"
|
|
104
104
|
}
|
|
105
105
|
}
|