1 /**************************************************************************
3 * Copyright 2011-2012 Jose Fonseca
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 **************************************************************************/
36 #include "trace_model.hpp"
37 #include "trace_parser.hpp"
38 #include "trace_profiler.hpp"
40 #include "scoped_allocator.hpp"
51 extern trace::Parser parser;
52 extern trace::Profiler profiler;
55 class ScopedAllocator : public ::ScopedAllocator
59 * Allocate an array with the same dimensions as the specified value.
62 alloc(const trace::Value *value, size_t size) {
63 const trace::Array *array = dynamic_cast<const trace::Array *>(value);
65 return ::ScopedAllocator::alloc(array->size() * size);
67 const trace::Null *null = dynamic_cast<const trace::Null *>(value);
79 * Output verbosity when retracing files.
89 * Add profiling data to the dump when retracing.
91 extern bool profiling;
92 extern bool profilingCpuTimes;
93 extern bool profilingGpuTimes;
94 extern bool profilingPixelsDrawn;
99 extern bool dumpingState;
104 DRIVER_HARDWARE, // force hardware
111 extern Driver driver;
112 extern const char *driverModule;
114 extern bool doubleBuffer;
115 extern bool coreProfile;
117 extern unsigned frameNo;
118 extern unsigned callNo;
121 std::ostream &warning(trace::Call &call);
124 void ignore(trace::Call &call);
125 void unsupported(trace::Call &call);
128 typedef void (*Callback)(trace::Call &call);
136 struct stringComparer {
137 bool operator() (const char *a, const char *b) const {
138 return strcmp(a, b) < 0;
143 extern const Entry stdc_callbacks[];
148 typedef std::map<const char *, Callback, stringComparer> Map;
151 std::vector<Callback> callbacks;
155 addCallbacks(stdc_callbacks);
158 virtual ~Retracer() {}
160 void addCallback(const Entry *entry);
161 void addCallbacks(const Entry *entries);
163 void retrace(trace::Call &call);
170 virtual image::Image *
176 dumpState(std::ostream &os) {
182 extern Dumper *dumper;
189 addCallbacks(retrace::Retracer &retracer);
192 frameComplete(trace::Call &call);
197 flushRendering(void);
206 } /* namespace retrace */
208 #endif /* _RETRACE_HPP_ */