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

Function RichResourceTextPaint

qrenderdoc/Code/QRDUtils.cpp:745–934  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

743static const int RichResourceTextMargin = 2;
744
745void RichResourceTextPaint(const QWidget *owner, QPainter *painter, QRect rect, QFont font,
746 QPalette palette, QStyle::State state, QPoint mousePos,
747 const QVariant &var)
748{
749 QBrush foreBrush = palette.brush(state & QStyle::State_Selected ? QPalette::HighlightedText
750 : QPalette::WindowText);
751
752 painter->save();
753
754 // special case handling for ResourceId/GPUAddress on its own
755 if(var.userType() == qMetaTypeId<ResourceId>() || var.userType() == qMetaTypeId<GPUAddressPtr>())
756 {
757 QFont f = painter->font();
758 f.setBold(true);
759 painter->setFont(f);
760
761 static const int margin = RichResourceTextMargin;
762
763 rect.adjust(margin, 0, -margin, 0);
764
765 QString name;
766
767 bool valid = false;
768
769 if(var.userType() == qMetaTypeId<ResourceId>())
770 {
771 ICaptureContext *ctxptr = getCaptureContext(owner);
772
773 ResourceId id = var.value<ResourceId>();
774
775 valid = (id != ResourceId());
776
777 if(ctxptr)
778 name = GetTruncatedResourceName(*ctxptr, id);
779 else
780 name = ToQStr(id);
781 }
782 else
783 {
784 GPUAddressPtr ptr = var.value<GPUAddressPtr>();
785
786 ptr->cacheAddress(owner);
787
788 valid = (ptr->val.pointer != 0);
789
790 if(valid)
791 {
792 if(ptr->base != ResourceId())
793 {
794 name =
795 QFormatStr("%1+%2").arg(GetTruncatedResourceName(*ptr->ctxptr, ptr->base)).arg(ptr->offset);
796 }
797 else
798 {
799 name = QFormatStr("Unknown 0x%1").arg(ptr->val.pointer, 16, 16, QLatin1Char('0'));
800 valid = false;
801 }
802 }

Callers 2

paintMethod · 0.85
paintEventMethod · 0.85

Calls 15

getCaptureContextFunction · 0.85
GetTruncatedResourceNameFunction · 0.85
QLatin1CharClass · 0.85
cacheAddressMethod · 0.80
drawTextMethod · 0.80
boundingRectMethod · 0.80
fontMetricsMethod · 0.80
devicePixelRatioMethod · 0.80
setClipRectMethod · 0.80
setLeftMethod · 0.80
drawPixmapMethod · 0.80
bottomMethod · 0.80

Tested by

no test coverage detected