Removed the deprecated SVG force rasterization flag from the cache manager.

This commit is contained in:
Leon Styhre 2022-08-28 20:21:58 +02:00
parent 48a9571609
commit 2c86e4f99e
6 changed files with 12 additions and 25 deletions

View file

@ -166,14 +166,14 @@ void ImageComponent::setImage(const std::string& path, bool tile)
// we perform the actual rasterization to have the cache entry updated with the proper
// texture. For SVG images this requires that every call to setImage is made only after
// a call to setResize or setMaxSize (so the requested size is known upfront).
mTexture = TextureResource::get(path, tile, mForceLoad, mDynamic, mLinearInterpolation,
false, 0, 0, mTileWidth, mTileHeight);
mTexture = TextureResource::get(path, tile, mForceLoad, mDynamic, mLinearInterpolation, 0,
0, mTileWidth, mTileHeight);
if (isScalable) {
resize(false);
mTexture.reset();
mTexture = TextureResource::get(path, tile, mForceLoad, mDynamic, mLinearInterpolation,
false, static_cast<size_t>(mSize.x),
static_cast<size_t>(mSize.x),
static_cast<size_t>(mSize.y), mTileWidth, mTileHeight);
mTexture->rasterizeAt(mSize.x, mSize.y);
onSizeChanged();

View file

@ -66,7 +66,7 @@ void NinePatchComponent::buildVertices()
}
glm::vec2 texSize {relCornerSize * 3.0f};
mTexture = TextureResource::get(mPath, false, false, false, false, false,
mTexture = TextureResource::get(mPath, false, false, false, false,
static_cast<size_t>(texSize.x), static_cast<size_t>(texSize.y));
mTexture->rasterizeAt(texSize.x, texSize.y);

View file

@ -38,7 +38,6 @@ TextureData::TextureData(bool tile)
, mHasRGBAData {false}
, mPendingRasterization {false}
, mLinearMagnify {false}
, mForceRasterization {false}
{
}
@ -84,10 +83,8 @@ bool TextureData::initSVGFromMemory(const std::string& fileData)
}
}
// If there is no image size defined yet, then don't rasterize unless mForceRasterization has
// been set.
// If there is no image size defined yet, then don't rasterize.
if (mSourceWidth == 0.0f && mSourceHeight == 0.0f) {
if (!mForceRasterization)
rasterize = false;
// Set a small temporary size that maintains the image aspect ratio.
mSourceWidth = 64.0f;

View file

@ -66,8 +66,6 @@ public:
// Whether to use linear filtering when magnifying the texture.
void setLinearMagnify(bool setting) { mLinearMagnify = setting; }
// Whether to rasterize the image even if a size has not been set yet.
void setForceRasterization(bool setting) { mForceRasterization = setting; }
// Has the image been loaded but not yet been rasterized as the size was not known?
const bool getPendingRasterization() { return mPendingRasterization; }
@ -96,7 +94,6 @@ private:
std::atomic<bool> mPendingRasterization;
bool mLinearMagnify;
bool mReloadable;
bool mForceRasterization;
};
#endif // ES_CORE_RESOURCES_TEXTURE_DATA_H

View file

@ -20,8 +20,7 @@ TextureResource::TextureResource(const std::string& path,
bool tile,
bool dynamic,
bool linearMagnify,
bool scalable,
bool forceRasterization)
bool scalable)
: mTextureData {nullptr}
, mForceLoad {false}
{
@ -35,7 +34,6 @@ TextureResource::TextureResource(const std::string& path,
data->initFromPath(path);
data->setTileSize(tileWidth, tileHeight);
data->setLinearMagnify(linearMagnify);
data->setForceRasterization(forceRasterization);
// Force the texture manager to load it using a blocking load.
sTextureDataManager.load(data, true);
}
@ -45,7 +43,6 @@ TextureResource::TextureResource(const std::string& path,
data->initFromPath(path);
data->setTileSize(tileWidth, tileHeight);
data->setLinearMagnify(linearMagnify);
data->setForceRasterization(forceRasterization);
// Load it so we can read the width/height.
data->load();
}
@ -156,7 +153,6 @@ std::shared_ptr<TextureResource> TextureResource::get(const std::string& path,
bool forceLoad,
bool dynamic,
bool linearMagnify,
bool forceRasterization,
size_t width,
size_t height,
float tileWidth,
@ -164,8 +160,8 @@ std::shared_ptr<TextureResource> TextureResource::get(const std::string& path,
{
const std::string canonicalPath {Utils::FileSystem::getCanonicalPath(path)};
if (canonicalPath.empty()) {
std::shared_ptr<TextureResource> tex(new TextureResource(
"", tileWidth, tileHeight, tile, false, linearMagnify, false, forceRasterization));
std::shared_ptr<TextureResource> tex(
new TextureResource("", tileWidth, tileHeight, tile, false, linearMagnify, false));
// Make sure we get properly deinitialized even though we do nothing on reinitialization.
ResourceManager::getInstance().addReloadable(tex);
return tex;
@ -210,9 +206,8 @@ std::shared_ptr<TextureResource> TextureResource::get(const std::string& path,
}
// Need to create it.
std::shared_ptr<TextureResource> tex {std::shared_ptr<TextureResource>(
new TextureResource(std::get<0>(key), tileWidth, tileHeight, tile, dynamic, linearMagnify,
isScalable, forceRasterization))};
std::shared_ptr<TextureResource> tex {std::shared_ptr<TextureResource>(new TextureResource(
std::get<0>(key), tileWidth, tileHeight, tile, dynamic, linearMagnify, isScalable))};
std::shared_ptr<TextureData> data {sTextureDataManager.get(tex.get())};
if (!isScalable || (isScalable && width != 0.0f && height != 0.0f)) {

View file

@ -31,7 +31,6 @@ public:
bool forceLoad = false,
bool dynamic = true,
bool linearMagnify = false,
bool forceRasterization = false,
size_t width = 0,
size_t height = 0,
float tileWidth = 0.0f,
@ -86,8 +85,7 @@ protected:
bool tile,
bool dynamic,
bool linearMagnify,
bool scalable,
bool forceRasterization);
bool scalable);
virtual void unload(ResourceManager& rm);
virtual void reload(ResourceManager& rm);