ManaPlus
testlauncher.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2011-2019 The ManaPlus Developers
4  * Copyright (C) 2019-2021 Andrei Karas
5  *
6  * This file is part of The ManaPlus Client.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include "test/testlauncher.h"
23 
24 #ifdef USE_OPENGL
25 
26 #include "graphicsmanager.h"
27 #include "settings.h"
28 #include "soundmanager.h"
29 
30 #include "fs/virtfs/rwops.h"
31 
32 #include "gui/skin.h"
33 #include "gui/theme.h"
34 
35 #include "gui/fonts/font.h"
36 
37 #include "utils/pnglib.h"
38 #include "utils/stringutils.h"
39 
40 #include "render/graphics.h"
41 
43 
47 #include "resources/wallpaper.h"
48 
49 #include "resources/dye/dye.h"
50 #if defined __linux__ || defined __linux
51 #ifdef SIMD_SUPPORTED
53 #endif // SIMD_SUPPORTED
54 #endif // defined __linux__ || defined __linux
55 
56 #include "resources/image/image.h"
57 
58 PRAGMA48(GCC diagnostic push)
59 PRAGMA48(GCC diagnostic ignored "-Wshadow")
60 #ifndef USE_SDL2
61 #include <SDL_gfxBlitFunc.h>
62 #endif // USE_SDL2
63 PRAGMA48(GCC diagnostic pop)
64 
65 #include <unistd.h>
66 
67 #ifdef WIN32
68 #include <windows.h>
69 #define sleep(seconds) Sleep((seconds) * 1000)
70 #endif // WIN32
71 
72 #include <sys/time.h>
73 
74 #include "localconsts.h"
75 
76 #ifndef SDL_BIG_ENDIAN
77 #error missing SDL_endian.h
78 #endif // SDL_BYTEORDER
79 
80 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
81 #ifndef USE_SDL2
83 #endif // USE_SDL2
84 #endif // SDL_BYTEORDER == SDL_LIL_ENDIAN
85 
86 #include "debug.h"
87 
88 extern Font *boldFont;
89 
90 TestLauncher::TestLauncher(std::string test) :
91  mTest(test),
92  file()
93 {
94  file.open(pathJoin(settings.localDataDir, "test.log").c_str(),
95  std::ios::out);
96 }
97 
99 {
100  file.close();
101 }
102 
104 {
105  if (mTest == "1" || mTest == "2" || mTest == "3" || mTest == "19")
106  return testBackend();
107  else if (mTest == "4")
108  return testSound();
109  else if (mTest == "5" || mTest == "6" || mTest == "7" || mTest == "18")
110  return testRescale();
111  else if (mTest == "8" || mTest == "9" || mTest == "10" || mTest == "17")
112  return testFps();
113  else if (mTest == "11")
114  return testBatches();
115  else if (mTest == "14" || mTest == "15" || mTest == "16" || mTest == "20")
116  return testTextures();
117  else if (mTest == "99")
118  return testVideoDetection();
119  else if (mTest == "100")
120  return testInternal();
121  else if (mTest == "101")
122  return testDye();
123  else if (mTest == "102")
124  return testDraw();
125  else if (mTest == "103")
126  return testFps2();
127  else if (mTest == "104")
128  return testFps3();
129  else if (mTest == "105")
130  return testDyeSSpeed();
131  else if (mTest == "106")
132  return testStackSpeed();
133  else if (mTest == "107")
134  return testDyeASpeed();
135  else if (mTest == "108")
136  return testBlitSpeed();
137 
138  return -1;
139 }
140 
142 {
143  const Image *const img = Theme::getImageFromTheme(
144  "graphics/sprites/arrow_up.png");
145  if (img == nullptr)
146  return 1;
147  const int cnt = 100;
148 
149  for (int f = 0; f < cnt; f ++)
150  {
151  mainGraphics->drawImage(img, cnt * 7, cnt * 5);
153  }
154 
155  sleep(1);
156  return 0;
157 }
158 
160 {
161  soundManager.playGuiSfx("system/newmessage.ogg");
162  sleep(1);
163  soundManager.playSfx("system/newmessage.ogg", 0, 0);
164  soundManager.playMusic("sfx/system/newmessage.ogg", SkipError_false);
165  sleep(3);
167  return 0;
168 }
169 
171 {
173  const std::string wallpaperName = Wallpaper::getWallpaper(800, 600);
174  const volatile Image *const img = Theme::getImageFromTheme(wallpaperName);
175  if (img == nullptr)
176  return 1;
177 
178  sleep(1);
179  return 0;
180 }
181 
182 PRAGMA45(GCC diagnostic push)
183 PRAGMA45(GCC diagnostic ignored "-Wunused-result")
184 
186 {
187  timeval start;
188  timeval end;
189 
191  Wallpaper::getWallpaper(800, 600);
192  Image *img[5];
193  const int sz = 4;
194 
195  img[0] = Theme::getImageFromTheme("graphics/sprites/arrow_up.png");
196  img[1] = Theme::getImageFromTheme(
197  "graphics/gui/target-cursor-normal-l.png");
198  img[2] = Theme::getImageFromTheme("themes/wood/window.png");
199  img[3] = Theme::getImageFromTheme("themes/pink/window.png");
200  img[4] = Theme::getImageFromTheme("graphics/images/login_wallpaper.png");
201  int idx = 0;
202 
203  const int cnt = 50;
204 
205  gettimeofday(&start, nullptr);
206  for (int k = 0; k < cnt; k ++)
207  {
208  for (int x = 0; x < 800; x += 30)
209  {
210  for (int y = 0; y < 600; y += 50)
211  {
212  mainGraphics->drawImage(img[idx], x, y);
213  idx ++;
214  if (idx > sz)
215  idx = 0;
216  mainGraphics->drawImage(img[idx], x, y);
217  idx ++;
218  if (idx > sz)
219  idx = 0;
220  }
221  }
223  }
224 
225  gettimeofday(&end, nullptr);
226  const int tFps = calcFps(start, end, cnt);
227  file << mTest << std::endl;
228  file << tFps << std::endl;
229 
230  printf("fps: %d\n", tFps / 10);
231  sleep(1);
232  return 0;
233 }
234 
236 {
237  timeval start;
238  timeval end;
239 
241  Wallpaper::getWallpaper(800, 600);
242  Image *img[1];
243 
244  img[0] = Theme::getImageFromTheme("graphics/images/login_wallpaper.png");
245  mainGraphics->drawImage(img[0], 0, 0);
246 
247  const int cnt = 500;
248 
249  gettimeofday(&start, nullptr);
250  for (int k = 0; k < cnt; k ++)
251  {
252  for (int f = 0; f < 300; f ++)
255  }
256 
257  gettimeofday(&end, nullptr);
258  const int tFps = calcFps(start, end, cnt);
259  file << mTest << std::endl;
260  file << tFps << std::endl;
261 
262  printf("fps: %d\n", tFps / 10);
263  sleep(1);
264  return 0;
265 }
266 
268 {
269  timeval start;
270  timeval end;
271 
273  Wallpaper::getWallpaper(800, 600);
274  Image *img[2];
275 
276  img[0] = Theme::getImageFromTheme("graphics/sprites/arrow_up.png");
277  img[1] = Theme::getImageFromTheme("graphics/sprites/arrow_left.png");
278  ImageVertexes *const vert1 = new ImageVertexes;
279  vert1->image = img[0];
280  ImageVertexes *const vert2 = new ImageVertexes;
281  vert2->image = img[1];
282 
283  for (int f = 0; f < 50; f ++)
284  {
285  for (int d = 0; d < 50; d ++)
286  {
287  mainGraphics->calcTileVertexes(vert1, img[0], f * 16, d * 12);
288  mainGraphics->calcTileVertexes(vert1, img[1], f * 16 + 5, d * 12);
289  }
290  }
291  mainGraphics->finalize(vert1);
292  mainGraphics->finalize(vert2);
293 
294  const int cnt = 2000;
295 
296  gettimeofday(&start, nullptr);
297  for (int k = 0; k < cnt; k ++)
298  {
302  }
303 
304  gettimeofday(&end, nullptr);
305  const int tFps = calcFps(start, end, cnt);
306  file << mTest << std::endl;
307  file << tFps << std::endl;
308 
309  printf("fps: %d\n", tFps / 10);
310  sleep(1);
311  return 0;
312 }
313 PRAGMA45(GCC diagnostic pop)
314 
316 {
317  int batches = 512;
318 
319  file << mTest << std::endl;
320  file << batches << std::endl;
321  return 0;
322 }
323 
325 {
326  int maxSize = 512;
327  int nextSize = 512;
328  int sz = OpenGLImageHelper::getTextureSize() + 1;
329  if (sz > 16500)
330  sz = 16500;
331 
332  const uint32_t bytes1[] =
333  {
334  0xFFFF0000U, 0xFFFFFF00U, 0xFF00FFFFU, 0xFF0000FFU,
335  0xFF000000U, 0xFFFF00FFU
336  };
337 
338  const uint32_t bytes2[] =
339  {
340  0xFF0000FFU, 0xFF00FFFFU, 0xFFFFFF00U, 0xFFFF0000U,
341  0xFF000000U, 0xFFFF00FFU
342  };
343 
344  for (nextSize = 512; nextSize < sz; nextSize *= 2)
345  {
347  SDL_Surface *const surface = imageHelper->create32BitSurface(
348  nextSize, nextSize);
349  if (surface == nullptr)
350  break;
351  uint32_t *pixels = static_cast<uint32_t*>(surface->pixels);
352  for (int f = 0; f < 6; f ++)
353  pixels[f] = bytes1[f];
356  Image *const image = imageHelper->loadSurface(surface);
357  SDL_FreeSurface(surface);
358  if (image == nullptr)
359  break;
360 
361  if (graphicsManager.getLastErrorCached() != GL_NO_ERROR)
362  {
363  delete image;
364  break;
365  }
366  Image *const subImage = image->getSubImage(0, 0, 10, 10);
367  if (subImage == nullptr)
368  {
369  delete image;
370  break;
371  }
372  mainGraphics->drawImage(subImage, 0, 0);
374  mainGraphics->drawImage(subImage, 0, 0);
375  delete subImage;
376  SDL_Surface *const screen1 = screenshortHelper->getScreenshot();
377  SDL_Surface *const screen2 = ImageHelper::convertTo32Bit(screen1);
378  SDL_FreeSurface(screen1);
379  if (screen2 == nullptr)
380  break;
381  pixels = static_cast<uint32_t*>(screen2->pixels);
382  bool fail(false);
383  for (int f = 0; f < 6; f ++)
384  {
385  if (pixels[f] != bytes2[f])
386  {
387  fail = true;
388  break;
389  }
390  }
391 
392  SDL_FreeSurface(screen2);
393  if (fail)
394  break;
395 
396  maxSize = nextSize;
397  }
398 
399  file << mTest << std::endl;
400  file << maxSize << std::endl;
401  printf("OpenGL max size: %d\n", sz);
402  printf("actual max size: %d\n", maxSize);
403  return 0;
404 }
405 
406 PRAGMA45(GCC diagnostic push)
407 PRAGMA45(GCC diagnostic ignored "-Wunused-result")
408 
410 {
411  timeval start;
412  timeval end;
413 
415  Wallpaper::getWallpaper(800, 600);
416  Image *img[4];
417 
418  img[0] = Theme::getImageFromTheme(
419  "graphics/sprites/manaplus_emotions.png");
420  img[1] = Theme::getImageFromTheme(
421  "graphics/sprites/manaplus_emotions.png");
422  img[2] = Theme::getImageFromTheme("graphics/sprites/arrow_left.png");
423  img[3] = Theme::getImageFromTheme("graphics/sprites/arrow_right.png");
424  int idx = 0;
425  const int mem = mainGraphics->getMemoryUsage();
426 
427 // int cnt = 5;
428  const int cnt = 5000;
429 
430  gettimeofday(&start, nullptr);
431  for (int k = 0; k < cnt; k ++)
432  {
433  for (int x = 0; x < 800; x += 20)
434  {
435  for (int y = 0; y < 600; y += 25)
436  {
437  mainGraphics->drawImage(img[idx], x, y);
438  mainGraphics->drawImage(img[idx], x + 1, y);
439  mainGraphics->drawImage(img[idx], x, y + 5);
440 
441  idx ++;
442  if (idx > 3)
443  idx = 0;
444  }
445  }
447  }
448 
449  gettimeofday(&end, nullptr);
450  const int tFps = calcFps(start, end, cnt);
451  file << mTest << std::endl;
452  file << tFps << std::endl;
453  file << mem << std::endl;
454 
455  sleep(1);
456  return 0;
457 }
458 
459 PRAGMA45(GCC diagnostic pop)
460 
462 {
463  SDL_RWops *rw = VirtFs::rwopsOpenRead(
464  "graphics/sprites/arrow_up.png");
465  Dye *d = nullptr;
466 
467  if (rw != nullptr)
468  {
469  Image *image = d != nullptr ? surfaceImageHelper->load(rw, *d)
470  : surfaceImageHelper->load(rw);
471  if (image != nullptr)
472  {
473  const SDL_Rect &rect = image->mBounds;
474  SDL_Surface *surface = surfaceImageHelper->create32BitSurface(
475  rect.w, rect.h);
476  if (surface != nullptr)
477  {
478  SurfaceImageHelper::combineSurface(image->mSDLSurface, nullptr,
479  surface, nullptr);
480  PngLib::writePNG(image->mSDLSurface,
481  settings.tempDir + "/testimage1.png");
482  PngLib::writePNG(surface,
483  settings.tempDir + "/testimage2.png");
484  }
485 
487  "graphics/sprites/arrow_up.png");
488  d = new Dye("S:#0000ff,00ff00,5c5cff,ff0000");
489  image = surfaceImageHelper->load(rw, *d);
490  if (image != nullptr)
491  {
493  rect.w, rect.h);
494  if (surface != nullptr)
495  {
496  SurfaceImageHelper::combineSurface(image->mSDLSurface,
497  nullptr, surface, nullptr);
498  PngLib::writePNG(image->mSDLSurface,
499  settings.tempDir + "/testimage3.png");
500  PngLib::writePNG(surface,
501  settings.tempDir + "/testimage4.png");
502  }
503  }
504  }
505  }
506  return 0;
507 }
508 
509 #if defined __linux__ || defined __linux
510 #if defined(SIMD_SUPPORTED) || (SDL_BYTEORDER == SDL_LIL_ENDIAN \
511 && !defined(USE_SDL2))
512 static void calcTime(const char *const msg1,
513  const char *const msg2,
514  const timespec &time1,
515  timespec &time2,
516  const uint32_t *const buf)
517 {
518  clock_gettime(CLOCK_MONOTONIC, &time2);
519  long diff = ((static_cast<long int>(time2.tv_sec) * 1000000000L
520  + static_cast<long int>(time2.tv_nsec)) / 1) -
521  ((static_cast<long int>(time1.tv_sec) * 1000000000L
522  + static_cast<long int>(time1.tv_nsec)) / 1);
523  printf("%s: %u\n", msg1, buf[0]);
524  printf("%s: %011ld\n", msg2, diff);
525 }
526 #endif // defined(SIMD_SUPPORTED) || (SDL_BYTEORDER == SDL_LIL_ENDIAN
527 
528 #ifdef SIMD_SUPPORTED
529 static void initBuffer(uint32_t *const buf,
530  const int sz)
531 {
532  for (int f = 0; f < sz; f ++)
533  buf[f] = f;
534 }
535 
536 #define runDyeTest(msg1, msg2, func) \
537  initBuffer(buf, sz); \
538  pal.func(buf, sz); \
539  clock_gettime(CLOCK_MONOTONIC, &time1); \
540  for (int f = 0; f < 50000; f ++) \
541  pal.func(buf, sz); \
542  calcTime(msg1, \
543  msg2, \
544  time1, \
545  time2, \
546  buf)
547 #endif // SIMD_SUPPORTED
548 #endif // defined __linux__ || defined __linux
549 
551 {
552 #if defined __linux__ || defined __linux
553 #ifdef SIMD_SUPPORTED
554  const int sz = 100000;
555  uint32_t buf[sz];
556  timespec time1;
557  timespec time2;
558 
559  DyePalette pal("#0000ff,000000,000020,706050", 6);
560 
561  runDyeTest("dye s salt", "default time", replaceSColorDefault);
562  runDyeTest("dye s salt", "sse2 time ", replaceSColorSse2);
563  runDyeTest("dye s salt", "avx2 time ", replaceSColorAvx2);
564 #endif // SIMD_SUPPORTED
565 #endif // defined __linux__ || defined __linux
566  return 0;
567 }
568 
570 {
571 #if defined __linux__ || defined __linux
572 #ifdef SIMD_SUPPORTED
573  const int sz = 100000;
574  uint32_t buf[sz];
575  timespec time1;
576  timespec time2;
577 
578  DyePalette pal("#0000ffff,00000000,000020ff,70605040", 8);
579 
580  runDyeTest("dye a salt", "default time", replaceAColorDefault);
581  runDyeTest("dye a salt", "sse2 time ", replaceAColorSse2);
582  runDyeTest("dye a salt", "avx2 time ", replaceAColorAvx2);
583 #endif // SIMD_SUPPORTED
584 #endif // defined __linux__ || defined __linux
585  return 0;
586 }
587 
589 {
590 #if defined __linux__ || defined __linux
591 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
592 #ifndef USE_SDL2
593 
594  timespec time1;
595  timespec time2;
596  const int cnt1 = 10000;
597  const int cnt2 = 10;
598 
599  SDL_Surface *const srcSurface = imageHelper->create32BitSurface(
600  64, 64);
601  SDL_Surface *const dstSurface = imageHelper->create32BitSurface(
602  512, 512);
603  for (int f = 0; f < 64 * 64; f ++)
604  static_cast<uint32_t*>(srcSurface->pixels)[f] = 0x11223344;
605  clock_gettime(CLOCK_MONOTONIC, &time1);
606  for (int d = 0; d < cnt2; d ++)
607  {
608  for (int f = 0; f < 512 * 512; f ++)
609  static_cast<uint32_t*>(dstSurface->pixels)[f] = 0x55667788;
610  for (int f = 0; f < cnt1; f ++)
611  {
612  SDLgfxBlitRGBA(srcSurface,
613  nullptr,
614  dstSurface,
615  nullptr);
616  }
617  }
618  calcTime("blit test",
619  "custom time",
620  time1,
621  time2,
622  static_cast<uint32_t*>(dstSurface->pixels));
623 
624  clock_gettime(CLOCK_MONOTONIC, &time1);
625  for (int d = 0; d < cnt2; d ++)
626  {
627  for (int f = 0; f < 512 * 512; f ++)
628  static_cast<uint32_t*>(dstSurface->pixels)[f] = 0x55667788;
629  for (int f = 0; f < cnt1; f ++)
630  {
631  SDL_gfxBlitRGBA(srcSurface,
632  nullptr,
633  dstSurface,
634  nullptr);
635  }
636  }
637  calcTime("blit test",
638  "SDL_gfx time",
639  time1,
640  time2,
641  static_cast<uint32_t*>(dstSurface->pixels));
642 
643 #endif // USE_SDL2
644 #endif // SDL_BYTEORDER == SDL_LIL_ENDIAN
645 #endif // defined __linux__ || defined __linux
646  return 0;
647 }
648 
650 {
651 /*
652  const int sz = 100000;
653  const int k = 100;
654  const int sz2 = sz * k;
655 
656  std::stack<ClipRect> stack1;
657  MStack<ClipRect> stack2(sz2);
658  timespec time1;
659  timespec time2;
660 
661 #if defined __linux__ || defined __linux
662  for (int d = 0; d < 100; d ++)
663  {
664  for (int f = 0; f < sz; f ++)
665  {
666  ClipRect rect;
667  rect.xOffset = f;
668  rect.yOffset = f;
669  stack1.push(rect);
670  }
671  }
672  while (!stack1.empty())
673  stack1.pop();
674 
675  clock_gettime(CLOCK_MONOTONIC, &time1);
676 
677  for (int d = 0; d < 100; d ++)
678  {
679  for (int f = 0; f < sz; f ++)
680  {
681  ClipRect rect;
682  rect.xOffset = f;
683  rect.yOffset = f;
684  stack1.push(rect);
685  }
686  }
687 
688  clock_gettime(CLOCK_MONOTONIC, &time2);
689  long diff = ((static_cast<long int>(time2.tv_sec) * 1000000000L
690  + static_cast<long int>(time2.tv_nsec)) / 1) -
691  ((static_cast<long int>(time1.tv_sec) * 1000000000L
692  + static_cast<long int>(time1.tv_nsec)) / 1);
693  printf("debug: %d\n", stack1.top().xOffset);
694  printf("stl time: %ld\n", diff);
695 
696  for (int d = 0; d < 100; d ++)
697  {
698  for (int f = 0; f < sz; f ++)
699  {
700  ClipRect &rect = stack2.push();
701  rect.xOffset = f;
702  rect.yOffset = f;
703  }
704  }
705  stack2.clear();
706 
707  clock_gettime(CLOCK_MONOTONIC, &time1);
708 
709  for (int d = 0; d < 100; d ++)
710  {
711  for (int f = 0; f < sz; f ++)
712  {
713  ClipRect &rect = stack2.push();
714  rect.xOffset = f;
715  rect.yOffset = f;
716  }
717  }
718 
719  clock_gettime(CLOCK_MONOTONIC, &time2);
720  diff = ((static_cast<long int>(time2.tv_sec) * 1000000000L
721  + static_cast<long int>(time2.tv_nsec)) / 1) -
722  ((static_cast<long int>(time1.tv_sec) * 1000000000L
723  + static_cast<long int>(time1.tv_nsec)) / 1);
724  printf("debug: %d\n", stack2.top().xOffset);
725  printf("my time: %ld\n", diff);
726 
727 #endif
728 */
729  return 0;
730 }
731 
733 {
734  Image *img[3];
735  img[0] = Theme::getImageFromTheme("graphics/sprites/arrow_left.png");
736  img[1] = Theme::getImageFromTheme("graphics/sprites/arrow_right.png");
737  img[2] = Theme::getImageFromTheme("graphics/sprites/arrow_up.png");
738  Skin *skin = theme->load("button.xml",
739  "button.xml",
740  true,
742  if (skin == nullptr)
743  return 0;
744 
745  ImageCollection *const col = new ImageCollection;
746  ImageCollection *const col2 = new ImageCollection;
747  ImageVertexes *const vert = new ImageVertexes;
748  vert->image = img[2];
749 
750  mainGraphics->pushClipArea(Rect(10, 20, 790, 580));
751  mainGraphics->setColor(Color(0xFFU, 0xFFU, 0x00U, 0xFFU));
752  mainGraphics->drawRectangle(Rect(0, 0, 400, 200));
753 
754  mainGraphics->setColor(Color(0xFFU, 0x00U, 0x00U, 0xB0U));
755  img[0]->setAlpha(0.5F);
756  mainGraphics->drawImage(img[0], 190, 383);
757  img[0]->setAlpha(1.0F);
758 
759  mainGraphics->calcWindow(col2,
760  5, 40,
761  500, 40,
762  skin->getBorder());
763  mainGraphics->finalize(col2);
764 
765  mainGraphics->calcTileVertexes(vert, img[2], 10, 10);
766  mainGraphics->calcTileVertexes(vert, img[2], 40, 10);
767  mainGraphics->finalize(vert);
768 
769  mainGraphics->setColor(Color(0x80U, 0x00U, 0xA0U, 0x90U));
770  mainGraphics->fillRectangle(Rect(200, 100, 300, 300));
772 
773  Color color(0xFFU, 0x00U, 0x00U, 0xB0U);
774  Color color2(0x00U, 0xFFU, 0x00U, 0xB0U);
776  color, color2,
777  "test test test test test test test test ", 300, 100);
778 
780 
781  mainGraphics->drawPattern(img[0], 10, 400, 300, 180);
782 
783  mainGraphics->calcPattern(col, img[1], 500, 400, 150, 100);
784  mainGraphics->finalize(col);
785 
787 
788  mainGraphics->drawRescaledImage(img[0], 250, 350, 35, 90);
789 
790  mainGraphics->setColor(Color(0x00U, 0xFFU, 0x00U, 0x90U));
791  mainGraphics->drawNet(450, 10, 600, 300, 32, 20);
792 
794 
795  img[0]->setAlpha(0.3F);
796  mainGraphics->drawRescaledPattern(img[0], 250, 150, 250, 300, 30, 100);
797 
798  for (int f = 0; f < 255; f ++)
799  {
800  mainGraphics->setColor(Color(0x20U, 0x60U, f, 0x90U));
801  mainGraphics->drawLine(300 + f, 490, 300 + f, 480);
802  for (int d = 0; d < 10; d ++)
803  mainGraphics->drawPoint(300 + f, 500 + d);
804  }
806  sleep(10);
807 
808  delete col;
809  delete col2;
810  delete vert;
811  return 0;
812 }
813 
815 {
816  file << mTest << std::endl;
817  file << graphicsManager.detectGraphics() << std::endl;
818  return 0;
819 }
820 
821 int TestLauncher::calcFps(const timeval &start,
822  const timeval &end,
823  const int calls) const
824 {
825  long mtime;
826  long seconds;
827  long useconds;
828 
829  seconds = end.tv_sec - start.tv_sec;
830  useconds = end.tv_usec - start.tv_usec;
831 
832  mtime = (seconds * 1000 + useconds / 1000.0) + 0.5;
833  if (mtime == 0)
834  return 100000;
835 
836  return CAST_S32(static_cast<long>(calls) * 10000 / mtime);
837 }
838 
839 #endif // USE_OPENGL
#define CAST_S32
Definition: cast.h:30
Definition: color.h:76
Definition: dye.h:41
Definition: font.h:90
void drawString(Graphics *const graphics, Color col, const Color &col2, const std::string &text, const int x, const int y)
Definition: font.cpp:254
static GLenum getLastError()
static void resetCachedError()
static GLenum getLastErrorCached()
virtual void updateScreen()=0
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
virtual void popClipArea()
Definition: graphics.cpp:739
virtual void drawRescaledPattern(const Image *const image, const int x, const int y, const int w, const int h, const int scaledWidth, const int scaledHeight)=0
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
virtual void fillRectangle(const Rect &rectangle)=0
virtual void testDraw()
Definition: graphics.h:473
virtual void calcPattern(ImageVertexes *const vert, const Image *const image, const int x, const int y, const int w, const int h) const =0
virtual void setColor(const Color &color)
Definition: graphics.h:320
virtual void finalize(ImageCollection *const col)
Definition: graphics.h:465
virtual void drawRectangle(const Rect &rectangle)=0
virtual void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
virtual void drawLine(int x1, int y1, int x2, int y2)=0
virtual void calcTileVertexes(ImageVertexes *const vert, const Image *const image, int x, int y) const =0
virtual void drawPattern(const Image *const image, const int x, const int y, const int w, const int h)=0
virtual void clearScreen() const
Definition: graphics.h:456
virtual void drawPoint(int x, int y)=0
int getMemoryUsage() const
Definition: graphics.cpp:441
virtual void pushClipArea(const Rect &area)
Definition: graphics.cpp:677
virtual void drawTileVertexes(const ImageVertexes *const vert)=0
virtual void drawNet(const int x1, const int y1, const int x2, const int y2, const int width, const int height)
Definition: graphics.cpp:653
virtual void drawRescaledImage(const Image *const image, int dstX, int dstY, const int desiredWidth, const int desiredHeight)=0
static SDL_Surface * convertTo32Bit(SDL_Surface *const tmpImage)
virtual Image * loadSurface(SDL_Surface *const)
Definition: imagehelper.h:73
virtual SDL_Surface * create32BitSurface(int width, int height) const
Image * load(SDL_RWops *const rw)
Definition: imagehelper.cpp:50
const Image * image
Definition: imagevertexes.h:48
static int getTextureSize()
Definition: rect.h:74
virtual SDL_Surface * getScreenshot()=0
std::string tempDir
Definition: settings.h:113
std::string localDataDir
Definition: settings.h:112
Definition: skin.h:37
const ImageRect & getBorder() const
Definition: skin.h:68
void playGuiSfx(const std::string &path)
void playSfx(const std::string &path, const int x, const int y) const
void playMusic(const std::string &fileName, const SkipError skipError)
std::string mTest
Definition: testlauncher.h:87
int testInternal()
int testVideoDetection()
int testRescale() const
int calcFps(const timeval &start, const timeval &end, const int calls) const
int testSound() const
TestLauncher(std::string test)
std::ofstream file
Definition: testlauncher.h:89
int testStackSpeed()
int testBatches()
int testBackend() const
static std::string getThemePath()
Definition: theme.h:67
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
Definition: theme.cpp:179
static Image * getImageFromTheme(const std::string &path)
Definition: theme.cpp:655
static void loadWallpapers()
Definition: wallpaper.cpp:88
static std::string getWallpaper(const int width, const int height)
Definition: wallpaper.cpp:137
Graphics * mainGraphics
Definition: graphics.cpp:109
GraphicsManager graphicsManager
ScreenshotHelper * screenshortHelper
ImageHelper * imageHelper
Definition: imagehelper.cpp:44
ImageHelper * surfaceImageHelper
Definition: imagehelper.cpp:45
#define PRAGMA48(str)
Definition: localconsts.h:199
bool msg2(InputEvent &event)
Definition: chat.cpp:41
bool writePNG(SDL_Surface *const surface, const std::string &filename)
Definition: pnglib.cpp:37
SDL_RWops * rwopsOpenRead(const std::string &fname)
Definition: rwops.cpp:107
int SDLgfxBlitRGBA(const SDL_Surface *const src, const SDL_Rect *const srcrect, SDL_Surface *const dst, const SDL_Rect *const dstrect)
Settings settings
Definition: settings.cpp:32
const bool SkipError_false
Definition: skiperror.h:30
SoundManager soundManager
std::string pathJoin(std::string str1, const std::string &str2)
Font * boldFont
Definition: gui.cpp:112
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wunused-result") int TestLauncher
Theme * theme
Definition: theme.cpp:62