Skip to content

Commit

Permalink
[GLJS-1141] Rasterize on the fly background pattern vector icons (int…
Browse files Browse the repository at this point in the history
…ernal-2081)
  • Loading branch information
underoot authored and mourner committed Dec 23, 2024
1 parent bf77519 commit 749e8bb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/render/image_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Dispatcher from '../util/dispatcher';
import {getImageRasterizerWorkerPool} from '../util/worker_pool_factory';
import offscreenCanvasSupported from '../util/offscreen_canvas_supported';
import {ImageRasterizer} from './image_rasterizer';
import ResolvedImage from '../style-spec/expression/types/resolved_image';

import type {ImageIdWithOptions} from '../style-spec/expression/types/image_id_with_options';
import type {StyleImage} from '../style/style_image';
Expand Down Expand Up @@ -358,6 +359,9 @@ class ImageManager extends Evented {
}

if (!pattern) {
if (image.usvg && !image.data) {
image.data = this.imageRasterizer.rasterize(ResolvedImage.from(id).getPrimary(), image, scope, '');
}
const w = image.data.width + PATTERN_PADDING * 2;
const h = image.data.height + PATTERN_PADDING * 2;
const bin = {w, h, x: 0, y: 0};
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"metadata": {
"test": {
"width": 64,
"height": 64,
"spriteFormat": "icon_set"
}
},
"version": 8,
"sprite": "local://sprites/park",
"sources":{},
"layers": [
{
"id": "background",
"type": "background",
"paint": {
"background-pattern": "park"
}
}
]
}

0 comments on commit 749e8bb

Please sign in to comment.