Doc, make needs*Loading methods accessible.
This commit is contained in:
parent
7bcb43ea4b
commit
a5e5bee6a8
|
|
@ -5,7 +5,13 @@ namespace Cesium3DTilesSelection {
|
|||
class Tile;
|
||||
|
||||
/**
|
||||
* @brief An interface to something that requests that specific tiles be loaded.
|
||||
* @brief An interface to something that requests loading of specific tiles from
|
||||
* a 3D Tiles {@link Tileset}.
|
||||
*
|
||||
* When multiple requesters are active, each is given a fair chance to load
|
||||
* tiles in proportion with its {@link ITileLoadRequester::getWeight}.
|
||||
*
|
||||
* Methods of this class may only be called from the main thread.
|
||||
*
|
||||
* @see TilesetViewGroup
|
||||
* @see TilesetHeightRequest
|
||||
|
|
@ -14,12 +20,67 @@ class ITileLoadRequester {
|
|||
public:
|
||||
virtual ~ITileLoadRequester() = default;
|
||||
|
||||
/**
|
||||
* @brief Gets the weight of this requester relative to others.
|
||||
*
|
||||
* Most requesters should return a weight of 1.0. When all requesters have the
|
||||
* same weight, they will all have an equal opportunity to load tiles. If one
|
||||
* requester's weight is 2.0 and the rest are 1.0, that requester will have
|
||||
* twice as many opportunities to load tiles as the others.
|
||||
*
|
||||
* A very high weight will prevent all other requesters from loading tiles
|
||||
* until this requester has none lef to load. A very low weight (but above
|
||||
* 0.0!) will allow all other requesters to finish loading tiles before this
|
||||
* one starts.
|
||||
*
|
||||
* @return The weight of this requester, which must be greater than 0.0.
|
||||
*/
|
||||
virtual double getWeight() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Determines if this requester has any more tiles that need to be
|
||||
* loaded in a worker thread. To determine if a particular {@link Tile} needs
|
||||
* to be loaded in a worker thread, call
|
||||
* {@link Tile::needsWorkerThreadLoading}.
|
||||
*
|
||||
* @return true if this requester has further tiles that need loading by a
|
||||
* worker thread; otherwise, false.
|
||||
*/
|
||||
virtual bool hasMoreTilesToLoadInWorkerThread() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Gets the next {@link Tile} that this requester would like loaded in
|
||||
* a worker thread.
|
||||
*
|
||||
* When {@link hasMoreTilesToLoadInWorkerThread} returns false, this method
|
||||
* can and should return `nullptr`. However, when that method returns true,
|
||||
* this method _must_ return a valid `Tile` pointer.
|
||||
*
|
||||
* @return The next tile to load in a worker thread.
|
||||
*/
|
||||
virtual Tile* getNextTileToLoadInWorkerThread() = 0;
|
||||
|
||||
/**
|
||||
* @brief Determines if this requester has any more tiles that need to be
|
||||
* loaded in the main thread. To determine if a particular {@link Tile} needs
|
||||
* to be loaded in the main thread, call
|
||||
* {@link Tile::needsMainThreadLoading}.
|
||||
*
|
||||
* @return true if this requester has further tiles that need loading by the
|
||||
* main thread; otherwise, false.
|
||||
*/
|
||||
virtual bool hasMoreTilesToLoadInMainThread() const = 0;
|
||||
|
||||
/**
|
||||
* @brief Gets the next {@link Tile} that this requester would like loaded in
|
||||
* the main thread.
|
||||
*
|
||||
* When {@link hasMoreTilesToLoadInMainThread} returns false, this method
|
||||
* can and should return `nullptr`. However, when that method returns true,
|
||||
* this method _must_ return a valid `Tile` pointer.
|
||||
*
|
||||
* @return The next tile to load in the main thread.
|
||||
*/
|
||||
virtual Tile* getNextTileToLoadInMainThread() = 0;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -490,6 +490,22 @@ public:
|
|||
*/
|
||||
TileLoadState getState() const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Determines if this tile requires worker-thread loading.
|
||||
*
|
||||
* @return true if this Tile needs further work done in a worker thread to
|
||||
* load it; otherwise, false.
|
||||
*/
|
||||
bool needsWorkerThreadLoading() const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Determines if this tile requires main-thread loading.
|
||||
*
|
||||
* @return true if this Tile needs further work done in the main thread to
|
||||
* load it; otherwise, false.
|
||||
*/
|
||||
bool needsMainThreadLoading() const noexcept;
|
||||
|
||||
/**
|
||||
* @brief Returns the internal count denoting that the tile and its ancestors
|
||||
* should not be unloaded.
|
||||
|
|
|
|||
|
|
@ -303,6 +303,36 @@ TilesetContentLoader* Tile::getLoader() const noexcept {
|
|||
|
||||
TileLoadState Tile::getState() const noexcept { return this->_loadState; }
|
||||
|
||||
namespace {
|
||||
|
||||
bool anyRasterOverlaysNeedLoading(const Tile& tile) noexcept {
|
||||
for (const RasterMappedTo3DTile& mapped : tile.getMappedRasterTiles()) {
|
||||
const CesiumRasterOverlays::RasterOverlayTile* pLoading =
|
||||
mapped.getLoadingTile();
|
||||
if (pLoading &&
|
||||
pLoading->getState() ==
|
||||
CesiumRasterOverlays::RasterOverlayTile::LoadState::Unloaded) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool Tile::needsWorkerThreadLoading() const noexcept {
|
||||
TileLoadState state = this->getState();
|
||||
return state == TileLoadState::Unloaded ||
|
||||
state == TileLoadState::FailedTemporarily ||
|
||||
anyRasterOverlaysNeedLoading(*this);
|
||||
}
|
||||
|
||||
bool Tile::needsMainThreadLoading() const noexcept {
|
||||
return this->getState() == TileLoadState::ContentLoaded &&
|
||||
this->isRenderContent();
|
||||
}
|
||||
|
||||
void Tile::setParent(Tile* pParent) noexcept { this->_pParent = pParent; }
|
||||
|
||||
void Tile::setState(TileLoadState state) noexcept { this->_loadState = state; }
|
||||
|
|
|
|||
|
|
@ -1621,10 +1621,10 @@ void Tileset::addTileToLoadQueue(
|
|||
[&](const TileLoadTask& task) { return task.pTile == &tile; }) ==
|
||||
frameState.viewGroup._mainThreadLoadQueue.end());
|
||||
|
||||
if (this->_pTilesetContentManager->tileNeedsWorkerThreadLoading(tile)) {
|
||||
if (tile.needsWorkerThreadLoading()) {
|
||||
frameState.viewGroup._workerThreadLoadQueue.push_back(
|
||||
{&tile, priorityGroup, priority});
|
||||
} else if (this->_pTilesetContentManager->tileNeedsMainThreadLoading(tile)) {
|
||||
} else if (tile.needsMainThreadLoading()) {
|
||||
frameState.viewGroup._mainThreadLoadQueue.push_back(
|
||||
{&tile, priorityGroup, priority});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,18 +133,6 @@ void unloadTileRecursively(
|
|||
}
|
||||
}
|
||||
|
||||
bool anyRasterOverlaysNeedLoading(const Tile& tile) noexcept {
|
||||
for (const RasterMappedTo3DTile& mapped : tile.getMappedRasterTiles()) {
|
||||
const RasterOverlayTile* pLoading = mapped.getLoadingTile();
|
||||
if (pLoading &&
|
||||
pLoading->getState() == RasterOverlayTile::LoadState::Unloaded) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::optional<RegionAndCenter>
|
||||
getTileBoundingRegionForUpsampling(const Tile& parent) {
|
||||
// To create subdivided children, we need to know a bounding region for each.
|
||||
|
|
@ -1384,20 +1372,6 @@ int64_t TilesetContentManager::getTotalDataUsed() const noexcept {
|
|||
return bytes;
|
||||
}
|
||||
|
||||
bool TilesetContentManager::tileNeedsWorkerThreadLoading(
|
||||
const Tile& tile) const noexcept {
|
||||
auto state = tile.getState();
|
||||
return state == TileLoadState::Unloaded ||
|
||||
state == TileLoadState::FailedTemporarily ||
|
||||
anyRasterOverlaysNeedLoading(tile);
|
||||
}
|
||||
|
||||
bool TilesetContentManager::tileNeedsMainThreadLoading(
|
||||
const Tile& tile) const noexcept {
|
||||
return tile.getState() == TileLoadState::ContentLoaded &&
|
||||
tile.isRenderContent();
|
||||
}
|
||||
|
||||
void TilesetContentManager::finishLoading(
|
||||
Tile& tile,
|
||||
const TilesetOptions& tilesetOptions) {
|
||||
|
|
|
|||
|
|
@ -144,9 +144,6 @@ public:
|
|||
|
||||
int64_t getTotalDataUsed() const noexcept;
|
||||
|
||||
bool tileNeedsWorkerThreadLoading(const Tile& tile) const noexcept;
|
||||
bool tileNeedsMainThreadLoading(const Tile& tile) const noexcept;
|
||||
|
||||
// Transition the tile from the ContentLoaded to the Done state.
|
||||
void finishLoading(Tile& tile, const TilesetOptions& tilesetOptions);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue