1 /**************************************************************************
3 * Copyright 2011-2012 Jose Fonseca
4 * Copyright (C) 2013 Intel Corporation. All rights reversed.
5 * Author: Shuang He <shuang.he@intel.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 **************************************************************************/
38 #include "trace_model.hpp"
39 #include "trace_parser.hpp"
40 #include "trace_profiler.hpp"
41 #include "trace_dump.hpp"
43 #include "scoped_allocator.hpp"
54 extern trace::Parser parser;
55 extern trace::Profiler profiler;
58 class ScopedAllocator : public ::ScopedAllocator
62 * Allocate an array with the same dimensions as the specified value.
65 alloc(const trace::Value *value, size_t size) {
66 const trace::Array *array = dynamic_cast<const trace::Array *>(value);
68 return ::ScopedAllocator::alloc(array->size() * size);
70 const trace::Null *null = dynamic_cast<const trace::Null *>(value);
82 * Output verbosity when retracing files.
92 * Add profiling data to the dump when retracing.
94 extern bool profiling;
95 extern bool profilingCpuTimes;
96 extern bool profilingGpuTimes;
97 extern bool profilingPixelsDrawn;
98 extern bool profilingMemoryUsage;
103 extern bool dumpingState;
108 DRIVER_HARDWARE, // force hardware
115 extern Driver driver;
116 extern const char *driverModule;
118 extern bool doubleBuffer;
119 extern bool coreProfile;
121 extern unsigned frameNo;
122 extern unsigned callNo;
124 extern trace::DumpFlags dumpFlags;
126 std::ostream &warning(trace::Call &call);
129 void ignore(trace::Call &call);
130 void unsupported(trace::Call &call);
133 typedef void (*Callback)(trace::Call &call);
141 struct stringComparer {
142 bool operator() (const char *a, const char *b) const {
143 return strcmp(a, b) < 0;
148 extern const Entry stdc_callbacks[];
153 typedef std::map<const char *, Callback, stringComparer> Map;
156 std::vector<Callback> callbacks;
160 addCallbacks(stdc_callbacks);
163 virtual ~Retracer() {}
165 void addCallback(const Entry *entry);
166 void addCallbacks(const Entry *entries);
168 void retrace(trace::Call &call);
175 virtual image::Image *
181 dumpState(std::ostream &os) {
187 extern Dumper *dumper;
194 addCallbacks(retrace::Retracer &retracer);
197 frameComplete(trace::Call &call);
202 flushRendering(void);
211 } /* namespace retrace */
213 #endif /* _RETRACE_HPP_ */