platform initialization/deinitialization refactoring

This commit is contained in:
Vadim Lopatin 2015-03-27 11:39:55 +03:00
parent c54da25549
commit 1b50e0586a
3 changed files with 22 additions and 22 deletions

View File

@ -222,10 +222,10 @@ class Window {
measure(); measure();
//Log.d("measured size: ", _mainWidget.measuredWidth, "x", _mainWidget.measuredHeight); //Log.d("measured size: ", _mainWidget.measuredWidth, "x", _mainWidget.measuredHeight);
long measureEnd = currentTimeMillis; long measureEnd = currentTimeMillis;
Log.d("measure took ", measureEnd - measureStart, " ms"); debug Log.d("resize: measure took ", measureEnd - measureStart, " ms");
layout(); layout();
long layoutEnd = currentTimeMillis; long layoutEnd = currentTimeMillis;
Log.d("layout took ", layoutEnd - measureEnd, " ms"); debug Log.d("resize: layout took ", layoutEnd - measureEnd, " ms");
//Log.d("layout position: ", _mainWidget.pos); //Log.d("layout position: ", _mainWidget.pos);
} }
update(true); update(true);
@ -986,7 +986,7 @@ class Window {
if (!needLayout) { if (!needLayout) {
needLayout = root.needLayout || needLayout; needLayout = root.needLayout || needLayout;
if (needLayout) { if (needLayout) {
Log.d("need layout: ", root.id); debug(DebugRedraw) Log.d("need layout: ", root.id);
} }
} }
if (root.animating && root.visible) if (root.animating && root.visible)
@ -1567,3 +1567,17 @@ void releaseResourcesOnAppExit() {
} }
} }
} }
/// initialize logging (for win32 - to file ui.log, for other platforms - stderr; log level is TRACE for debug builds, and WARN for release builds)
void initLogs() {
version (Windows) {
Log.setFileLogger(std.stdio.File("ui.log", "w"));
} else {
Log.setStderrLogger();
}
debug {
Log.setLogLevel(LogLevel.Trace);
} else {
Log.setLogLevel(LogLevel.Warn);
}
}

View File

@ -1237,12 +1237,7 @@ version (Windows) {
int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{ {
Log.setFileLogger(std.stdio.File("ui.log", "w")); initLogs();
debug {
Log.setLogLevel(LogLevel.Trace);
} else {
Log.setLogLevel(LogLevel.Warn);
}
Log.d("myWinMain()"); Log.d("myWinMain()");
string basePath = exePath(); string basePath = exePath();
Log.i("Current executable: ", exePath()); Log.i("Current executable: ", exePath());
@ -1268,12 +1263,7 @@ version (Windows) {
int main(string[] args) int main(string[] args)
{ {
Log.setStderrLogger(); initLogs();
debug {
Log.setLogLevel(LogLevel.Trace);
} else {
Log.setLogLevel(LogLevel.Warn);
}
if (!initFontManager()) { if (!initFontManager()) {
Log.e("******************************************************************"); Log.e("******************************************************************");

View File

@ -929,12 +929,8 @@ private __gshared Win32Platform w32platform;
int myWinMain(void* hInstance, void* hPrevInstance, char* lpCmdLine, int iCmdShow) int myWinMain(void* hInstance, void* hPrevInstance, char* lpCmdLine, int iCmdShow)
{ {
Log.setFileLogger(std.stdio.File("ui.log", "w")); initLogs();
debug {
Log.setLogLevel(LogLevel.Trace);
} else {
Log.setLogLevel(LogLevel.Info);
}
Log.d("myWinMain()"); Log.d("myWinMain()");
string basePath = exePath(); string basePath = exePath();
Log.i("Current executable: ", exePath()); Log.i("Current executable: ", exePath());