• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visgl / deck.gl / 23854685480

01 Apr 2026 02:46PM UTC coverage: 80.387% (+0.02%) from 80.371%
23854685480

Pull #10158

github

web-flow
Merge 45a23d2d0 into 49744518e
Pull Request #10158: chore: Bump to luma@9.3.1 & loaders@4.4.1

3102 of 3747 branches covered (82.79%)

Branch coverage included in aggregate %.

14207 of 17785 relevant lines covered (79.88%)

26678.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.1
/modules/core/src/utils/texture.ts
1
// deck.gl
2
// SPDX-License-Identifier: MIT
3
// Copyright (c) vis.gl contributors
4

5
import {Device, Texture, SamplerProps} from '@luma.gl/core';
6

7
const DEFAULT_TEXTURE_PARAMETERS: SamplerProps = {
4✔
8
  minFilter: 'linear',
9
  mipmapFilter: 'linear',
10
  magFilter: 'linear',
11
  addressModeU: 'clamp-to-edge',
12
  addressModeV: 'clamp-to-edge'
13
};
14

15
// Track the textures that are created by us. They need to be released when they are no longer used.
16
const internalTextures: Record<string, string> = {};
4✔
17

18
/**
19
 *
20
 * @param owner
21
 * @param device
22
 * @param image could be one of:
23
 *   - Texture
24
 *   - Browser object: Image, ImageData, ImageData, HTMLCanvasElement, HTMLVideoElement, ImageBitmap
25
 *   - Plain object: {width: <number>, height: <number>, data: <Uint8Array>}
26
 * @param parameters
27
 * @returns
28
 */
29
export function createTexture(
30
  owner: string,
31
  device: Device,
32
  image: any,
33
  sampler: SamplerProps
34
): Texture | null {
35
  if (image instanceof Texture) {
59✔
36
    return image;
6✔
37
  } else if (image.constructor && image.constructor.name !== 'Object') {
53✔
38
    // Browser object
39
    image = {data: image};
36✔
40
  }
41

42
  let samplerParameters: SamplerProps | null = null;
53✔
43
  if (image.compressed) {
53✔
44
    samplerParameters = {
×
45
      minFilter: 'linear',
46
      mipmapFilter: image.data.length > 1 ? 'nearest' : 'linear'
47
    };
48
  }
49

50
  const {width, height} = image.data;
53✔
51
  const texture = device.createTexture({
53✔
52
    ...image,
53
    sampler: {
54
      ...DEFAULT_TEXTURE_PARAMETERS,
55
      ...samplerParameters,
56
      ...sampler
57
    },
58
    mipLevels: device.getMipLevelCount(width, height)
59
  });
60
  if (device.type === 'webgl') {
53✔
61
    texture.generateMipmapsWebGL();
52✔
62
  } else if (device.type === 'webgpu') {
1✔
63
    device.generateMipmapsWebGPU(texture);
×
64
  }
65

66
  // Track this texture
67
  internalTextures[texture.id] = owner;
53✔
68
  return texture;
53✔
69
}
70

71
export function destroyTexture(owner: string, texture: Texture) {
72
  if (!texture || !(texture instanceof Texture)) {
130✔
73
    return;
71✔
74
  }
75
  // Only delete the texture if requested by the same layer that created it
76
  if (internalTextures[texture.id] === owner) {
59✔
77
    texture.delete();
53✔
78
    delete internalTextures[texture.id];
53✔
79
  }
80
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc