@antv/g-webgpu 1.7.72 → 1.8.0-alpha.1
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 +31 -0
- package/dist/ContextRegisterPlugin.d.ts +9 -10
- package/dist/WebGPUContextService.d.ts +19 -20
- package/dist/index.d.ts +14 -12
- package/dist/index.esm.js +114 -476
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +132 -494
- package/dist/index.js.map +1 -0
- package/dist/index.umd.min.js +2 -1
- package/dist/index.umd.min.js.map +1 -0
- package/package.json +19 -14
- package/dist/ContextRegisterPlugin.d.ts.map +0 -1
- package/dist/WebGPUContextService.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.umd.js +0 -16290
package/dist/index.esm.js
CHANGED
|
@@ -1,502 +1,140 @@
|
|
|
1
|
+
import { __awaiter, __generator, __extends } from 'tslib';
|
|
1
2
|
import { setDOMSize, isBrowser, AbstractRendererPlugin, AbstractRenderer } from '@antv/g-lite';
|
|
2
|
-
import { Plugin } from '@antv/g-plugin-device-renderer';
|
|
3
3
|
import * as DeviceRenderer from '@antv/g-plugin-device-renderer';
|
|
4
4
|
export { DeviceRenderer };
|
|
5
|
-
import { Plugin as Plugin$3 } from '@antv/g-plugin-dom-interaction';
|
|
6
5
|
import * as DomInteraction from '@antv/g-plugin-dom-interaction';
|
|
7
6
|
export { DomInteraction };
|
|
8
|
-
import { Plugin as Plugin$4 } from '@antv/g-plugin-html-renderer';
|
|
9
7
|
import * as HTMLRenderer from '@antv/g-plugin-html-renderer';
|
|
10
8
|
export { HTMLRenderer };
|
|
11
|
-
import
|
|
12
|
-
import { Plugin as Plugin$2 } from '@antv/g-plugin-webgpu-device';
|
|
9
|
+
import * as ImageLoader from '@antv/g-plugin-image-loader';
|
|
13
10
|
import * as WebGPUDevice from '@antv/g-plugin-webgpu-device';
|
|
14
11
|
export { WebGPUDevice };
|
|
15
12
|
import { isString } from '@antv/util';
|
|
16
13
|
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Op = Object.prototype,
|
|
23
|
-
hasOwn = Op.hasOwnProperty,
|
|
24
|
-
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
25
|
-
obj[key] = desc.value;
|
|
26
|
-
},
|
|
27
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
28
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
29
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
30
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
31
|
-
function define(obj, key, value) {
|
|
32
|
-
return Object.defineProperty(obj, key, {
|
|
33
|
-
value: value,
|
|
34
|
-
enumerable: !0,
|
|
35
|
-
configurable: !0,
|
|
36
|
-
writable: !0
|
|
37
|
-
}), obj[key];
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
define({}, "");
|
|
41
|
-
} catch (err) {
|
|
42
|
-
define = function (obj, key, value) {
|
|
43
|
-
return obj[key] = value;
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
47
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
48
|
-
generator = Object.create(protoGenerator.prototype),
|
|
49
|
-
context = new Context(tryLocsList || []);
|
|
50
|
-
return defineProperty(generator, "_invoke", {
|
|
51
|
-
value: makeInvokeMethod(innerFn, self, context)
|
|
52
|
-
}), generator;
|
|
53
|
-
}
|
|
54
|
-
function tryCatch(fn, obj, arg) {
|
|
55
|
-
try {
|
|
56
|
-
return {
|
|
57
|
-
type: "normal",
|
|
58
|
-
arg: fn.call(obj, arg)
|
|
59
|
-
};
|
|
60
|
-
} catch (err) {
|
|
61
|
-
return {
|
|
62
|
-
type: "throw",
|
|
63
|
-
arg: err
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.wrap = wrap;
|
|
68
|
-
var ContinueSentinel = {};
|
|
69
|
-
function Generator() {}
|
|
70
|
-
function GeneratorFunction() {}
|
|
71
|
-
function GeneratorFunctionPrototype() {}
|
|
72
|
-
var IteratorPrototype = {};
|
|
73
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
74
|
-
return this;
|
|
75
|
-
});
|
|
76
|
-
var getProto = Object.getPrototypeOf,
|
|
77
|
-
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
78
|
-
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
79
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
80
|
-
function defineIteratorMethods(prototype) {
|
|
81
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
82
|
-
define(prototype, method, function (arg) {
|
|
83
|
-
return this._invoke(method, arg);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
88
|
-
function invoke(method, arg, resolve, reject) {
|
|
89
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
90
|
-
if ("throw" !== record.type) {
|
|
91
|
-
var result = record.arg,
|
|
92
|
-
value = result.value;
|
|
93
|
-
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
94
|
-
invoke("next", value, resolve, reject);
|
|
95
|
-
}, function (err) {
|
|
96
|
-
invoke("throw", err, resolve, reject);
|
|
97
|
-
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
98
|
-
result.value = unwrapped, resolve(result);
|
|
99
|
-
}, function (error) {
|
|
100
|
-
return invoke("throw", error, resolve, reject);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
reject(record.arg);
|
|
14
|
+
var WebGPUContextService = /** @class */ (function () {
|
|
15
|
+
function WebGPUContextService(context) {
|
|
16
|
+
this.canvasConfig = context.config;
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
this.deviceRendererPlugin = context.deviceRendererPlugin;
|
|
104
19
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
118
|
-
var state = "suspendedStart";
|
|
119
|
-
return function (method, arg) {
|
|
120
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
121
|
-
if ("completed" === state) {
|
|
122
|
-
if ("throw" === method) throw arg;
|
|
123
|
-
return doneResult();
|
|
124
|
-
}
|
|
125
|
-
for (context.method = method, context.arg = arg;;) {
|
|
126
|
-
var delegate = context.delegate;
|
|
127
|
-
if (delegate) {
|
|
128
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
129
|
-
if (delegateResult) {
|
|
130
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
131
|
-
return delegateResult;
|
|
132
|
-
}
|
|
20
|
+
WebGPUContextService.prototype.init = function () {
|
|
21
|
+
var _a = this.canvasConfig, container = _a.container, canvas = _a.canvas;
|
|
22
|
+
if (canvas) {
|
|
23
|
+
this.$canvas = canvas;
|
|
24
|
+
if (container &&
|
|
25
|
+
canvas.parentElement !== container) {
|
|
26
|
+
container.appendChild(canvas);
|
|
27
|
+
}
|
|
28
|
+
this.$container = canvas.parentElement;
|
|
29
|
+
this.canvasConfig.container = this.$container;
|
|
133
30
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
31
|
+
else if (container) {
|
|
32
|
+
// create container
|
|
33
|
+
this.$container = isString(container)
|
|
34
|
+
? document.getElementById(container)
|
|
35
|
+
: container;
|
|
36
|
+
if (this.$container) {
|
|
37
|
+
// create canvas
|
|
38
|
+
var $canvas = document.createElement('canvas');
|
|
39
|
+
this.$container.appendChild($canvas);
|
|
40
|
+
if (!this.$container.style.position) {
|
|
41
|
+
this.$container.style.position = 'relative';
|
|
42
|
+
}
|
|
43
|
+
this.$canvas = $canvas;
|
|
44
|
+
}
|
|
146
45
|
}
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
152
|
-
var methodName = context.method,
|
|
153
|
-
method = delegate.iterator[methodName];
|
|
154
|
-
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
155
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
156
|
-
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
157
|
-
var info = record.arg;
|
|
158
|
-
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
159
|
-
}
|
|
160
|
-
function pushTryEntry(locs) {
|
|
161
|
-
var entry = {
|
|
162
|
-
tryLoc: locs[0]
|
|
163
|
-
};
|
|
164
|
-
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
165
|
-
}
|
|
166
|
-
function resetTryEntry(entry) {
|
|
167
|
-
var record = entry.completion || {};
|
|
168
|
-
record.type = "normal", delete record.arg, entry.completion = record;
|
|
169
|
-
}
|
|
170
|
-
function Context(tryLocsList) {
|
|
171
|
-
this.tryEntries = [{
|
|
172
|
-
tryLoc: "root"
|
|
173
|
-
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
174
|
-
}
|
|
175
|
-
function values(iterable) {
|
|
176
|
-
if (iterable) {
|
|
177
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
178
|
-
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
179
|
-
if ("function" == typeof iterable.next) return iterable;
|
|
180
|
-
if (!isNaN(iterable.length)) {
|
|
181
|
-
var i = -1,
|
|
182
|
-
next = function next() {
|
|
183
|
-
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
184
|
-
return next.value = undefined, next.done = !0, next;
|
|
185
|
-
};
|
|
186
|
-
return next.next = next;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return {
|
|
190
|
-
next: doneResult
|
|
46
|
+
this.resize(this.canvasConfig.width, this.canvasConfig.height);
|
|
191
47
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
return {
|
|
195
|
-
value: undefined,
|
|
196
|
-
done: !0
|
|
48
|
+
WebGPUContextService.prototype.getDomElement = function () {
|
|
49
|
+
return this.$canvas;
|
|
197
50
|
};
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
203
|
-
value: GeneratorFunction,
|
|
204
|
-
configurable: !0
|
|
205
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
206
|
-
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
207
|
-
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
208
|
-
}, exports.mark = function (genFun) {
|
|
209
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
210
|
-
}, exports.awrap = function (arg) {
|
|
211
|
-
return {
|
|
212
|
-
__await: arg
|
|
51
|
+
WebGPUContextService.prototype.getContext = function () {
|
|
52
|
+
return (
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
this.deviceRendererPlugin.getDevice().canvasContext);
|
|
213
55
|
};
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
219
|
-
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
220
|
-
return result.done ? result.value : iter.next();
|
|
221
|
-
});
|
|
222
|
-
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
223
|
-
return this;
|
|
224
|
-
}), define(Gp, "toString", function () {
|
|
225
|
-
return "[object Generator]";
|
|
226
|
-
}), exports.keys = function (val) {
|
|
227
|
-
var object = Object(val),
|
|
228
|
-
keys = [];
|
|
229
|
-
for (var key in object) keys.push(key);
|
|
230
|
-
return keys.reverse(), function next() {
|
|
231
|
-
for (; keys.length;) {
|
|
232
|
-
var key = keys.pop();
|
|
233
|
-
if (key in object) return next.value = key, next.done = !1, next;
|
|
234
|
-
}
|
|
235
|
-
return next.done = !0, next;
|
|
56
|
+
WebGPUContextService.prototype.getBoundingClientRect = function () {
|
|
57
|
+
if (this.$canvas.getBoundingClientRect) {
|
|
58
|
+
return this.$canvas.getBoundingClientRect();
|
|
59
|
+
}
|
|
236
60
|
};
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
stop: function () {
|
|
243
|
-
this.done = !0;
|
|
244
|
-
var rootRecord = this.tryEntries[0].completion;
|
|
245
|
-
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
246
|
-
return this.rval;
|
|
247
|
-
},
|
|
248
|
-
dispatchException: function (exception) {
|
|
249
|
-
if (this.done) throw exception;
|
|
250
|
-
var context = this;
|
|
251
|
-
function handle(loc, caught) {
|
|
252
|
-
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
253
|
-
}
|
|
254
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
255
|
-
var entry = this.tryEntries[i],
|
|
256
|
-
record = entry.completion;
|
|
257
|
-
if ("root" === entry.tryLoc) return handle("end");
|
|
258
|
-
if (entry.tryLoc <= this.prev) {
|
|
259
|
-
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
260
|
-
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
261
|
-
if (hasCatch && hasFinally) {
|
|
262
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
263
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
264
|
-
} else if (hasCatch) {
|
|
265
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
266
|
-
} else {
|
|
267
|
-
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
268
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
269
|
-
}
|
|
61
|
+
WebGPUContextService.prototype.destroy = function () {
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
this.$container.removeChild(this.$canvas);
|
|
270
66
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
var
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
67
|
+
};
|
|
68
|
+
WebGPUContextService.prototype.resize = function (width, height) {
|
|
69
|
+
// use user-defined dpr first
|
|
70
|
+
var devicePixelRatio = this.canvasConfig.devicePixelRatio;
|
|
71
|
+
var dpr = devicePixelRatio || (isBrowser && window.devicePixelRatio) || 1;
|
|
72
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
73
|
+
this.dpr = dpr;
|
|
74
|
+
if (this.$canvas) {
|
|
75
|
+
var dpr_1 = this.getDPR();
|
|
76
|
+
// set canvas width & height
|
|
77
|
+
this.$canvas.width = dpr_1 * width;
|
|
78
|
+
this.$canvas.height = dpr_1 * height;
|
|
79
|
+
// set CSS style width & height
|
|
80
|
+
setDOMSize(this.$canvas, width, height);
|
|
279
81
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
288
|
-
},
|
|
289
|
-
finish: function (finallyLoc) {
|
|
290
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
291
|
-
var entry = this.tryEntries[i];
|
|
292
|
-
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
catch: function (tryLoc) {
|
|
296
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
297
|
-
var entry = this.tryEntries[i];
|
|
298
|
-
if (entry.tryLoc === tryLoc) {
|
|
299
|
-
var record = entry.completion;
|
|
300
|
-
if ("throw" === record.type) {
|
|
301
|
-
var thrown = record.arg;
|
|
302
|
-
resetTryEntry(entry);
|
|
303
|
-
}
|
|
304
|
-
return thrown;
|
|
82
|
+
};
|
|
83
|
+
WebGPUContextService.prototype.getDPR = function () {
|
|
84
|
+
return this.dpr;
|
|
85
|
+
};
|
|
86
|
+
WebGPUContextService.prototype.applyCursorStyle = function (cursor) {
|
|
87
|
+
if (this.$container && this.$container.style) {
|
|
88
|
+
this.$container.style.cursor = cursor;
|
|
305
89
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}, exports;
|
|
317
|
-
}
|
|
318
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
319
|
-
try {
|
|
320
|
-
var info = gen[key](arg);
|
|
321
|
-
var value = info.value;
|
|
322
|
-
} catch (error) {
|
|
323
|
-
reject(error);
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
if (info.done) {
|
|
327
|
-
resolve(value);
|
|
328
|
-
} else {
|
|
329
|
-
Promise.resolve(value).then(_next, _throw);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
function _asyncToGenerator(fn) {
|
|
333
|
-
return function () {
|
|
334
|
-
var self = this,
|
|
335
|
-
args = arguments;
|
|
336
|
-
return new Promise(function (resolve, reject) {
|
|
337
|
-
var gen = fn.apply(self, args);
|
|
338
|
-
function _next(value) {
|
|
339
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
340
|
-
}
|
|
341
|
-
function _throw(err) {
|
|
342
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
343
|
-
}
|
|
344
|
-
_next(undefined);
|
|
345
|
-
});
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
function _inheritsLoose(subClass, superClass) {
|
|
349
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
350
|
-
subClass.prototype.constructor = subClass;
|
|
351
|
-
_setPrototypeOf(subClass, superClass);
|
|
352
|
-
}
|
|
353
|
-
function _setPrototypeOf(o, p) {
|
|
354
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
355
|
-
o.__proto__ = p;
|
|
356
|
-
return o;
|
|
357
|
-
};
|
|
358
|
-
return _setPrototypeOf(o, p);
|
|
359
|
-
}
|
|
90
|
+
};
|
|
91
|
+
WebGPUContextService.prototype.toDataURL = function (options) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
return [2 /*return*/, ''];
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
return WebGPUContextService;
|
|
99
|
+
}());
|
|
360
100
|
|
|
361
|
-
var
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
this.canvasConfig = context.config;
|
|
369
|
-
// @ts-ignore
|
|
370
|
-
this.deviceRendererPlugin = context.deviceRendererPlugin;
|
|
371
|
-
}
|
|
372
|
-
var _proto = WebGPUContextService.prototype;
|
|
373
|
-
_proto.init = function init() {
|
|
374
|
-
var _this$canvasConfig = this.canvasConfig,
|
|
375
|
-
container = _this$canvasConfig.container,
|
|
376
|
-
canvas = _this$canvasConfig.canvas;
|
|
377
|
-
if (canvas) {
|
|
378
|
-
this.$canvas = canvas;
|
|
379
|
-
if (container && canvas.parentElement !== container) {
|
|
380
|
-
container.appendChild(canvas);
|
|
381
|
-
}
|
|
382
|
-
this.$container = canvas.parentElement;
|
|
383
|
-
this.canvasConfig.container = this.$container;
|
|
384
|
-
} else if (container) {
|
|
385
|
-
// create container
|
|
386
|
-
this.$container = isString(container) ? document.getElementById(container) : container;
|
|
387
|
-
if (this.$container) {
|
|
388
|
-
// create canvas
|
|
389
|
-
var $canvas = document.createElement('canvas');
|
|
390
|
-
this.$container.appendChild($canvas);
|
|
391
|
-
if (!this.$container.style.position) {
|
|
392
|
-
this.$container.style.position = 'relative';
|
|
393
|
-
}
|
|
394
|
-
this.$canvas = $canvas;
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
this.resize(this.canvasConfig.width, this.canvasConfig.height);
|
|
398
|
-
};
|
|
399
|
-
_proto.getDomElement = function getDomElement() {
|
|
400
|
-
return this.$canvas;
|
|
401
|
-
};
|
|
402
|
-
_proto.getContext = function getContext() {
|
|
403
|
-
return (
|
|
404
|
-
// @ts-ignore
|
|
405
|
-
this.deviceRendererPlugin.getDevice().canvasContext
|
|
406
|
-
);
|
|
407
|
-
};
|
|
408
|
-
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
409
|
-
if (this.$canvas.getBoundingClientRect) {
|
|
410
|
-
return this.$canvas.getBoundingClientRect();
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
_proto.destroy = function destroy() {
|
|
414
|
-
// @ts-ignore
|
|
415
|
-
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
416
|
-
// @ts-ignore
|
|
417
|
-
this.$container.removeChild(this.$canvas);
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
_proto.resize = function resize(width, height) {
|
|
421
|
-
// use user-defined dpr first
|
|
422
|
-
var devicePixelRatio = this.canvasConfig.devicePixelRatio;
|
|
423
|
-
var dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
|
|
424
|
-
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
425
|
-
this.dpr = dpr;
|
|
426
|
-
if (this.$canvas) {
|
|
427
|
-
var _dpr = this.getDPR();
|
|
428
|
-
// set canvas width & height
|
|
429
|
-
this.$canvas.width = _dpr * width;
|
|
430
|
-
this.$canvas.height = _dpr * height;
|
|
431
|
-
// set CSS style width & height
|
|
432
|
-
setDOMSize(this.$canvas, width, height);
|
|
433
|
-
}
|
|
434
|
-
};
|
|
435
|
-
_proto.getDPR = function getDPR() {
|
|
436
|
-
return this.dpr;
|
|
437
|
-
};
|
|
438
|
-
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
439
|
-
if (this.$container && this.$container.style) {
|
|
440
|
-
this.$container.style.cursor = cursor;
|
|
101
|
+
var ContextRegisterPlugin = /** @class */ (function (_super) {
|
|
102
|
+
__extends(ContextRegisterPlugin, _super);
|
|
103
|
+
function ContextRegisterPlugin(rendererPlugin) {
|
|
104
|
+
var _this = _super.call(this) || this;
|
|
105
|
+
_this.rendererPlugin = rendererPlugin;
|
|
106
|
+
_this.name = 'webgpu-context-register';
|
|
107
|
+
return _this;
|
|
441
108
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
}
|
|
453
|
-
}, _callee);
|
|
454
|
-
}));
|
|
455
|
-
function toDataURL(_x) {
|
|
456
|
-
return _toDataURL.apply(this, arguments);
|
|
457
|
-
}
|
|
458
|
-
return toDataURL;
|
|
459
|
-
}();
|
|
460
|
-
return WebGPUContextService;
|
|
461
|
-
}();
|
|
462
|
-
|
|
463
|
-
var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
464
|
-
_inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
|
|
465
|
-
function ContextRegisterPlugin(rendererPlugin) {
|
|
466
|
-
var _this;
|
|
467
|
-
_this = _AbstractRendererPlug.call(this) || this;
|
|
468
|
-
_this.rendererPlugin = void 0;
|
|
469
|
-
_this.name = 'webgpu-context-register';
|
|
470
|
-
_this.rendererPlugin = rendererPlugin;
|
|
471
|
-
return _this;
|
|
472
|
-
}
|
|
473
|
-
var _proto = ContextRegisterPlugin.prototype;
|
|
474
|
-
_proto.init = function init() {
|
|
475
|
-
this.context.ContextService = WebGPUContextService;
|
|
476
|
-
// @ts-ignore
|
|
477
|
-
this.context.deviceRendererPlugin = this.rendererPlugin;
|
|
478
|
-
};
|
|
479
|
-
_proto.destroy = function destroy() {
|
|
480
|
-
delete this.context.ContextService;
|
|
481
|
-
};
|
|
482
|
-
return ContextRegisterPlugin;
|
|
483
|
-
}(AbstractRendererPlugin);
|
|
109
|
+
ContextRegisterPlugin.prototype.init = function () {
|
|
110
|
+
this.context.ContextService = WebGPUContextService;
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
this.context.deviceRendererPlugin = this.rendererPlugin;
|
|
113
|
+
};
|
|
114
|
+
ContextRegisterPlugin.prototype.destroy = function () {
|
|
115
|
+
delete this.context.ContextService;
|
|
116
|
+
};
|
|
117
|
+
return ContextRegisterPlugin;
|
|
118
|
+
}(AbstractRendererPlugin));
|
|
484
119
|
|
|
485
|
-
var Renderer =
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}
|
|
120
|
+
var Renderer = /** @class */ (function (_super) {
|
|
121
|
+
__extends(Renderer, _super);
|
|
122
|
+
function Renderer(config) {
|
|
123
|
+
var _this = _super.call(this, config) || this;
|
|
124
|
+
var deviceRendererPlugin = new DeviceRenderer.Plugin();
|
|
125
|
+
_this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin));
|
|
126
|
+
_this.registerPlugin(new ImageLoader.Plugin());
|
|
127
|
+
_this.registerPlugin(new WebGPUDevice.Plugin({
|
|
128
|
+
shaderCompilerPath: config === null || config === void 0 ? void 0 : config.shaderCompilerPath,
|
|
129
|
+
onContextLost: config === null || config === void 0 ? void 0 : config.onContextLost,
|
|
130
|
+
}));
|
|
131
|
+
_this.registerPlugin(deviceRendererPlugin);
|
|
132
|
+
_this.registerPlugin(new DomInteraction.Plugin());
|
|
133
|
+
_this.registerPlugin(new HTMLRenderer.Plugin());
|
|
134
|
+
return _this;
|
|
135
|
+
}
|
|
136
|
+
return Renderer;
|
|
137
|
+
}(AbstractRenderer));
|
|
501
138
|
|
|
502
139
|
export { Renderer };
|
|
140
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/packages/g-webgpu/src/WebGPUContextService.ts","../src/packages/g-webgpu/src/ContextRegisterPlugin.ts","../src/packages/g-webgpu/src/index.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":";;;;;;;;;;;;;AAYA,IAAA,oBAAA,kBAAA,YAAA;AAQE,IAAA,SAAA,oBAAA,CAAY,OAAsC,EAAA;AAChD,QAAA,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;;AAEnC,QAAA,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC;KAC1D;AAED,IAAA,oBAAA,CAAA,SAAA,CAAA,IAAI,GAAJ,YAAA;QACQ,IAAA,EAAA,GAAwB,IAAI,CAAC,YAAY,EAAvC,SAAS,GAAA,EAAA,CAAA,SAAA,EAAE,MAAM,GAAA,EAAA,CAAA,MAAsB,CAAC;AAEhD,QAAA,IAAI,MAAM,EAAE;AACV,YAAA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;AAEtB,YAAA,IACE,SAAS;AACR,gBAAA,MAA4B,CAAC,aAAa,KAAK,SAAS,EACzD;AACC,gBAAA,SAAyB,CAAC,WAAW,CAAC,MAA2B,CAAC,CAAC;AACrE,aAAA;AAED,YAAA,IAAI,CAAC,UAAU,GAAI,MAA4B,CAAC,aAAa,CAAC;YAC9D,IAAI,CAAC,YAAY,CAAC,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;AAC/C,SAAA;AAAM,aAAA,IAAI,SAAS,EAAE;;AAEpB,YAAA,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,SAAS,CAAC;AACnC,kBAAE,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC;kBAClC,SAAS,CAAC;YACd,IAAI,IAAI,CAAC,UAAU,EAAE;;gBAEnB,IAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAA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