csRef<iDataBuffer> csCommonImageFile::GetRawData() const { csRef<iDataBuffer> d; #ifdef THREADED_LOADING if (!loadJob) return d; WaitForJob(); csRef<iImageFileLoader> currentLoader = loadJob->currentLoader; #endif if (currentLoader.IsValid() && (DataTypeString (currentLoader->GetDataType()) != 0)) return currentLoader->GetRawData(); MakeImageData(); return csImageMemory::GetRawData (); }
void csCommonImageFile::MakeImageData() const { #ifdef THREADED_LOADING if (loadJob) { WaitForJob(); // Ugly ugly ugly so we can call ApplyTo()... csImageMemory* thisNonConst = const_cast<csCommonImageFile*> (this); loadJob->currentLoader->ApplyTo (thisNonConst); loadJob = 0; jobQueue = 0; } #else if (currentLoader) { // Ugly ugly ugly so we can call ApplyTo()... csImageMemory* thisNonConst = const_cast<csCommonImageFile*> (this); currentLoader->ApplyTo (thisNonConst); currentLoader = 0; } #endif }
static SrvJob *NextJob(int wait) { SrvJob *job; int done = 0; while (!done) { LockQueue(); job = FirstQueueEntry; if (job) { FirstQueueEntry = job->h.next; if (FirstQueueEntry != 0) FirstQueueEntry->h.previous = 0; else LastQueueEntry = 0; } UnlockQueue(); if (job || (!wait)) done = 1; else WaitForJob(); } return job; }