ManaPlus
Public Member Functions | Private Attributes
TestLauncher Class Reference

#include <testlauncher.h>

Public Member Functions

 TestLauncher (std::string test)
 
 ~TestLauncher ()
 
int exec ()
 
int calcFps (const timeval &start, const timeval &end, const int calls) const
 
int testBackend () const
 
int testSound () const
 
int testRescale () const
 
int testFps ()
 
int testFps2 ()
 
int testFps3 ()
 
int testInternal ()
 
int testDye ()
 
int testVideoDetection ()
 
int testBatches ()
 
int testTextures ()
 
int testDraw ()
 
int testDyeSSpeed ()
 
int testDyeASpeed ()
 
int testStackSpeed ()
 
int testBlitSpeed ()
 

Private Attributes

std::string mTest
 
std::ofstream file
 

Detailed Description

Definition at line 38 of file testlauncher.h.

Constructor & Destructor Documentation

◆ TestLauncher()

TestLauncher::TestLauncher ( std::string  test)
explicit

Definition at line 89 of file testlauncher.cpp.

References file, Settings::localDataDir, pathJoin(), and settings.

89  :
90  mTest(test),
91  file()
92 {
93  file.open(pathJoin(settings.localDataDir, "test.log").c_str(),
94  std::ios::out);
95 }
std::string pathJoin(std::string str1, const std::string &str2)
std::string mTest
Definition: testlauncher.h:86
std::string localDataDir
Definition: settings.h:110
Settings settings
Definition: settings.cpp:31
std::ofstream file
Definition: testlauncher.h:88

◆ ~TestLauncher()

TestLauncher::~TestLauncher ( )

Definition at line 97 of file testlauncher.cpp.

References file.

98 {
99  file.close();
100 }
std::ofstream file
Definition: testlauncher.h:88

Member Function Documentation

◆ calcFps()

int TestLauncher::calcFps ( const timeval &  start,
const timeval &  end,
const int  calls 
) const

Definition at line 820 of file testlauncher.cpp.

References CAST_S32.

Referenced by PRAGMA45(), testFps2(), testFps3(), and testTextures().

823 {
824  long mtime;
825  long seconds;
826  long useconds;
827 
828  seconds = end.tv_sec - start.tv_sec;
829  useconds = end.tv_usec - start.tv_usec;
830 
831  mtime = (seconds * 1000 + useconds / 1000.0) + 0.5;
832  if (mtime == 0)
833  return 100000;
834 
835  return CAST_S32(static_cast<long>(calls) * 10000 / mtime);
836 }
#define CAST_S32
Definition: cast.h:29

◆ exec()

int TestLauncher::exec ( )

Definition at line 102 of file testlauncher.cpp.

References mTest, testBackend(), testBatches(), testBlitSpeed(), testDraw(), testDye(), testDyeASpeed(), testDyeSSpeed(), testFps(), testFps2(), testFps3(), testInternal(), testRescale(), testSound(), testStackSpeed(), testTextures(), and testVideoDetection().

Referenced by Client::initConfigListeners().

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 }
int testStackSpeed()
std::string mTest
Definition: testlauncher.h:86
int testSound() const
int testBatches()
int testVideoDetection()
int testBackend() const
int testInternal()
int testRescale() const

◆ testBackend()

int TestLauncher::testBackend ( ) const

Definition at line 140 of file testlauncher.cpp.

References Graphics::drawImage(), Theme::getImageFromTheme(), mainGraphics, and Graphics::updateScreen().

Referenced by exec().

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 }
virtual void updateScreen()=0
static Image * getImageFromTheme(const std::string &path)
Definition: theme.cpp:654
Graphics * mainGraphics
Definition: graphics.cpp:108
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
Definition: image.h:61

◆ testBatches()

int TestLauncher::testBatches ( )

Referenced by exec(), and testFps3().

◆ testBlitSpeed()

int TestLauncher::testBlitSpeed ( )

Definition at line 587 of file testlauncher.cpp.

References ImageHelper::create32BitSurface(), imageHelper, and SDLgfxBlitRGBA().

Referenced by exec().

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 }
ImageHelper * imageHelper
Definition: imagehelper.cpp:43
virtual SDL_Surface * create32BitSurface(int width, int height) const
int SDLgfxBlitRGBA(SDL_Surface *const src, const SDL_Rect *const srcrect, SDL_Surface *const dst, const SDL_Rect *const dstrect)

◆ testDraw()

int TestLauncher::testDraw ( )

Definition at line 731 of file testlauncher.cpp.

References Graphics::calcPattern(), Graphics::calcTileVertexes(), Graphics::calcWindow(), Graphics::drawImage(), Graphics::drawLine(), Graphics::drawNet(), Graphics::drawPattern(), Graphics::drawPoint(), Graphics::drawRectangle(), Graphics::drawRescaledImage(), Graphics::drawRescaledPattern(), Graphics::drawTileCollection(), Graphics::drawTileVertexes(), Graphics::fillRectangle(), Graphics::finalize(), Skin::getBorder(), Theme::getImageFromTheme(), Theme::getThemePath(), ImageVertexes::image, Theme::load(), mainGraphics, Graphics::popClipArea(), Graphics::pushClipArea(), Image::setAlpha(), Graphics::setColor(), theme, and Graphics::updateScreen().

Referenced by exec().

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",
738  "button.xml",
739  true,
741  if (skin == nullptr)
742  return 0;
743 
744  ImageCollection *const col = new ImageCollection;
745  ImageCollection *const col2 = new ImageCollection;
746  ImageVertexes *const vert = new ImageVertexes;
747  vert->image = img[2];
748 
749  mainGraphics->pushClipArea(Rect(10, 20, 790, 580));
750  mainGraphics->setColor(Color(0xFFU, 0xFFU, 0x00U, 0xFFU));
751  mainGraphics->drawRectangle(Rect(0, 0, 400, 200));
752 
753  mainGraphics->setColor(Color(0xFFU, 0x00U, 0x00U, 0xB0U));
754  img[0]->setAlpha(0.5f);
755  mainGraphics->drawImage(img[0], 190, 383);
756  img[0]->setAlpha(1.0f);
757 
758  mainGraphics->calcWindow(col2,
759  5, 40,
760  500, 40,
761  skin->getBorder());
762  mainGraphics->finalize(col2);
763 
764  mainGraphics->calcTileVertexes(vert, img[2], 10, 10);
765  mainGraphics->calcTileVertexes(vert, img[2], 40, 10);
766  mainGraphics->finalize(vert);
767 
768  mainGraphics->setColor(Color(0x80U, 0x00U, 0xA0U, 0x90U));
769  mainGraphics->fillRectangle(Rect(200, 100, 300, 300));
771 
772  Color color(0xFFU, 0x00U, 0x00U, 0xB0U);
773  Color color2(0x00U, 0xFFU, 0x00U, 0xB0U);
775  color, color2,
776  "test test test test test test test test ", 300, 100);
777 
779 
780  mainGraphics->drawPattern(img[0], 10, 400, 300, 180);
781 
782  mainGraphics->calcPattern(col, img[1], 500, 400, 150, 100);
783  mainGraphics->finalize(col);
784 
786 
787  mainGraphics->drawRescaledImage(img[0], 250, 350, 35, 90);
788 
789  mainGraphics->setColor(Color(0x00U, 0xFFU, 0x00U, 0x90U));
790  mainGraphics->drawNet(450, 10, 600, 300, 32, 20);
791 
793 
794  img[0]->setAlpha(0.3f);
795  mainGraphics->drawRescaledPattern(img[0], 250, 150, 250, 300, 30, 100);
796 
797  for (int f = 0; f < 255; f ++)
798  {
799  mainGraphics->setColor(Color(0x20U, 0x60U, f, 0x90U));
800  mainGraphics->drawLine(300 + f, 490, 300 + f, 480);
801  for (int d = 0; d < 10; d ++)
802  mainGraphics->drawPoint(300 + f, 500 + d);
803  }
805  sleep(10);
806 
807  delete col;
808  delete col2;
809  delete vert;
810  return 0;
811 }
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
Definition: skin.h:35
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
Definition: rect.h:72
const Image * image
Definition: imagevertexes.h:47
static std::string getThemePath()
Definition: theme.h:66
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
Definition: theme.cpp:178
virtual void updateScreen()=0
virtual void popClipArea()
Definition: graphics.cpp:738
virtual void drawRectangle(const Rect &rectangle)=0
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
virtual void finalize(ImageCollection *const col)
Definition: graphics.h:464
virtual void setAlpha(const float alpha)
Definition: image.cpp:286
virtual void setColor(const Color &color)
Definition: graphics.h:319
const ImageRect & getBorder() const
Definition: skin.h:67
virtual void drawRescaledImage(const Image *const image, int dstX, int dstY, const int desiredWidth, const int desiredHeight)=0
static Image * getImageFromTheme(const std::string &path)
Definition: theme.cpp:654
void drawString(Graphics *const graphics, Color col, const Color &col2, const std::string &text, const int x, const int y)
Definition: font.cpp:253
Graphics * mainGraphics
Definition: graphics.cpp:108
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 fillRectangle(const Rect &rectangle)=0
Theme * theme
Definition: theme.cpp:61
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
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
virtual void drawPoint(int x, int y)=0
virtual void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0

◆ testDye()

int TestLauncher::testDye ( )

Referenced by exec(), and testTextures().

◆ testDyeASpeed()

int TestLauncher::testDyeASpeed ( )

Definition at line 568 of file testlauncher.cpp.

Referenced by exec().

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 }

◆ testDyeSSpeed()

int TestLauncher::testDyeSSpeed ( )

Definition at line 549 of file testlauncher.cpp.

Referenced by exec().

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 }

◆ testFps()

int TestLauncher::testFps ( )

Referenced by exec().

◆ testFps2()

int TestLauncher::testFps2 ( )

Definition at line 234 of file testlauncher.cpp.

References calcFps(), Graphics::drawImage(), file, Theme::getImageFromTheme(), Wallpaper::getWallpaper(), Wallpaper::loadWallpapers(), mainGraphics, mTest, anonymous_namespace{stringutils.cpp}::start, Graphics::testDraw(), and Graphics::updateScreen().

Referenced by exec().

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 }
int calcFps(const timeval &start, const timeval &end, const int calls) const
virtual void updateScreen()=0
std::string mTest
Definition: testlauncher.h:86
static Image * getImageFromTheme(const std::string &path)
Definition: theme.cpp:654
Graphics * mainGraphics
Definition: graphics.cpp:108
static void loadWallpapers()
Definition: wallpaper.cpp:87
std::ofstream file
Definition: testlauncher.h:88
virtual void testDraw()
Definition: graphics.h:472
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
Definition: image.h:61
static std::string getWallpaper(const int width, const int height)
Definition: wallpaper.cpp:136

◆ testFps3()

int TestLauncher::testFps3 ( )

Definition at line 266 of file testlauncher.cpp.

References calcFps(), Graphics::calcTileVertexes(), Graphics::drawTileVertexes(), file, Graphics::finalize(), Theme::getImageFromTheme(), Wallpaper::getWallpaper(), ImageVertexes::image, Wallpaper::loadWallpapers(), mainGraphics, mTest, PRAGMA45(), anonymous_namespace{stringutils.cpp}::start, testBatches(), and Graphics::updateScreen().

Referenced by exec().

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 }
int calcFps(const timeval &start, const timeval &end, const int calls) const
const Image * image
Definition: imagevertexes.h:47
virtual void updateScreen()=0
std::string mTest
Definition: testlauncher.h:86
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 finalize(ImageCollection *const col)
Definition: graphics.h:464
static Image * getImageFromTheme(const std::string &path)
Definition: theme.cpp:654
Graphics * mainGraphics
Definition: graphics.cpp:108
static void loadWallpapers()
Definition: wallpaper.cpp:87
std::ofstream file
Definition: testlauncher.h:88
Definition: image.h:61
static std::string getWallpaper(const int width, const int height)
Definition: wallpaper.cpp:136

◆ testInternal()

int TestLauncher::testInternal ( )

Referenced by exec(), and testTextures().

◆ testRescale()

int TestLauncher::testRescale ( ) const

Definition at line 169 of file testlauncher.cpp.

References Theme::getImageFromTheme(), Wallpaper::getWallpaper(), and Wallpaper::loadWallpapers().

Referenced by exec().

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 }
static Image * getImageFromTheme(const std::string &path)
Definition: theme.cpp:654
static void loadWallpapers()
Definition: wallpaper.cpp:87
Definition: image.h:61
static std::string getWallpaper(const int width, const int height)
Definition: wallpaper.cpp:136

◆ testSound()

int TestLauncher::testSound ( ) const

Definition at line 158 of file testlauncher.cpp.

References SoundManager::playGuiSfx(), SoundManager::playMusic(), SoundManager::playSfx(), SkipError_false, soundManager, and SoundManager::stopMusic().

Referenced by exec().

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 }
const bool SkipError_false
Definition: skiperror.h:29
void playGuiSfx(const std::string &path)
SoundManager soundManager
void playMusic(const std::string &fileName, const SkipError skipError)
void playSfx(const std::string &path, const int x, const int y) const

◆ testStackSpeed()

int TestLauncher::testStackSpeed ( )

Definition at line 648 of file testlauncher.cpp.

Referenced by exec().

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 }

◆ testTextures()

int TestLauncher::testTextures ( )

Definition at line 323 of file testlauncher.cpp.

References calcFps(), Graphics::clearScreen(), ImageHelper::convertTo32Bit(), ImageHelper::create32BitSurface(), Graphics::drawImage(), file, Theme::getImageFromTheme(), GraphicsManager::getLastError(), GraphicsManager::getLastErrorCached(), Graphics::getMemoryUsage(), ScreenshotHelper::getScreenshot(), Image::getSubImage(), OpenGLImageHelper::getTextureSize(), Wallpaper::getWallpaper(), graphicsManager, imageHelper, ImageHelper::load(), ImageHelper::loadSurface(), Wallpaper::loadWallpapers(), mainGraphics, Image::mBounds, Image::mSDLSurface, Actions::msg2(), mTest, PRAGMA45(), GraphicsManager::resetCachedError(), VirtFs::rwopsOpenRead(), screenshortHelper, settings, anonymous_namespace{stringutils.cpp}::start, surfaceImageHelper, Settings::tempDir, testDye(), testInternal(), Graphics::updateScreen(), PngLib::writePNG(), x, and y.

Referenced by exec().

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 }
ImageHelper * imageHelper
Definition: imagehelper.cpp:43
virtual SDL_Surface * create32BitSurface(int width, int height) const
virtual void updateScreen()=0
std::string mTest
Definition: testlauncher.h:86
static SDL_Surface * convertTo32Bit(SDL_Surface *const tmpImage)
static void resetCachedError()
virtual Image * getSubImage(const int x, const int y, const int width, const int height)
Definition: image.cpp:466
Graphics * mainGraphics
Definition: graphics.cpp:108
virtual void clearScreen() const
Definition: graphics.h:455
std::ofstream file
Definition: testlauncher.h:88
static int getTextureSize()
virtual Image * loadSurface(SDL_Surface *const)
Definition: imagehelper.h:72
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
Definition: image.h:61
static GLenum getLastError()
ScreenshotHelper * screenshortHelper
virtual SDL_Surface * getScreenshot()=0
static GLenum getLastErrorCached()
GraphicsManager graphicsManager

◆ testVideoDetection()

int TestLauncher::testVideoDetection ( )

Definition at line 813 of file testlauncher.cpp.

References GraphicsManager::detectGraphics(), file, graphicsManager, and mTest.

Referenced by exec().

814 {
815  file << mTest << std::endl;
816  file << graphicsManager.detectGraphics() << std::endl;
817  return 0;
818 }
std::string mTest
Definition: testlauncher.h:86
std::ofstream file
Definition: testlauncher.h:88
GraphicsManager graphicsManager

Field Documentation

◆ file

std::ofstream TestLauncher::file
private

◆ mTest

std::string TestLauncher::mTest
private

Definition at line 86 of file testlauncher.h.

Referenced by exec(), PRAGMA45(), testFps2(), testFps3(), testTextures(), and testVideoDetection().


The documentation for this class was generated from the following files: