@shijiu/jsview 1.9.719

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.
Files changed (148) hide show
  1. package/dom/bin/jsview-browser-debug-dom.min.js +1 -0
  2. package/dom/bin/jsview-dom.min.js +1 -0
  3. package/dom/bin/jsview-engine-js-browser.min.js +1 -0
  4. package/dom/bin/jsview-forge-define.min.js +1 -0
  5. package/dom/browser-root-style.css +21 -0
  6. package/dom/jsv-browser-debug-dom.js +8 -0
  7. package/dom/jsv-dom.js +6 -0
  8. package/dom/jsv-engine-js-browser.js +6 -0
  9. package/dom/jsv-forge-define.js +6 -0
  10. package/dom/jsview-dom/README.md +5 -0
  11. package/dom/jsview-dom/package-lock.json-perfect +3898 -0
  12. package/dom/jsview-dom/package.json +23 -0
  13. package/dom/jsview-dom/rollup/browser-debug-dom.rollup.config.js +15 -0
  14. package/dom/jsview-dom/rollup/dom.rollup.config.js +14 -0
  15. package/dom/jsview-dom/rollup/engine-js-browser.rollup.config.js +14 -0
  16. package/dom/jsview-dom/rollup/forge-define.rollup.config.js +14 -0
  17. package/dom/jsview-dom/scripts/release_dist.sh +36 -0
  18. package/dom/jsview-dom/src/dom-browser-hook/HookDocument.js +118 -0
  19. package/dom/jsview-dom/src/dom-browser-hook/OriginDocument.js +19 -0
  20. package/dom/jsview-dom/src/dom-browser-hook/StyleFormatCheck.js +559 -0
  21. package/dom/jsview-dom/src/dom-browser-hook/index.js +6 -0
  22. package/dom/jsview-dom/src/dom-wrapper/ForgeExtension.js +226 -0
  23. package/dom/jsview-dom/src/dom-wrapper/JsViewForgeApp.js +85 -0
  24. package/dom/jsview-dom/src/dom-wrapper/JsViewProxy.js +51 -0
  25. package/dom/jsview-dom/src/dom-wrapper/event/AnimationEvent.js +7 -0
  26. package/dom/jsview-dom/src/dom-wrapper/event/Event.js +12 -0
  27. package/dom/jsview-dom/src/dom-wrapper/event/FocusEvent.js +9 -0
  28. package/dom/jsview-dom/src/dom-wrapper/event/KeyboardEvent.js +43 -0
  29. package/dom/jsview-dom/src/dom-wrapper/event/LoadEvent.js +8 -0
  30. package/dom/jsview-dom/src/dom-wrapper/index.js +16 -0
  31. package/dom/jsview-dom/src/dom-wrapper/node/AnchorElement.js +24 -0
  32. package/dom/jsview-dom/src/dom-wrapper/node/AudioElement.js +60 -0
  33. package/dom/jsview-dom/src/dom-wrapper/node/Comment.js +10 -0
  34. package/dom/jsview-dom/src/dom-wrapper/node/DivElement.js +498 -0
  35. package/dom/jsview-dom/src/dom-wrapper/node/Document.js +274 -0
  36. package/dom/jsview-dom/src/dom-wrapper/node/Element.js +852 -0
  37. package/dom/jsview-dom/src/dom-wrapper/node/FDivElement.js +48 -0
  38. package/dom/jsview-dom/src/dom-wrapper/node/HeadElement.js +47 -0
  39. package/dom/jsview-dom/src/dom-wrapper/node/ImageElement.js +203 -0
  40. package/dom/jsview-dom/src/dom-wrapper/node/JsvAudioTrackElement.js +22 -0
  41. package/dom/jsview-dom/src/dom-wrapper/node/JsvElement.js +40 -0
  42. package/dom/jsview-dom/src/dom-wrapper/node/LinkElement.js +48 -0
  43. package/dom/jsview-dom/src/dom-wrapper/node/MediaElement.js +230 -0
  44. package/dom/jsview-dom/src/dom-wrapper/node/Node.js +178 -0
  45. package/dom/jsview-dom/src/dom-wrapper/node/SVGElement.js +9 -0
  46. package/dom/jsview-dom/src/dom-wrapper/node/ScriptElement.js +45 -0
  47. package/dom/jsview-dom/src/dom-wrapper/node/StyleElement.js +33 -0
  48. package/dom/jsview-dom/src/dom-wrapper/node/StyleElementCache.js +41 -0
  49. package/dom/jsview-dom/src/dom-wrapper/node/Text.js +22 -0
  50. package/dom/jsview-dom/src/dom-wrapper/node/UnknownElement.js +4 -0
  51. package/dom/jsview-dom/src/dom-wrapper/node/VideoElement.js +237 -0
  52. package/dom/jsview-dom/src/dom-wrapper/style/BorderImage.js +25 -0
  53. package/dom/jsview-dom/src/dom-wrapper/style/Inset.js +26 -0
  54. package/dom/jsview-dom/src/dom-wrapper/style/JsvStyleVariable.js +65 -0
  55. package/dom/jsview-dom/src/dom-wrapper/style/KeyframeRule.js +11 -0
  56. package/dom/jsview-dom/src/dom-wrapper/style/StyleDeclaration.js +609 -0
  57. package/dom/jsview-dom/src/dom-wrapper/style/StyleSheet.js +51 -0
  58. package/dom/jsview-dom/src/dom-wrapper/style/StyleValue.js +385 -0
  59. package/dom/jsview-dom/src/dom-wrapper/style/TextStylePackMap.js +43 -0
  60. package/dom/jsview-dom/src/dom-wrapper/style/URL.js +144 -0
  61. package/dom/jsview-dom/src/dom-wrapper/utils/EventHandler.js +42 -0
  62. package/dom/jsview-dom/src/dom-wrapper/utils/FDivRoot.js +86 -0
  63. package/dom/jsview-dom/src/dom-wrapper/utils/JsvLazySyncCache.js +64 -0
  64. package/dom/jsview-dom/src/dom-wrapper/utils/Log.js +42 -0
  65. package/dom/jsview-dom/src/dom-wrapper/utils/MutationObserver.js +32 -0
  66. package/dom/jsview-dom/src/dom-wrapper/utils/focusableNode.js +715 -0
  67. package/dom/jsview-dom/src/engine-js/ForgeDefine.js +8 -0
  68. package/dom/jsview-dom/src/engine-js/ForgeExtensionDefine.js +14 -0
  69. package/dom/jsview-dom/src/engine-js/browser/PlatformUtils.js +100 -0
  70. package/dom/jsview-dom/src/engine-js/browser/animation_base.js +313 -0
  71. package/dom/jsview-dom/src/engine-js/browser/animation_keyframe.js +64 -0
  72. package/dom/jsview-dom/src/engine-js/browser/animation_progress.js +287 -0
  73. package/dom/jsview-dom/src/engine-js/browser/animation_proxy.js +906 -0
  74. package/dom/jsview-dom/src/engine-js/browser/apic_decoder/demux.js +143 -0
  75. package/dom/jsview-dom/src/engine-js/browser/apic_decoder/gifDecoder.js +12 -0
  76. package/dom/jsview-dom/src/engine-js/browser/apic_decoder/libwebp-0.6.0.min.js +160 -0
  77. package/dom/jsview-dom/src/engine-js/browser/console_log.js +25 -0
  78. package/dom/jsview-dom/src/engine-js/browser/dynamic_key_frames.js +95 -0
  79. package/dom/jsview-dom/src/engine-js/browser/easing.js +114 -0
  80. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/element_transform.js +122 -0
  81. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/gjk.js +450 -0
  82. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/mat.js +102 -0
  83. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/range_model.js +296 -0
  84. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/test_collide.js +10 -0
  85. package/dom/jsview-dom/src/engine-js/browser/index.js +38 -0
  86. package/dom/jsview-dom/src/engine-js/browser/latex_parse.js +336 -0
  87. package/dom/jsview-dom/src/engine-js/browser/layout_params.js +113 -0
  88. package/dom/jsview-dom/src/engine-js/browser/layout_view.js +3545 -0
  89. package/dom/jsview-dom/src/engine-js/browser/layout_view_debug.js +15 -0
  90. package/dom/jsview-dom/src/engine-js/browser/media.js +379 -0
  91. package/dom/jsview-dom/src/engine-js/browser/page_base.js +941 -0
  92. package/dom/jsview-dom/src/engine-js/browser/particle_view.js +526 -0
  93. package/dom/jsview-dom/src/engine-js/browser/platform_timer.js +61 -0
  94. package/dom/jsview-dom/src/engine-js/browser/react_utils.js +5 -0
  95. package/dom/jsview-dom/src/engine-js/browser/rect_utils.js +91 -0
  96. package/dom/jsview-dom/src/engine-js/browser/render_bridge.js +128 -0
  97. package/dom/jsview-dom/src/engine-js/browser/render_texture_proxy.js +155 -0
  98. package/dom/jsview-dom/src/engine-js/browser/renderer_deprecated.js +75 -0
  99. package/dom/jsview-dom/src/engine-js/browser/sound_pool.js +139 -0
  100. package/dom/jsview-dom/src/engine-js/browser/steps_animation.js +192 -0
  101. package/dom/jsview-dom/src/engine-js/browser/text_style_cache.js +454 -0
  102. package/dom/jsview-dom/src/engine-js/browser/text_utils.js +299 -0
  103. package/dom/jsview-dom/src/engine-js/browser/text_view.js +428 -0
  104. package/dom/jsview-dom/src/engine-js/browser/texture_manager.js +1060 -0
  105. package/dom/jsview-dom/src/engine-js/browser/url.js +69 -0
  106. package/dom/jsview-dom/src/engine-js/browser/velocity.js +40 -0
  107. package/dom/jsview-dom/src/engine-js/browser/view_sensor/autofroze_sensor.js +77 -0
  108. package/dom/jsview-dom/src/engine-js/browser/view_sensor/drag_impact_sensor.js +67 -0
  109. package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor.js +98 -0
  110. package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor_callback.js +21 -0
  111. package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor_manager.js +24 -0
  112. package/dom/jsview-dom/src/engine-js/browser/view_sensor/index.js +9 -0
  113. package/dom/jsview-dom/src/engine-js/browser/view_sensor/view_sensor.js +268 -0
  114. package/dom/jsview-dom/src/engine-js/browser/view_sensor/view_sensor_manager.js +84 -0
  115. package/dom/jsview-dom/src/engine-js/browser/view_sensor/visible_sensor.js +213 -0
  116. package/dom/jsview-dom/src/engine-js/browser/view_store.js +41 -0
  117. package/dom/jsview-dom/src/engine-js/index.js +2 -0
  118. package/dom/jsview-dom/src/engine-js/native/README.md +1 -0
  119. package/dom/target_core_revision.mjs +15 -0
  120. package/index.js +0 -0
  121. package/loader/header_script_loader.js +134 -0
  122. package/loader/jsview-main.js +42 -0
  123. package/loader/jsview.config.default.js +37 -0
  124. package/loader/jsview.default.config.js +37 -0
  125. package/loader/loader.js +183 -0
  126. package/loader/loader_webkit.js +40 -0
  127. package/package.json +31 -0
  128. package/patches/node_modules/@vitejs/plugin-react/dist/index.cjs +520 -0
  129. package/patches/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +17609 -0
  130. package/patches/node_modules/@vue/compiler-sfc/dist/jsview-css-to-js.js +335 -0
  131. package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-format.js +446 -0
  132. package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-types.js +91 -0
  133. package/patches/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +8038 -0
  134. package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +1700 -0
  135. package/patches/node_modules/postcss-js/objectifier.js +90 -0
  136. package/patches/node_modules/vite/dist/node/chunks/dep-0fc8e132.js +63175 -0
  137. package/patches/node_modules/vite/dist/node/jsview-react.vite.config.js +7 -0
  138. package/patches/node_modules/vite/dist/node/jsview-vue.vite.config.js +7 -0
  139. package/patches/node_modules/vite/dist/node/jsview.vite.config.js +56 -0
  140. package/patches/node_modules/vue-router/dist/vue-router.mjs +3595 -0
  141. package/tools/common.js +58 -0
  142. package/tools/jsview-jsmap-serve.js +105 -0
  143. package/tools/jsview-post-build.js +184 -0
  144. package/tools/jsview-post-install-react.js +13 -0
  145. package/tools/jsview-post-install-vue.js +16 -0
  146. package/tools/jsview-post-install.js +116 -0
  147. package/tools/jsview-run-android.js +67 -0
  148. package/tsconfig.json +34 -0
@@ -0,0 +1,1060 @@
1
+ /* eslint-disable no-unused-vars */
2
+ import Forge from "../ForgeDefine";
3
+
4
+ Forge.ColorSpace = {
5
+ RGBA_8888: "RGBA_8888",
6
+ RGBA_4444: "RGBA_4444",
7
+ RGBA_5551: "RGBA_5551",
8
+ RGB_565: "RGB_565",
9
+
10
+ // ETC1 format
11
+ RGB_ETC1: "RGB_ETC1",
12
+ RGBA_ETC1: "RGBA_ETC1",
13
+ };
14
+
15
+ Forge.QRCodeLevel = {
16
+ L: 1,
17
+ M: 0,
18
+ Q: 3,
19
+ H: 2,
20
+ };
21
+ const CONST_CACHE_MAX_SIZE = 100;
22
+
23
+ class ImageTexture {
24
+ /**
25
+ * 用于LayoutView方格显示的Texture
26
+ *
27
+ * @public
28
+ * @constructor Forge.ImageTexture
29
+ * @param {Forge.TextureManager} texture_manager Texture管理类
30
+ * @param {Object} resource_info RenderTexture的配置,创建自RenderTextureDelegateManager.CreateResourceInfo()
31
+ * @param {String} status (文字Texture状态信息同步)
32
+ * */
33
+ constructor(texture_manager, resource_info, status) {
34
+ this._Manager = texture_manager;
35
+ if (status) {
36
+ const status_texture = Forge.sRenderTextureDelegateManager.CreateTextureStatus();
37
+ status_texture.SetResourceInfo(status);
38
+ }
39
+ this.RenderTexture = Forge.sRenderTextureDelegateManager.CreateTexture();
40
+ this.RenderTexture.SetResourceInfo(resource_info);
41
+ this._CallbackIdToken = 0;
42
+
43
+ this._OnLoadCallback = [];
44
+
45
+ // Trace memory
46
+ if (Forge.ForgeDebug.EnableTextureTracer) {
47
+ texture_manager._ImageTextureTracer.push(this);
48
+ this._TracerDescript = "";
49
+ // this._TracerStack = new Error().stack;
50
+ }
51
+ }
52
+
53
+ // Texture loading status
54
+ // before start to load: LoadTime = 0, Unloaded = false, InLoading = false
55
+ // Be unloaded: LoadTime = 0, Unloaded = true, InLoading = false
56
+ // In loading: LoadTime = 0, Unloaded = false, InLoading = true
57
+ // Image loaded: LoadTime = Number, Unloaded = false, InLoading = false
58
+ get Unloaded() {
59
+ if (this.RenderTexture !== null) {
60
+ return this.RenderTexture.Unloaded;
61
+ }
62
+ return true;
63
+ }
64
+
65
+ set Unloaded(val) {
66
+ // Unloaded
67
+ }
68
+
69
+ get LoadTime() {
70
+ if (this.RenderTexture !== null) {
71
+ return this.RenderTexture.LoadTime;
72
+ }
73
+ return 0;
74
+ }
75
+
76
+ set LoadTime(val) {
77
+ // load time
78
+ }
79
+
80
+ get Width() {
81
+ if (this.RenderTexture !== null) {
82
+ return this.RenderTexture.Width;
83
+ }
84
+ return 0;
85
+ }
86
+
87
+ set Width(val) {
88
+ // width
89
+ }
90
+
91
+ get Height() {
92
+ if (this.RenderTexture !== null) {
93
+ return this.RenderTexture.Height;
94
+ }
95
+ return 0;
96
+ }
97
+
98
+ set Height(val) {
99
+ // height
100
+ }
101
+
102
+ /**
103
+ * 释放渲染端的Texture
104
+ *
105
+ * @public
106
+ * @func UnloadTex
107
+ * @memberof Forge.ImageTexture
108
+ * @instance
109
+ * */
110
+ UnloadTex() {
111
+ // Clear onload callbacks
112
+ this._OnLoadCallback = [];
113
+ if (this.RenderTexture !== null) {
114
+ if (this._CallbackIdToken > 0) {
115
+ this.RenderTexture.UnregisterOnloadCallback(this._CallbackIdToken);
116
+ this._CallbackIdToken = 0;
117
+ }
118
+ this.RenderTexture.UndoRef();
119
+ this.RenderTexture = null;
120
+ }
121
+
122
+ // Clear tracer descript
123
+ this._TracerDescript = "";
124
+ }
125
+
126
+ /**
127
+ * 注册加载完成后的回调(只被调用一次,或则当图片Unload时,所有回调会被清楚)<br>
128
+ * 为了释放被回调函数引用的外部变量
129
+ *
130
+ * @public
131
+ * @func RegisterLoadImageCallback
132
+ * @memberof Forge.ImageTexture
133
+ * @instance
134
+ * @param {String} url 预留,请设置为null
135
+ * @param {Function} on_load_callback 回调函数
136
+ * @param {Object} params 原封不动传递给回调函数的参数
137
+ * */
138
+ RegisterLoadImageCallback(url, on_load_callback, params) {
139
+ if (this.IsLoaded() && on_load_callback != null) {
140
+ if (this.RenderTexture) {
141
+ on_load_callback({ width: this.RenderTexture.Width, height: this.RenderTexture.Height }, params);
142
+ }
143
+ return null;
144
+ }
145
+
146
+ let callback_pack = null;
147
+ if (on_load_callback != null) {
148
+ callback_pack = { callback: on_load_callback, params: params };
149
+ this._OnLoadCallback.push(callback_pack);
150
+ if (this._CallbackIdToken === 0) {
151
+ Forge.Assert(this.RenderTexture !== null);
152
+ this._CallbackIdToken = this.RenderTexture.RegisterOnloadCallback(
153
+ ImageTexture.prototype._InvokeOnLoadCallbacks.bind(this)
154
+ );
155
+ }
156
+ }
157
+
158
+ return callback_pack;
159
+ }
160
+
161
+ UnregisterLoadImageCallback(token) {
162
+ if (token) {
163
+ this._OnLoadCallback.some((o, i, arr)=>{
164
+ if (o === token) {
165
+ arr.splice(i, 1);
166
+ return true; // break
167
+ }
168
+ });
169
+ }
170
+ }
171
+
172
+ // Important的Texture,则无论是否在当前屏幕上显示,都会加载
173
+ // 主要用于处理有用户Onload回调场景
174
+ // 以及后台预加载场景
175
+ // refer为任意Object,用于 EnableBackgroundLoad/DisableBackgroundLoad 配对,以实现配对开关
176
+ EnableBackgroundLoad(refer) {
177
+ // TODO: Forge html处理不需要Import处理
178
+ }
179
+
180
+ DisableBackgroundLoad(refer) {
181
+ // TODO: Forge html处理不需要Import处理
182
+ }
183
+
184
+ _InvokeOnLoadCallbacks() {
185
+ const callbacks = this._OnLoadCallback;
186
+ this._OnLoadCallback = []; // Clear all callbacks before invoke
187
+ for (let i = 0; i < callbacks.length; i++) {
188
+ const callback_setting = callbacks[i];
189
+ callback_setting.callback(callback_setting.params);
190
+ }
191
+ if (this.RenderTexture) {
192
+ this.RenderTexture.UnregisterOnloadCallback(this._CallbackIdToken);
193
+ }
194
+ }
195
+
196
+ /**
197
+ * 判断图片是否加载进内存
198
+ *
199
+ * @public
200
+ * @func IsLoaded
201
+ * @memberof Forge.ImageTexture
202
+ * @instance
203
+ * @return {boolean} 图片是否加载进内存
204
+ * */
205
+ IsLoaded() {
206
+ return this.LoadTime !== 0 && !this.Unloaded;
207
+ }
208
+
209
+ SetTextureTracerDescript(descript) {
210
+ this._TracerDescript = descript;
211
+ }
212
+
213
+ ReallocRenderTexture() {
214
+ // Should be override for some reload able texture
215
+ }
216
+ }
217
+ Forge.ImageTexture = ImageTexture;
218
+
219
+ class UrlImageTexture extends Forge.ImageTexture {
220
+ constructor(texture_manage, url, is_forever, size, color_space, net_setting) {
221
+ const name = "IMG";
222
+ const resource_info = Forge.sRenderTextureDelegateManager.CreateResourceInfo(
223
+ texture_manage.GetId(),
224
+ name
225
+ );
226
+ resource_info.Set = {
227
+ URL: url,
228
+ Siz: size,
229
+ Clr: color_space || "",
230
+ IsF: is_forever ? 1 : 0,
231
+ NtS: net_setting,
232
+ ILd: 0, // instant decode 0:false 1:true
233
+ };
234
+ super(texture_manage, resource_info);
235
+
236
+ this.Name = name;
237
+ // public
238
+ this.Source = url;
239
+ this.IsForever = is_forever ? 1 : 0;
240
+ this.TargetSize = size;
241
+ /* Forge.RectArea */
242
+ this.ColorSpace = color_space || "";
243
+ /* Forge.ColorSpace */
244
+ this.NetSetting = net_setting || null;
245
+ this._InstantLoad = 0; // 默认为0 //instant decode 0:false 1:true
246
+ this._ImageElement = new Image();
247
+ this._ImageElement.onload = function () {
248
+ this._Loaded();
249
+ }.bind(this);
250
+ this._ImageElement.onerror = function () {
251
+ this._Loaded();
252
+ }.bind(this);
253
+
254
+ this._ImageElement.src = url;
255
+ this.RenderTexture.NeedCheckExpired = true;
256
+ }
257
+
258
+ _Loaded() {
259
+ this.RenderTexture.Unloaded = false;
260
+ this.RenderTexture.LoadTime = Date.now();
261
+ this.RenderTexture.Width = this._ImageElement.width;
262
+ this.RenderTexture.Height = this._ImageElement.height;
263
+ this.RenderTexture.InvokeOnloadCallbacks();
264
+ }
265
+
266
+ /**
267
+ * 是否开启当前帧Load图片
268
+ *
269
+ * @public
270
+ * @func InstantLoad
271
+ * @memberof Forge.UrlImageTexture
272
+ * @instance
273
+ * @param {bool} enable_flag 是否即时Load
274
+ * */
275
+ InstantLoad(enable_flag) {
276
+ this._InstantLoad = enable_flag ? 1 : 0;
277
+ if (this.RenderTexture) {
278
+ const resource_info = this.RenderTexture.GetResourceInfo();
279
+ if (resource_info !== null) {
280
+ resource_info.Set.ILd = this._InstantLoad;
281
+ this.RenderTexture.SetResourceInfo(resource_info);
282
+ }
283
+ }
284
+
285
+ return this;
286
+ }
287
+
288
+ ReallocRenderTexture() {
289
+ if (this.IsForever) {
290
+ Forge.LogE("ReallocRenderTexture(): NOT need for forever texture");
291
+ return;
292
+ }
293
+
294
+ // if (this.RenderTexture === null) {
295
+ // Forge.LogD("ReallocRenderTexture(): Render texture still alive");
296
+ // }
297
+ const url = this.Source;
298
+ const target_size = this.TargetSize;
299
+ /* Forge.RectArea */
300
+ const color_space = this.ColorSpace;
301
+ /* Forge.ColorSpace */
302
+
303
+ const is_forever = this.IsForever;
304
+ const resource_info = Forge.sRenderTextureDelegateManager.CreateResourceInfo(
305
+ this._Manager.GetId(),
306
+ this.Name
307
+ );
308
+ resource_info.Set = {
309
+ URL: url,
310
+ Siz: target_size,
311
+ Clr: color_space,
312
+ IsF: is_forever,
313
+ ILd: this._InstantLoad, // instant decode 0:false 1:true
314
+ };
315
+
316
+ this.RenderTexture = Forge.sRenderTextureDelegateManager.CreateTexture();
317
+ this.RenderTexture.SetResourceInfo(resource_info);
318
+ this._Manager.CachedTextureManager.CacheTheTexture(this);
319
+ }
320
+ }
321
+ Forge.UrlImageTexture = UrlImageTexture;
322
+
323
+ class GradientTexture extends Forge.ImageTexture {
324
+ constructor(
325
+ texture_manage,
326
+ is_vertical, color_start, color_end,
327
+ raw_value
328
+ ) {
329
+ const name = "GRAD";
330
+ const resource_info = Forge.sRenderTextureDelegateManager.CreateResourceInfo(
331
+ texture_manage.GetId(),
332
+ name
333
+ );
334
+ resource_info.Set = {
335
+ URL: raw_value,
336
+ };
337
+ super(texture_manage, resource_info);
338
+
339
+ this.Gradient = raw_value;
340
+ }
341
+
342
+ }
343
+ Forge.GradientTexture = GradientTexture;
344
+
345
+ class TextStyleTexture extends Forge.ImageTexture {
346
+ constructor(
347
+ texture_manage,
348
+ str,
349
+ tsp,
350
+ has_load_callback,
351
+ rect_area,
352
+ font_size,
353
+ line_height,
354
+ is_instant,
355
+ latex_mode,
356
+ has_emoji,
357
+ empty_rect,
358
+ ) {
359
+ const name = "TST";
360
+ const resource_info = Forge.sRenderTextureDelegateManager.CreateResourceInfo(
361
+ texture_manage.GetId(),
362
+ name
363
+ );
364
+
365
+ let EA = null;
366
+ if (empty_rect) {
367
+ EA = {x: 0, y: 0, w: 0, h: 0};
368
+ Object.assign(EA, empty_rect);
369
+ }
370
+ resource_info["Set"] = {
371
+ ST: str,
372
+ IDS: tsp.GetIdsPack(),
373
+ W: Math.floor(rect_area.width + 0.5),
374
+ H: Math.floor(rect_area.height + 0.5),
375
+ FS: font_size,
376
+ LA: latex_mode,
377
+ EM: has_emoji,
378
+ LH: Math.floor(line_height + 0.5),
379
+ ILD: is_instant ? 1 : 0,
380
+ TLC: has_load_callback ? 1 : 0,
381
+ EA,
382
+ };
383
+
384
+ super(texture_manage, resource_info);
385
+
386
+ this.Name = name;
387
+ this._TextStylePack = tsp;
388
+ tsp.DoRef();
389
+ }
390
+
391
+ // Override
392
+ UnloadTex() {
393
+ this._TextStylePack.UnRef();
394
+ super.UnloadTex();
395
+ }
396
+ }
397
+ Forge.TextStyleTexture = TextStyleTexture;
398
+
399
+ class CachedTextureManager {
400
+ constructor(texture_manager) {
401
+ this._TextureManager = texture_manager;
402
+ this._Renderer = texture_manager.GetRenderer();
403
+ this._CachedTextureStack = [];
404
+ this._LockedTextureStack = [];
405
+ this._MemoryLimited = 10 * 1024 * 1024; // Limit to 10M
406
+ this._VisibleMark = 1;
407
+ // this._MemoryLimited = 2 * 1024 * 1024; // Limit to 1M for test
408
+ }
409
+
410
+ SetMemoryLimited(new_limit) {
411
+ this._MemoryLimited = new_limit * 1024 * 1024;
412
+ }
413
+
414
+ _FindTexture(url, size, color_space) {
415
+ const stack_length = this._CachedTextureStack.length;
416
+ for (let i = stack_length - 1; i >= 0; i--) {
417
+ const compare_texture = this._CachedTextureStack[i];
418
+ if (
419
+ compare_texture.Source === url &&
420
+ (size === compare_texture.TargetSize ||
421
+ (size !== null && size.Equals(compare_texture.TargetSize))) &&
422
+ color_space === compare_texture.ColorSpace
423
+ ) {
424
+ if (compare_texture.RenderTexture === null) {
425
+ continue;
426
+ }
427
+ return compare_texture;
428
+ }
429
+ }
430
+
431
+ return null;
432
+ }
433
+
434
+ CacheTheTexture(texture_to_cache) {
435
+ const stack_length = this._CachedTextureStack.length;
436
+ for (let i = stack_length - 1; i >= 0; i--) {
437
+ if (texture_to_cache === this._CachedTextureStack[i]) return;
438
+ }
439
+ this._CachedTextureStack.push(texture_to_cache);
440
+ }
441
+
442
+ _MarkVisibleViewTextures(check_view, new_mark) {
443
+ if (check_view.TextureSetting && check_view.TextureSetting.Texture) {
444
+ check_view.TextureSetting.Texture.VisibleMark = new_mark;
445
+ }
446
+
447
+ const child_view_length = check_view.ChildViews.length;
448
+ for (let i = 0; i < child_view_length; i++) {
449
+ const child_view = check_view.ChildViews[i];
450
+ if (child_view && child_view.Visibility !== "VISIBLE") {
451
+ continue;
452
+ }
453
+ this._MarkVisibleViewTextures(child_view, new_mark);
454
+ }
455
+ }
456
+
457
+ ReduceInvisibleTexture(main_view) {
458
+ this._MarkVisibleViewTextures(main_view, ++this._VisibleMark);
459
+ for (let i = 0; i < this._CachedTextureStack.length; i++) {
460
+ const texture = this._CachedTextureStack[i];
461
+ if (texture.VisibleMark === this._VisibleMark) {
462
+ continue;
463
+ }
464
+ texture.UnloadTex();
465
+ // Remove from stack
466
+ this._CachedTextureStack.splice(i, 1);
467
+ i--; // reset looper
468
+ }
469
+ }
470
+
471
+ GetCacheSize() {
472
+ return this._CachedTextureStack.length;
473
+ }
474
+ }
475
+ Forge.CachedTextureManager = CachedTextureManager;
476
+
477
+ const TEXT_FONT_STYLE_CACHE = new Map();
478
+ let TEXT_FONT_STYLE_TOKEN = 0;
479
+ const TEXT_DISPLAY_STYLE_CACHE = new Map();
480
+ let TEXT_DISPLAY_STYLE_TOKEN = 0;
481
+ class TextureManager {
482
+ constructor() {
483
+ this.CachedTextureManager = new Forge.CachedTextureManager(this);
484
+ this._ForeverCachedTextureManager = new Forge.CachedTextureManager(this);
485
+
486
+ this._AtlasDataInfo = {
487
+ atlas_data: [],
488
+ buffer_data_offset: 0,
489
+ textures: [],
490
+ };
491
+
492
+ // Cached image stack cleaner
493
+ this._ClearTimer = -1;
494
+
495
+ this._ImageTextureTracer = [];
496
+
497
+ // TextureManager Id
498
+ this._Id = TextureManager.sTextureManagerToken++;
499
+
500
+ this._CacheMaxSize = CONST_CACHE_MAX_SIZE;
501
+
502
+ this.StartScavengerCachedTimer();
503
+ }
504
+
505
+ StartScavengerCachedTimer() {
506
+ if (this._ClearTimer === -1) {
507
+ this._ClearTimer = Forge.ForegroundTimer.setInterval(
508
+ this.ScavengerCached.bind(this),
509
+ 30000
510
+ );
511
+ }
512
+ }
513
+
514
+ GetId() {
515
+ return this._Id;
516
+ }
517
+
518
+ GetRenderer() {
519
+ return Forge.sDeprecatedRenderer;
520
+ }
521
+
522
+ GetGifImage(url, is_forever, net_setting) {
523
+ return this.GetImage(url, is_forever, net_setting);
524
+ }
525
+
526
+ GetImage(url, is_forever, net_setting) {
527
+ // return this.GetImage2(url, is_forever, new Forge.RectArea(0, 0, 150, 150));
528
+ if (!url) {
529
+ Forge.LogI("GetImage, url is null!");
530
+ return null;
531
+ }
532
+ const texture_new = this._GetImageInternal(
533
+ url,
534
+ null,
535
+ Forge.ColorSpace.RGBA_8888,
536
+ is_forever,
537
+ false,
538
+ net_setting
539
+ );
540
+ return texture_new;
541
+ }
542
+
543
+ GetImage2(url, is_forever, target_size, color_space, net_setting) {
544
+ if (!url) {
545
+ Forge.LogI("GetImage2, url is null!");
546
+ return null;
547
+ }
548
+ const formated_target_size = Forge.sRectUitls.FormatRectArea(target_size);
549
+ if (typeof color_space !== "string") {
550
+ if (url.indexOf(".pkm") >= 0) {
551
+ if (url.indexOf(".pkma") >= 0) {
552
+ color_space = Forge.ColorSpace.RGBA_ETC1;
553
+ } else {
554
+ color_space = Forge.ColorSpace.RGB_ETC1;
555
+ }
556
+ } else {
557
+ color_space = Forge.ColorSpace.RGB_565;
558
+ }
559
+ }
560
+ const texture_new = this._GetImageInternal(
561
+ url,
562
+ formated_target_size,
563
+ color_space,
564
+ is_forever,
565
+ false,
566
+ net_setting
567
+ );
568
+ return texture_new;
569
+ }
570
+
571
+ CreateMiniGradientTexture(is_vertical, color_start, color_end, raw_value) {
572
+ const texture_new = new Forge.GradientTexture(this, is_vertical, color_start, color_end, raw_value);
573
+
574
+ return texture_new;
575
+ }
576
+
577
+
578
+ _GetImageInternal(
579
+ url,
580
+ target_size,
581
+ color_space,
582
+ is_forever,
583
+ is_gif,
584
+ net_setting
585
+ ) {
586
+ // 先尝试从Cache中拿取ImageTexture
587
+ if (!is_forever) {
588
+ const texture = this.CachedTextureManager._FindTexture(
589
+ url,
590
+ target_size,
591
+ color_space
592
+ );
593
+ if (texture) {
594
+ return texture;
595
+ }
596
+ } else {
597
+ const texture = this._ForeverCachedTextureManager._FindTexture(
598
+ url,
599
+ target_size,
600
+ color_space
601
+ );
602
+ if (texture) {
603
+ return texture;
604
+ }
605
+ }
606
+ const texture_new = new Forge.UrlImageTexture(
607
+ this,
608
+ url,
609
+ is_forever,
610
+ target_size,
611
+ color_space,
612
+ net_setting
613
+ );
614
+
615
+ // 加入到Cache中
616
+ if (!texture_new.IsForever) {
617
+ this.CachedTextureManager.CacheTheTexture(texture_new);
618
+ } else {
619
+ this._ForeverCachedTextureManager.CacheTheTexture(texture_new);
620
+ }
621
+
622
+ return texture_new;
623
+ }
624
+
625
+ GetRoundCornerMask(rect_area, rad) {
626
+ return this.GetCustomCornerMask(rect_area, rad, rad, rad, rad);
627
+ }
628
+
629
+ GetCustomCornerMask(
630
+ rect_area,
631
+ rad_left_top,
632
+ rad_right_top,
633
+ rad_left_bottom,
634
+ rad_right_bottom
635
+ ) {
636
+ const formatted_rect_area = Forge.sRectUitls.FormatRectArea(rect_area);
637
+ const max_rad = Math.max(
638
+ rad_left_top,
639
+ rad_right_top,
640
+ rad_left_bottom,
641
+ rad_right_bottom
642
+ );
643
+ if (
644
+ max_rad > formatted_rect_area.width / 2 ||
645
+ max_rad > formatted_rect_area.height / 2
646
+ ) {
647
+ Forge.LogE(
648
+ `TextureManager.GetRoundCornerMask(): radius is too large, radius=${max_rad} w=${formatted_rect_area.width} h=${formatted_rect_area.height}`
649
+ );
650
+ return null;
651
+ }
652
+ const resource_info = Forge.sRenderTextureDelegateManager.CreateResourceInfo(
653
+ this._Id,
654
+ "CCM"
655
+ );
656
+ resource_info.Set = {
657
+ W: formatted_rect_area.width,
658
+ H: formatted_rect_area.height,
659
+ LT: rad_left_top,
660
+ RT: rad_right_top,
661
+ LB: rad_left_bottom,
662
+ RB: rad_right_bottom,
663
+ };
664
+ const image_texture = new Forge.ImageTexture(this, resource_info);
665
+
666
+ if (Forge.ForgeDebug.EnableTextureTracer) {
667
+ image_texture.SetTextureTracerDescript("CornerMask");
668
+ }
669
+
670
+ return image_texture;
671
+ }
672
+
673
+ GetOneCornerMask(rad) {
674
+ const resource_info = Forge.sRenderTextureDelegateManager.CreateResourceInfo(
675
+ this._Id,
676
+ "OCM"
677
+ );
678
+ resource_info.Set = {
679
+ Rad: rad,
680
+ };
681
+ const image_texture = new Forge.ImageTexture(this, resource_info);
682
+
683
+ if (Forge.ForgeDebug.EnableTextureTracer) {
684
+ image_texture.SetTextureTracerDescript("OneCornerMask");
685
+ }
686
+
687
+ return image_texture;
688
+ }
689
+
690
+ /**
691
+ * 通过TextStylePack设定创建TextTexture
692
+ *
693
+ * @public
694
+ * @func BuildTextView
695
+ * @memberof Forge.TextureManager
696
+ * @param {String} str 文件内容
697
+ * @param {Forge.TextStylePack} tsp 文字配置信息
698
+ * @param {boolean} has_load_callback 是否有加载回调函数
699
+ * @param {Object} rect_area 文字描画区域,有宽高即可{width:xxxx, height:xxxx}, 当height为0表示按照文字长度处理高
700
+ * @param {int} font_size 字号
701
+ * @param {int} line_height 文字行高
702
+ * @param {int} is_instant 是否立即加载
703
+ * @param {boolean} latex_mode 多格式混排模式
704
+ * @param {boolean} has_emoji 是否含有emoji
705
+ * @param {Object} empty_rect {x: 0, y: 0, w: 0, h: 0} 文字留白区域
706
+ * @return {Forge.TextStyleTexture} 文字Texture
707
+ */
708
+ GetTextTextureFromStylePack(
709
+ str,
710
+ tsp,
711
+ has_load_callback,
712
+ rect_area,
713
+ font_size,
714
+ line_height,
715
+ is_instant,
716
+ latex_mode,
717
+ has_emoji,
718
+ empty_rect
719
+ ) {
720
+ if (!str || str.length === 0) {
721
+ return null;
722
+ }
723
+
724
+ return new Forge.TextStyleTexture(
725
+ this,
726
+ str,
727
+ tsp,
728
+ has_load_callback,
729
+ rect_area,
730
+ font_size,
731
+ line_height,
732
+ is_instant,
733
+ latex_mode,
734
+ has_emoji,
735
+ empty_rect,
736
+ );
737
+ }
738
+
739
+ _getParamsId(string_with_font, attr, shader) {
740
+ const font = string_with_font.font;
741
+ const size = string_with_font.size;
742
+ const italic = string_with_font.italic;
743
+ const bold = string_with_font.bold;
744
+ const alignment = string_with_font.alignment;
745
+ const vertical_align = string_with_font.vertical_align;
746
+ const vertical_area_align = string_with_font.vertical_area_align;
747
+ const text_color = string_with_font.textColour;
748
+ const bg_color = string_with_font.backgroundColour;
749
+ // let enable_blend = string_with_font.enableBlend;
750
+ const shadow = string_with_font.shadow;
751
+ let stroke_width = "";
752
+ if (string_with_font.stroke_width) {
753
+ stroke_width = string_with_font.stroke_width;
754
+ }
755
+ const text_overflow = attr.text_overflow;
756
+ const word_wrap = attr.word_wrap;
757
+
758
+ const fs_key = [font, italic, bold, shadow, stroke_width].join(":");
759
+ const ds_key = [
760
+ size,
761
+ alignment,
762
+ vertical_align,
763
+ vertical_area_align,
764
+ text_overflow,
765
+ word_wrap,
766
+ ].join(":");
767
+ let fs_id = "";
768
+ let ds_id = "";
769
+ if (!TEXT_FONT_STYLE_CACHE.has(fs_key)) {
770
+ fs_id = `TS${TEXT_FONT_STYLE_TOKEN}`;
771
+ TEXT_FONT_STYLE_CACHE.set(fs_key, fs_id);
772
+ TEXT_FONT_STYLE_TOKEN++;
773
+ } else {
774
+ fs_id = TEXT_FONT_STYLE_CACHE.get(fs_key);
775
+ }
776
+
777
+ if (!TEXT_DISPLAY_STYLE_CACHE.has(ds_key)) {
778
+ ds_id = `DS${TEXT_DISPLAY_STYLE_TOKEN}`;
779
+ TEXT_DISPLAY_STYLE_CACHE.set(ds_key, ds_id);
780
+ TEXT_DISPLAY_STYLE_TOKEN++;
781
+ } else {
782
+ ds_id = TEXT_DISPLAY_STYLE_CACHE.get(ds_key);
783
+ }
784
+ return [fs_id, ds_id, text_color, bg_color];
785
+ }
786
+
787
+ GetTextTextureByMultiRows(
788
+ t_StringWithFont,
789
+ t_TextAttr,
790
+ t_RectArea,
791
+ line_height,
792
+ need_quick,
793
+ shader,
794
+ is_instant,
795
+ latex_mode,
796
+ duplicate_info_bag
797
+ ) {
798
+ const text = t_StringWithFont.str;
799
+ if (text === null || text.length === 0) {
800
+ return null;
801
+ }
802
+
803
+ // 清晰度调整
804
+ const screen_info = Forge.sRenderBridge.GetScreenInfo();
805
+ const display_scale_ratio = screen_info.scaleRatio;
806
+ const rect_area = Object.assign(t_RectArea);
807
+
808
+ rect_area.x *= display_scale_ratio;
809
+ rect_area.y *= display_scale_ratio;
810
+ rect_area.width *= display_scale_ratio;
811
+ rect_area.height *= display_scale_ratio;
812
+ const string_with_font = Object.assign(t_StringWithFont);
813
+ string_with_font.size = Math.ceil(
814
+ string_with_font.size * display_scale_ratio
815
+ );
816
+ line_height *= display_scale_ratio;
817
+
818
+ // Create TextTexture Setting Info
819
+ const texture_set = {
820
+ ST: t_StringWithFont.str,
821
+ AT: JSON.stringify({
822
+ // 【重要】
823
+ // 顺序不能调整,native按顺序而非key-value读取
824
+ // 字段追加只能放在末尾
825
+ TO: t_TextAttr.text_overflow,
826
+ WW: t_TextAttr.word_wrap,
827
+ }),
828
+ RA: JSON.stringify({
829
+ X: parseInt(rect_area.x + 0.5, 10),
830
+ Y: parseInt(rect_area.y + 0.5, 10),
831
+ W: parseInt(rect_area.width + 0.5, 10),
832
+ H: parseInt(rect_area.height + 0.5, 10),
833
+ }),
834
+ LA: latex_mode,
835
+ LH: parseInt(line_height + 0.5, 10),
836
+ ILD: typeof is_instant !== "undefined" ? is_instant : 1,
837
+ };
838
+
839
+ // 若有shader,则传输
840
+ if (shader) {
841
+ texture_set.SH = JSON.stringify({
842
+ T: shader.Type, // type
843
+ P: shader.Params, // params
844
+ });
845
+ }
846
+ if (
847
+ typeof window.JsView !== "undefined" &&
848
+ typeof window.JsView.ForgeNativeRevision !== "undefined" &&
849
+ window.JsView.ForgeNativeRevision > 0
850
+ ) {
851
+ const ids = this._getParamsId(string_with_font, t_TextAttr, shader);
852
+ texture_set.PI = {
853
+ FS: ids[0],
854
+ DS: ids[1],
855
+ TC: ids[2],
856
+ BC: ids[3],
857
+ };
858
+ }
859
+
860
+ // 创建TextTexture
861
+ const texture = this._BuildTextTextureAndSerialStatus(
862
+ texture_set,
863
+ string_with_font
864
+ );
865
+
866
+ // 填充Duplicate信息
867
+ if (duplicate_info_bag !== null) {
868
+ const dup_texture_set = Object.assign({}, texture_set);
869
+
870
+ // 重置Style以外的配置
871
+ dup_texture_set.ST = null;
872
+ dup_texture_set.TLC = 0;
873
+
874
+ // 进行记录
875
+ duplicate_info_bag.Set = dup_texture_set;
876
+ duplicate_info_bag.Swf = Object.assign({}, string_with_font);
877
+ }
878
+
879
+ let real_height = rect_area.height;
880
+ if (typeof window.PlatformUtils !== "undefined" && need_quick === false) {
881
+ const real_rect = window.PlatformUtils.GetTextRect(
882
+ text,
883
+ rect_area,
884
+ string_with_font,
885
+ t_TextAttr,
886
+ line_height
887
+ );
888
+ real_height = real_rect.height;
889
+ }
890
+
891
+ real_height = Math.floor(real_height / display_scale_ratio + 0.5);
892
+
893
+ if (Forge.ForgeDebug.EnableTextureTracer) {
894
+ let descript = t_StringWithFont.str;
895
+ if (descript.length > 8) {
896
+ descript = `${t_StringWithFont.str.substr(0, 8)}...`;
897
+ }
898
+ texture.SetTextureTracerDescript(`[${descript}]`);
899
+ }
900
+
901
+ return {
902
+ texture, // export member
903
+ real_height, // export member
904
+ };
905
+ }
906
+
907
+ /**
908
+ * 快速重建属性相同的的TextTexture
909
+ * hide public
910
+ *
911
+ * @protected
912
+ * @func GetCopiedTextTexture
913
+ * @memberof Forge.TextureManager
914
+ * @instance
915
+ * @param {String} text 描画的文字信息
916
+ * @param {Object} duplicate_info_bag 含有{Set, Swf(StringWithFont设定)}
917
+ * @param {bool} if_texture_onload_callback 是否texture加载回调
918
+ * @return {Forge.TextTexture} 创建完成的文字Texture
919
+ * */
920
+ GetCopiedTextTexture(
921
+ text,
922
+ text_area,
923
+ duplicate_info_bag,
924
+ if_texture_onload_callback
925
+ ) {
926
+ // 取出TextureSetting和StringWithFont信息
927
+ const texture_set = Object.assign({}, duplicate_info_bag.Set);
928
+ texture_set.ST = text;
929
+ texture_set.TLC =
930
+ typeof if_texture_onload_callback !== "undefined" &&
931
+ if_texture_onload_callback
932
+ ? 1
933
+ : 0;
934
+ const string_with_font = duplicate_info_bag.Swf;
935
+
936
+ // 重新配置Size
937
+ const display_scale_ratio = Forge.sRenderBridge.GetScreenInfo().scaleRatio;
938
+ texture_set.RA = JSON.stringify({
939
+ X: parseInt(text_area.x * display_scale_ratio + 0.5, 10),
940
+ Y: parseInt(text_area.y * display_scale_ratio + 0.5, 10),
941
+ W: parseInt(text_area.width * display_scale_ratio + 0.5, 10),
942
+ H: parseInt(text_area.height * display_scale_ratio + 0.5, 10),
943
+ });
944
+
945
+ // 创建TextTexture
946
+ const texture = this._BuildTextTextureAndSerialStatus(
947
+ texture_set,
948
+ string_with_font
949
+ );
950
+
951
+ if (Forge.ForgeDebug.EnableTextureTracer && text) {
952
+ let descript = text;
953
+ if (descript.length > 8) {
954
+ descript = `${text.substr(0, 8)}...`;
955
+ }
956
+ texture.SetTextureTracerDescript(`[${descript}]`);
957
+ }
958
+
959
+ return texture;
960
+ }
961
+
962
+ // 创建文字的Texture,文字信息传输时,共通的信息会通过串行化的同步发送的Status传递
963
+ _BuildTextTextureAndSerialStatus(texture_set, string_with_font) {
964
+ Forge.sRenderTextureDelegateManager.AppendFontStatusIfNeed(
965
+ texture_set,
966
+ string_with_font
967
+ );
968
+ let status = null;
969
+
970
+ if (texture_set.FO) {
971
+ // 状态变化后,串行化Status信息
972
+ status = {
973
+ STA: {
974
+ Nam: "T",
975
+ Sta: texture_set.FO,
976
+ },
977
+ };
978
+ }
979
+ const resource_info = Forge.sRenderTextureDelegateManager.CreateResourceInfo(
980
+ this._Id,
981
+ "T"
982
+ );
983
+ resource_info.Set = texture_set;
984
+
985
+ return new Forge.ImageTexture(this, resource_info, status);
986
+ }
987
+
988
+ GetColorTexture(fill_style) {
989
+ const resource_info = Forge.sRenderTextureDelegateManager.CreateResourceInfo(
990
+ this._Id,
991
+ "CT"
992
+ );
993
+ resource_info.Set = {
994
+ Clr: fill_style,
995
+ };
996
+ const image_texture = new Forge.ImageTexture(this, resource_info);
997
+
998
+ if (Forge.ForgeDebug.EnableTextureTracer) {
999
+ image_texture.SetTextureTracerDescript(`Color[${fill_style}]`);
1000
+ }
1001
+
1002
+ return image_texture;
1003
+ }
1004
+
1005
+ GetColorTextureCached(fill_style) {
1006
+ // PC Browser版本简化为非cache管理
1007
+ return this.GetColorTexture(fill_style);
1008
+ }
1009
+
1010
+ ScavengerCached() {
1011
+ const cache_size = this.CachedTextureManager.GetCacheSize();
1012
+ if (cache_size >= this._CacheMaxSize) {
1013
+ this.CachedTextureManager.ReduceInvisibleTexture(Forge.sRootView);
1014
+ }
1015
+ }
1016
+
1017
+ GetOffScreenMediaTexture(video_player_hdl) {
1018
+ if (
1019
+ typeof window.OffscreenVideoPlayer === "undefined" ||
1020
+ !(video_player_hdl instanceof window.OffscreenVideoPlayer)
1021
+ ) {
1022
+ // 未运行在JsView中
1023
+ return null;
1024
+ }
1025
+
1026
+ if (!video_player_hdl.hasTerminator()) {
1027
+ const main_texture = this._BuildVideoTexture(video_player_hdl);
1028
+
1029
+ // 当播放器释放时,清理Texture资源
1030
+ video_player_hdl.setResourceTerminator(() => {
1031
+ main_texture.UnloadTex();
1032
+ });
1033
+ }
1034
+
1035
+ return this._BuildVideoTexture(video_player_hdl);
1036
+ }
1037
+
1038
+ _BuildVideoTexture(video_player_hdl) {
1039
+ const resource_info = Forge.sRenderTextureDelegateManager.CreateResourceInfo(
1040
+ this._Id,
1041
+ "VPLY"
1042
+ );
1043
+ resource_info.Set = {
1044
+ Hdl: video_player_hdl.mediaHandler(),
1045
+ };
1046
+
1047
+ const image_texture = new Forge.ImageTexture(this, resource_info);
1048
+ if (Forge.ForgeDebug.EnableTextureTracer) {
1049
+ image_texture.SetTextureTracerDescript(
1050
+ `Video[${video_player_hdl.mediaHandler()}]`
1051
+ );
1052
+ }
1053
+
1054
+ return image_texture;
1055
+ }
1056
+ }
1057
+ TextureManager.sTextureManagerToken = 100;
1058
+ Forge.TextureManager = TextureManager;
1059
+ window.TextureManager = Forge.TextureManager; // export class
1060
+ export { TextureManager };