@luma.gl/core 9.2.0-alpha.5 → 9.2.0-alpha.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/core",
3
- "version": "9.2.0-alpha.5",
3
+ "version": "9.2.0-alpha.6",
4
4
  "description": "The luma.gl core Device API",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -46,5 +46,5 @@
46
46
  "@probe.gl/stats": "^4.0.8",
47
47
  "@types/offscreencanvas": "^2019.6.4"
48
48
  },
49
- "gitHead": "bf8346ab62619ec2c3e0b6dd54be3142328c6377"
49
+ "gitHead": "63fe3fd0912c83f7c4a012016c57048a250b591f"
50
50
  }
@@ -35,6 +35,11 @@ export type CanvasContextProps = {
35
35
  trackPosition?: boolean;
36
36
  };
37
37
 
38
+ export type MutableCanvasContextProps = {
39
+ /** Whether to size the drawing buffer to the pixel size during auto resize. If a number is provided it is used as a static pixel ratio */
40
+ useDevicePixels?: boolean | number;
41
+ };
42
+
38
43
  /**
39
44
  * Manages a canvas. Supports both HTML or offscreen canvas
40
45
  * - Creates a new canvas or looks up a canvas from the DOM
@@ -186,6 +191,14 @@ export abstract class CanvasContext {
186
191
  this.destroyed = true;
187
192
  }
188
193
 
194
+ setProps(props: MutableCanvasContextProps): this {
195
+ if ('useDevicePixels' in props) {
196
+ this.props.useDevicePixels = props.useDevicePixels || false;
197
+ this._updateDrawingBufferSize();
198
+ }
199
+ return this;
200
+ }
201
+
189
202
  /** Returns a framebuffer with properly resized current 'swap chain' textures */
190
203
  abstract getCurrentFramebuffer(options?: {
191
204
  depthStencilFormat?: TextureFormatDepthStencil | false;
@@ -360,6 +373,13 @@ export abstract class CanvasContext {
360
373
  this.devicePixelWidth = Math.max(1, Math.min(devicePixelWidth, maxDevicePixelWidth));
361
374
  this.devicePixelHeight = Math.max(1, Math.min(devicePixelHeight, maxDevicePixelHeight));
362
375
 
376
+ this._updateDrawingBufferSize();
377
+
378
+ // Inform the device
379
+ this.device.props.onResize(this, {oldPixelSize});
380
+ }
381
+
382
+ protected _updateDrawingBufferSize() {
363
383
  // Update the canvas drawing buffer size
364
384
  if (this.props.autoResize) {
365
385
  if (typeof this.props.useDevicePixels === 'number') {
@@ -380,9 +400,6 @@ export abstract class CanvasContext {
380
400
  this.isInitialized = true;
381
401
 
382
402
  this.updatePosition();
383
-
384
- // Inform the device
385
- this.device.props.onResize(this, {oldPixelSize});
386
403
  }
387
404
 
388
405
  /** Monitor DPR changes */