@itwin/core-frontend 3.1.0-dev.1 → 3.1.0-dev.8

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 (193) hide show
  1. package/lib/cjs/BriefcaseConnection.d.ts.map +1 -1
  2. package/lib/cjs/BriefcaseConnection.js +6 -5
  3. package/lib/cjs/BriefcaseConnection.js.map +1 -1
  4. package/lib/cjs/DrawingViewState.js +3 -3
  5. package/lib/cjs/DrawingViewState.js.map +1 -1
  6. package/lib/cjs/SheetViewState.js +3 -3
  7. package/lib/cjs/SheetViewState.js.map +1 -1
  8. package/lib/cjs/Viewport.d.ts +6 -3
  9. package/lib/cjs/Viewport.d.ts.map +1 -1
  10. package/lib/cjs/Viewport.js +16 -9
  11. package/lib/cjs/Viewport.js.map +1 -1
  12. package/lib/cjs/render/webgl/Texture.d.ts.map +1 -1
  13. package/lib/cjs/render/webgl/Texture.js +2 -2
  14. package/lib/cjs/render/webgl/Texture.js.map +1 -1
  15. package/lib/cjs/tile/DynamicIModelTile.d.ts.map +1 -1
  16. package/lib/cjs/tile/DynamicIModelTile.js +1 -1
  17. package/lib/cjs/tile/DynamicIModelTile.js.map +1 -1
  18. package/lib/cjs/tile/LRUTileList.d.ts +29 -29
  19. package/lib/cjs/tile/LRUTileList.d.ts.map +1 -1
  20. package/lib/cjs/tile/LRUTileList.js +50 -50
  21. package/lib/cjs/tile/LRUTileList.js.map +1 -1
  22. package/lib/cjs/tile/OrbitGtTileTree.js +1 -1
  23. package/lib/cjs/tile/OrbitGtTileTree.js.map +1 -1
  24. package/lib/cjs/tile/RealityModelTileTree.d.ts.map +1 -1
  25. package/lib/cjs/tile/RealityModelTileTree.js +1 -1
  26. package/lib/cjs/tile/RealityModelTileTree.js.map +1 -1
  27. package/lib/cjs/tile/RealityTile.d.ts +2 -2
  28. package/lib/cjs/tile/RealityTile.d.ts.map +1 -1
  29. package/lib/cjs/tile/RealityTile.js +2 -2
  30. package/lib/cjs/tile/RealityTile.js.map +1 -1
  31. package/lib/cjs/tile/RealityTileLoader.d.ts +2 -2
  32. package/lib/cjs/tile/RealityTileLoader.d.ts.map +1 -1
  33. package/lib/cjs/tile/RealityTileLoader.js +1 -1
  34. package/lib/cjs/tile/RealityTileLoader.js.map +1 -1
  35. package/lib/cjs/tile/RealityTileTree.js +1 -1
  36. package/lib/cjs/tile/RealityTileTree.js.map +1 -1
  37. package/lib/cjs/tile/Tile.d.ts +5 -4
  38. package/lib/cjs/tile/Tile.d.ts.map +1 -1
  39. package/lib/cjs/tile/Tile.js +3 -2
  40. package/lib/cjs/tile/Tile.js.map +1 -1
  41. package/lib/cjs/tile/TileAdmin.d.ts +43 -45
  42. package/lib/cjs/tile/TileAdmin.d.ts.map +1 -1
  43. package/lib/cjs/tile/TileAdmin.js +104 -99
  44. package/lib/cjs/tile/TileAdmin.js.map +1 -1
  45. package/lib/cjs/tile/TileRequest.d.ts +12 -9
  46. package/lib/cjs/tile/TileRequest.d.ts.map +1 -1
  47. package/lib/cjs/tile/TileRequest.js +19 -11
  48. package/lib/cjs/tile/TileRequest.js.map +1 -1
  49. package/lib/cjs/tile/TileRequestChannel.js +3 -3
  50. package/lib/cjs/tile/TileRequestChannel.js.map +1 -1
  51. package/lib/cjs/tile/TileTree.js +1 -1
  52. package/lib/cjs/tile/TileTree.js.map +1 -1
  53. package/lib/cjs/tile/TileTreeReference.d.ts +1 -1
  54. package/lib/cjs/tile/TileTreeReference.js +1 -1
  55. package/lib/cjs/tile/TileTreeReference.js.map +1 -1
  56. package/lib/cjs/tile/TileUsageMarker.d.ts +9 -9
  57. package/lib/cjs/tile/TileUsageMarker.d.ts.map +1 -1
  58. package/lib/cjs/tile/TileUsageMarker.js +9 -9
  59. package/lib/cjs/tile/TileUsageMarker.js.map +1 -1
  60. package/lib/cjs/tile/TileUser.d.ts +33 -0
  61. package/lib/cjs/tile/TileUser.d.ts.map +1 -0
  62. package/lib/cjs/tile/TileUser.js +28 -0
  63. package/lib/cjs/tile/TileUser.js.map +1 -0
  64. package/lib/cjs/tile/TileUserSet.d.ts +28 -0
  65. package/lib/cjs/tile/TileUserSet.d.ts.map +1 -0
  66. package/lib/cjs/tile/TileUserSet.js +123 -0
  67. package/lib/cjs/tile/TileUserSet.js.map +1 -0
  68. package/lib/cjs/tile/internal.d.ts +2 -0
  69. package/lib/cjs/tile/internal.d.ts.map +1 -1
  70. package/lib/cjs/tile/internal.js +2 -0
  71. package/lib/cjs/tile/internal.js.map +1 -1
  72. package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts +1 -2
  73. package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
  74. package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +1 -1
  75. package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
  76. package/lib/cjs/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.d.ts +1 -2
  77. package/lib/cjs/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.d.ts.map +1 -1
  78. package/lib/cjs/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.js +1 -1
  79. package/lib/cjs/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.js.map +1 -1
  80. package/lib/cjs/tile/map/ImageryProviders/BingImageryProvider.js +1 -1
  81. package/lib/cjs/tile/map/ImageryProviders/BingImageryProvider.js.map +1 -1
  82. package/lib/cjs/tile/map/ImageryProviders/MapBoxLayerImageryProvider.d.ts +1 -2
  83. package/lib/cjs/tile/map/ImageryProviders/MapBoxLayerImageryProvider.d.ts.map +1 -1
  84. package/lib/cjs/tile/map/ImageryProviders/MapBoxLayerImageryProvider.js +1 -1
  85. package/lib/cjs/tile/map/ImageryProviders/MapBoxLayerImageryProvider.js.map +1 -1
  86. package/lib/cjs/tile/map/ImageryTileTree.d.ts +2 -2
  87. package/lib/cjs/tile/map/ImageryTileTree.d.ts.map +1 -1
  88. package/lib/cjs/tile/map/ImageryTileTree.js +1 -1
  89. package/lib/cjs/tile/map/ImageryTileTree.js.map +1 -1
  90. package/lib/cjs/tile/map/MapTileTree.d.ts +3 -3
  91. package/lib/cjs/tile/map/MapTileTree.js +4 -4
  92. package/lib/cjs/tile/map/MapTileTree.js.map +1 -1
  93. package/lib/esm/BriefcaseConnection.d.ts.map +1 -1
  94. package/lib/esm/BriefcaseConnection.js +6 -5
  95. package/lib/esm/BriefcaseConnection.js.map +1 -1
  96. package/lib/esm/DrawingViewState.js +3 -3
  97. package/lib/esm/DrawingViewState.js.map +1 -1
  98. package/lib/esm/SheetViewState.js +3 -3
  99. package/lib/esm/SheetViewState.js.map +1 -1
  100. package/lib/esm/Viewport.d.ts +6 -3
  101. package/lib/esm/Viewport.d.ts.map +1 -1
  102. package/lib/esm/Viewport.js +17 -10
  103. package/lib/esm/Viewport.js.map +1 -1
  104. package/lib/esm/render/webgl/Texture.d.ts.map +1 -1
  105. package/lib/esm/render/webgl/Texture.js +2 -2
  106. package/lib/esm/render/webgl/Texture.js.map +1 -1
  107. package/lib/esm/tile/DynamicIModelTile.d.ts.map +1 -1
  108. package/lib/esm/tile/DynamicIModelTile.js +1 -1
  109. package/lib/esm/tile/DynamicIModelTile.js.map +1 -1
  110. package/lib/esm/tile/LRUTileList.d.ts +29 -29
  111. package/lib/esm/tile/LRUTileList.d.ts.map +1 -1
  112. package/lib/esm/tile/LRUTileList.js +47 -47
  113. package/lib/esm/tile/LRUTileList.js.map +1 -1
  114. package/lib/esm/tile/OrbitGtTileTree.js +1 -1
  115. package/lib/esm/tile/OrbitGtTileTree.js.map +1 -1
  116. package/lib/esm/tile/RealityModelTileTree.d.ts.map +1 -1
  117. package/lib/esm/tile/RealityModelTileTree.js +1 -1
  118. package/lib/esm/tile/RealityModelTileTree.js.map +1 -1
  119. package/lib/esm/tile/RealityTile.d.ts +2 -2
  120. package/lib/esm/tile/RealityTile.d.ts.map +1 -1
  121. package/lib/esm/tile/RealityTile.js +2 -2
  122. package/lib/esm/tile/RealityTile.js.map +1 -1
  123. package/lib/esm/tile/RealityTileLoader.d.ts +2 -2
  124. package/lib/esm/tile/RealityTileLoader.d.ts.map +1 -1
  125. package/lib/esm/tile/RealityTileLoader.js +1 -1
  126. package/lib/esm/tile/RealityTileLoader.js.map +1 -1
  127. package/lib/esm/tile/RealityTileTree.js +1 -1
  128. package/lib/esm/tile/RealityTileTree.js.map +1 -1
  129. package/lib/esm/tile/Tile.d.ts +5 -4
  130. package/lib/esm/tile/Tile.d.ts.map +1 -1
  131. package/lib/esm/tile/Tile.js +3 -2
  132. package/lib/esm/tile/Tile.js.map +1 -1
  133. package/lib/esm/tile/TileAdmin.d.ts +43 -45
  134. package/lib/esm/tile/TileAdmin.d.ts.map +1 -1
  135. package/lib/esm/tile/TileAdmin.js +105 -100
  136. package/lib/esm/tile/TileAdmin.js.map +1 -1
  137. package/lib/esm/tile/TileRequest.d.ts +12 -9
  138. package/lib/esm/tile/TileRequest.d.ts.map +1 -1
  139. package/lib/esm/tile/TileRequest.js +19 -11
  140. package/lib/esm/tile/TileRequest.js.map +1 -1
  141. package/lib/esm/tile/TileRequestChannel.js +3 -3
  142. package/lib/esm/tile/TileRequestChannel.js.map +1 -1
  143. package/lib/esm/tile/TileTree.js +1 -1
  144. package/lib/esm/tile/TileTree.js.map +1 -1
  145. package/lib/esm/tile/TileTreeReference.d.ts +1 -1
  146. package/lib/esm/tile/TileTreeReference.js +1 -1
  147. package/lib/esm/tile/TileTreeReference.js.map +1 -1
  148. package/lib/esm/tile/TileUsageMarker.d.ts +9 -9
  149. package/lib/esm/tile/TileUsageMarker.d.ts.map +1 -1
  150. package/lib/esm/tile/TileUsageMarker.js +9 -9
  151. package/lib/esm/tile/TileUsageMarker.js.map +1 -1
  152. package/lib/esm/tile/TileUser.d.ts +33 -0
  153. package/lib/esm/tile/TileUser.d.ts.map +1 -0
  154. package/lib/esm/tile/TileUser.js +25 -0
  155. package/lib/esm/tile/TileUser.js.map +1 -0
  156. package/lib/esm/tile/TileUserSet.d.ts +28 -0
  157. package/lib/esm/tile/TileUserSet.d.ts.map +1 -0
  158. package/lib/esm/tile/TileUserSet.js +118 -0
  159. package/lib/esm/tile/TileUserSet.js.map +1 -0
  160. package/lib/esm/tile/internal.d.ts +2 -0
  161. package/lib/esm/tile/internal.d.ts.map +1 -1
  162. package/lib/esm/tile/internal.js +2 -0
  163. package/lib/esm/tile/internal.js.map +1 -1
  164. package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts +1 -2
  165. package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
  166. package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +1 -1
  167. package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
  168. package/lib/esm/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.d.ts +1 -2
  169. package/lib/esm/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.d.ts.map +1 -1
  170. package/lib/esm/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.js +1 -1
  171. package/lib/esm/tile/map/ImageryProviders/AzureMapsLayerImageryProvider.js.map +1 -1
  172. package/lib/esm/tile/map/ImageryProviders/BingImageryProvider.js +1 -1
  173. package/lib/esm/tile/map/ImageryProviders/BingImageryProvider.js.map +1 -1
  174. package/lib/esm/tile/map/ImageryProviders/MapBoxLayerImageryProvider.d.ts +1 -2
  175. package/lib/esm/tile/map/ImageryProviders/MapBoxLayerImageryProvider.d.ts.map +1 -1
  176. package/lib/esm/tile/map/ImageryProviders/MapBoxLayerImageryProvider.js +1 -1
  177. package/lib/esm/tile/map/ImageryProviders/MapBoxLayerImageryProvider.js.map +1 -1
  178. package/lib/esm/tile/map/ImageryTileTree.d.ts +2 -2
  179. package/lib/esm/tile/map/ImageryTileTree.d.ts.map +1 -1
  180. package/lib/esm/tile/map/ImageryTileTree.js +1 -1
  181. package/lib/esm/tile/map/ImageryTileTree.js.map +1 -1
  182. package/lib/esm/tile/map/MapTileTree.d.ts +3 -3
  183. package/lib/esm/tile/map/MapTileTree.js +4 -4
  184. package/lib/esm/tile/map/MapTileTree.js.map +1 -1
  185. package/package.json +20 -20
  186. package/lib/cjs/ViewportSet.d.ts +0 -28
  187. package/lib/cjs/ViewportSet.d.ts.map +0 -1
  188. package/lib/cjs/ViewportSet.js +0 -126
  189. package/lib/cjs/ViewportSet.js.map +0 -1
  190. package/lib/esm/ViewportSet.d.ts +0 -28
  191. package/lib/esm/ViewportSet.d.ts.map +0 -1
  192. package/lib/esm/ViewportSet.js +0 -121
  193. package/lib/esm/ViewportSet.js.map +0 -1
@@ -4,34 +4,34 @@
4
4
  import { ReadonlySortedArray, SortedArray } from "@itwin/core-bentley";
5
5
  import { RenderMemory } from "../render/RenderMemory";
6
6
  import { Tile } from "./internal";
7
- /** Maintains in sorted order a set of Viewport Ids for which a given tile has been selected for display. The number of viewports in a set is expected to be very small - often only 1 for a typical application.
7
+ /** Maintains in sorted order a set of [[TileUser]] Ids for which a given tile has been selected for display. The number of users in a set is expected to be very small - often only 1 for a typical application.
8
8
  * Strictly for use by LRUTileList.
9
- * @see ViewportIdSets.
9
+ * @see TileUserIdSets.
10
10
  * @internal
11
11
  */
12
- export declare class ViewportIdSet extends ReadonlySortedArray<number> {
13
- constructor(viewportId?: number);
14
- equals(set: ViewportIdSet): boolean;
15
- add(viewportId: number): void;
16
- drop(viewportId: number): void;
12
+ export declare class TileUserIdSet extends ReadonlySortedArray<number> {
13
+ constructor(userId?: number);
14
+ equals(set: TileUserIdSet): boolean;
15
+ add(userId: number): void;
16
+ drop(userId: number): void;
17
17
  clear(): void;
18
- copyFrom(src: ViewportIdSet): void;
19
- clone(): ViewportIdSet;
18
+ copyFrom(src: TileUserIdSet): void;
19
+ clone(): TileUserIdSet;
20
20
  }
21
- /** Maintains a set of ViewportIdSets such that each set represents a unique combination of Viewport ids and each set contains at least one Viewport id.
21
+ /** Maintains a set of TileUserIdSets such that each set represents a unique combination of TileUser ids and each set contains at least one TileUser id.
22
22
  * Exported strictly for tests.
23
23
  * @see LRUTileList.
24
24
  * @internal
25
25
  */
26
- export declare class ViewportIdSets extends SortedArray<ViewportIdSet> {
26
+ export declare class TileUserIdSets extends SortedArray<TileUserIdSet> {
27
27
  private readonly _scratch;
28
28
  constructor();
29
- /** Remove the specified viewport Id from all sets and remove empty and duplicate sets. */
30
- drop(viewportId: number): void;
31
- /** Obtain a ViewportIdSet owned by this object containing viewportId and (if specified) viewportIds. */
32
- plus(viewportId: number, viewportIds?: ViewportIdSet): ViewportIdSet;
33
- /** Obtain a ViewportIdSet owned by this object containing all of viewportIds (if specified) but not viewportId. Returns undefined if the resultant set would be empty. */
34
- minus(viewportId: number, viewportIds?: ViewportIdSet): ViewportIdSet | undefined;
29
+ /** Remove the specified TileUser Id from all sets and remove empty and duplicate sets. */
30
+ drop(userId: number): void;
31
+ /** Obtain a TileUserIdSet owned by this object containing userId and (if specified) userIds. */
32
+ plus(userId: number, userIds?: TileUserIdSet): TileUserIdSet;
33
+ /** Obtain a TileUserIdSet owned by this object containing all of userIds (if specified) but not userId. Returns undefined if the resultant set would be empty. */
34
+ minus(userId: number, userIds?: TileUserIdSet): TileUserIdSet | undefined;
35
35
  private scratch;
36
36
  private getEquivalent;
37
37
  }
@@ -44,12 +44,12 @@ export interface LRUTileListNode {
44
44
  next?: LRUTileListNode;
45
45
  /** The number of bytes of GPU memory allocated to the tile's content. The only node in a LRUTileListNode with `bytesUsed` less than 1 is the sentinel node. */
46
46
  bytesUsed: number;
47
- /** For a tile, the Ids of all of the Viewports for which the tile is currently selected for display. The ViewportIdSet is owned by the LRUTileList's ViewportIdSets member.
48
- * Undefined if the tile is not selected for display in any viewport.
47
+ /** For a tile, the Ids of all of the TileUsers for which the tile is currently in use. The TileUserIdSet is owned by the LRUTileList's TileUserIdSets member.
48
+ * Undefined if the tile is not in use by any TileUser.
49
49
  */
50
- viewportIds?: ViewportIdSet | undefined;
50
+ tileUserIds?: TileUserIdSet | undefined;
51
51
  }
52
- /** An intrusive doubly-linked list of LRUTileListNodes, containing Tiles partitioned by a singleton sentinel node into two partitions and ordered from least-recently- to most-recently-selected for display in any Viewport.
52
+ /** An intrusive doubly-linked list of LRUTileListNodes, containing Tiles partitioned by a singleton sentinel node into two partitions and ordered from least-recently- to most-recently-used by any TileUser.
53
53
  * Used by TileAdmin to keep track of and impose limits upon the total amount of GPU memory allocated to tile content.
54
54
  *
55
55
  * Illustration of the structure of the list:
@@ -70,8 +70,8 @@ export interface LRUTileListNode {
70
70
  *
71
71
  * - When a tile's content is loaded, it is added to the end of the "not selected" partition. Its memory usage is computed and added to the list's total.
72
72
  * - When a tile's content is unloaded, it is removed from the list. Its memory usage is deducted from the list's totla.
73
- * - Just before a Viewport selects tiles for display, it is removed from each tile's set of viewports in which they are selected. If a tile's set of viewports becomes empty as a result, it is moved to the end of the "not selected" partition.
74
- * - When a tile becomes selected for display in a Viewport, the viewport is added to its viewport set and the tile is moved to the end of the "selected" partition.
73
+ * - Just before a TileUser selects tiles for use (e.g., Viewport selects tiles for display), it is removed from each tile's set of viewports in which they are selected. If a tile's set of users becomes empty as a result, it is moved to the end of the "not selected" partition.
74
+ * - When a tile becomes selected for use by a TileUser, the user is added to its user set and the tile is moved to the end of the "selected" partition.
75
75
  *
76
76
  * When the system determines that GPU memory should be freed up, it can simply pop nodes off the beginning of the "not selected" partition, freeing their content, until the target memory usage is reached or no more non-selected nodes exist.
77
77
  *
@@ -81,7 +81,7 @@ export interface LRUTileListNode {
81
81
  export declare class LRUTileList {
82
82
  protected readonly _sentinel: LRUTileListNode;
83
83
  protected readonly _stats: RenderMemory.Statistics;
84
- protected readonly _viewportIdSets: ViewportIdSets;
84
+ protected readonly _userIdSets: TileUserIdSets;
85
85
  protected _head: LRUTileListNode;
86
86
  protected _tail: LRUTileListNode;
87
87
  protected _totalBytesUsed: number;
@@ -97,12 +97,12 @@ export declare class LRUTileList {
97
97
  * Invoked by TileAdmin when a tile's content is unloaded, including when the list itself disposes of the content in its `freeMemory` method.
98
98
  */
99
99
  drop(tile: Tile): void;
100
- /** Mark the tiles as selected for display in the specified Viewport. They are moved to the end of the "selected" partition. */
101
- markSelectedForViewport(viewportId: number, tiles: Iterable<Tile>): void;
102
- /** Mark the tiles as no longer selected for display in the specified Viewport.
103
- * If this results in a tile being no longer selected for any viewport, it is moved to the end of the "not selected" partition.
100
+ /** Mark the tiles as in use by the specified TileUser. They are moved to the end of the "selected" partition. */
101
+ markUsed(userId: number, tiles: Iterable<Tile>): void;
102
+ /** Mark the tiles as no longer in user by the specified TileUser.
103
+ * If this results in a tile being no longer selected for any user, it is moved to the end of the "not selected" partition.
104
104
  */
105
- clearSelectedForViewport(viewportId: number): void;
105
+ clearUsed(userId: number): void;
106
106
  /** Dispose of the contents of tiles currently not selected for display until the total amount of memory consumed is no more than `maxBytes`
107
107
  * or until the contents of all un-selected tiles have been disposed.
108
108
  */
@@ -1 +1 @@
1
- {"version":3,"file":"LRUTileList.d.ts","sourceRoot":"","sources":["../../../src/tile/LRUTileList.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,mBAAmB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,mBAAmB,CAAC,MAAM,CAAC;gBACzC,UAAU,CAAC,EAAE,MAAM;IAM/B,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO;IAWnC,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAI7B,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAI9B,KAAK,IAAI,IAAI;IAIb,QAAQ,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI;IAOlC,KAAK,IAAI,aAAa;CAK9B;AAED;;;;G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AAE,IAAI,GAAG,IAAI;IAgB7B,iHAAiH;IAC1G,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI;IAc5D;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IActC;;OAEG;IACI,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAczC,iEAAiE;IACjE,IAAW,eAAe,IAAI,QAAQ,CAAC,IAAI,CAAC,CAK3C;IAED,+DAA+D;IAC/D,IAAW,aAAa,IAAI,QAAQ,CAAC,IAAI,CAAC,CAIzC;IAED,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;IAM9C,SAAS,CAAC,UAAU,IAAI,IAAI;IAK5B,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAUlC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAiClC,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAKrC,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;CAW/C"}
@@ -7,19 +7,19 @@
7
7
  * @module Tiles
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.LRUTileList = exports.ViewportIdSets = exports.ViewportIdSet = void 0;
10
+ exports.LRUTileList = exports.TileUserIdSets = exports.TileUserIdSet = void 0;
11
11
  const core_bentley_1 = require("@itwin/core-bentley");
12
12
  const RenderMemory_1 = require("../render/RenderMemory");
13
- /** Maintains in sorted order a set of Viewport Ids for which a given tile has been selected for display. The number of viewports in a set is expected to be very small - often only 1 for a typical application.
13
+ /** Maintains in sorted order a set of [[TileUser]] Ids for which a given tile has been selected for display. The number of users in a set is expected to be very small - often only 1 for a typical application.
14
14
  * Strictly for use by LRUTileList.
15
- * @see ViewportIdSets.
15
+ * @see TileUserIdSets.
16
16
  * @internal
17
17
  */
18
- class ViewportIdSet extends core_bentley_1.ReadonlySortedArray {
19
- constructor(viewportId) {
18
+ class TileUserIdSet extends core_bentley_1.ReadonlySortedArray {
19
+ constructor(userId) {
20
20
  super((lhs, rhs) => lhs - rhs);
21
- if (undefined !== viewportId)
22
- this._array.push(viewportId);
21
+ if (undefined !== userId)
22
+ this._array.push(userId);
23
23
  }
24
24
  equals(set) {
25
25
  if (this.length !== set.length)
@@ -29,11 +29,11 @@ class ViewportIdSet extends core_bentley_1.ReadonlySortedArray {
29
29
  return false;
30
30
  return true;
31
31
  }
32
- add(viewportId) {
33
- this._insert(viewportId);
32
+ add(userId) {
33
+ this._insert(userId);
34
34
  }
35
- drop(viewportId) {
36
- this._remove(viewportId);
35
+ drop(userId) {
36
+ this._remove(userId);
37
37
  }
38
38
  clear() {
39
39
  this._clear();
@@ -41,22 +41,22 @@ class ViewportIdSet extends core_bentley_1.ReadonlySortedArray {
41
41
  copyFrom(src) {
42
42
  this._array.length = src.length;
43
43
  let i = 0;
44
- for (const viewportId of src)
45
- this._array[i++] = viewportId;
44
+ for (const userId of src)
45
+ this._array[i++] = userId;
46
46
  }
47
47
  clone() {
48
- const clone = new ViewportIdSet();
48
+ const clone = new TileUserIdSet();
49
49
  clone.copyFrom(this);
50
50
  return clone;
51
51
  }
52
52
  }
53
- exports.ViewportIdSet = ViewportIdSet;
54
- /** Maintains a set of ViewportIdSets such that each set represents a unique combination of Viewport ids and each set contains at least one Viewport id.
53
+ exports.TileUserIdSet = TileUserIdSet;
54
+ /** Maintains a set of TileUserIdSets such that each set represents a unique combination of TileUser ids and each set contains at least one TileUser id.
55
55
  * Exported strictly for tests.
56
56
  * @see LRUTileList.
57
57
  * @internal
58
58
  */
59
- class ViewportIdSets extends core_bentley_1.SortedArray {
59
+ class TileUserIdSets extends core_bentley_1.SortedArray {
60
60
  constructor() {
61
61
  super((lhs, rhs) => {
62
62
  if (lhs === rhs)
@@ -73,15 +73,15 @@ class ViewportIdSets extends core_bentley_1.SortedArray {
73
73
  }
74
74
  return 0;
75
75
  });
76
- this._scratch = new ViewportIdSet();
76
+ this._scratch = new TileUserIdSet();
77
77
  }
78
- /** Remove the specified viewport Id from all sets and remove empty and duplicate sets. */
79
- drop(viewportId) {
78
+ /** Remove the specified TileUser Id from all sets and remove empty and duplicate sets. */
79
+ drop(userId) {
80
80
  // Remove from all sets, and delete empty sets.
81
81
  let i = 0;
82
82
  for ( /* */; i < this._array.length; i++) {
83
83
  const set = this._array[i];
84
- set.drop(viewportId);
84
+ set.drop(userId);
85
85
  if (set.length === 0)
86
86
  this._array.splice(i, 1);
87
87
  }
@@ -97,22 +97,22 @@ class ViewportIdSets extends core_bentley_1.SortedArray {
97
97
  }
98
98
  }
99
99
  }
100
- /** Obtain a ViewportIdSet owned by this object containing viewportId and (if specified) viewportIds. */
101
- plus(viewportId, viewportIds) {
102
- const scratch = this.scratch(viewportIds);
103
- scratch.add(viewportId);
100
+ /** Obtain a TileUserIdSet owned by this object containing userId and (if specified) userIds. */
101
+ plus(userId, userIds) {
102
+ const scratch = this.scratch(userIds);
103
+ scratch.add(userId);
104
104
  return this.getEquivalent(scratch);
105
105
  }
106
- /** Obtain a ViewportIdSet owned by this object containing all of viewportIds (if specified) but not viewportId. Returns undefined if the resultant set would be empty. */
107
- minus(viewportId, viewportIds) {
108
- const scratch = this.scratch(viewportIds);
109
- scratch.drop(viewportId);
106
+ /** Obtain a TileUserIdSet owned by this object containing all of userIds (if specified) but not userId. Returns undefined if the resultant set would be empty. */
107
+ minus(userId, userIds) {
108
+ const scratch = this.scratch(userIds);
109
+ scratch.drop(userId);
110
110
  return scratch.length > 0 ? this.getEquivalent(scratch) : undefined;
111
111
  }
112
- scratch(viewportIds) {
112
+ scratch(userIds) {
113
113
  const scratch = this._scratch;
114
- if (viewportIds)
115
- scratch.copyFrom(viewportIds);
114
+ if (userIds)
115
+ scratch.copyFrom(userIds);
116
116
  else
117
117
  scratch.clear();
118
118
  return scratch;
@@ -127,7 +127,7 @@ class ViewportIdSets extends core_bentley_1.SortedArray {
127
127
  return newSet;
128
128
  }
129
129
  }
130
- exports.ViewportIdSets = ViewportIdSets;
130
+ exports.TileUserIdSets = TileUserIdSets;
131
131
  function isLinked(node) {
132
132
  return undefined !== node.previous || undefined !== node.next;
133
133
  }
@@ -139,7 +139,7 @@ function* lruListIterator(start, end) {
139
139
  yield prev;
140
140
  }
141
141
  }
142
- /** An intrusive doubly-linked list of LRUTileListNodes, containing Tiles partitioned by a singleton sentinel node into two partitions and ordered from least-recently- to most-recently-selected for display in any Viewport.
142
+ /** An intrusive doubly-linked list of LRUTileListNodes, containing Tiles partitioned by a singleton sentinel node into two partitions and ordered from least-recently- to most-recently-used by any TileUser.
143
143
  * Used by TileAdmin to keep track of and impose limits upon the total amount of GPU memory allocated to tile content.
144
144
  *
145
145
  * Illustration of the structure of the list:
@@ -160,8 +160,8 @@ function* lruListIterator(start, end) {
160
160
  *
161
161
  * - When a tile's content is loaded, it is added to the end of the "not selected" partition. Its memory usage is computed and added to the list's total.
162
162
  * - When a tile's content is unloaded, it is removed from the list. Its memory usage is deducted from the list's totla.
163
- * - Just before a Viewport selects tiles for display, it is removed from each tile's set of viewports in which they are selected. If a tile's set of viewports becomes empty as a result, it is moved to the end of the "not selected" partition.
164
- * - When a tile becomes selected for display in a Viewport, the viewport is added to its viewport set and the tile is moved to the end of the "selected" partition.
163
+ * - Just before a TileUser selects tiles for use (e.g., Viewport selects tiles for display), it is removed from each tile's set of viewports in which they are selected. If a tile's set of users becomes empty as a result, it is moved to the end of the "not selected" partition.
164
+ * - When a tile becomes selected for use by a TileUser, the user is added to its user set and the tile is moved to the end of the "selected" partition.
165
165
  *
166
166
  * When the system determines that GPU memory should be freed up, it can simply pop nodes off the beginning of the "not selected" partition, freeing their content, until the target memory usage is reached or no more non-selected nodes exist.
167
167
  *
@@ -171,7 +171,7 @@ function* lruListIterator(start, end) {
171
171
  class LRUTileList {
172
172
  constructor() {
173
173
  this._stats = new RenderMemory_1.RenderMemory.Statistics();
174
- this._viewportIdSets = new ViewportIdSets();
174
+ this._userIdSets = new TileUserIdSets();
175
175
  this._totalBytesUsed = 0;
176
176
  this._head = this._tail = this._sentinel = { bytesUsed: 0 };
177
177
  }
@@ -186,12 +186,12 @@ class LRUTileList {
186
186
  next = node.next;
187
187
  node.previous = node.next = undefined;
188
188
  node.bytesUsed = 0;
189
- node.viewportIds = undefined;
189
+ node.tileUserIds = undefined;
190
190
  node = next;
191
191
  }
192
192
  this._head = this._tail = this._sentinel;
193
193
  this._totalBytesUsed = 0;
194
- this._viewportIdSets.clear();
194
+ this._userIdSets.clear();
195
195
  }
196
196
  /** Compute the amount of GPU memory allocated to the tile's content and, if greater than zero, add the tile to the end of the "not selected" partition.
197
197
  * Invoked by TileAdmin whenever a tile's content is set to a valid RenderGraphic.
@@ -201,7 +201,7 @@ class LRUTileList {
201
201
  if (isLinked(tile))
202
202
  return;
203
203
  (0, core_bentley_1.assert)(tile.bytesUsed === 0);
204
- (0, core_bentley_1.assert)(tile.viewportIds === undefined);
204
+ (0, core_bentley_1.assert)(tile.tileUserIds === undefined);
205
205
  this._stats.clear();
206
206
  tile.collectStatistics(this._stats, false);
207
207
  tile.bytesUsed = this.computeBytesUsed(tile);
@@ -225,33 +225,33 @@ class LRUTileList {
225
225
  this._totalBytesUsed -= tile.bytesUsed;
226
226
  (0, core_bentley_1.assert)(this._totalBytesUsed >= 0);
227
227
  this.unlink(tile);
228
- tile.viewportIds = undefined;
228
+ tile.tileUserIds = undefined;
229
229
  tile.bytesUsed = 0;
230
230
  this.assertList();
231
231
  }
232
- /** Mark the tiles as selected for display in the specified Viewport. They are moved to the end of the "selected" partition. */
233
- markSelectedForViewport(viewportId, tiles) {
232
+ /** Mark the tiles as in use by the specified TileUser. They are moved to the end of the "selected" partition. */
233
+ markUsed(userId, tiles) {
234
234
  for (const tile of tiles) {
235
235
  if (tile.bytesUsed <= 0)
236
236
  continue;
237
237
  (0, core_bentley_1.assert)(isLinked(tile));
238
238
  if (isLinked(tile)) {
239
- tile.viewportIds = this._viewportIdSets.plus(viewportId, tile.viewportIds);
239
+ tile.tileUserIds = this._userIdSets.plus(userId, tile.tileUserIds);
240
240
  this.moveToEnd(tile);
241
241
  }
242
242
  }
243
243
  }
244
- /** Mark the tiles as no longer selected for display in the specified Viewport.
245
- * If this results in a tile being no longer selected for any viewport, it is moved to the end of the "not selected" partition.
244
+ /** Mark the tiles as no longer in user by the specified TileUser.
245
+ * If this results in a tile being no longer selected for any user, it is moved to the end of the "not selected" partition.
246
246
  */
247
- clearSelectedForViewport(viewportId) {
248
- this._viewportIdSets.drop(viewportId);
247
+ clearUsed(userId) {
248
+ this._userIdSets.drop(userId);
249
249
  let prev = this._sentinel;
250
250
  while (prev && prev.next) {
251
251
  const tile = prev.next;
252
252
  (0, core_bentley_1.assert)(tile !== this._sentinel);
253
- tile.viewportIds = this._viewportIdSets.minus(viewportId, tile.viewportIds);
254
- if (undefined === tile.viewportIds)
253
+ tile.tileUserIds = this._userIdSets.minus(userId, tile.tileUserIds);
254
+ if (undefined === tile.tileUserIds)
255
255
  this.moveBeforeSentinel(tile);
256
256
  else
257
257
  prev = tile;
@@ -1 +1 @@
1
- {"version":3,"file":"LRUTileList.js","sourceRoot":"","sources":["../../../src/tile/LRUTileList.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+E;AAC/E,yDAAsD;AAGtD;;;;GAIG;AACH,MAAa,aAAc,SAAQ,kCAA2B;IAC5D,YAAmB,UAAmB;QACpC,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;QAC/B,IAAI,SAAS,KAAK,UAAU;YAC1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC;IAEM,MAAM,CAAC,GAAkB;QAC9B,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM;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B,CAAC;CACF;AApND,kCAoNC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { assert, ReadonlySortedArray, SortedArray } from \"@itwin/core-bentley\";\r\nimport { RenderMemory } from \"../render/RenderMemory\";\r\nimport { Tile } from \"./internal\";\r\n\r\n/** Maintains in sorted order a set of Viewport Ids for which a given tile has been selected for display. The number of viewports in a set is expected to be very small - often only 1 for a typical application.\r\n * Strictly for use by LRUTileList.\r\n * @see ViewportIdSets.\r\n * @internal\r\n */\r\nexport class ViewportIdSet extends ReadonlySortedArray<number> {\r\n public constructor(viewportId?: number) {\r\n super((lhs, rhs) => lhs - rhs);\r\n if (undefined !== viewportId)\r\n this._array.push(viewportId);\r\n }\r\n\r\n public equals(set: ViewportIdSet): boolean {\r\n if (this.length !== set.length)\r\n return false;\r\n\r\n for (let i = 0; i < this.length; i++)\r\n if (this._array[i] !== set._array[i])\r\n return false;\r\n\r\n return true;\r\n }\r\n\r\n public add(viewportId: number): void {\r\n this._insert(viewportId);\r\n }\r\n\r\n public drop(viewportId: number): void {\r\n this._remove(viewportId);\r\n }\r\n\r\n public clear(): void {\r\n this._clear();\r\n }\r\n\r\n public copyFrom(src: ViewportIdSet): void {\r\n this._array.length = src.length;\r\n let i = 0;\r\n for (const viewportId of src)\r\n this._array[i++] = viewportId;\r\n }\r\n\r\n public clone(): ViewportIdSet {\r\n const clone = new ViewportIdSet();\r\n clone.copyFrom(this);\r\n return clone;\r\n }\r\n}\r\n\r\n/** Maintains a set of ViewportIdSets such that each set represents a unique combination of Viewport ids and each set contains at least one Viewport id.\r\n * Exported strictly for tests.\r\n * @see LRUTileList.\r\n * @internal\r\n */\r\nexport class ViewportIdSets extends SortedArray<ViewportIdSet> {\r\n private readonly _scratch = new ViewportIdSet();\r\n\r\n public constructor() {\r\n super((lhs, rhs) => {\r\n if (lhs === rhs)\r\n return 0;\r\n\r\n let diff = lhs.length - rhs.length;\r\n if (0 !== diff)\r\n return diff;\r\n\r\n for (let i = 0; i < lhs.length; i++) {\r\n const lhId = lhs.get(i)!;\r\n const rhId = rhs.get(i)!;\r\n diff = lhId - rhId;\r\n if (0 !== diff)\r\n return diff;\r\n }\r\n\r\n return 0;\r\n });\r\n }\r\n\r\n /** Remove the specified viewport Id from all sets and remove empty and duplicate sets. */\r\n public drop(viewportId: number): void {\r\n // Remove from all sets, and delete empty sets.\r\n let i = 0;\r\n for (/* */; i < this._array.length; i++) {\r\n const set = this._array[i];\r\n set.drop(viewportId);\r\n if (set.length === 0)\r\n this._array.splice(i, 1);\r\n }\r\n\r\n // Collapse equivalent sets.\r\n i = 0;\r\n for (let j = 1; j < this._array.length; /* */) {\r\n if (this._array[i].equals(this._array[j])) {\r\n this._array.splice(i, 1);\r\n } else {\r\n i++;\r\n j++;\r\n }\r\n }\r\n }\r\n\r\n /** Obtain a ViewportIdSet owned by this object containing viewportId and (if specified) viewportIds. */\r\n public plus(viewportId: number, viewportIds?: ViewportIdSet): ViewportIdSet {\r\n const scratch = this.scratch(viewportIds);\r\n scratch.add(viewportId);\r\n return this.getEquivalent(scratch);\r\n }\r\n\r\n /** Obtain a ViewportIdSet owned by this object containing all of viewportIds (if specified) but not viewportId. Returns undefined if the resultant set would be empty. */\r\n public minus(viewportId: number, viewportIds?: ViewportIdSet): ViewportIdSet | undefined {\r\n const scratch = this.scratch(viewportIds);\r\n scratch.drop(viewportId);\r\n return scratch.length > 0 ? this.getEquivalent(scratch) : undefined;\r\n }\r\n\r\n private scratch(viewportIds?: ViewportIdSet): ViewportIdSet {\r\n const scratch = this._scratch;\r\n if (viewportIds)\r\n scratch.copyFrom(viewportIds);\r\n else\r\n scratch.clear();\r\n\r\n return scratch;\r\n }\r\n\r\n private getEquivalent(sought: ViewportIdSet): ViewportIdSet {\r\n assert(sought.length > 0);\r\n\r\n for (const set of this)\r\n if (set.equals(sought))\r\n return set;\r\n\r\n const newSet = sought.clone();\r\n this.insert(newSet);\r\n return newSet;\r\n }\r\n}\r\n\r\n/** A node in an LRUTileList. It is either a [[Tile]], or a sentinel node used to partition the list.\r\n * Strictly for use by LRUTileList.\r\n * @internal\r\n */\r\nexport interface LRUTileListNode {\r\n previous?: LRUTileListNode;\r\n next?: LRUTileListNode;\r\n /** The number of bytes of GPU memory allocated to the tile's content. The only node in a LRUTileListNode with `bytesUsed` less than 1 is the sentinel node. */\r\n bytesUsed: number;\r\n /** For a tile, the Ids of all of the Viewports for which the tile is currently selected for display. The ViewportIdSet is owned by the LRUTileList's ViewportIdSets member.\r\n * Undefined if the tile is not selected for display in any viewport.\r\n */\r\n viewportIds?: ViewportIdSet | undefined;\r\n}\r\n\r\nfunction isLinked(node: LRUTileListNode): boolean {\r\n return undefined !== node.previous || undefined !== node.next;\r\n}\r\n\r\nfunction* lruListIterator(start: Tile | undefined, end: LRUTileListNode | undefined): Iterator<Tile> {\r\n let cur = start;\r\n while (cur && cur !== end) {\r\n const prev = cur;\r\n cur = cur.next as Tile | undefined;\r\n yield prev;\r\n }\r\n}\r\n\r\n/** An intrusive doubly-linked list of LRUTileListNodes, containing Tiles partitioned by a singleton sentinel node into two partitions and ordered from least-recently- to most-recently-selected for display in any Viewport.\r\n * Used by TileAdmin to keep track of and impose limits upon the total amount of GPU memory allocated to tile content.\r\n *\r\n * Illustration of the structure of the list:\r\n *\r\n * ```\r\n * v------------- Not selected --------------v v----------------- Selected ------------------v\r\n * ______ ______ __________ ______ ______\r\n * | head |.next => | |.next => ... | sentinel |.next => ... | |.next => | tail |\r\n * | 12kb | | 8kb | | 0kb | | 19kb | | 23kb |\r\n * |______| <= previous.|______| ... <= previous.|__________| ... <= previous.|______| <= previous.|______|\r\n *\r\n * least-recently-selected --> --> --> --> --> --> --> --> --> --> --> --> --> --> --> --> --> --> --> most-recently-selected\r\n * ```\r\n *\r\n * The sentinel node is always present and floats freely as the contents of each partition change. Note that the `next` and `previous` pointers are stored directly on the tiles - no link nodes are allocated to hold the entries in the list. This of course means that a Tile can only ever belong to one LRUTileList - the one owned by the TileAdmin.\r\n *\r\n * The list contains only those tiles whose content has been loaded. Each node records the amount of GPU memory allocated for the tile's content. The list keeps track of the total amount of GPU memory allocated by all tiles. The list's contents are updated as follows:\r\n *\r\n * - When a tile's content is loaded, it is added to the end of the \"not selected\" partition. Its memory usage is computed and added to the list's total.\r\n * - When a tile's content is unloaded, it is removed from the list. Its memory usage is deducted from the list's totla.\r\n * - Just before a Viewport selects tiles for display, it is removed from each tile's set of viewports in which they are selected. If a tile's set of viewports becomes empty as a result, it is moved to the end of the \"not selected\" partition.\r\n * - When a tile becomes selected for display in a Viewport, the viewport is added to its viewport set and the tile is moved to the end of the \"selected\" partition.\r\n *\r\n * When the system determines that GPU memory should be freed up, it can simply pop nodes off the beginning of the \"not selected\" partition, freeing their content, until the target memory usage is reached or no more non-selected nodes exist.\r\n *\r\n * Strictly for use by [[TileAdmin]].\r\n * @internal\r\n */\r\nexport class LRUTileList {\r\n protected readonly _sentinel: LRUTileListNode;\r\n protected readonly _stats = new RenderMemory.Statistics();\r\n protected readonly _viewportIdSets = new ViewportIdSets();\r\n protected _head: LRUTileListNode;\r\n protected _tail: LRUTileListNode;\r\n protected _totalBytesUsed = 0;\r\n\r\n /** The amount of GPU memory, in bytes, allocated to all tiles in the list. */\r\n public get totalBytesUsed(): number {\r\n return this._totalBytesUsed;\r\n }\r\n\r\n public constructor() {\r\n this._head = this._tail = this._sentinel = { bytesUsed: 0 };\r\n }\r\n\r\n public dispose(): void {\r\n let node: LRUTileListNode | undefined = this._head;\r\n let next: LRUTileListNode | undefined;\r\n while (node) {\r\n next = node.next;\r\n node.previous = node.next = undefined;\r\n node.bytesUsed = 0;\r\n node.viewportIds = undefined;\r\n node = next;\r\n }\r\n\r\n this._head = this._tail = this._sentinel;\r\n this._totalBytesUsed = 0;\r\n this._viewportIdSets.clear();\r\n }\r\n\r\n /** Compute the amount of GPU memory allocated to the tile's content and, if greater than zero, add the tile to the end of the \"not selected\" partition.\r\n * Invoked by TileAdmin whenever a tile's content is set to a valid RenderGraphic.\r\n */\r\n public add(tile: Tile): void {\r\n assert(!isLinked(tile));\r\n if (isLinked(tile))\r\n return;\r\n\r\n assert(tile.bytesUsed === 0);\r\n assert(tile.viewportIds === undefined);\r\n\r\n this._stats.clear();\r\n tile.collectStatistics(this._stats, false);\r\n tile.bytesUsed = this.computeBytesUsed(tile);\r\n assert(tile.bytesUsed >= 0);\r\n assert(tile.bytesUsed === Math.floor(tile.bytesUsed));\r\n\r\n if (tile.bytesUsed <= 0)\r\n return;\r\n\r\n // Insert just before the sentinel, indicating this is the most-recently-used non-selected tile.\r\n this._totalBytesUsed += tile.bytesUsed;\r\n this.append(tile);\r\n this.moveBeforeSentinel(tile);\r\n }\r\n\r\n /** Remove the tile from the list and deduct its previously-used GPU memory from the list's running total.\r\n * Invoked by TileAdmin when a tile's content is unloaded, including when the list itself disposes of the content in its `freeMemory` method.\r\n */\r\n public drop(tile: Tile): void {\r\n assert(isLinked(tile) || tile.bytesUsed === 0);\r\n if (!isLinked(tile))\r\n return;\r\n\r\n assert(tile.bytesUsed > 0);\r\n this._totalBytesUsed -= tile.bytesUsed;\r\n assert(this._totalBytesUsed >= 0);\r\n\r\n this.unlink(tile);\r\n tile.viewportIds = undefined;\r\n tile.bytesUsed = 0;\r\n\r\n this.assertList();\r\n }\r\n\r\n /** Mark the tiles as selected for display in the specified Viewport. They are moved to the end of the \"selected\" partition. */\r\n public markSelectedForViewport(viewportId: number, tiles: Iterable<Tile>): void {\r\n for (const tile of tiles) {\r\n if (tile.bytesUsed <= 0)\r\n continue;\r\n\r\n assert(isLinked(tile));\r\n\r\n if (isLinked(tile)) {\r\n tile.viewportIds = this._viewportIdSets.plus(viewportId, tile.viewportIds);\r\n this.moveToEnd(tile);\r\n }\r\n }\r\n }\r\n\r\n /** Mark the tiles as no longer selected for display in the specified Viewport.\r\n * If this results in a tile being no longer selected for any viewport, it is moved to the end of the \"not selected\" partition.\r\n */\r\n public clearSelectedForViewport(viewportId: number): void {\r\n this._viewportIdSets.drop(viewportId);\r\n let prev: LRUTileListNode | undefined = this._sentinel;\r\n while (prev && prev.next) {\r\n const tile = prev.next as Tile;\r\n assert(tile !== this._sentinel);\r\n tile.viewportIds = this._viewportIdSets.minus(viewportId, tile.viewportIds);\r\n if (undefined === tile.viewportIds)\r\n this.moveBeforeSentinel(tile);\r\n else\r\n prev = tile;\r\n }\r\n }\r\n\r\n /** Dispose of the contents of tiles currently not selected for display until the total amount of memory consumed is no more than `maxBytes`\r\n * or until the contents of all un-selected tiles have been disposed.\r\n */\r\n public freeMemory(maxBytes: number): void {\r\n let prev: LRUTileListNode | undefined = this._head;\r\n while (prev && prev !== this._sentinel && this.totalBytesUsed > maxBytes) {\r\n const tile = prev as Tile;\r\n prev = tile.next;\r\n tile.freeMemory();\r\n\r\n // Some tiles (ImageryMapTile) use reference-counting, in which case freeMemory() may not actually free the contents.\r\n // If the contents *were* disposed, then `this.drop` will have been called, and `tile` is no longer in the list.\r\n // Otherwise, `tile` remains in the list. Either way, we proceed to the next entry in the list.\r\n assert((this.computeBytesUsed(tile) > 0) === isLinked(tile));\r\n }\r\n }\r\n\r\n /** Iterate over all of the tiles in the unselected partition. */\r\n public get unselectedTiles(): Iterable<Tile> {\r\n const start = this._head === this._sentinel ? undefined : this._head as Tile | undefined;\r\n return {\r\n [Symbol.iterator]: () => lruListIterator(start, this._sentinel),\r\n };\r\n }\r\n\r\n /** Iterate over all of the tiles in the selected partition. */\r\n public get selectedTiles(): Iterable<Tile> {\r\n return {\r\n [Symbol.iterator]: () => lruListIterator(this._sentinel.next as Tile | undefined, undefined),\r\n };\r\n }\r\n\r\n protected computeBytesUsed(tile: Tile): number {\r\n this._stats.clear();\r\n tile.collectStatistics(this._stats, false);\r\n return this._stats.totalBytes;\r\n }\r\n\r\n protected assertList(): void {\r\n assert(this._head !== undefined);\r\n assert(this._tail !== undefined);\r\n }\r\n\r\n protected append(tile: Tile): void {\r\n assert(!isLinked(tile));\r\n if (isLinked(tile))\r\n this.unlink(tile);\r\n\r\n this._tail.next = tile;\r\n tile.previous = this._tail;\r\n this._tail = tile;\r\n }\r\n\r\n protected unlink(tile: Tile): void {\r\n assert(isLinked(tile));\r\n if (!isLinked(tile))\r\n return;\r\n\r\n if (tile.next && tile.previous) {\r\n assert(tile !== this._head);\r\n assert(tile !== this._tail);\r\n assert(tile.previous.next === tile);\r\n assert(tile.next.previous === tile);\r\n\r\n tile.previous.next = tile.next;\r\n tile.next.previous = tile.previous;\r\n } else if (tile.previous) {\r\n assert(tile === this._tail);\r\n assert(undefined === tile.next);\r\n assert(tile.previous.next === tile);\r\n\r\n tile.previous.next = undefined;\r\n this._tail = tile.previous;\r\n } else {\r\n assert(tile === this._head);\r\n assert(undefined !== tile.next);\r\n assert(tile.next.previous === tile);\r\n\r\n tile.next.previous = undefined;\r\n this._head = tile.next;\r\n }\r\n\r\n tile.next = tile.previous = undefined;\r\n this.assertList();\r\n }\r\n\r\n protected moveToEnd(tile: Tile): void {\r\n this.unlink(tile);\r\n this.append(tile);\r\n }\r\n\r\n protected moveBeforeSentinel(tile: Tile): void {\r\n this.unlink(tile);\r\n tile.previous = this._sentinel.previous;\r\n this._sentinel.previous = tile;\r\n tile.next = this._sentinel;\r\n\r\n if (!tile.previous)\r\n this._head = tile;\r\n else\r\n tile.previous.next = tile;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"LRUTileList.js","sourceRoot":"","sources":["../../../src/tile/LRUTileList.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+E;AAC/E,yDAAsD;AAGtD;;;;GAIG;AACH,MAAa,aAAc,SAAQ,kCAA2B;IAC5D,YAAmB,MAAe;QAChC,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CA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AI,GAAG,IAAI,CAAC,SAAS,CAAC;QAE3B,IAAI,CAAC,IAAI,CAAC,QAAQ;YAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;;YAElB,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;IAC9B,CAAC;CACF;AApND,kCAoNC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { assert, ReadonlySortedArray, SortedArray } from \"@itwin/core-bentley\";\r\nimport { RenderMemory } from \"../render/RenderMemory\";\r\nimport { Tile } from \"./internal\";\r\n\r\n/** Maintains in sorted order a set of [[TileUser]] Ids for which a given tile has been selected for display. The number of users in a set is expected to be very small - often only 1 for a typical application.\r\n * Strictly for use by LRUTileList.\r\n * @see TileUserIdSets.\r\n * @internal\r\n */\r\nexport class TileUserIdSet extends ReadonlySortedArray<number> {\r\n public constructor(userId?: number) {\r\n super((lhs, rhs) => lhs - rhs);\r\n if (undefined !== userId)\r\n this._array.push(userId);\r\n }\r\n\r\n public equals(set: TileUserIdSet): boolean {\r\n if (this.length !== set.length)\r\n return false;\r\n\r\n for (let i = 0; i < this.length; i++)\r\n if (this._array[i] !== set._array[i])\r\n return false;\r\n\r\n return true;\r\n }\r\n\r\n public add(userId: number): void {\r\n this._insert(userId);\r\n }\r\n\r\n public drop(userId: number): void {\r\n this._remove(userId);\r\n }\r\n\r\n public clear(): void {\r\n this._clear();\r\n }\r\n\r\n public copyFrom(src: TileUserIdSet): void {\r\n this._array.length = src.length;\r\n let i = 0;\r\n for (const userId of src)\r\n this._array[i++] = userId;\r\n }\r\n\r\n public clone(): TileUserIdSet {\r\n const clone = new TileUserIdSet();\r\n clone.copyFrom(this);\r\n return clone;\r\n }\r\n}\r\n\r\n/** Maintains a set of TileUserIdSets such that each set represents a unique combination of TileUser ids and each set contains at least one TileUser id.\r\n * Exported strictly for tests.\r\n * @see LRUTileList.\r\n * @internal\r\n */\r\nexport class TileUserIdSets extends SortedArray<TileUserIdSet> {\r\n private readonly _scratch = new TileUserIdSet();\r\n\r\n public constructor() {\r\n super((lhs, rhs) => {\r\n if (lhs === rhs)\r\n return 0;\r\n\r\n let diff = lhs.length - rhs.length;\r\n if (0 !== diff)\r\n return diff;\r\n\r\n for (let i = 0; i < lhs.length; i++) {\r\n const lhId = lhs.get(i)!;\r\n const rhId = rhs.get(i)!;\r\n diff = lhId - rhId;\r\n if (0 !== diff)\r\n return diff;\r\n }\r\n\r\n return 0;\r\n });\r\n }\r\n\r\n /** Remove the specified TileUser Id from all sets and remove empty and duplicate sets. */\r\n public drop(userId: number): void {\r\n // Remove from all sets, and delete empty sets.\r\n let i = 0;\r\n for (/* */; i < this._array.length; i++) {\r\n const set = this._array[i];\r\n set.drop(userId);\r\n if (set.length === 0)\r\n this._array.splice(i, 1);\r\n }\r\n\r\n // Collapse equivalent sets.\r\n i = 0;\r\n for (let j = 1; j < this._array.length; /* */) {\r\n if (this._array[i].equals(this._array[j])) {\r\n this._array.splice(i, 1);\r\n } else {\r\n i++;\r\n j++;\r\n }\r\n }\r\n }\r\n\r\n /** Obtain a TileUserIdSet owned by this object containing userId and (if specified) userIds. */\r\n public plus(userId: number, userIds?: TileUserIdSet): TileUserIdSet {\r\n const scratch = this.scratch(userIds);\r\n scratch.add(userId);\r\n return this.getEquivalent(scratch);\r\n }\r\n\r\n /** Obtain a TileUserIdSet owned by this object containing all of userIds (if specified) but not userId. Returns undefined if the resultant set would be empty. */\r\n public minus(userId: number, userIds?: TileUserIdSet): TileUserIdSet | undefined {\r\n const scratch = this.scratch(userIds);\r\n scratch.drop(userId);\r\n return scratch.length > 0 ? this.getEquivalent(scratch) : undefined;\r\n }\r\n\r\n private scratch(userIds?: TileUserIdSet): TileUserIdSet {\r\n const scratch = this._scratch;\r\n if (userIds)\r\n scratch.copyFrom(userIds);\r\n else\r\n scratch.clear();\r\n\r\n return scratch;\r\n }\r\n\r\n private getEquivalent(sought: TileUserIdSet): TileUserIdSet {\r\n assert(sought.length > 0);\r\n\r\n for (const set of this)\r\n if (set.equals(sought))\r\n return set;\r\n\r\n const newSet = sought.clone();\r\n this.insert(newSet);\r\n return newSet;\r\n }\r\n}\r\n\r\n/** A node in an LRUTileList. It is either a [[Tile]], or a sentinel node used to partition the list.\r\n * Strictly for use by LRUTileList.\r\n * @internal\r\n */\r\nexport interface LRUTileListNode {\r\n previous?: LRUTileListNode;\r\n next?: LRUTileListNode;\r\n /** The number of bytes of GPU memory allocated to the tile's content. The only node in a LRUTileListNode with `bytesUsed` less than 1 is the sentinel node. */\r\n bytesUsed: number;\r\n /** For a tile, the Ids of all of the TileUsers for which the tile is currently in use. The TileUserIdSet is owned by the LRUTileList's TileUserIdSets member.\r\n * Undefined if the tile is not in use by any TileUser.\r\n */\r\n tileUserIds?: TileUserIdSet | undefined;\r\n}\r\n\r\nfunction isLinked(node: LRUTileListNode): boolean {\r\n return undefined !== node.previous || undefined !== node.next;\r\n}\r\n\r\nfunction* lruListIterator(start: Tile | undefined, end: LRUTileListNode | undefined): Iterator<Tile> {\r\n let cur = start;\r\n while (cur && cur !== end) {\r\n const prev = cur;\r\n cur = cur.next as Tile | undefined;\r\n yield prev;\r\n }\r\n}\r\n\r\n/** An intrusive doubly-linked list of LRUTileListNodes, containing Tiles partitioned by a singleton sentinel node into two partitions and ordered from least-recently- to most-recently-used by any TileUser.\r\n * Used by TileAdmin to keep track of and impose limits upon the total amount of GPU memory allocated to tile content.\r\n *\r\n * Illustration of the structure of the list:\r\n *\r\n * ```\r\n * v------------- Not selected --------------v v----------------- Selected ------------------v\r\n * ______ ______ __________ ______ ______\r\n * | head |.next => | |.next => ... | sentinel |.next => ... | |.next => | tail |\r\n * | 12kb | | 8kb | | 0kb | | 19kb | | 23kb |\r\n * |______| <= previous.|______| ... <= previous.|__________| ... <= previous.|______| <= previous.|______|\r\n *\r\n * least-recently-selected --> --> --> --> --> --> --> --> --> --> --> --> --> --> --> --> --> --> --> most-recently-selected\r\n * ```\r\n *\r\n * The sentinel node is always present and floats freely as the contents of each partition change. Note that the `next` and `previous` pointers are stored directly on the tiles - no link nodes are allocated to hold the entries in the list. This of course means that a Tile can only ever belong to one LRUTileList - the one owned by the TileAdmin.\r\n *\r\n * The list contains only those tiles whose content has been loaded. Each node records the amount of GPU memory allocated for the tile's content. The list keeps track of the total amount of GPU memory allocated by all tiles. The list's contents are updated as follows:\r\n *\r\n * - When a tile's content is loaded, it is added to the end of the \"not selected\" partition. Its memory usage is computed and added to the list's total.\r\n * - When a tile's content is unloaded, it is removed from the list. Its memory usage is deducted from the list's totla.\r\n * - Just before a TileUser selects tiles for use (e.g., Viewport selects tiles for display), it is removed from each tile's set of viewports in which they are selected. If a tile's set of users becomes empty as a result, it is moved to the end of the \"not selected\" partition.\r\n * - When a tile becomes selected for use by a TileUser, the user is added to its user set and the tile is moved to the end of the \"selected\" partition.\r\n *\r\n * When the system determines that GPU memory should be freed up, it can simply pop nodes off the beginning of the \"not selected\" partition, freeing their content, until the target memory usage is reached or no more non-selected nodes exist.\r\n *\r\n * Strictly for use by [[TileAdmin]].\r\n * @internal\r\n */\r\nexport class LRUTileList {\r\n protected readonly _sentinel: LRUTileListNode;\r\n protected readonly _stats = new RenderMemory.Statistics();\r\n protected readonly _userIdSets = new TileUserIdSets();\r\n protected _head: LRUTileListNode;\r\n protected _tail: LRUTileListNode;\r\n protected _totalBytesUsed = 0;\r\n\r\n /** The amount of GPU memory, in bytes, allocated to all tiles in the list. */\r\n public get totalBytesUsed(): number {\r\n return this._totalBytesUsed;\r\n }\r\n\r\n public constructor() {\r\n this._head = this._tail = this._sentinel = { bytesUsed: 0 };\r\n }\r\n\r\n public dispose(): void {\r\n let node: LRUTileListNode | undefined = this._head;\r\n let next: LRUTileListNode | undefined;\r\n while (node) {\r\n next = node.next;\r\n node.previous = node.next = undefined;\r\n node.bytesUsed = 0;\r\n node.tileUserIds = undefined;\r\n node = next;\r\n }\r\n\r\n this._head = this._tail = this._sentinel;\r\n this._totalBytesUsed = 0;\r\n this._userIdSets.clear();\r\n }\r\n\r\n /** Compute the amount of GPU memory allocated to the tile's content and, if greater than zero, add the tile to the end of the \"not selected\" partition.\r\n * Invoked by TileAdmin whenever a tile's content is set to a valid RenderGraphic.\r\n */\r\n public add(tile: Tile): void {\r\n assert(!isLinked(tile));\r\n if (isLinked(tile))\r\n return;\r\n\r\n assert(tile.bytesUsed === 0);\r\n assert(tile.tileUserIds === undefined);\r\n\r\n this._stats.clear();\r\n tile.collectStatistics(this._stats, false);\r\n tile.bytesUsed = this.computeBytesUsed(tile);\r\n assert(tile.bytesUsed >= 0);\r\n assert(tile.bytesUsed === Math.floor(tile.bytesUsed));\r\n\r\n if (tile.bytesUsed <= 0)\r\n return;\r\n\r\n // Insert just before the sentinel, indicating this is the most-recently-used non-selected tile.\r\n this._totalBytesUsed += tile.bytesUsed;\r\n this.append(tile);\r\n this.moveBeforeSentinel(tile);\r\n }\r\n\r\n /** Remove the tile from the list and deduct its previously-used GPU memory from the list's running total.\r\n * Invoked by TileAdmin when a tile's content is unloaded, including when the list itself disposes of the content in its `freeMemory` method.\r\n */\r\n public drop(tile: Tile): void {\r\n assert(isLinked(tile) || tile.bytesUsed === 0);\r\n if (!isLinked(tile))\r\n return;\r\n\r\n assert(tile.bytesUsed > 0);\r\n this._totalBytesUsed -= tile.bytesUsed;\r\n assert(this._totalBytesUsed >= 0);\r\n\r\n this.unlink(tile);\r\n tile.tileUserIds = undefined;\r\n tile.bytesUsed = 0;\r\n\r\n this.assertList();\r\n }\r\n\r\n /** Mark the tiles as in use by the specified TileUser. They are moved to the end of the \"selected\" partition. */\r\n public markUsed(userId: number, tiles: Iterable<Tile>): void {\r\n for (const tile of tiles) {\r\n if (tile.bytesUsed <= 0)\r\n continue;\r\n\r\n assert(isLinked(tile));\r\n\r\n if (isLinked(tile)) {\r\n tile.tileUserIds = this._userIdSets.plus(userId, tile.tileUserIds);\r\n this.moveToEnd(tile);\r\n }\r\n }\r\n }\r\n\r\n /** Mark the tiles as no longer in user by the specified TileUser.\r\n * If this results in a tile being no longer selected for any user, it is moved to the end of the \"not selected\" partition.\r\n */\r\n public clearUsed(userId: number): void {\r\n this._userIdSets.drop(userId);\r\n let prev: LRUTileListNode | undefined = this._sentinel;\r\n while (prev && prev.next) {\r\n const tile = prev.next as Tile;\r\n assert(tile !== this._sentinel);\r\n tile.tileUserIds = this._userIdSets.minus(userId, tile.tileUserIds);\r\n if (undefined === tile.tileUserIds)\r\n this.moveBeforeSentinel(tile);\r\n else\r\n prev = tile;\r\n }\r\n }\r\n\r\n /** Dispose of the contents of tiles currently not selected for display until the total amount of memory consumed is no more than `maxBytes`\r\n * or until the contents of all un-selected tiles have been disposed.\r\n */\r\n public freeMemory(maxBytes: number): void {\r\n let prev: LRUTileListNode | undefined = this._head;\r\n while (prev && prev !== this._sentinel && this.totalBytesUsed > maxBytes) {\r\n const tile = prev as Tile;\r\n prev = tile.next;\r\n tile.freeMemory();\r\n\r\n // Some tiles (ImageryMapTile) use reference-counting, in which case freeMemory() may not actually free the contents.\r\n // If the contents *were* disposed, then `this.drop` will have been called, and `tile` is no longer in the list.\r\n // Otherwise, `tile` remains in the list. Either way, we proceed to the next entry in the list.\r\n assert((this.computeBytesUsed(tile) > 0) === isLinked(tile));\r\n }\r\n }\r\n\r\n /** Iterate over all of the tiles in the unselected partition. */\r\n public get unselectedTiles(): Iterable<Tile> {\r\n const start = this._head === this._sentinel ? undefined : this._head as Tile | undefined;\r\n return {\r\n [Symbol.iterator]: () => lruListIterator(start, this._sentinel),\r\n };\r\n }\r\n\r\n /** Iterate over all of the tiles in the selected partition. */\r\n public get selectedTiles(): Iterable<Tile> {\r\n return {\r\n [Symbol.iterator]: () => lruListIterator(this._sentinel.next as Tile | undefined, undefined),\r\n };\r\n }\r\n\r\n protected computeBytesUsed(tile: Tile): number {\r\n this._stats.clear();\r\n tile.collectStatistics(this._stats, false);\r\n return this._stats.totalBytes;\r\n }\r\n\r\n protected assertList(): void {\r\n assert(this._head !== undefined);\r\n assert(this._tail !== undefined);\r\n }\r\n\r\n protected append(tile: Tile): void {\r\n assert(!isLinked(tile));\r\n if (isLinked(tile))\r\n this.unlink(tile);\r\n\r\n this._tail.next = tile;\r\n tile.previous = this._tail;\r\n this._tail = tile;\r\n }\r\n\r\n protected unlink(tile: Tile): void {\r\n assert(isLinked(tile));\r\n if (!isLinked(tile))\r\n return;\r\n\r\n if (tile.next && tile.previous) {\r\n assert(tile !== this._head);\r\n assert(tile !== this._tail);\r\n assert(tile.previous.next === tile);\r\n assert(tile.next.previous === tile);\r\n\r\n tile.previous.next = tile.next;\r\n tile.next.previous = tile.previous;\r\n } else if (tile.previous) {\r\n assert(tile === this._tail);\r\n assert(undefined === tile.next);\r\n assert(tile.previous.next === tile);\r\n\r\n tile.previous.next = undefined;\r\n this._tail = tile.previous;\r\n } else {\r\n assert(tile === this._head);\r\n assert(undefined !== tile.next);\r\n assert(tile.next.previous === tile);\r\n\r\n tile.next.previous = undefined;\r\n this._head = tile.next;\r\n }\r\n\r\n tile.next = tile.previous = undefined;\r\n this.assertList();\r\n }\r\n\r\n protected moveToEnd(tile: Tile): void {\r\n this.unlink(tile);\r\n this.append(tile);\r\n }\r\n\r\n protected moveBeforeSentinel(tile: Tile): void {\r\n this.unlink(tile);\r\n tile.previous = this._sentinel.previous;\r\n this._sentinel.previous = tile;\r\n tile.next = this._sentinel;\r\n\r\n if (!tile.previous)\r\n this._head = tile;\r\n else\r\n tile.previous.next = tile;\r\n }\r\n}\r\n"]}
@@ -216,7 +216,7 @@ class OrbitGtTileTree extends internal_1.TileTree {
216
216
  let totalPointCount = 0;
217
217
  const tileCount = frameData.tilesToRender.size();
218
218
  // Inform TileAdmin about tiles we are handling ourselves...
219
- IModelApp_1.IModelApp.tileAdmin.addExternalTilesForViewport(args.context.viewport, { requested: frameData.tilesToLoad.size(), selected: tileCount, ready: tileCount });
219
+ IModelApp_1.IModelApp.tileAdmin.addExternalTilesForUser(args.context.viewport, { requested: frameData.tilesToLoad.size(), selected: tileCount, ready: tileCount });
220
220
  if (debugBuilder)
221
221
  debugBuilder.setSymbology(core_common_1.ColorDef.red, core_common_1.ColorDef.red, 1);
222
222
  let minLevel = 100, maxLevel = -100;