diff --git a/src/display/bitmap.cpp b/src/display/bitmap.cpp index 62ad9df..cabfd6f 100644 --- a/src/display/bitmap.cpp +++ b/src/display/bitmap.cpp @@ -737,16 +737,16 @@ Bitmap::Bitmap(const Bitmap &other, int frame) throw e; } - GLMeta::blitBegin(p->gl); + GLMeta::blitBegin(p->gl, false, SameScale); // Blit just the current frame of the other animated bitmap if (!other.isAnimated() || frame == -1) { - GLMeta::blitSource(other.getGLTypes()); + GLMeta::blitSource(other.getGLTypes(), SameScale); } else { auto &frames = other.getFrames(); - GLMeta::blitSource(frames[clamp(frame, 0, (int)frames.size() - 1)]); + GLMeta::blitSource(frames[clamp(frame, 0, (int)frames.size() - 1)], SameScale); } - GLMeta::blitRectangle(rect(), rect(), true); + GLMeta::blitRectangle(rect(), rect()); GLMeta::blitEnd(); } else { @@ -768,9 +768,9 @@ Bitmap::Bitmap(const Bitmap &other, int frame) throw e; } - GLMeta::blitBegin(newframe); - GLMeta::blitSource(sourceframe); - GLMeta::blitRectangle(rect(), rect(), true); + GLMeta::blitBegin(newframe, false, SameScale); + GLMeta::blitSource(sourceframe, SameScale); + GLMeta::blitRectangle(rect(), rect()); GLMeta::blitEnd(); p->animation.frames.push_back(newframe); @@ -806,9 +806,9 @@ Bitmap::Bitmap(TEXFBO &other) // Skip blitting to lores texture, since only the hires one will be displayed. if (p->selfHires == nullptr) { - GLMeta::blitBegin(p->gl); - GLMeta::blitSource(other); - GLMeta::blitRectangle(rect(), rect(), true); + GLMeta::blitBegin(p->gl, false, SameScale); + GLMeta::blitSource(other, SameScale); + GLMeta::blitRectangle(rect(), rect()); GLMeta::blitEnd(); } @@ -1086,10 +1086,16 @@ void Bitmap::stretchBlt(IntRect destRect, SDL_Surface *blitTemp = 0; bool touchesTaintedArea = p->touchesTaintedArea(destRect); bool unpack_subimage = srcSurf && gl.unpack_subimage; - + + const bool scaleIsOne = sourceRect.w == destRect.w && sourceRect.h == destRect.h; + if (scaleIsOne) { + smooth = false; + } + if (!srcSurf && opacity == 255 && !touchesTaintedArea) { /* Fast blit */ + // TODO: Use bitmapSmoothScaling/bitmapSmoothScalingDown configs for this. GLMeta::blitBegin(getGLTypes()); GLMeta::blitSource(source.getGLTypes()); GLMeta::blitRectangle(sourceRect, destRect, smooth); @@ -1227,8 +1233,8 @@ void Bitmap::stretchBlt(IntRect destRect, TEXFBO &gpTex = shState->gpTexFBO(abs(destRect.w), abs(destRect.h)); Vec2i gpTexSize; - GLMeta::blitBegin(gpTex); - GLMeta::blitSource(getGLTypes()); + GLMeta::blitBegin(gpTex, false, SameScale); + GLMeta::blitSource(getGLTypes(), SameScale); GLMeta::blitRectangle(destRect, IntRect(0, 0, abs(destRect.w), abs(destRect.h))); GLMeta::blitEnd(); @@ -2432,9 +2438,9 @@ int Bitmap::addFrame(Bitmap &source, int position) p->surface = 0; } else { - GLMeta::blitBegin(newframe); - GLMeta::blitSource(source.getGLTypes()); - GLMeta::blitRectangle(rect(), rect(), true); + GLMeta::blitBegin(newframe, false, SameScale); + GLMeta::blitSource(source.getGLTypes(), SameScale); + GLMeta::blitRectangle(rect(), rect()); GLMeta::blitEnd(); } diff --git a/tests/benchmark-bitmap-dup/Graphics/Pictures/lime.png b/tests/benchmark-bitmap-dup/Graphics/Pictures/lime.png new file mode 100644 index 0000000..d7b6723 Binary files /dev/null and b/tests/benchmark-bitmap-dup/Graphics/Pictures/lime.png differ diff --git a/tests/benchmark-bitmap-dup/dup-speed-test.rb b/tests/benchmark-bitmap-dup/dup-speed-test.rb new file mode 100755 index 0000000..cd8893a --- /dev/null +++ b/tests/benchmark-bitmap-dup/dup-speed-test.rb @@ -0,0 +1,47 @@ +# Test suite for mkxp-z. +# Copyright 2023-2024 Splendide Imaginarius. +# License GPLv2+. +# +# Run the suite via the "customScript" field in mkxp.json. + +def dump(bmp, spr, desc) + spr.bitmap = bmp + Graphics.wait(1) +end + +src = Bitmap.new("Graphics/Pictures/lime") + +starttime = System.uptime + +for i in 1..100 do + dst1 = src.dup + dst2 = src.dup + dst3 = src.dup + dst4 = src.dup + dst5 = src.dup + dst6 = src.dup + dst7 = src.dup + dst8 = src.dup + dst9 = src.dup + dst10 = src.dup + + dst1.dispose + dst2.dispose + dst3.dispose + dst4.dispose + dst5.dispose + dst6.dispose + dst7.dispose + dst8.dispose + dst9.dispose + dst10.dispose + + GC.start + Graphics.wait(1) +end + +endtime = System.uptime + +System::puts("\n\nTotal dup time: %s\n\n" % [endtime - starttime]) + +exit