MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / LoadSprites

Method LoadSprites

Source/Engine/Render2D/SpriteAtlas.cpp:137–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135#endif
136
137bool SpriteAtlas::LoadSprites(ReadStream& stream)
138{
139 ScopeLock lock(Locker);
140
141 // Sprites may be used on rendering thread so lock drawing for a while
142#if USE_EDITOR
143 GPUDevice* gpuDevice = GPUDevice::Instance;
144 if (gpuDevice)
145 gpuDevice->Locker.Lock();
146#endif
147
148 Sprites.Clear();
149
150 int32 tilesVersion, tilesCount;
151 stream.Read(tilesVersion);
152 if (tilesVersion != 1)
153 {
154#if USE_EDITOR
155 if (gpuDevice)
156 gpuDevice->Locker.Unlock();
157#endif
158 LOG(Warning, "Invalid tiles version.");
159 return true;
160 }
161 stream.Read(tilesCount);
162 Sprites.Resize(tilesCount);
163 for (Sprite& t : Sprites)
164 {
165 stream.Read(t.Area);
166 stream.Read(t.Name, 49);
167 }
168
169#if USE_EDITOR
170 if (gpuDevice)
171 gpuDevice->Locker.Unlock();
172#endif
173 return false;
174}
175
176Asset::LoadResult SpriteAtlas::load()
177{

Callers

nothing calls this directly

Calls 5

LockMethod · 0.80
UnlockMethod · 0.80
ClearMethod · 0.45
ReadMethod · 0.45
ResizeMethod · 0.45

Tested by

no test coverage detected