TBImage TBImageManager::GetImage(const char *filename) { uint32 hash_key = TBGetHash(filename); TBImageRep *image_rep = m_image_rep_hash.Get(hash_key); if (!image_rep) { // Load a fragment. Load a destination DPI bitmap if available. TBBitmapFragment *fragment = nullptr; if (g_tb_skin->GetDimensionConverter()->NeedConversion()) { TBTempBuffer filename_dst_DPI; g_tb_skin->GetDimensionConverter()->GetDstDPIFilename(filename, &filename_dst_DPI); fragment = m_frag_manager.GetFragmentFromFile(filename_dst_DPI.GetData(), false); } if (!fragment) fragment = m_frag_manager.GetFragmentFromFile(filename, false); image_rep = new TBImageRep(this, fragment, hash_key); if (!image_rep || !fragment || !m_image_rep_hash.Add(hash_key, image_rep)) { delete image_rep; m_frag_manager.FreeFragment(fragment); image_rep = nullptr; } TBDebugOut(image_rep ? "TBImageManager - Loaded new image.\n" : "TBImageManager - Loading image failed.\n"); } return TBImage(image_rep); }
void TBID::Set(const char *string) { id = TBGetHash(string); TB_IF_DEBUG(debug_string.Set(string)); if (!is_adding && tb_core_is_initialized()) { if (TBID *other_id = all_id_hash.Get(id)) { assert(other_id->debug_string.Equals(debug_string)); } else { is_adding = true; all_id_hash.Add(id, new TBID(*this)); is_adding = false; } } }