D3D9Image* MythD3D9Painter::GetImageFromCache(MythImage *im) { if (m_ImageBitmapMap.contains(im)) { if (!im->IsChanged()) { m_ImageExpireList.remove(im); m_ImageExpireList.push_back(im); return m_ImageBitmapMap[im]; } else { DeleteFormatImagePriv(im); } } im->SetChanged(false); D3D9Image *newimage = NULL; if (m_render) newimage = new D3D9Image(m_render,im->size()); if (newimage && newimage->IsValid()) { CheckFormatImage(im); m_HardwareCacheSize += newimage->GetDataSize(); newimage->UpdateImage(im); m_ImageBitmapMap[im] = newimage; m_ImageExpireList.push_back(im); while (m_HardwareCacheSize > m_MaxHardwareCacheSize) { MythImage *expiredIm = m_ImageExpireList.front(); m_ImageExpireList.pop_front(); DeleteFormatImagePriv(expiredIm); DeleteBitmaps(); } } else { LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create D3D9 UI bitmap."); delete newimage; newimage = NULL; } return newimage; }
uint MythVDPAUPainter::GetTextureFromCache(MythImage *im) { if (m_ImageBitmapMap.contains(im)) { if (!im->IsChanged()) { m_ImageExpireList.remove(im); m_ImageExpireList.push_back(im); return m_ImageBitmapMap[im]; } else { DeleteFormatImagePriv(im); } } im->SetChanged(false); uint newbitmap = 0; if (m_render) newbitmap = m_render->CreateBitmapSurface(im->size()); if (newbitmap) { CheckFormatImage(im); m_render->UploadMythImage(newbitmap, im); m_ImageBitmapMap[im] = newbitmap; m_ImageExpireList.push_back(im); m_HardwareCacheSize += m_render->GetBitmapSize(newbitmap); while (m_HardwareCacheSize > m_MaxHardwareCacheSize) { MythImage *expiredIm = m_ImageExpireList.front(); m_ImageExpireList.pop_front(); DeleteFormatImagePriv(expiredIm); DeleteBitmaps(); } } else { LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create VDPAU UI bitmap."); } return newbitmap; }