mirror of
https://github.com/leozide/leocad.git
synced 2026-10-26 22:10:32 +00:00
Keep piece readiness, mesh publication, and settled synth errors in the library while the loader manages scheduling, request outcomes, cancellation, and deferred notifications. Capture synth inputs and base identities at the library boundary so the loader treats pieces as opaque identities. Use a shared asset readiness enum for pieces and textures. Keep texture queueing, decoding, and retry progress in requests, pass resolved sources to the loader, and centralize texture failure messages in lcTexture. Preserve scoped wait failure and cancellation results alongside final readiness checks. Consolidate shared priorities, sources, snapshots, build results, and texture error codes in lc_assettypes.h, replacing lc_filesource.h. Forward declarations remove the loader header's piece, library, and texture-manager dependencies. Validated with the Qt Debug build, header isolation compilation, asset loader lifecycle and scheduling regression checks, and 14 first/repeat export checks.
125 lines
2.5 KiB
C++
125 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#define LC_TEXTURE_WRAPU 0x01
|
|
#define LC_TEXTURE_WRAPV 0x02
|
|
#define LC_TEXTURE_MIPMAPS 0x04
|
|
#define LC_TEXTURE_CUBEMAP 0x08
|
|
|
|
#define LC_TEXTURE_POINT 0x00
|
|
#define LC_TEXTURE_LINEAR 0x10
|
|
#define LC_TEXTURE_BILINEAR 0x20
|
|
#define LC_TEXTURE_TRILINEAR 0x30
|
|
#define LC_TEXTURE_ANISOTROPIC 0x40
|
|
#define LC_TEXTURE_FILTER_MASK 0xf0
|
|
#define LC_TEXTURE_FILTER_SHIFT 4
|
|
|
|
#define LC_TEXTURE_NAME_LEN 256
|
|
|
|
#include "lc_assettypes.h"
|
|
|
|
class lcTexture
|
|
{
|
|
public:
|
|
lcTexture(int Flags = 0);
|
|
~lcTexture();
|
|
|
|
lcTexture(const lcTexture&) = delete;
|
|
lcTexture(lcTexture&&) = delete;
|
|
lcTexture& operator=(const lcTexture&) = delete;
|
|
lcTexture& operator=(lcTexture&&) = delete;
|
|
|
|
void CreateGridTexture();
|
|
static QImage PrepareImage(QImage Image);
|
|
|
|
void SetImage(QImage Image, int Flags);
|
|
void SetImages(std::vector<QImage>&& Images, int Flags);
|
|
void DiscardDecodedImage();
|
|
// Records a failure without discarding pixels retained for upload retries.
|
|
void SetFailed(lcTextureLoadError Error, QString Details);
|
|
// Failure details or a fallback message; empty unless loading has failed.
|
|
QString GetLoadError() const;
|
|
void Upload(lcContext* Context);
|
|
void Unload();
|
|
|
|
bool HasImageData() const
|
|
{
|
|
return mTexture != 0 || !mImages.empty();
|
|
}
|
|
|
|
// Reference bookkeeping belongs to lcTextureManager.
|
|
void AddRef()
|
|
{
|
|
mRefCount.ref();
|
|
}
|
|
|
|
// Reference bookkeeping belongs to lcTextureManager.
|
|
bool Release()
|
|
{
|
|
const bool InUse = mRefCount.deref();
|
|
|
|
if (!InUse)
|
|
Unload();
|
|
|
|
return InUse;
|
|
}
|
|
|
|
int GetRefCount() const
|
|
{
|
|
return mRefCount.loadRelaxed();
|
|
}
|
|
|
|
void SetTemporary(bool Temporary)
|
|
{
|
|
mTemporary = Temporary;
|
|
}
|
|
|
|
bool IsTemporary() const
|
|
{
|
|
return mTemporary;
|
|
}
|
|
|
|
bool NeedsUpload() const
|
|
{
|
|
return mTexture == 0 && !mImages.empty() && mState != lcAssetState::Failed;
|
|
}
|
|
|
|
bool IsReady() const
|
|
{
|
|
return mState == lcAssetState::Loaded && mTexture != 0;
|
|
}
|
|
|
|
int GetFlags() const
|
|
{
|
|
return mFlags;
|
|
}
|
|
|
|
const QImage& GetImage(int Index) const
|
|
{
|
|
return mImages[Index];
|
|
}
|
|
|
|
size_t GetImageCount() const
|
|
{
|
|
return mImages.size();
|
|
}
|
|
|
|
int mWidth;
|
|
int mHeight;
|
|
char mName[LC_TEXTURE_NAME_LEN] = {};
|
|
lcFileSource mSource;
|
|
GLuint mTexture = 0;
|
|
lcAssetState mState = lcAssetState::Unloaded;
|
|
lcTextureLoadError mLoadFailure = lcTextureLoadError::None;
|
|
QString mLoadFailureDetails;
|
|
|
|
protected:
|
|
bool mTemporary = false;
|
|
QAtomicInt mRefCount = 0;
|
|
std::vector<QImage> mImages;
|
|
int mFlags = 0;
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(lcTexture)
|
|
};
|
|
|
|
extern lcTexture* gGridTexture;
|