Skip to content

Commit

Permalink
Better naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Oct 4, 2024
1 parent ab21441 commit 275bac0
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ class CESIUM3DTILESSELECTION_API Tileset final {
/**
* @brief Returns the {@link SharedAssetDepot} of this tileset.
*/
CesiumGltf::SharedAssetDepots& getSharedAssetDepot() noexcept;
CesiumGltf::SharedAssetSystem& getSharedAssetSystem() noexcept;

/** @copydoc Tileset::getSharedAssetDepot() */
const CesiumGltf::SharedAssetDepots& getSharedAssetDepot() const noexcept;
/** @copydoc Tileset::getSharedAssetSystem() */
const CesiumGltf::SharedAssetSystem& getSharedAssetSystem() const noexcept;

/**
* @brief Updates this view but waits for all tiles that meet sse to finish
Expand Down
2 changes: 1 addition & 1 deletion Cesium3DTilesSelection/src/TileContentLoadInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ TileContentLoadInfo::TileContentLoadInfo(
const std::shared_ptr<IPrepareRendererResources>&
pPrepareRendererResources_,
const std::shared_ptr<spdlog::logger>& pLogger_,
const CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetDepots>
const CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetSystem>
pAssetDepot_,
const TilesetContentOptions& contentOptions_,
const Tile& tile)
Expand Down
6 changes: 3 additions & 3 deletions Cesium3DTilesSelection/src/TileContentLoadInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <CesiumAsync/AsyncSystem.h>
#include <CesiumAsync/IAssetAccessor.h>
#include <CesiumGeometry/Axis.h>
#include <CesiumGltf/SharedAssetDepots.h>
#include <CesiumGltf/SharedAssetSystem.h>

#include <gsl/span>
#include <spdlog/fwd.h>
Expand All @@ -25,7 +25,7 @@ struct TileContentLoadInfo {
const std::shared_ptr<IPrepareRendererResources>&
pPrepareRendererResources,
const std::shared_ptr<spdlog::logger>& pLogger,
const CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetDepots>
const CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetSystem>
maybeAssetDepot,
const TilesetContentOptions& contentOptions,
const Tile& tile);
Expand All @@ -43,7 +43,7 @@ struct TileContentLoadInfo {
BoundingVolume tileBoundingVolume;

std::optional<BoundingVolume> tileContentBoundingVolume;
CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetDepots> pAssetDepot;
CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetSystem> pAssetDepot;

TileRefine tileRefine;

Expand Down
10 changes: 5 additions & 5 deletions Cesium3DTilesSelection/src/Tileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ const RasterOverlayCollection& Tileset::getOverlays() const noexcept {
return this->_pTilesetContentManager->getRasterOverlayCollection();
}

CesiumGltf::SharedAssetDepots& Tileset::getSharedAssetDepot() noexcept {
return *this->_pTilesetContentManager->getSharedAssetDepot();
CesiumGltf::SharedAssetSystem& Tileset::getSharedAssetSystem() noexcept {
return *this->_pTilesetContentManager->getSharedAssetSystem();
}

const CesiumGltf::SharedAssetDepots&
Tileset::getSharedAssetDepot() const noexcept {
return *this->_pTilesetContentManager->getSharedAssetDepot();
const CesiumGltf::SharedAssetSystem&
Tileset::getSharedAssetSystem() const noexcept {
return *this->_pTilesetContentManager->getSharedAssetSystem();
}

static bool
Expand Down
10 changes: 5 additions & 5 deletions Cesium3DTilesSelection/src/TilesetContentManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ TilesetContentManager::TilesetContentManager(
_tileLoadsInProgress{0},
_loadedTilesCount{0},
_tilesDataUsed{0},
_pAssetDepot(new CesiumGltf::SharedAssetDepots()),
_pAssetDepot(new CesiumGltf::SharedAssetSystem()),
_destructionCompletePromise{externals.asyncSystem.createPromise<void>()},
_destructionCompleteFuture{
this->_destructionCompletePromise.getFuture().share()},
Expand Down Expand Up @@ -696,7 +696,7 @@ TilesetContentManager::TilesetContentManager(
_tileLoadsInProgress{0},
_loadedTilesCount{0},
_tilesDataUsed{0},
_pAssetDepot(new CesiumGltf::SharedAssetDepots()),
_pAssetDepot(new CesiumGltf::SharedAssetSystem()),
_destructionCompletePromise{externals.asyncSystem.createPromise<void>()},
_destructionCompleteFuture{
this->_destructionCompletePromise.getFuture().share()},
Expand Down Expand Up @@ -848,7 +848,7 @@ TilesetContentManager::TilesetContentManager(
_tileLoadsInProgress{0},
_loadedTilesCount{0},
_tilesDataUsed{0},
_pAssetDepot(new CesiumGltf::SharedAssetDepots()),
_pAssetDepot(new CesiumGltf::SharedAssetSystem()),
_destructionCompletePromise{externals.asyncSystem.createPromise<void>()},
_destructionCompleteFuture{
this->_destructionCompletePromise.getFuture().share()},
Expand Down Expand Up @@ -1237,8 +1237,8 @@ TilesetContentManager::getTilesetCredits() const noexcept {
return this->_tilesetCredits;
}

const CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetDepots>&
TilesetContentManager::getSharedAssetDepot() const noexcept {
const CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetSystem>&
TilesetContentManager::getSharedAssetSystem() const noexcept {
return this->_pAssetDepot;
}

Expand Down
6 changes: 3 additions & 3 deletions Cesium3DTilesSelection/src/TilesetContentManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ class TilesetContentManager

const std::vector<CesiumUtility::Credit>& getTilesetCredits() const noexcept;

const CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetDepots>&
getSharedAssetDepot() const noexcept;
const CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetSystem>&
getSharedAssetSystem() const noexcept;

int32_t getNumberOfTilesLoading() const noexcept;

Expand Down Expand Up @@ -172,7 +172,7 @@ class TilesetContentManager
int64_t _tilesDataUsed;

// Stores assets that might be shared between tiles.
CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetDepots> _pAssetDepot;
CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetSystem> _pAssetDepot;

CesiumAsync::Promise<void> _destructionCompletePromise;
CesiumAsync::SharedFuture<void> _destructionCompleteFuture;
Expand Down
4 changes: 2 additions & 2 deletions Cesium3DTilesSelection/src/TilesetJsonLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <Cesium3DTilesSelection/TilesetExternals.h>
#include <CesiumAsync/Future.h>
#include <CesiumAsync/IAssetAccessor.h>
#include <CesiumGltf/SharedAssetDepots.h>
#include <CesiumGltf/SharedAssetSystem.h>

#include <rapidjson/fwd.h>

Expand Down Expand Up @@ -56,7 +56,7 @@ class TilesetJsonLoader : public TilesetContentLoader {
private:
std::string _baseUrl;
CesiumGeospatial::Ellipsoid _ellipsoid;
CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetDepots> _pAssetDepot;
CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetSystem> _pAssetDepot;

/**
* @brief The axis that was declared as the "up-axis" for glTF content.
Expand Down
4 changes: 1 addition & 3 deletions Cesium3DTilesSelection/test/TestTilesetContentManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1682,9 +1682,7 @@ TEST_CASE("Test the tileset content manager's post processing for gltf") {
CHECK(images.size() == 1);
}

CHECK(
pManager->getSharedAssetDepot()->getImageDepot()->getDistinctCount() ==
2);
CHECK(pManager->getSharedAssetSystem()->image().getDistinctCount() == 2);

// unload the tile content
for (auto& child : containerTile.getChildren()) {
Expand Down
10 changes: 4 additions & 6 deletions CesiumGltf/include/CesiumGltf/SharedAssetDepot.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@

#include <chrono>
#include <cstddef>
#include <forward_list>
#include <functional>
#include <memory>
#include <mutex>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <variant>
#include <vector>

namespace CesiumGltf {

Expand Down Expand Up @@ -184,8 +182,8 @@ class SharedAssetDepot : public CesiumUtility::ReferenceCountedThreadSafe<
*/
size_t getUsageCount() const {
size_t count = 0;
for (auto& [key, item] : assets) {
count += item->counter;
for (const auto& [key, item] : assets) {
count += item->_referenceCount;
}
return count;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
#pragma once

#include <CesiumAsync/SharedFuture.h>
#include <CesiumGltf/ImageCesium.h>
#include <CesiumGltf/SharedAssetDepot.h>

namespace CesiumGltf {

struct ImageCesium;

/**
* @brief Contains assets that are potentially shared across multiple glTF
* models.
*/
class SharedAssetDepots
: public CesiumUtility::ReferenceCountedThreadSafe<SharedAssetDepots> {
class SharedAssetSystem
: public CesiumUtility::ReferenceCountedThreadSafe<SharedAssetSystem> {
public:
SharedAssetDepots() = default;
void operator=(const SharedAssetDepots& other) = delete;
SharedAssetSystem() noexcept;
~SharedAssetSystem() noexcept;

SharedAssetSystem(const SharedAssetSystem&) = delete;
void operator=(const SharedAssetSystem& other) = delete;

/**
* Obtains an existing {@link ImageCesium} or constructs a new one using the provided factory.
Expand All @@ -27,18 +32,17 @@ class SharedAssetDepots
const Factory& factory,
const std::string& uri,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& headers) {
return images
.getOrFetch(asyncSystem, pAssetAccessor, factory, uri, headers);
return this->_pImages
->getOrFetch(asyncSystem, pAssetAccessor, factory, uri, headers);
}

const SharedAssetDepot<CesiumGltf::ImageCesium>* getImageDepot() {
return &this->images;
}
const SharedAssetDepot<CesiumGltf::ImageCesium>& image();

void deletionTick() { this->images.deletionTick(); }
void deletionTick();

private:
SharedAssetDepot<CesiumGltf::ImageCesium> images;
CesiumUtility::IntrusivePointer<SharedAssetDepot<CesiumGltf::ImageCesium>>
_pImages;
};

} // namespace CesiumGltf
17 changes: 17 additions & 0 deletions CesiumGltf/src/SharedAssetSystem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <CesiumGltf/ImageCesium.h>
#include <CesiumGltf/SharedAssetSystem.h>

namespace CesiumGltf {

SharedAssetSystem::SharedAssetSystem() noexcept
: _pImages(new SharedAssetDepot<CesiumGltf::ImageCesium>()) {}

SharedAssetSystem::~SharedAssetSystem() noexcept = default;

const SharedAssetDepot<CesiumGltf::ImageCesium>& SharedAssetSystem::image() {
return *this->_pImages;
}

void SharedAssetSystem::deletionTick() { this->_pImages->deletionTick(); }

} // namespace CesiumGltf
4 changes: 2 additions & 2 deletions CesiumGltfReader/include/CesiumGltfReader/GltfReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <CesiumGltf/ImageCesium.h>
#include <CesiumGltf/Ktx2TranscodeTargets.h>
#include <CesiumGltf/Model.h>
#include <CesiumGltf/SharedAssetDepots.h>
#include <CesiumGltf/SharedAssetSystem.h>
#include <CesiumJsonReader/IExtensionJsonHandler.h>
#include <CesiumJsonReader/JsonReaderOptions.h>

Expand Down Expand Up @@ -115,7 +115,7 @@ struct CESIUMGLTFREADER_API GltfReaderOptions {
* appear in this glTF. If not present, assets will not be shared between
* glTFs, even if they're loaded from the same URL.
*/
CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetDepots> pSharedAssets =
CesiumUtility::IntrusivePointer<CesiumGltf::SharedAssetSystem> pSharedAssets =
nullptr;
};

Expand Down

0 comments on commit 275bac0

Please sign in to comment.