| Index: gpu/common/gpu_trace_event.h
|
| diff --git a/gpu/common/gpu_trace_event.h b/gpu/common/gpu_trace_event.h
|
| index 2ed9b9d09938fb75ab560ef81d3ff4907687f76d..415b4841819e8e98818b348c838bce666f00789a 100644
|
| --- a/gpu/common/gpu_trace_event.h
|
| +++ b/gpu/common/gpu_trace_event.h
|
| @@ -180,6 +180,113 @@ enum TraceEventPhase {
|
| GPU_TRACE_EVENT_PHASE_INSTANT
|
| };
|
|
|
| +class TraceAnyType {
|
| + public:
|
| + enum Type {
|
| + NONE,
|
| + BOOLEAN,
|
| + UINT,
|
| + INT,
|
| + DOUBLE,
|
| + POINTER,
|
| + STRING
|
| + };
|
| +
|
| + TraceAnyType() : type_(NONE) {
|
| + value_.as_uint = 0ull;
|
| + }
|
| + TraceAnyType(bool rhs) : type_(BOOLEAN) {
|
| + value_.as_uint = 0ull; // zero all bits
|
| + value_.as_bool = rhs;
|
| + }
|
| + TraceAnyType(uint64 rhs) : type_(UINT) {
|
| + value_.as_uint = rhs;
|
| + }
|
| + TraceAnyType(uint32 rhs) : type_(UINT) {
|
| + value_.as_uint = rhs;
|
| + }
|
| + TraceAnyType(uint16 rhs) : type_(UINT) {
|
| + value_.as_uint = rhs;
|
| + }
|
| + TraceAnyType(uint8 rhs) : type_(UINT) {
|
| + value_.as_uint = rhs;
|
| + }
|
| + TraceAnyType(int64 rhs) : type_(INT) {
|
| + value_.as_int = rhs;
|
| + }
|
| + TraceAnyType(int32 rhs) : type_(INT) {
|
| + value_.as_int = rhs;
|
| + }
|
| + TraceAnyType(int16 rhs) : type_(INT) {
|
| + value_.as_int = rhs;
|
| + }
|
| + TraceAnyType(int8 rhs) : type_(INT) {
|
| + value_.as_int = rhs;
|
| + }
|
| + TraceAnyType(double rhs) : type_(DOUBLE) {
|
| + value_.as_double = rhs;
|
| + }
|
| + TraceAnyType(void* rhs) : type_(POINTER) {
|
| + value_.as_uint = 0ull; // zero all bits
|
| + value_.as_pointer = rhs;
|
| + }
|
| + TraceAnyType(const char* rhs) : type_(STRING) {
|
| + value_.as_uint = 0ull; // zero all bits
|
| + value_.as_string = strdup(rhs);
|
| + }
|
| + TraceAnyType(const TraceAnyType& rhs) : type_(NONE) {
|
| + operator=(rhs);
|
| + }
|
| + ~TraceAnyType() {
|
| + Destroy();
|
| + }
|
| +
|
| + TraceAnyType& operator=(const TraceAnyType& rhs);
|
| + bool operator==(const TraceAnyType& rhs) const;
|
| + bool operator!=(const TraceAnyType& rhs) const {
|
| + return !operator==(rhs);
|
| + }
|
| +
|
| + void Destroy();
|
| +
|
| + void AppendAsJSON(std::string* out) const;
|
| +
|
| + Type type() const {
|
| + return type_;
|
| + }
|
| + uint64 as_uint() const {
|
| + return value_.as_uint;
|
| + }
|
| + bool as_bool() const {
|
| + return value_.as_bool;
|
| + }
|
| + int64 as_int() const {
|
| + return value_.as_int;
|
| + }
|
| + double as_double() const {
|
| + return value_.as_double;
|
| + }
|
| + void* as_pointer() const {
|
| + return value_.as_pointer;
|
| + }
|
| + const char* as_string() const {
|
| + return value_.as_string;
|
| + }
|
| +
|
| + private:
|
| + union Value {
|
| + bool as_bool;
|
| + uint64 as_uint;
|
| + int64 as_int;
|
| + double as_double;
|
| + void* as_pointer;
|
| + char* as_string;
|
| + };
|
| +
|
| + Type type_;
|
| + Value value_;
|
| +};
|
| +
|
| // Output records are "Events" and can be obtained via the
|
| // OutputCallback whenever the logging system decides to flush. This
|
| // can happen at any time, on any thread, or you can programatically
|
| @@ -201,7 +308,7 @@ struct TraceEvent {
|
| TraceCategory* category;
|
| const char* name;
|
| const char* argNames[TRACE_MAX_NUM_ARGS];
|
| - std::string argValues[TRACE_MAX_NUM_ARGS];
|
| + TraceAnyType argValues[TRACE_MAX_NUM_ARGS];
|
| };
|
|
|
|
|
| @@ -243,8 +350,8 @@ class TraceLog {
|
| const char* file, int line,
|
| TraceCategory* category,
|
| const char* name,
|
| - const char* arg1name, const char* arg1val,
|
| - const char* arg2name, const char* arg2val);
|
| + const char* arg1name, TraceAnyType arg1val,
|
| + const char* arg2name, TraceAnyType arg2val);
|
|
|
| private:
|
| // This allows constructor and destructor to be private and usable only
|
|
|