void UIDirect3D9Window::DrawShape(UIEffect *Effect, QRectF *Dest, bool &PositionChanged, UIShapePath *Path) { if (!Dest || !Path) return; UIImage* image = GetShapeImage(Path, Dest); if (!image) return; if (image->GetState() == UIImage::ImageLoading) return; PositionChanged |= Path->IsShared(); DrawImage(Effect, Dest, PositionChanged, image); }
UIImage* UIDirect3D9Window::DrawText(UIEffect *Effect, QRectF *Dest, bool &PositionChanged, const QString &Text, UIFont *Font, int Flags, int Blur, UIImage *Fallback) { if (!Font->GetImageReady()) { // font is image backed QString file = Font->GetImageFileName(); UIImage *image = Font->GetImage(); // allocate an image if (!image) { QString name = Font->GetHash() + file; QSize size(Dest->size().width(), Dest->size().height()); image = AllocateImage(name, size, file); Font->SetImage(image); } if (!image) { LOG(VB_GENERAL, LOG_ERR, QString("Failed to load '%1' text image.") .arg(file)); // don't try again Font->SetImageReady(true); return NULL; } UIImage::ImageState state = image->GetState(); if (state == UIImage::ImageUploadedToGPU || state == UIImage::ImageReleasedFromGPU) { LOG(VB_GENERAL, LOG_ERR, "Font image cannot be unloaded from memory"); Font->SetImageReady(true); return NULL; } if (state == UIImage::ImageLoading) return NULL; // trigger loading if (state == UIImage::ImageNull) { LoadImageFromFile(image); return NULL; } // update the font's brush Font->UpdateTexture(); } UIImage* image = GetSimpleTextImage(Text, Dest, Font, Flags, Blur); if (!image) return NULL; if ((image->GetState() == UIImage::ImageLoading) && Fallback) image = Fallback; DrawImage(Effect, Dest, PositionChanged, image); return image; }