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