diff --git a/gui/Data/EventData.cs b/gui/Data/EventData.cs index d4e196ff..91b79c4d 100644 --- a/gui/Data/EventData.cs +++ b/gui/Data/EventData.cs @@ -39,6 +39,8 @@ public abstract class Description { public abstract Object GetSharedKey(); + public abstract bool HasShortName { get; } + private String name; public String Name { get { return name; } } @@ -49,12 +51,14 @@ public String FullName set { fullName = value; + name = value; - String shortName = StripFunctionArguments(fullName); - if (shortName.Length != fullName.Length) - name = StripReturnValue(shortName); - else - name = fullName; + if (HasShortName) + { + String shortName = StripFunctionArguments(fullName); + if (shortName.Length != fullName.Length) + name = StripReturnValue(shortName); + } } } diff --git a/gui/Data/EventDescription.cs b/gui/Data/EventDescription.cs index b123699d..1dc5ca8e 100644 --- a/gui/Data/EventDescription.cs +++ b/gui/Data/EventDescription.cs @@ -38,20 +38,6 @@ public override string ToString() public class EventDescription : Description { - private bool isSampling = false; - public bool IsSampling - { - get { return isSampling; } - set - { - if (isSampling != value) - { - ProfilerClient.Get().SendMessage(new TurnSamplingMessage(id, value)); - isSampling = value; - } - } - } - private int id; private Color forceColor; @@ -105,8 +91,16 @@ public EventDescription(String name, int id = -1) this.id = id; } - const byte IS_SAMPLING_FLAG = 0x1; + public enum DescFlags : byte + { + NONE = 0, + IS_CUSTOM_NAME = 1 << 0, + } + public DescFlags Flags { get; private set; } + + public override bool HasShortName { get { return (Flags & DescFlags.IS_CUSTOM_NAME) == 0; } } + public void SetOverrideColor(Color color) { Color = color; @@ -116,8 +110,7 @@ public void SetOverrideColor(Color color) static public EventDescription Read(BinaryReader reader, int id) { EventDescription desc = new EventDescription(); - int nameLength = reader.ReadInt32(); - desc.FullName = new String(reader.ReadChars(nameLength)); + String fullName = Utils.ReadBinaryString(reader); desc.id = id; int fileLength = reader.ReadInt32(); @@ -132,8 +125,8 @@ static public EventDescription Read(BinaryReader reader, int id) desc.Brush = new SolidColorBrush(desc.Color); desc.Budget = reader.ReadSingle(); - byte flags = reader.ReadByte(); - desc.isSampling = (flags & IS_SAMPLING_FLAG) != 0; + desc.Flags = (DescFlags)reader.ReadByte(); + desc.FullName = fullName; return desc; } diff --git a/gui/Data/SamplingFrame.cs b/gui/Data/SamplingFrame.cs index 89195acc..d8bb552b 100644 --- a/gui/Data/SamplingFrame.cs +++ b/gui/Data/SamplingFrame.cs @@ -64,6 +64,8 @@ public bool IsIgnore } } + public override bool HasShortName => true; + public static SamplingDescription UnresolvedDescription = new SamplingDescription() { FullName = "Unresolved", Address = 0, Path = FileLine.Empty }; public static SamplingDescription Create(BinaryReader reader, uint version) diff --git a/src/optick.h b/src/optick.h index b701645d..84e9df22 100644 --- a/src/optick.h +++ b/src/optick.h @@ -521,12 +521,18 @@ struct TagData //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// struct OPTICK_API EventDescription { + enum Flags : uint8_t + { + IS_CUSTOM_NAME = 1 << 0, + }; + const char* name; const char* file; uint32_t line; uint32_t index; uint32_t color; uint32_t filter; + uint8_t flags; static EventDescription* Create(const char* eventName, const char* fileName, const unsigned long fileLine, const unsigned long eventColor = Color::Null, const unsigned long filter = 0); static EventDescription* CreateShared(const char* eventName, const char* fileName = nullptr, const unsigned long fileLine = 0, const unsigned long eventColor = Color::Null, const unsigned long filter = 0); @@ -567,7 +573,10 @@ struct OPTICK_API Event //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// OPTICK_INLINE Optick::EventDescription* CreateDescription(const char* functionName, const char* fileName, int fileLine, const char* eventName = nullptr, const ::Optick::Category::Type category = ::Optick::Category::None) { - return ::Optick::EventDescription::Create(eventName != nullptr ? eventName : functionName, fileName, (unsigned long)fileLine, ::Optick::Category::GetColor(category), ::Optick::Category::GetMask(category)); + ::Optick::EventDescription* desc = ::Optick::EventDescription::Create(eventName != nullptr ? eventName : functionName, fileName, (unsigned long)fileLine, ::Optick::Category::GetColor(category), ::Optick::Category::GetMask(category)); + if (eventName == nullptr) + desc->flags &= ~::Optick::EventDescription::IS_CUSTOM_NAME; + return desc; } OPTICK_INLINE Optick::EventDescription* CreateDescription(const char* functionName, const char* fileName, int fileLine, const ::Optick::Category::Type category) { diff --git a/src/optick_core.cpp b/src/optick_core.cpp index d7076f78..a78960c3 100644 --- a/src/optick_core.cpp +++ b/src/optick_core.cpp @@ -207,7 +207,7 @@ EventDescription* EventDescription::CreateShared(const char* eventName, const ch return EventDescriptionBoard::Get().CreateSharedDescription(eventName, fileName, fileLine, eventColor, filter); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -EventDescription::EventDescription() : name(""), file(""), line(0), color(0) +EventDescription::EventDescription() : name(""), file(""), line(0), color(0), flags(IS_CUSTOM_NAME) { } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -379,8 +379,7 @@ void Tag::Attach(const EventDescription& description, const char* val) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// OutputDataStream & operator<<(OutputDataStream &stream, const EventDescription &ob) { - byte flags = 0; - return stream << ob.name << ob.file << ob.line << ob.filter << ob.color << (float)0.0f << flags; + return stream << ob.name << ob.file << ob.line << ob.filter << ob.color << (float)0.0f << ob.flags; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// OutputDataStream& operator<<(OutputDataStream& stream, const EventTime& ob)