Merge lp:~linaro-graphics-wg/libmatrix/misc-changes-glmark2 into lp:~jesse-barker/libmatrix/trunk

Proposed by Alexandros Frantzis
Status: Merged
Merged at revision: 41
Proposed branch: lp:~linaro-graphics-wg/libmatrix/misc-changes-glmark2
Merge into: lp:~jesse-barker/libmatrix/trunk
Diff against target: 222 lines (+64/-51)
4 files modified
log.cc (+45/-50)
log.h (+6/-1)
program.cc (+12/-0)
program.h (+1/-0)
To merge this branch: bzr merge lp:~linaro-graphics-wg/libmatrix/misc-changes-glmark2
Reviewer Review Type Date Requested Status
Jesse Barker Approve
Review via email: mp+119083@code.launchpad.net

Description of the change

Bring in changes from the in-tree version of libmatrix in glmark2.

To post a comment you must log in.
Revision history for this message
Jesse Barker (jesse-barker) wrote :

Seems fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'log.cc'
2--- log.cc 2012-01-27 21:40:46 +0000
3+++ log.cc 2012-08-10 06:13:29 +0000
4@@ -10,6 +10,7 @@
5 // Alexandros Frantzis <alexandros.frantzis@linaro.org>
6 // Jesse Barker <jesse.barker@linaro.org>
7 //
8+#include <unistd.h>
9 #include <cstdio>
10 #include <cstdarg>
11 #include <string>
12@@ -26,8 +27,7 @@
13 const string Log::continuation_prefix("\x10");
14 string Log::appname_;
15 bool Log::do_debug_(false);
16-
17-#ifndef ANDROID
18+std::ostream* Log::extra_out_(0);
19
20 static const string terminal_color_normal("\033[0m");
21 static const string terminal_color_red("\033[1;31m");
22@@ -96,17 +96,26 @@
23 delete[] buf;
24 }
25
26+
27 void
28 Log::info(const char *fmt, ...)
29 {
30 static const string infoprefix("Info");
31+ const string& prefix(do_debug_ ? infoprefix : empty);
32+ va_list ap;
33+ va_start(ap, fmt);
34+
35+#ifndef ANDROID
36 static const string& infocolor(isatty(fileno(stdout)) ? terminal_color_cyan : empty);
37- va_list ap;
38- va_start(ap, fmt);
39- if (do_debug_)
40- print_prefixed_message(std::cout, infocolor, infoprefix, fmt, ap);
41- else
42- print_prefixed_message(std::cout, empty, empty, fmt, ap);
43+ const string& color(do_debug_ ? infocolor : empty);
44+ print_prefixed_message(std::cout, color, prefix, fmt, ap);
45+#else
46+ __android_log_vprint(ANDROID_LOG_INFO, appname_.c_str(), fmt, ap);
47+#endif
48+
49+ if (extra_out_)
50+ print_prefixed_message(*extra_out_, empty, prefix, fmt, ap);
51+
52 va_end(ap);
53 }
54
55@@ -114,12 +123,21 @@
56 Log::debug(const char *fmt, ...)
57 {
58 static const string dbgprefix("Debug");
59+ if (!do_debug_)
60+ return;
61+ va_list ap;
62+ va_start(ap, fmt);
63+
64+#ifndef ANDROID
65 static const string& dbgcolor(isatty(fileno(stdout)) ? terminal_color_yellow : empty);
66- if (!do_debug_)
67- return;
68- va_list ap;
69- va_start(ap, fmt);
70 print_prefixed_message(std::cout, dbgcolor, dbgprefix, fmt, ap);
71+#else
72+ __android_log_vprint(ANDROID_LOG_DEBUG, appname_.c_str(), fmt, ap);
73+#endif
74+
75+ if (extra_out_)
76+ print_prefixed_message(*extra_out_, empty, dbgprefix, fmt, ap);
77+
78 va_end(ap);
79 }
80
81@@ -127,52 +145,29 @@
82 Log::error(const char *fmt, ...)
83 {
84 static const string errprefix("Error");
85+ va_list ap;
86+ va_start(ap, fmt);
87+
88+#ifndef ANDROID
89 static const string& errcolor(isatty(fileno(stderr)) ? terminal_color_red : empty);
90- va_list ap;
91- va_start(ap, fmt);
92 print_prefixed_message(std::cerr, errcolor, errprefix, fmt, ap);
93+#else
94+ __android_log_vprint(ANDROID_LOG_ERROR, appname_.c_str(), fmt, ap);
95+#endif
96+
97+ if (extra_out_)
98+ print_prefixed_message(*extra_out_, empty, errprefix, fmt, ap);
99+
100 va_end(ap);
101 }
102
103 void
104 Log::flush()
105 {
106+#ifndef ANDROID
107 std::cout.flush();
108 std::cerr.flush();
109-}
110-#else
111-void
112-Log::info(const char *fmt, ...)
113-{
114- va_list ap;
115- va_start(ap, fmt);
116- __android_log_vprint(ANDROID_LOG_INFO, appname_.c_str(), fmt, ap);
117- va_end(ap);
118-}
119-
120-void
121-Log::debug(const char *fmt, ...)
122-{
123- if (!do_debug_)
124- return;
125- va_list ap;
126- va_start(ap, fmt);
127- __android_log_vprint(ANDROID_LOG_DEBUG, appname_.c_str(), fmt, ap);
128- va_end(ap);
129-}
130-
131-void
132-Log::error(const char *fmt, ...)
133-{
134- va_list ap;
135- va_start(ap, fmt);
136- __android_log_vprint(ANDROID_LOG_ERROR, appname_.c_str(), fmt, ap);
137- va_end(ap);
138-}
139-
140-void
141-Log::flush()
142-{
143-}
144-
145 #endif
146+ if (extra_out_)
147+ extra_out_->flush();
148+}
149
150=== modified file 'log.h'
151--- log.h 2012-01-27 21:40:46 +0000
152+++ log.h 2012-08-10 06:13:29 +0000
153@@ -14,14 +14,17 @@
154 #define LOG_H_
155
156 #include <string>
157+#include <iostream>
158
159 class Log
160 {
161 public:
162- static void init(const std::string& appname, bool do_debug = false)
163+ static void init(const std::string& appname, bool do_debug = false,
164+ std::ostream *extra_out = 0)
165 {
166 appname_ = appname;
167 do_debug_ = do_debug;
168+ extra_out_ = extra_out;
169 }
170 // Emit an informational message
171 static void info(const char *fmt, ...);
172@@ -41,6 +44,8 @@
173 static std::string appname_;
174 // Indicates whether debug level messages should generate any output
175 static bool do_debug_;
176+ // Extra stream to output log messages to
177+ static std::ostream *extra_out_;
178 };
179
180 #endif /* LOG_H_ */
181
182=== modified file 'program.cc'
183--- program.cc 2012-01-26 16:12:35 +0000
184+++ program.cc 2012-08-10 06:13:29 +0000
185@@ -19,6 +19,7 @@
186
187 using std::string;
188 using LibMatrix::mat4;
189+using LibMatrix::mat3;
190 using LibMatrix::vec2;
191 using LibMatrix::vec3;
192 using LibMatrix::vec4;
193@@ -275,6 +276,17 @@
194 }
195
196 Program::Symbol&
197+Program::Symbol::operator=(const mat3& m)
198+{
199+ if (type_ == Uniform)
200+ {
201+ // Our matrix representation is column-major, so transpose is false here.
202+ glUniformMatrix3fv(location_, 1, GL_FALSE, m);
203+ }
204+ return *this;
205+}
206+
207+Program::Symbol&
208 Program::Symbol::operator=(const vec2& v)
209 {
210 if (type_ == Uniform)
211
212=== modified file 'program.h'
213--- program.h 2012-01-26 16:12:35 +0000
214+++ program.h 2012-08-10 06:13:29 +0000
215@@ -126,6 +126,7 @@
216 // These members cause data to be bound to program variables, so
217 // the program must be bound for use for these to be effective.
218 Symbol& operator=(const LibMatrix::mat4& m);
219+ Symbol& operator=(const LibMatrix::mat3& m);
220 Symbol& operator=(const LibMatrix::vec2& v);
221 Symbol& operator=(const LibMatrix::vec3& v);
222 Symbol& operator=(const LibMatrix::vec4& v);

Subscribers

People subscribed via source and target branches