mirror of
https://github.com/TechplexEngineer/opensimWebAssets.git
synced 2026-08-14 09:12:10 +00:00
minor : getImageDatas() implementation
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
class WebAsset_Viewer implements IAssetViewer {
|
||||
private static $_instance; /**< pointer to current instance */
|
||||
|
||||
private $_asset;
|
||||
|
||||
/**
|
||||
* @brief simple singleton mechanism
|
||||
* @return (WebAsset_Viewer) newly_created or current instance
|
||||
@@ -33,12 +35,23 @@ class WebAsset_Viewer implements IAssetViewer {
|
||||
return (self::$_instance);
|
||||
}
|
||||
|
||||
public function load($assetUUID) {
|
||||
public function load($asset) {
|
||||
// if (fetch timeout) throw new WaException_Timeout("asset fetch timed out");
|
||||
// if (connect failed) throw new WaException_Fetch("unable to connect...");
|
||||
// if (cache or read failed) throw new WaException_Cache("write permission denied");
|
||||
// if (conversion failed) throw new WaException_Convert("Imagick error msg..")
|
||||
|
||||
}
|
||||
$this->_asset = $asset;
|
||||
|
||||
public function loadSuccessful() {
|
||||
$cache = WebAsset_Cache::instance();
|
||||
if ($cache->isCached($asset)) {
|
||||
// available in cache, no need to fetch asset
|
||||
// FIXME : if cache expires between load() and renderImage() | getImageDatas(), read fails
|
||||
return;
|
||||
}
|
||||
|
||||
$fetcher = WebAsset_Fetcher::instance();
|
||||
$cache->store($asset, $fetcher->fetch($asset));
|
||||
}
|
||||
|
||||
public function renderImage($toFormat) {
|
||||
@@ -46,7 +59,21 @@ class WebAsset_Viewer implements IAssetViewer {
|
||||
}
|
||||
|
||||
public function getImageDatas($toFormat) {
|
||||
$cache = WebAsset_Cache::instance();
|
||||
|
||||
$is_cached = $cache->isFormatCached($this->_asset, $toFormat);
|
||||
if ($is_cached) {
|
||||
return ($cache->retrieveFormat($this->_asset, $toFormat));
|
||||
}
|
||||
|
||||
// convert to requested format:
|
||||
$converter = WebAsset_Converter::instance();
|
||||
$datas = $converter->convert($this->_asset, $toFormat);
|
||||
|
||||
// store converted asset to cache:
|
||||
$cache->storeFormat($this->_asset, $toFormat, $datas);
|
||||
|
||||
return ($datas);
|
||||
}
|
||||
|
||||
public function renderSound() {
|
||||
|
||||
Reference in New Issue
Block a user