1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 | Object.defineProperty(exports, "__esModule", {
|
5 | value: true
|
6 | });
|
7 | exports.default = void 0;
|
8 | var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
9 | var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
10 | var _gWebgpuCore = require("@antv/g-webgpu-core");
|
11 | var _constants = require("./constants");
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | var ReglTexture2D = function () {
|
17 | function ReglTexture2D(reGl, options) {
|
18 | (0, _classCallCheck2.default)(this, ReglTexture2D);
|
19 | this.texture = void 0;
|
20 | this.width = void 0;
|
21 | this.height = void 0;
|
22 | var data = options.data,
|
23 | _options$type = options.type,
|
24 | type = _options$type === void 0 ? _gWebgpuCore.gl.UNSIGNED_BYTE : _options$type,
|
25 | width = options.width,
|
26 | height = options.height,
|
27 | _options$flipY = options.flipY,
|
28 | flipY = _options$flipY === void 0 ? false : _options$flipY,
|
29 | _options$format = options.format,
|
30 | format = _options$format === void 0 ? _gWebgpuCore.gl.RGBA : _options$format,
|
31 | _options$mipmap = options.mipmap,
|
32 | mipmap = _options$mipmap === void 0 ? false : _options$mipmap,
|
33 | _options$wrapS = options.wrapS,
|
34 | wrapS = _options$wrapS === void 0 ? _gWebgpuCore.gl.CLAMP_TO_EDGE : _options$wrapS,
|
35 | _options$wrapT = options.wrapT,
|
36 | wrapT = _options$wrapT === void 0 ? _gWebgpuCore.gl.CLAMP_TO_EDGE : _options$wrapT,
|
37 | _options$aniso = options.aniso,
|
38 | aniso = _options$aniso === void 0 ? 0 : _options$aniso,
|
39 | _options$alignment = options.alignment,
|
40 | alignment = _options$alignment === void 0 ? 1 : _options$alignment,
|
41 | _options$premultiplyA = options.premultiplyAlpha,
|
42 | premultiplyAlpha = _options$premultiplyA === void 0 ? false : _options$premultiplyA,
|
43 | _options$mag = options.mag,
|
44 | mag = _options$mag === void 0 ? _gWebgpuCore.gl.NEAREST : _options$mag,
|
45 | _options$min = options.min,
|
46 | min = _options$min === void 0 ? _gWebgpuCore.gl.NEAREST : _options$min,
|
47 | _options$colorSpace = options.colorSpace,
|
48 | colorSpace = _options$colorSpace === void 0 ? _gWebgpuCore.gl.BROWSER_DEFAULT_WEBGL : _options$colorSpace;
|
49 | this.width = width;
|
50 | this.height = height;
|
51 | var textureOptions = {
|
52 | width: width,
|
53 | height: height,
|
54 |
|
55 | type: _constants.dataTypeMap[type],
|
56 | format: _constants.formatMap[format],
|
57 | wrapS: _constants.wrapModeMap[wrapS],
|
58 | wrapT: _constants.wrapModeMap[wrapT],
|
59 |
|
60 | mag: _constants.filterMap[mag],
|
61 | min: _constants.filterMap[min],
|
62 | alignment: alignment,
|
63 | flipY: flipY,
|
64 | colorSpace: _constants.colorSpaceMap[colorSpace],
|
65 | premultiplyAlpha: premultiplyAlpha,
|
66 | aniso: aniso
|
67 | };
|
68 | if (data) {
|
69 | textureOptions.data = data;
|
70 | }
|
71 | if (typeof mipmap === 'number') {
|
72 | textureOptions.mipmap = _constants.mipmapMap[mipmap];
|
73 | } else if (typeof mipmap === 'boolean') {
|
74 | textureOptions.mipmap = mipmap;
|
75 | }
|
76 | this.texture = reGl.texture(textureOptions);
|
77 | }
|
78 | (0, _createClass2.default)(ReglTexture2D, [{
|
79 | key: "get",
|
80 | value: function get() {
|
81 | return this.texture;
|
82 | }
|
83 | }, {
|
84 | key: "update",
|
85 | value: function update() {
|
86 |
|
87 | this.texture._texture.bind();
|
88 | }
|
89 | }, {
|
90 | key: "resize",
|
91 | value: function resize(_ref) {
|
92 | var width = _ref.width,
|
93 | height = _ref.height;
|
94 | this.texture.resize(width, height);
|
95 | this.width = width;
|
96 | this.height = height;
|
97 | }
|
98 | }, {
|
99 | key: "destroy",
|
100 | value: function destroy() {
|
101 | this.texture.destroy();
|
102 | }
|
103 | }]);
|
104 | return ReglTexture2D;
|
105 | }();
|
106 | exports.default = ReglTexture2D;
|
107 |
|
\ | No newline at end of file |