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 // 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 // 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). // a call to setResize or setMaxSize (so the requested size is known upfront).
mTexture = TextureResource::get(path, tile, mForceLoad, mDynamic, mLinearInterpolation, mTexture = TextureResource::get(path, tile, mForceLoad, mDynamic, mLinearInterpolation, 0,
false, 0, 0, mTileWidth, mTileHeight); 0, mTileWidth, mTileHeight);
if (isScalable) { if (isScalable) {
resize(false); resize(false);
mTexture.reset(); mTexture.reset();
mTexture = TextureResource::get(path, tile, mForceLoad, mDynamic, mLinearInterpolation, 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); static_cast<size_t>(mSize.y), mTileWidth, mTileHeight);
mTexture->rasterizeAt(mSize.x, mSize.y); mTexture->rasterizeAt(mSize.x, mSize.y);
onSizeChanged(); onSizeChanged();

View file

@ -66,7 +66,7 @@ void NinePatchComponent::buildVertices()
} }
glm::vec2 texSize {relCornerSize * 3.0f}; 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)); static_cast<size_t>(texSize.x), static_cast<size_t>(texSize.y));
mTexture->rasterizeAt(texSize.x, texSize.y); mTexture->rasterizeAt(texSize.x, texSize.y);

View file

@ -38,7 +38,6 @@ TextureData::TextureData(bool tile)
, mHasRGBAData {false} , mHasRGBAData {false}
, mPendingRasterization {false} , mPendingRasterization {false}
, mLinearMagnify {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 // If there is no image size defined yet, then don't rasterize.
// been set.
if (mSourceWidth == 0.0f && mSourceHeight == 0.0f) { if (mSourceWidth == 0.0f && mSourceHeight == 0.0f) {
if (!mForceRasterization)
rasterize = false; rasterize = false;
// Set a small temporary size that maintains the image aspect ratio. // Set a small temporary size that maintains the image aspect ratio.
mSourceWidth = 64.0f; mSourceWidth = 64.0f;

View file

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

View file

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

View file

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