|
24 | 24 | */ |
25 | 25 | package de.bluecolored.bluemap.api.renderer; |
26 | 26 |
|
27 | | -import java.util.Collection; |
28 | | -import java.util.HashSet; |
29 | 27 | import java.util.UUID; |
30 | 28 |
|
31 | 29 | import com.flowpowered.math.vector.Vector2i; |
32 | 30 | import com.flowpowered.math.vector.Vector3i; |
33 | 31 |
|
| 32 | +/** |
| 33 | + * The {@link Renderer} is used to schedule tile-renders and process them on a number of different threads. |
| 34 | + */ |
34 | 35 | public interface Renderer { |
35 | 36 |
|
36 | 37 | /** |
37 | | - * Schedules the map-tile at this block position for all maps of this world and returns the created render-tickets.<br> |
38 | | - * If there already is a render-ticket scheduled for a tile, the existing one is returned instead of creating a new one. |
| 38 | + * Schedules the render of the map-tile at this block position for all maps of this world.<br> |
| 39 | + * If there already is a render scheduled for one of the tiles, a second one will <b>not</b> be created. |
39 | 40 | * |
40 | 41 | * @param world the {@link UUID} of the {@link BlueMapWorld} to render |
41 | 42 | * @param blockPosition a {@link Vector3i} for the block-position to render (the whole map-tiles will be rendered not only that block) |
42 | 43 | * |
43 | | - * @return a {@link Collection} of the scheduled {@link RenderTicket}s |
| 44 | + * @throws IllegalArgumentException if there is no world loaded with the provided {@link UUID} |
44 | 45 | */ |
45 | | - Collection<RenderTicket> render(UUID world, Vector3i blockPosition); |
| 46 | + void render(UUID world, Vector3i blockPosition); |
46 | 47 |
|
47 | 48 | /** |
48 | | - * Schedules the map-tile at this block position for all maps of this world and returns the created render-tickets.<br> |
49 | | - * If there already is a render-ticket scheduled for a tile, the existing one is returned instead of creating a new one. |
| 49 | + * Schedules the render of the map-tile at this block position for all maps of this world.<br> |
| 50 | + * If there already is a render scheduled for one of the tiles, a second one will <b>not</b> be created. |
50 | 51 | * |
51 | 52 | * @param world the {@link BlueMapWorld} to render |
52 | 53 | * @param blockPosition a {@link Vector3i} for the block-position to render (the whole map-tiles will be rendered not only that block) |
53 | | - * |
54 | | - * @return a {@link Collection} of the scheduled {@link RenderTicket}s |
55 | 54 | */ |
56 | | - default Collection<RenderTicket> render(BlueMapWorld world, Vector3i blockPosition) { |
57 | | - Collection<RenderTicket> tickets = new HashSet<>(); |
58 | | - |
| 55 | + default void render(BlueMapWorld world, Vector3i blockPosition) { |
59 | 56 | for (BlueMapMap map : world.getMaps()) { |
60 | | - tickets.add(render(map, blockPosition)); |
| 57 | + render(map, blockPosition); |
61 | 58 | } |
62 | | - |
63 | | - return tickets; |
64 | 59 | } |
65 | 60 |
|
66 | 61 | /** |
67 | | - * Schedules the map-tile at this block position and returns the created render-ticket.<br> |
68 | | - * If there already is a render-ticket scheduled for that map-tile, the existing one is returned instead of creating a new one. |
| 62 | + * Schedules the render of the map-tile at this block position.<br> |
| 63 | + * If there already is a render scheduled for the tile, a second one will <b>not</b> be created. |
69 | 64 | * |
70 | 65 | * @param mapId the id of the {@link BlueMapMap} to render |
71 | 66 | * @param blockPosition a {@link Vector3i} for the block-position to render (the whole map-tile will be rendered not only that block) |
72 | 67 | * |
73 | 68 | * @return the scheduled {@link RenderTicket} |
| 69 | + * |
| 70 | + * @throws IllegalArgumentException if there is no map loaded with the provided mapId |
74 | 71 | */ |
75 | | - RenderTicket render(String mapId, Vector3i blockPosition); |
| 72 | + void render(String mapId, Vector3i blockPosition); |
76 | 73 |
|
77 | 74 | /** |
78 | | - * Schedules the map-tile at this block position and returns the created render-ticket.<br> |
79 | | - * If there already is a render-ticket scheduled for that map-tile, the existing one is returned instead of creating a new one. |
| 75 | + * Schedules the render of map-tile at this block position and returns the created render-ticket.<br> |
| 76 | + * If there already is a render scheduled for the tile, a second one will <b>not</b> be created. |
80 | 77 | * |
81 | 78 | * @param map the {@link BlueMapMap} |
82 | 79 | * @param blockPosition a {@link Vector3i} for the block-position to render (the whole map-tile will be rendered not only that block) |
83 | | - * |
84 | | - * @return the scheduled {@link RenderTicket} |
85 | 80 | */ |
86 | | - default RenderTicket render(BlueMapMap map, Vector3i blockPosition) { |
87 | | - return render(map, map.posToTile(blockPosition)); |
| 81 | + default void render(BlueMapMap map, Vector3i blockPosition) { |
| 82 | + render(map, map.posToTile(blockPosition)); |
88 | 83 | } |
89 | 84 |
|
90 | 85 | /** |
91 | | - * Schedules the map-tile and returns the created render-ticket.<br> |
92 | | - * If there already is a render-ticket scheduled for that map-tile, the existing one is returned instead of creating a new one. |
| 86 | + * Schedules the render of the map-tile.<br> |
| 87 | + * If there already is a render scheduled for the tile, a second one will <b>not</b> be created. |
93 | 88 | * |
94 | 89 | * @param mapId the id of the {@link BlueMapMap} to render |
95 | 90 | * @param tile a {@link Vector2i} for the tile-position to render |
96 | 91 | * |
97 | | - * @return the scheduled {@link RenderTicket} |
| 92 | + * @throws IllegalArgumentException if there is no map loaded with the provided mapId |
98 | 93 | */ |
99 | | - RenderTicket render(String mapId, Vector2i tile); |
| 94 | + void render(String mapId, Vector2i tile); |
100 | 95 |
|
101 | 96 | /** |
102 | | - * Schedules the map-tile and returns the created render-ticket.<br> |
103 | | - * If there already is a render-ticket scheduled for that map-tile, the existing one is returned instead of creating a new one. |
| 97 | + * Schedules the render of the map-tile.<br> |
| 98 | + * If there already is a render scheduled for the tile, a second one will <b>not</b> be created. |
104 | 99 | * |
105 | 100 | * @param map the {@link BlueMapMap} |
106 | 101 | * @param tile a {@link Vector2i} for the tile-position to render |
107 | | - * |
108 | | - * @return the scheduled {@link RenderTicket} |
109 | 102 | */ |
110 | | - RenderTicket render(BlueMapMap map, Vector2i tile); |
| 103 | + void render(BlueMapMap map, Vector2i tile); |
| 104 | + |
| 105 | + /** |
| 106 | + * Getter for the current size of the render-queue. |
| 107 | + * @return the current size of the render-queue |
| 108 | + */ |
| 109 | + int renderQueueSize(); |
| 110 | + |
| 111 | + /** |
| 112 | + * Getter for the count of render threads. |
| 113 | + * @return the count of render threads |
| 114 | + */ |
| 115 | + int renderThreadCount(); |
| 116 | + |
| 117 | + /** |
| 118 | + * Whether this {@link Renderer} is currently running or paused. |
| 119 | + * @return <code>true</code> if this renderer is running |
| 120 | + */ |
| 121 | + boolean isRunning(); |
| 122 | + |
| 123 | + /** |
| 124 | + * Starts the renderer if it is not already running. |
| 125 | + */ |
| 126 | + void start(); |
| 127 | + |
| 128 | + /** |
| 129 | + * Pauses the renderer if it currently is running. |
| 130 | + */ |
| 131 | + void pause(); |
111 | 132 |
|
112 | 133 | } |
0 commit comments