MCPcopy Create free account
hub / github.com/defold/defold / GetOrCreateCachedTextLayout

Function GetOrCreateCachedTextLayout

engine/profiler/src/profiler_render.cpp:228–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226 }
227
228 static HTextLayout GetOrCreateCachedTextLayout(HRenderProfile render_profile, dmRender::HFontMap font_map, const char* text, const dmRender::DrawTextParams& params)
229 {
230 const char* safe_text = text ? text : "";
231 uint64_t text_hash = dmHashBufferNoReverse64(safe_text, (uint32_t)strlen(safe_text));
232
233 HTextLayout* cached_layout = render_profile->m_LabelTextLayouts.Get(text_hash);
234 if (cached_layout)
235 return *cached_layout;
236
237 HTextLayout layout = 0;
238 if (!CreateProfilerTextLayout(render_profile, font_map, safe_text, params, &layout))
239 return 0;
240
241 if (render_profile->m_LabelTextLayouts.Full())
242 render_profile->m_LabelTextLayouts.OffsetCapacity(64);
243 render_profile->m_LabelTextLayouts.Put(text_hash, layout);
244 return layout;
245 }
246
247 static void DrawProfilerTextCached(HRenderProfile render_profile, dmRender::HRenderContext render_context, dmRender::HFontMap font_map, uint64_t batch_key, const dmRender::DrawTextParams& params, const char* text)
248 {

Callers 1

DrawProfilerTextCachedFunction · 0.85

Calls 6

dmHashBufferNoReverse64Function · 0.85
CreateProfilerTextLayoutFunction · 0.85
GetMethod · 0.45
FullMethod · 0.45
OffsetCapacityMethod · 0.45
PutMethod · 0.45

Tested by

no test coverage detected