33 #include "gui/theme.h"
40 #include "render/graphics.h"
50 #if defined __linux__ || defined __linux
59 PRAGMA48(GCC diagnostic ignored
"-Wshadow")
61 #include <SDL_gfxBlitFunc.h>
69 #define sleep(seconds) Sleep((seconds) * 1000)
76 #ifndef SDL_BIG_ENDIAN
77 #error missing SDL_endian.h
80 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
107 else if (
mTest ==
"4")
113 else if (
mTest ==
"11")
117 else if (
mTest ==
"99")
119 else if (
mTest ==
"100")
121 else if (
mTest ==
"101")
123 else if (
mTest ==
"102")
125 else if (
mTest ==
"103")
127 else if (
mTest ==
"104")
129 else if (
mTest ==
"105")
131 else if (
mTest ==
"106")
133 else if (
mTest ==
"107")
135 else if (
mTest ==
"108")
144 "graphics/sprites/arrow_up.png");
149 for (
int f = 0; f < cnt; f ++)
183 PRAGMA45(GCC diagnostic ignored
"-Wunused-result")
197 "graphics/gui/target-cursor-normal-l.png");
205 gettimeofday(&
start,
nullptr);
206 for (
int k = 0; k < cnt; k ++)
208 for (
int x = 0;
x < 800;
x += 30)
210 for (
int y = 0;
y < 600;
y += 50)
225 gettimeofday(&end,
nullptr);
228 file << tFps << std::endl;
230 printf(
"fps: %d\n", tFps / 10);
249 gettimeofday(&
start,
nullptr);
250 for (
int k = 0; k < cnt; k ++)
252 for (
int f = 0; f < 300; f ++)
257 gettimeofday(&end,
nullptr);
260 file << tFps << std::endl;
262 printf(
"fps: %d\n", tFps / 10);
279 vert1->
image = img[0];
281 vert2->
image = img[1];
283 for (
int f = 0; f < 50; f ++)
285 for (
int d = 0; d < 50; d ++)
294 const int cnt = 2000;
296 gettimeofday(&
start,
nullptr);
297 for (
int k = 0; k < cnt; k ++)
304 gettimeofday(&end,
nullptr);
307 file << tFps << std::endl;
309 printf(
"fps: %d\n", tFps / 10);
320 file << batches << std::endl;
332 const uint32_t bytes1[] =
334 0xFFFF0000U, 0xFFFFFF00U, 0xFF00FFFFU, 0xFF0000FFU,
335 0xFF000000U, 0xFFFF00FFU
338 const uint32_t bytes2[] =
340 0xFF0000FFU, 0xFF00FFFFU, 0xFFFFFF00U, 0xFFFF0000U,
341 0xFF000000U, 0xFFFF00FFU
344 for (nextSize = 512; nextSize < sz; nextSize *= 2)
349 if (surface ==
nullptr)
351 uint32_t *pixels =
static_cast<uint32_t*
>(surface->pixels);
352 for (
int f = 0; f < 6; f ++)
353 pixels[f] = bytes1[f];
357 SDL_FreeSurface(surface);
358 if (image ==
nullptr)
366 Image *
const subImage = image->getSubImage(0, 0, 10, 10);
367 if (subImage ==
nullptr)
378 SDL_FreeSurface(screen1);
379 if (screen2 ==
nullptr)
381 pixels =
static_cast<uint32_t*
>(screen2->pixels);
383 for (
int f = 0; f < 6; f ++)
385 if (pixels[f] != bytes2[f])
392 SDL_FreeSurface(screen2);
400 file << maxSize << std::endl;
401 printf(
"OpenGL max size: %d\n", sz);
402 printf(
"actual max size: %d\n", maxSize);
407 PRAGMA45(GCC diagnostic ignored
"-Wunused-result")
419 "graphics/sprites/manaplus_emotions.png");
421 "graphics/sprites/manaplus_emotions.png");
428 const int cnt = 5000;
430 gettimeofday(&
start,
nullptr);
431 for (
int k = 0; k < cnt; k ++)
433 for (
int x = 0;
x < 800;
x += 20)
435 for (
int y = 0;
y < 600;
y += 25)
449 gettimeofday(&end,
nullptr);
452 file << tFps << std::endl;
453 file << mem << std::endl;
464 "graphics/sprites/arrow_up.png");
471 if (image !=
nullptr)
473 const SDL_Rect &rect = image->mBounds;
476 if (surface !=
nullptr)
478 SurfaceImageHelper::combineSurface(image->mSDLSurface,
nullptr,
487 "graphics/sprites/arrow_up.png");
488 d =
new Dye(
"S:#0000ff,00ff00,5c5cff,ff0000");
490 if (image !=
nullptr)
494 if (surface !=
nullptr)
496 SurfaceImageHelper::combineSurface(image->mSDLSurface,
497 nullptr, surface,
nullptr);
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,
516 const uint32_t *
const buf)
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);
528 #ifdef SIMD_SUPPORTED
529 static void initBuffer(uint32_t *
const buf,
532 for (
int f = 0; f < sz; f ++)
536 #define runDyeTest(msg1, msg2, func) \
537 initBuffer(buf, sz); \
539 clock_gettime(CLOCK_MONOTONIC, &time1); \
540 for (int f = 0; f < 50000; f ++) \
552 #if defined __linux__ || defined __linux
553 #ifdef SIMD_SUPPORTED
554 const int sz = 100000;
559 DyePalette pal(
"#0000ff,000000,000020,706050", 6);
561 runDyeTest(
"dye s salt",
"default time", replaceSColorDefault);
562 runDyeTest(
"dye s salt",
"sse2 time ", replaceSColorSse2);
563 runDyeTest(
"dye s salt",
"avx2 time ", replaceSColorAvx2);
571 #if defined __linux__ || defined __linux
572 #ifdef SIMD_SUPPORTED
573 const int sz = 100000;
578 DyePalette pal(
"#0000ffff,00000000,000020ff,70605040", 8);
580 runDyeTest(
"dye a salt",
"default time", replaceAColorDefault);
581 runDyeTest(
"dye a salt",
"sse2 time ", replaceAColorSse2);
582 runDyeTest(
"dye a salt",
"avx2 time ", replaceAColorAvx2);
590 #if defined __linux__ || defined __linux
591 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
596 const int cnt1 = 10000;
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 ++)
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 ++)
618 calcTime(
"blit test",
622 static_cast<uint32_t*
>(dstSurface->pixels));
624 clock_gettime(CLOCK_MONOTONIC, &time1);
625 for (
int d = 0; d < cnt2; d ++)
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 ++)
631 SDL_gfxBlitRGBA(srcSurface,
637 calcTime(
"blit test",
641 static_cast<uint32_t*
>(dstSurface->pixels));
748 vert->
image = img[2];
755 img[0]->setAlpha(0.5F);
757 img[0]->setAlpha(1.0F);
773 Color color(0xFFU, 0x00U, 0x00U, 0xB0U);
774 Color color2(0x00U, 0xFFU, 0x00U, 0xB0U);
777 "test test test test test test test test ", 300, 100);
795 img[0]->setAlpha(0.3F);
798 for (
int f = 0; f < 255; f ++)
802 for (
int d = 0; d < 10; d ++)
823 const int calls)
const
829 seconds = end.tv_sec -
start.tv_sec;
830 useconds = end.tv_usec -
start.tv_usec;
832 mtime = (seconds * 1000 + useconds / 1000.0) + 0.5;
836 return CAST_S32(
static_cast<long>(calls) * 10000 / mtime);
void drawString(Graphics *const graphics, Color col, const Color &col2, const std::string &text, const int x, const int y)
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()
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 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)
virtual void finalize(ImageCollection *const col)
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
virtual void drawPoint(int x, int y)=0
int getMemoryUsage() const
virtual void pushClipArea(const Rect &area)
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)
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)
virtual SDL_Surface * create32BitSurface(int width, int height) const
Image * load(SDL_RWops *const rw)
static int getTextureSize()
virtual SDL_Surface * getScreenshot()=0
const ImageRect & getBorder() const
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)
int calcFps(const timeval &start, const timeval &end, const int calls) const
TestLauncher(std::string test)
static std::string getThemePath()
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
static Image * getImageFromTheme(const std::string &path)
static void loadWallpapers()
static std::string getWallpaper(const int width, const int height)
GraphicsManager graphicsManager
ScreenshotHelper * screenshortHelper
ImageHelper * imageHelper
ImageHelper * surfaceImageHelper
bool msg2(InputEvent &event)
bool writePNG(SDL_Surface *const surface, const std::string &filename)
SDL_RWops * rwopsOpenRead(const std::string &fname)
int SDLgfxBlitRGBA(const SDL_Surface *const src, const SDL_Rect *const srcrect, SDL_Surface *const dst, const SDL_Rect *const dstrect)
const bool SkipError_false
SoundManager soundManager
std::string pathJoin(std::string str1, const std::string &str2)
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wunused-result") int TestLauncher