MCPcopy Create free account
hub / github.com/baldurk/renderdoc / RichResourceTextInitialise

Function RichResourceTextInitialise

qrenderdoc/Code/QRDUtils.cpp:565–732  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

563}
564
565void RichResourceTextInitialise(QVariant &var, ICaptureContext *ctx, bool parseURLs)
566{
567 // we only upconvert from strings, any other type with a string representation is not expected to
568 // contain ResourceIds. In particular if the variant is already a ResourceId we can return.
569 if(GetVariantMetatype(var) != QMetaType::QString)
570 return;
571
572 // we trim the string because that will happen naturally when rendering as HTML, and it makes it
573 // easier to detect strings where the only contents are ResourceId text.
574 QString text = var.toString().trimmed();
575
576 // do a simple string search first before using regular expressions
577 if(!text.contains(lit("ResourceId::")) && !text.contains(lit("GPUAddress::")) &&
578 !text.contains(lit("__rd_msgs::")) && !text.contains(QLatin1Char('@')) && !parseURLs &&
579 !(text.startsWith(lit("<rdhtml>")) && text.endsWith(lit("</rdhtml>"))))
580 return;
581
582 // two forms: GPUAddress::012345 - typeless
583 // GPUAddress::012345::991 - using type 991 from PointerTypeRegistry
584 static QRegularExpression addrRE(lit("GPUAddress::([0-9]*)(::([0-9]*))?"));
585
586 QRegularExpressionMatch match = addrRE.match(text);
587
588 if(match.hasMatch())
589 {
590 // don't support mixed text & addresses. Only do the replacement if we matched the whole string
591 if(match.capturedStart(0) == 0 && match.capturedLength(0) == text.length())
592 {
593 GPUAddressPtr addr(new GPUAddress);
594 addr->val.pointer = match.captured(1).toULongLong();
595
596 // we deliberately set this to ResourceId() to indicate that we're using an ID from the
597 // registry, not a shader-relative index
598 addr->val.shader = ResourceId();
599 addr->val.pointerTypeID = match.captured(3).toULong();
600
601 var = QVariant::fromValue(addr);
602 return;
603 }
604
605 return;
606 }
607
608 const bool forcehtml = text.startsWith(lit("<rdhtml>")) && text.endsWith(lit("</rdhtml>"));
609 if(forcehtml)
610 {
611 text = text.mid(8, text.length() - 17);
612 }
613
614 // use regexp to split up into fragments of text and resourceid. The resourceid is then
615 // formatted on the fly in RichResourceText::cacheDocument
616 static QRegularExpression resRE(
617 lit("(ResourceId::)([0-9]+)|(@)([0-9]+)|(__rd_msgs::)([0-9]+):([0-9]+)"));
618
619 match = resRE.match(text);
620
621 RichResourceTextPtr linkedText(new RichResourceText);
622

Callers 11

RichResourceTextFormatFunction · 0.85
dataMethod · 0.85
setTextMethod · 0.85
RDTreeWidgetItemMethod · 0.85
checkForResourceIdMethod · 0.85
dataMethod · 0.85
dataMethod · 0.85
LoadEditorMethod · 0.85
dataMethod · 0.85
GetCachedEIDNameMethod · 0.85
dataMethod · 0.85

Calls 15

GetVariantMetatypeFunction · 0.85
QLatin1CharClass · 0.85
fromValueFunction · 0.85
HandleURLFragmentFunction · 0.85
trimmedMethod · 0.80
ResourceIdFunction · 0.50
memcpyFunction · 0.50
toStringMethod · 0.45
containsMethod · 0.45
startsWithMethod · 0.45
endsWithMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected