mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-03-06 14:27:43 +00:00
Renamed alwaysRasterize to forceRasterization.
Also removed an unnecessary function call in ImageComponent.
This commit is contained in:
parent
848e0a1a94
commit
3d3d951842
|
@ -333,7 +333,7 @@ void ImageComponent::setSaturation(float saturation)
|
|||
|
||||
void ImageComponent::updateVertices()
|
||||
{
|
||||
if (!mTexture || !mTexture->isInitialized())
|
||||
if (!mTexture)
|
||||
return;
|
||||
|
||||
// We go through this mess to make sure everything is properly rounded.
|
||||
|
@ -398,7 +398,7 @@ void ImageComponent::render(const glm::mat4& parentTrans)
|
|||
Renderer::drawRect(0.0f, 0.0f, mSize.x, mSize.y, 0xFF000033, 0xFF000033);
|
||||
}
|
||||
// An image with zero size would normally indicate a corrupt image file.
|
||||
if (mTexture->isInitialized() && mTexture->getSize() != glm::ivec2{}) {
|
||||
if (mTexture->getSize() != glm::ivec2{}) {
|
||||
// Actually draw the image.
|
||||
// The bind() function returns false if the texture is not currently loaded. A blank
|
||||
// texture is bound in this case but we want to handle a fade so it doesn't just
|
||||
|
|
|
@ -34,7 +34,7 @@ TextureData::TextureData(bool tile)
|
|||
, mScaleDuringLoad{1.0f}
|
||||
, mScalable{false}
|
||||
, mLinearMagnify{false}
|
||||
, mAlwaysRasterize{false}
|
||||
, mForceRasterization{false}
|
||||
, mPendingRasterization{false}
|
||||
{
|
||||
}
|
||||
|
@ -70,10 +70,10 @@ bool TextureData::initSVGFromMemory(const std::string& fileData)
|
|||
|
||||
bool rasterize{true};
|
||||
|
||||
// If there is no image size defined yet, then don't rasterize unless mAlwaysRasterize has
|
||||
// If there is no image size defined yet, then don't rasterize unless mForceRasterization has
|
||||
// been set (this is only used by NinePatchComponent to avoid flickering menus).
|
||||
if (mSourceWidth == 0.0f && mSourceHeight == 0.0f) {
|
||||
if (!mAlwaysRasterize)
|
||||
if (!mForceRasterization)
|
||||
rasterize = false;
|
||||
// Set a small temporary size that maintains the image aspect ratio.
|
||||
mSourceWidth = 64.0f;
|
||||
|
|
|
@ -62,7 +62,7 @@ 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 setAlwaysRasterize(bool setting) { mAlwaysRasterize = setting; }
|
||||
void setForceRasterization(bool setting) { mForceRasterization = setting; }
|
||||
|
||||
// Has the image been loaded but not yet been rasterized as the size was not known?
|
||||
bool getPendingRasterization() { return mPendingRasterization; }
|
||||
|
@ -85,7 +85,7 @@ private:
|
|||
bool mScalable;
|
||||
bool mLinearMagnify;
|
||||
bool mReloadable;
|
||||
bool mAlwaysRasterize;
|
||||
bool mForceRasterization;
|
||||
bool mPendingRasterization;
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ TextureResource::TextureResource(const std::string& path,
|
|||
bool tile,
|
||||
bool dynamic,
|
||||
bool linearMagnify,
|
||||
bool alwaysRasterize,
|
||||
bool forceRasterization,
|
||||
float scaleDuringLoad)
|
||||
: mTextureData(nullptr)
|
||||
, mForceLoad(false)
|
||||
|
@ -36,7 +36,7 @@ TextureResource::TextureResource(const std::string& path,
|
|||
if (scaleDuringLoad != 1.0f)
|
||||
data->setScaleDuringLoad(scaleDuringLoad);
|
||||
data->setLinearMagnify(linearMagnify);
|
||||
data->setAlwaysRasterize(alwaysRasterize);
|
||||
data->setForceRasterization(forceRasterization);
|
||||
// Force the texture manager to load it using a blocking load.
|
||||
sTextureDataManager.load(data, true);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ TextureResource::TextureResource(const std::string& path,
|
|||
if (scaleDuringLoad != 1.0f)
|
||||
data->setScaleDuringLoad(scaleDuringLoad);
|
||||
data->setLinearMagnify(linearMagnify);
|
||||
data->setAlwaysRasterize(alwaysRasterize);
|
||||
data->setForceRasterization(forceRasterization);
|
||||
// Load it so we can read the width/height.
|
||||
data->load();
|
||||
}
|
||||
|
@ -154,15 +154,15 @@ std::shared_ptr<TextureResource> TextureResource::get(const std::string& path,
|
|||
bool forceLoad,
|
||||
bool dynamic,
|
||||
bool linearMagnify,
|
||||
bool alwaysRasterize,
|
||||
bool forceRasterization,
|
||||
float scaleDuringLoad)
|
||||
{
|
||||
std::shared_ptr<ResourceManager>& rm = ResourceManager::getInstance();
|
||||
|
||||
const std::string canonicalPath = Utils::FileSystem::getCanonicalPath(path);
|
||||
if (canonicalPath.empty()) {
|
||||
std::shared_ptr<TextureResource> tex(
|
||||
new TextureResource("", tile, false, linearMagnify, alwaysRasterize, scaleDuringLoad));
|
||||
std::shared_ptr<TextureResource> tex(new TextureResource(
|
||||
"", tile, false, linearMagnify, forceRasterization, scaleDuringLoad));
|
||||
// Make sure we get properly deinitialized even though we do nothing on reinitialization.
|
||||
rm->addReloadable(tex);
|
||||
return tex;
|
||||
|
@ -179,7 +179,7 @@ std::shared_ptr<TextureResource> TextureResource::get(const std::string& path,
|
|||
// Need to create it.
|
||||
std::shared_ptr<TextureResource> tex;
|
||||
tex = std::shared_ptr<TextureResource>(new TextureResource(
|
||||
key.first, tile, dynamic, linearMagnify, alwaysRasterize, scaleDuringLoad));
|
||||
key.first, tile, dynamic, linearMagnify, forceRasterization, scaleDuringLoad));
|
||||
std::shared_ptr<TextureData> data = sTextureDataManager.get(tex.get());
|
||||
|
||||
// Is it an SVG?
|
||||
|
@ -217,7 +217,7 @@ void TextureResource::rasterizeAt(float width, float height)
|
|||
data = sTextureDataManager.get(this);
|
||||
mSourceSize = glm::vec2{static_cast<float>(width), static_cast<float>(height)};
|
||||
data->setSourceSize(static_cast<float>(width), static_cast<float>(height));
|
||||
if (mForceLoad || (mTextureData != nullptr))
|
||||
if (mForceLoad || mTextureData != nullptr)
|
||||
data->load();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
bool forceLoad = false,
|
||||
bool dynamic = true,
|
||||
bool linearMagnify = false,
|
||||
bool alwaysRasterize = false,
|
||||
bool forceRasterization = false,
|
||||
float scaleDuringLoad = 1.0f);
|
||||
void initFromPixels(const unsigned char* dataRGBA, size_t width, size_t height);
|
||||
virtual void initFromMemory(const char* data, size_t length);
|
||||
|
@ -41,7 +41,10 @@ public:
|
|||
std::vector<unsigned char> getRawRGBAData();
|
||||
|
||||
// Has the image been loaded but not yet been rasterized as the size was not known?
|
||||
bool getPendingRasterization() { return mTextureData->getPendingRasterization(); }
|
||||
bool getPendingRasterization()
|
||||
{
|
||||
return (mTextureData != nullptr ? mTextureData->getPendingRasterization() : false);
|
||||
}
|
||||
|
||||
std::string getTextureFilePath();
|
||||
|
||||
|
@ -54,7 +57,6 @@ public:
|
|||
|
||||
virtual ~TextureResource();
|
||||
|
||||
bool isInitialized() const { return true; }
|
||||
bool isTiled() const;
|
||||
|
||||
const glm::ivec2 getSize() const { return mSize; }
|
||||
|
@ -70,7 +72,7 @@ protected:
|
|||
bool tile,
|
||||
bool dynamic,
|
||||
bool linearMagnify,
|
||||
bool alwaysRasterize,
|
||||
bool forceRasterization,
|
||||
float scaleDuringLoad);
|
||||
virtual void unload(std::shared_ptr<ResourceManager>& rm);
|
||||
virtual void reload(std::shared_ptr<ResourceManager>& rm);
|
||||
|
|
Loading…
Reference in a new issue